Skip to content

Commit

Permalink
Fix #97 - build per package with -lib
Browse files Browse the repository at this point in the history
  • Loading branch information
atilaneves committed Mar 8, 2021
1 parent ca758fe commit 4f2216b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion payload/reggae/dub/info.d
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ struct DubInfo {
!options.dubDepObjsInsteadOfStaticLib;

return isStaticLibDep
? &dlangStaticLibraryTogether
//? &dlangStaticLibraryTogether
? &dlangStaticLibFilesPerPackage
: compileFunc;
}

Expand Down
39 changes: 39 additions & 0 deletions payload/reggae/rules/d.d
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Target[] dlangObjectsPerPackage(
);
}


Target[] dlangObjectsPerModule(
alias sourcesFunc = Sources!(),
CompilerFlags compilerFlags = CompilerFlags(),
Expand Down Expand Up @@ -136,6 +137,44 @@ Target[] dlangObjectFilesPerPackage(in string[] srcFiles,
.array;
}

/// Generate object files for D sources, compiling the whole package together.
Target[] dlangStaticLibFilesPerPackage(
in string[] srcFiles,
in string[] flags = [],
in string[] importPaths = [],
in string[] stringImportPaths = [],
Target[] implicits = [],
in string projDir = "$project",
)
@trusted pure
{

if(srcFiles.empty) return [];

auto command(in string[] files) {
return compileCommand(files[0].packagePath ~ ".d",
"-lib" ~ flags,
importPaths,
stringImportPaths,
projDir);
}

// the object file for a D package containing pkgFiles
static string outputFileName(in string[] pkgFiles) {
import std.path: baseName;
const path = packagePath(pkgFiles[0]) ~ "_" ~ pkgFiles[0].baseName(".d");
return objFileName(path);
}

return srcFiles
.byPackage
.map!(a => Target(outputFileName(a),
command(a),
a.map!(a => Target(a)).array,
implicits))
.array;
}

/// Generate object files for D sources, compiling each module separately
Target[] dlangObjectFilesPerModule(in string[] srcFiles,
in string[] flags = [],
Expand Down

0 comments on commit 4f2216b

Please sign in to comment.