Skip to content

Commit

Permalink
Fix binary backend executable name/location
Browse files Browse the repository at this point in the history
  • Loading branch information
atilaneves committed Feb 16, 2024
1 parent 36c9d40 commit 19f5cee
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/reggae/reggae.d
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private Binary buildReggaefileDub(O)(
import std.path: buildPath;
import std.algorithm: map, joiner;
import std.range: chain, only;
import std.array: replace;
import std.array: replace, join;

// calculates .dep so getReggaeFileDependenciesDlang works below
calculateReggaeFileDeps(output, options);
Expand Down Expand Up @@ -318,13 +318,21 @@ private Binary buildReggaefileDub(O)(
const dubRecipeDir = hiddenDirAbsPath(options);
const dubRecipePath = buildPath(dubRecipeDir, "dub.sdl");

const linesIfBinary = [
`targetPath ".."`,
`targetName "build"`,
];
const extraLines = options.backend == Backend.binary
? linesIfBinary
: [];

writeIfDiffers(
output,
dubRecipePath,
reggaeFileDubSdl.format(
userSourceFilesForDubSdl,
importPathsForDubSdl,
),
) ~ extraLines.join("\n"),
);

writeIfDiffers(
Expand Down Expand Up @@ -499,7 +507,7 @@ private string getBuildGenName(in Options options) @safe pure nothrow {
import reggae.rules.common: exeExt;

const baseName = options.backend == Backend.binary
? buildPath("../build")
? "../build"
: "buildgen";
return baseName ~ exeExt;
}
Expand Down
20 changes: 20 additions & 0 deletions tests/it/runtime/regressions.d
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,23 @@ unittest {
ninja.shouldFailToExecute(testPath);
}
}

@("buildgen.binary")
@Tags("binary")
unittest {
import reggae.rules.common: exeExt;
with(immutable ReggaeSandbox()) {
writeFile(
"reggaefile.d",
q{
import reggae;
alias lib = staticLibrary!("mylib", Sources!("src"));
mixin build!lib;
}
);

writeFile("src/foo.d", "void foo() {}");
runReggae("-b", "binary");
shouldExist("build" ~ exeExt);
}
}

0 comments on commit 19f5cee

Please sign in to comment.