main.cxx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "command_builder.h"
  2. // TODO(samjaffe): This function should perform a check to see if the
  3. // the buildfile actually needs to be recompiled.
  4. int compile_build_system() {
  5. std::cout << "Generating Build System..." << std::endl;
  6. // TODO(samjaffe): Magic constant for compiler
  7. auto cmd = build::command_builder("clang++", 1)
  8. // TODO(samjaffe): Detect the correct build source file
  9. << build::version::cxx17 << "build.cxx"
  10. << "-o"
  11. << "./build";
  12. int const rc = cmd.execute();
  13. if (rc) {
  14. std::cout << "Completed with errors, aborting" << std::endl;
  15. } else {
  16. std::cout << "Done!" << std::endl;
  17. }
  18. return rc;
  19. }
  20. int run_build_system(int const argc, char const * const argv[]) {
  21. std::vector<char const *> arguments(argv + 1, argv + argc);
  22. std::cout << "Building... ";
  23. // TODO(samjaffe): Magic constant
  24. auto cmd = build::command_builder("./build") << arguments;
  25. int const rc = cmd.execute();
  26. if (rc) {
  27. std::cout << "Build failed!" << std::endl;
  28. } else {
  29. std::cout << "Success!" << std::endl;
  30. }
  31. return rc;
  32. }
  33. int main(int argc, char const * const argv[]) {
  34. if (int rc = compile_build_system()) { return rc; }
  35. return run_build_system(argc, argv);
  36. }