summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2017-08-20 21:36:50 +0800
committerJohn Hodge <tpg@mutabah.net>2017-08-20 21:36:50 +0800
commit72571e39e4659cb32b82c633d45a0fcd7b8c5ffb (patch)
tree73f477164757fbacf533fe639bf671f69b8e17ad
parentc9f90fc62b742c237f2468e351467794f9a4e7e3 (diff)
downloadmrust-72571e39e4659cb32b82c633d45a0fcd7b8c5ffb.tar.gz
minicargo - Build script planning
-rw-r--r--tools/minicargo/build.cpp31
-rw-r--r--tools/minicargo/manifest.h1
2 files changed, 32 insertions, 0 deletions
diff --git a/tools/minicargo/build.cpp b/tools/minicargo/build.cpp
index 352a4dcd..55e45c49 100644
--- a/tools/minicargo/build.cpp
+++ b/tools/minicargo/build.cpp
@@ -160,17 +160,48 @@ bool Builder::build_target(const PackageManifest& manifest, const PackageTarget&
auto outdir = ::helpers::path("output");
auto outfile = outdir / ::format("lib", target.m_name, ".hir");
+ // TODO: Determine if it needs re-running
+ // Rerun if:
+ // > `outfile` is missing
+ // > mrustc/minicargo is newer than `outfile`
+ // > build script has changed
+ // > any input file has changed (requires depfile from mrustc)
+
StringList args;
args.push_back(::helpers::path(manifest.manifest_path()).parent() / ::helpers::path(target.m_path));
args.push_back("--crate-name"); args.push_back(target.m_name.c_str());
args.push_back("--crate-type"); args.push_back("rlib");
args.push_back("-o"); args.push_back(outfile);
args.push_back("-L"); args.push_back(outdir);
+ //for(const auto& dir : manifest.build_script.rustc_link_search) {
+ // args.push_back("-L"); args.push_back(dir.second.c_str());
+ //}
+ //for(const auto& lib : manifest.build_script.rustc_link_lib) {
+ // args.push_back("-l"); args.push_back(lib.second.c_str());
+ //}
+ //for(const auto& cfg : manifest.build_script.rustc_cfg) {
+ // args.push_back("--cfg"); args.push_back(cfg.c_str());
+ //}
+ //for(const auto& flag : manifest.build_script.rustc_flags) {
+ // args.push_back(flag.c_str());
+ //}
+ // TODO: Environment variables (rustc_env)
return this->spawn_process(args, outfile + "_dbg.txt");
}
bool Builder::build_library(const PackageManifest& manifest) const
{
+ if( manifest.build_script() != "" )
+ {
+ // Locate a build script override file
+ // > Note, override file can specify a list of commands to run.
+ //manifest.script_output = BuildScript::load( override_file );
+ // Otherwise, compile and run build script
+ //manifest.script_output = BuildScript::load( ::helpers::path("output") / "build_" + manifest.name + ".txt" );
+ // Parse build script output.
+ throw ::std::runtime_error("TODO: Build script");
+ }
+
return this->build_target(manifest, manifest.get_library());
}
bool Builder::spawn_process(const StringList& args, const ::helpers::path& logfile) const
diff --git a/tools/minicargo/manifest.h b/tools/minicargo/manifest.h
index 0e6c2d81..428a9721 100644
--- a/tools/minicargo/manifest.h
+++ b/tools/minicargo/manifest.h
@@ -152,6 +152,7 @@ public:
const ::std::string& name() const {
return m_name;
}
+ const ::std::string& build_script() const { return m_build_script; }
const ::std::vector<PackageRef>& dependencies() const {
return m_dependencies;
}