Skip to content

Commit

Permalink
Correctly handle out dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Dec 16, 2023
1 parent c9b40cc commit 2db6af8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/BuildConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <sstream>
#include <stdexcept>

static String OUT_DIR = "poac-out/debug";

struct Target {
Vec<String> commands;
Vec<String> dependsOn;
Expand Down Expand Up @@ -115,7 +117,8 @@ static void parseMMOutput(
Logger::debug("");
}

void emitMakefile(const Vec<String>& args) {
// Returns the directory where the Makefile is generated.
String emitMakefile(const Vec<String>& args) {
if (!fs::exists("src")) {
throw std::runtime_error("src directory not found");
}
Expand Down Expand Up @@ -194,6 +197,7 @@ void emitMakefile(const Vec<String>& args) {

std::ofstream ofs(OUT_DIR + "/Makefile");
config.emitMakefile(ofs);
return OUT_DIR;
}

#ifdef POAC_TEST
Expand Down
4 changes: 1 addition & 3 deletions src/BuildConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

#include "Rustify.hpp"

static inline String OUT_DIR = "poac-out/debug";

void emitMakefile(const Vec<String>&);
String emitMakefile(const Vec<String>&);
5 changes: 2 additions & 3 deletions src/Cmd/Build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
#include <iostream>

int build(Vec<String> args) {
emitMakefile(args);

std::system(("cd " + OUT_DIR + " && make").c_str());
const String outDir = emitMakefile(args);
std::system(("make -C " + outDir).c_str());
return EXIT_SUCCESS;
}

Expand Down

0 comments on commit 2db6af8

Please sign in to comment.