Skip to content

Commit

Permalink
Better Makefile generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Dec 16, 2023
1 parent 7178caf commit e5ec9c5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/BuildConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ struct BuildConfig {
for (const auto& dep : targets.at(".PHONY").dependsOn) {
os << " " << dep;
}
os << '\n';
os << "\n\n";
}
if (targets.count("all") != 0) {
os << "all:";
for (const auto& dep : targets.at("all").dependsOn) {
os << " " << dep;
}
os << '\n';
os << "\n\n";
}

const Vec<String> sortedTargets = topoSort(targets, targetDeps);
Expand Down Expand Up @@ -256,6 +256,7 @@ String emitMakefile(const Vec<String>& args) {

// Add a target to create the buildOutDir and buildTargetBaseDir.
Vec<String> buildTargetDeps = objTargetDeps;
buildTargetDeps.push_back("|"); // order-only dependency
buildTargetDeps.push_back(buildOutDir);
if (targetBaseDir != ".") {
addDirectoryTarget(config, buildTargetBaseDir);
Expand Down Expand Up @@ -290,6 +291,7 @@ String emitMakefile(const Vec<String>& args) {

// NOTE: Since we know that we don't use objTargetInfos for other
// targets, we can just update it here instead of creating a copy.
objTargetInfo.deps.push_back("|"); // order-only dependency
objTargetInfo.deps.push_back(testOutDir);

// Add a target to create the testTargetBaseDir.
Expand Down Expand Up @@ -352,7 +354,7 @@ String emitMakefile(const Vec<String>& args) {
// Target to create the tests directory.
addDirectoryTarget(config, testOutDir);

config.defineTarget("test", {}, testTargets);
config.defineTarget("test", testTargets, testTargets);
phonies.push_back("test");
}

Expand Down

0 comments on commit e5ec9c5

Please sign in to comment.