summaryrefslogtreecommitdiff
path: root/src/bootstrap.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/bootstrap.cc')
-rw-r--r--src/bootstrap.cc71
1 files changed, 51 insertions, 20 deletions
diff --git a/src/bootstrap.cc b/src/bootstrap.cc
index 55bd3e0..836504e 100644
--- a/src/bootstrap.cc
+++ b/src/bootstrap.cc
@@ -4,6 +4,7 @@
#include <iostream>
#include <array>
#include <cstdlib>
+#include <span>
#define BOOTSTRAP
@@ -18,9 +19,10 @@
#include "tasks.cc"
#include "build.cc"
#include "tools.cc"
+#include "pointerlist.cc"
-std::filesystem::path configurationFile("configuration.cc");
-std::filesystem::path configHeaderFile("config.h");
+const std::filesystem::path configurationFile("configuration.cc");
+const std::filesystem::path configHeaderFile("config.h");
const ctor::configuration& ctor::get_configuration()
{
@@ -40,46 +42,75 @@ bool ctor::configuration::has(const std::string& key) const
return false;
}
-const std::string& ctor::configuration::get(const std::string& key, const std::string& default_value) const
+std::string ctor::configuration::get(const std::string& key, const std::string& default_value) const
{
- if(key == ctor::cfg::build_cxx && std::getenv("CXX"))
+ static auto paths = get_paths();
+ auto cxx_env = std::getenv("CXX");
+ if(key == ctor::cfg::build_cxx && cxx_env)
{
- static std::string s = std::getenv("CXX");
- return s;
+ static auto cxx_prog = locate(cxx_env, paths);
+ return cxx_prog;
}
- if(key == ctor::cfg::build_cc && std::getenv("CC"))
+ auto cc_env = std::getenv("CC");
+ if(key == ctor::cfg::build_cc && cc_env)
{
- static std::string s = std::getenv("CC");
- return s;
+ static auto cc_prog = locate(cc_env, paths);
+ return cc_prog;
}
- if(key == ctor::cfg::build_ld && std::getenv("LD"))
+ auto ld_env = std::getenv("LD");
+ if(key == ctor::cfg::build_ld && ld_env)
{
- static std::string s = std::getenv("LD");
- return s;
+ static auto ld_prog = locate(ld_env, paths);
+ return ld_prog;
}
- if(key == ctor::cfg::build_ar && std::getenv("AR"))
+ auto ar_env = std::getenv("AR");
+ if(key == ctor::cfg::build_ar && ar_env)
{
- static std::string s = std::getenv("AR");
- return s;
+ static auto ar_prog = locate(ar_env, paths);
+ return ar_prog;
}
- if(key == ctor::cfg::builddir && std::getenv("BUILDDIR"))
+ auto builddir_env = std::getenv("BUILDDIR");
+ if(key == ctor::cfg::builddir && builddir_env)
{
- static std::string s = std::getenv("BUILDDIR");
- return s;
+ return builddir_env;
}
return default_value;
}
+std::string ctor::configuration::getenv(const std::string& key) const
+{
+ auto envit = env.find(key);
+ if(envit != env.end())
+ {
+ return envit->second;
+ }
+
+ auto env = std::getenv(key.data());
+ if(env)
+ {
+ return env;
+ }
+
+ return {};
+}
+
+std::vector<std::string> readDeps(const std::string& depFile,
+ ctor::toolchain toolchain)
+{
+ return {};
+}
+
int main(int argc, char* argv[])
{
- if(argc > 1)
+ auto args = std::span(argv, static_cast<std::size_t>(argc));
+ if(args.size() > 1)
{
- std::cerr << "This is a minimal bootstrap version of " << argv[0] <<
+ std::cerr << "This is a minimal bootstrap version of " << args[0] <<
" which doesn't support any arguments\n";
return 1;
}