Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor dubDependant #314

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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