]> git.tdb.fi Git - builder.git/blobdiff - source/bootstrap/bootstrap.cpp
Update the bootstrap to work with recent changes
[builder.git] / source / bootstrap / bootstrap.cpp
diff --git a/source/bootstrap/bootstrap.cpp b/source/bootstrap/bootstrap.cpp
new file mode 100644 (file)
index 0000000..9374533
--- /dev/null
@@ -0,0 +1,47 @@
+#include "bootstrap.h"
+#include <msp/builder/tool.h>
+#include <msp/core/getopt.h>
+#include <msp/fs/dir.h>
+#include "plugins/base/baseplugin.h"
+#include "plugins/gnu/gnuplugin.h"
+
+using namespace std;
+using namespace Msp;
+
+Bootstrap::Bootstrap(int argc, char **argv)
+{
+       string compiler;
+       string prefix;
+
+       GetOpt getopt;
+       getopt.add_option("compiler", compiler, GetOpt::REQUIRED_ARG).set_help("Use CMD instead of gcc as compiler.", "CMD");
+       getopt.add_option("prefix", prefix, GetOpt::REQUIRED_ARG).set_help("Install things to DIR.", "DIR");
+       getopt(argc, argv);
+
+       logger.enable_channel("tasks");
+       builder.set_logger(&logger);
+       builder.load_plugins<BasePlugin, GnuPlugin>();
+
+       if(!prefix.empty())
+               builder.set_prefix(FS::getcwd()/prefix);
+
+       builder.load_build_file(FS::getcwd()/"builderrc");
+
+       builder.add_default_tools();
+       if(!compiler.empty())
+               builder.get_toolchain().get_tool("CXX").set_command(compiler);
+}
+
+int Bootstrap::main()
+{
+       builder.load_build_file(FS::getcwd()/"Build");
+
+       builder.get_package_manager().get_main_package().prepare();
+       builder.get_build_graph().prepare();
+
+       int exit_code = builder.build();
+
+       builder.save_caches();
+
+       return exit_code;
+}