aboutsummaryrefslogtreecommitdiff
path: root/src/build.cc
blob: 88b40c73871a22b796065b60ddaeadbab2b3d61b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <filesystem>
#include <iostream>

#include "build.hh"
#include "lua_build.hh"
#include "vars.hh"

void build(std::filesystem::path build_dir) {
  if (build_dir != std::filesystem::current_path().string()) {
    std::filesystem::current_path(build_dir);
  }

  bool bldit_found = false;
  bool build_found = false;

  for (auto const &dir_entry : std::filesystem::directory_iterator(std::filesystem::current_path().string())) {
    if (dir_entry.path().filename() == "bldit") {
      bldit_found = true;
      break;
    }
  }

  if (bldit_found) {
    system("./bldit");
  } else if (lua_build(build_dir.c_str())) {
    return;
  } else {
    std::cout << print_error << "no usable build system was found\n";
  }
}