]> git.tdb.fi Git - builder.git/blob - source/bootstrap/bootstrap.cpp
Update the bootstrap to work with recent changes
[builder.git] / source / bootstrap / bootstrap.cpp
1 #include "bootstrap.h"
2 #include <msp/builder/tool.h>
3 #include <msp/core/getopt.h>
4 #include <msp/fs/dir.h>
5 #include "plugins/base/baseplugin.h"
6 #include "plugins/gnu/gnuplugin.h"
7
8 using namespace std;
9 using namespace Msp;
10
11 Bootstrap::Bootstrap(int argc, char **argv)
12 {
13         string compiler;
14         string prefix;
15
16         GetOpt getopt;
17         getopt.add_option("compiler", compiler, GetOpt::REQUIRED_ARG).set_help("Use CMD instead of gcc as compiler.", "CMD");
18         getopt.add_option("prefix", prefix, GetOpt::REQUIRED_ARG).set_help("Install things to DIR.", "DIR");
19         getopt(argc, argv);
20
21         logger.enable_channel("tasks");
22         builder.set_logger(&logger);
23         builder.load_plugins<BasePlugin, GnuPlugin>();
24
25         if(!prefix.empty())
26                 builder.set_prefix(FS::getcwd()/prefix);
27
28         builder.load_build_file(FS::getcwd()/"builderrc");
29
30         builder.add_default_tools();
31         if(!compiler.empty())
32                 builder.get_toolchain().get_tool("CXX").set_command(compiler);
33 }
34
35 int Bootstrap::main()
36 {
37         builder.load_build_file(FS::getcwd()/"Build");
38
39         builder.get_package_manager().get_main_package().prepare();
40         builder.get_build_graph().prepare();
41
42         int exit_code = builder.build();
43
44         builder.save_caches();
45
46         return exit_code;
47 }