Skip to content

Commit

Permalink
Refactor dubDependant
Browse files Browse the repository at this point in the history
  • Loading branch information
atilaneves committed Jun 25, 2024
1 parent 7febb23 commit 273fa61
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion payload/reggae/rules/common.d
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ private string staticLibraryShellCommand() @safe {
}
}

private Target[] srcFilesToObjectTargets(
Target[] srcFilesToObjectTargets(
in imported!"reggae.options".Options options,
in string[] srcFiles,
in CompilerFlags flags,
Expand Down
40 changes: 36 additions & 4 deletions payload/reggae/rules/dub/external.d
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,37 @@ imported!"reggae.build".Target dubDependant
auto ref A args,
)
{
import reggae.rules.common: objectFiles;
import reggae.rules.common: sourcesToFileNames;
import std.functional: forward;

const srcFiles = sourcesToFileNames!sourcesFunc(options);
return dubDependant(options, targetName, targetType, srcFiles, forward!args);
}

// runtime version
imported!"reggae.build".Target dubDependant
(A...)
(
in imported!"reggae.options".Options options,
in imported!"reggae.types".TargetName targetName,
DubPackageTargetType targetType,
in string[] srcFiles,
// the other arguments can be:
// * DubPath
// * DubVersion
// * CompilerFlags
// * LinkerFlags
// * ImportPaths
// * StringImportPaths
auto ref A args,
)
{
import reggae.rules.common: objectFiles, srcFilesToObjectTargets;
import reggae.rules.d: dlink;
import reggae.types: TargetName, CompilerFlags, LinkerFlags, ImportPaths, StringImportPaths;
import std.algorithm: map, joiner;
import std.array: array;
import std.range: chain;
import std.range: chain, only;
import std.traits: Unqual;

template oneOptionalOf(T) {
Expand Down Expand Up @@ -151,8 +176,14 @@ imported!"reggae.build".Target dubDependant
dubVersDependencies.map!(d => d.dubInfo.packages.map!(p => p.stringImportPaths).joiner).joiner,
);

auto objs = objectFiles!sourcesFunc(
// auto allLinkerFlags = chain(
// "-L--no-as-needed".only,
// linkerFlags.value,
// );

auto objs = srcFilesToObjectTargets(
options,
srcFiles,
compilerFlags,
const ImportPaths(allImportPaths),
const StringImportPaths(allStringImportPaths),
Expand All @@ -168,10 +199,11 @@ imported!"reggae.build".Target dubDependant
return dlink(
TargetName(targetNameWithExt),
objs ~ dubDepsObjs,
linkerFlags,
linkerFlags, //const LinkerFlags(allLinkerFlags),
);
}


private struct DubPathDependency {
import reggae.options: Options;
import reggae.build: Target;
Expand Down
7 changes: 7 additions & 0 deletions payload/reggae/types.d
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ struct CompilerFlags {
}

struct LinkerFlags {
import std.range.primitives: isInputRange;

string[] value;

this(string value) @trusted pure {
Expand All @@ -63,6 +65,11 @@ struct LinkerFlags {
this.value = values.dup;
}

this(R)(R range) inout @trusted /*array*/ if(isInputRange!R) {
import std.array: array;
this.value = cast(typeof(this.value)) range.array;
}

this(inout(string)[] values) inout @safe @nogc pure nothrow {
this.value = values;
}
Expand Down

0 comments on commit 273fa61

Please sign in to comment.