There's now a separate, simplified frontend for the stage1 binary.
set -e
+SOURCEDIRS="source/lib source/bootstrap plugins/base plugins/gnu"
INCLUDEDIR=temp/bootstrap/include
REQUIRED="core datafile"
-CFLAGS="-I$INCLUDEDIR `pkg-config --cflags sigc++-2.0`"
+CFLAGS="-std=c++11 -iquote . -I$INCLUDEDIR `pkg-config --cflags sigc++-2.0`"
LIBS="`pkg-config --libs sigc++-2.0` -lpthread"
-if pkg-config --exists "sigc++-2.0 >= 2.5.1"; then
- CFLAGS="$CFLAGS -std=c++11"
-fi
MACHINE="`uname -m`"
SYSTEM="`uname -s`"
if [ "$MACHINE" = "x86_64" ]; then
rm -rf "$INCLUDEDIR"
mkdir -p "$INCLUDEDIR/msp"
-sources=source/*.cpp
+sources=`find $SOURCEDIRS -name '*.cpp'`
+
+mkdir -p "$INCLUDEDIR/msp/builder"
+ln -sf "$PWD/source/lib"/*.h "$INCLUDEDIR/msp/builder/"
use_overlays="unix generic"
missing=""
ARGS="$ARGS --prefix='$PREFIX'"
fi
if [ "$CUSTOM_COMPILER" = "yes" ]; then
- ARGS="$ARGS CXX=$COMPILER"
+ ARGS="$ARGS --compiler=$COMPILER"
fi
eval "./builder-stage1 $ARGS"
--- /dev/null
+#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;
+}
--- /dev/null
+#ifndef BOOTSTRAP_H_
+#define BOOTSTRAP_H_
+
+#include <msp/builder/builder.h>
+#include <msp/core/application.h>
+
+class Bootstrap: public Msp::RegisteredApplication<Bootstrap>
+{
+private:
+ Logger logger;
+ Builder builder;
+
+public:
+ Bootstrap(int, char **);
+
+ int main() override;
+};
+
+#endif