From: Mikko Rasa Date: Sun, 12 Mar 2023 11:25:46 +0000 (+0200) Subject: Update the bootstrap to work with recent changes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d7c37f4286b68bdbc0e21c1ff67328f1bdc3075a;p=builder.git Update the bootstrap to work with recent changes There's now a separate, simplified frontend for the stage1 binary. --- diff --git a/bootstrap.sh b/bootstrap.sh index b853125..b8c8a7a 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -2,13 +2,11 @@ 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 @@ -75,7 +73,10 @@ fi 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="" @@ -152,6 +153,6 @@ if [ "$PREFIX" ]; then ARGS="$ARGS --prefix='$PREFIX'" fi if [ "$CUSTOM_COMPILER" = "yes" ]; then - ARGS="$ARGS CXX=$COMPILER" + ARGS="$ARGS --compiler=$COMPILER" fi eval "./builder-stage1 $ARGS" diff --git a/source/bootstrap/bootstrap.cpp b/source/bootstrap/bootstrap.cpp new file mode 100644 index 0000000..9374533 --- /dev/null +++ b/source/bootstrap/bootstrap.cpp @@ -0,0 +1,47 @@ +#include "bootstrap.h" +#include +#include +#include +#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(); + + 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; +} diff --git a/source/bootstrap/bootstrap.h b/source/bootstrap/bootstrap.h new file mode 100644 index 0000000..0b46621 --- /dev/null +++ b/source/bootstrap/bootstrap.h @@ -0,0 +1,19 @@ +#ifndef BOOTSTRAP_H_ +#define BOOTSTRAP_H_ + +#include +#include + +class Bootstrap: public Msp::RegisteredApplication +{ +private: + Logger logger; + Builder builder; + +public: + Bootstrap(int, char **); + + int main() override; +}; + +#endif