From 2db6af8fabeee8a15778289baa5b5408c8f3a056 Mon Sep 17 00:00:00 2001 From: Ken Matsui <26405363+ken-matsui@users.noreply.github.com> Date: Sat, 16 Dec 2023 06:32:10 -0800 Subject: [PATCH] Correctly handle out dir --- src/BuildConfig.cc | 6 +++++- src/BuildConfig.hpp | 4 +--- src/Cmd/Build.cc | 5 ++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/BuildConfig.cc b/src/BuildConfig.cc index c3531796a..8b695df6b 100644 --- a/src/BuildConfig.cc +++ b/src/BuildConfig.cc @@ -10,6 +10,8 @@ #include #include +static String OUT_DIR = "poac-out/debug"; + struct Target { Vec commands; Vec dependsOn; @@ -115,7 +117,8 @@ static void parseMMOutput( Logger::debug(""); } -void emitMakefile(const Vec& args) { +// Returns the directory where the Makefile is generated. +String emitMakefile(const Vec& args) { if (!fs::exists("src")) { throw std::runtime_error("src directory not found"); } @@ -194,6 +197,7 @@ void emitMakefile(const Vec& args) { std::ofstream ofs(OUT_DIR + "/Makefile"); config.emitMakefile(ofs); + return OUT_DIR; } #ifdef POAC_TEST diff --git a/src/BuildConfig.hpp b/src/BuildConfig.hpp index 65ae7199b..0c39c1799 100644 --- a/src/BuildConfig.hpp +++ b/src/BuildConfig.hpp @@ -2,6 +2,4 @@ #include "Rustify.hpp" -static inline String OUT_DIR = "poac-out/debug"; - -void emitMakefile(const Vec&); +String emitMakefile(const Vec&); diff --git a/src/Cmd/Build.cc b/src/Cmd/Build.cc index 753801474..7aefd547e 100644 --- a/src/Cmd/Build.cc +++ b/src/Cmd/Build.cc @@ -6,9 +6,8 @@ #include int build(Vec 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; }