Skip to content

Commit

Permalink
Merge pull request #295 from atilaneves/update
Browse files Browse the repository at this point in the history
Update to dub 1.37.0
  • Loading branch information
atilaneves authored Apr 23, 2024
2 parents 9a67d1a + f125834 commit 1d3b46e
Show file tree
Hide file tree
Showing 22 changed files with 103 additions and 81 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/d.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ jobs:
os: [ubuntu-22.04, windows-2019]
# Remember to change the compiler versions further below as well as here
dc:
- dmd-2.106.1
- dmd-2.108.0
- dmd-2.105.2
- ldc-1.36.0
- ldc-1.34.0
- ldc-1.37.0

runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -55,10 +54,9 @@ jobs:
matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
dc:
- dmd-2.106.1
- dmd-2.108.0
- dmd-2.105.2
- ldc-1.36.0
- ldc-1.34.0
- ldc-1.37.0
runs-on: ${{ matrix.os }}
defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"mainSourceFile": "src/reggae/reggae_main.d",
"preGenerateCommands": ["rdmd $PACKAGE_DIR/list_payload.d $PACKAGE_DIR"],
"dependencies": {
"dub": "~>1.36.0"
"dub": "~>1.37.0"
},
"subConfigurations": {
"dub": "library"
Expand Down
4 changes: 2 additions & 2 deletions dub.selections.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"fileVersion": 1,
"versions": {
"dub": "1.36.0",
"unit-threaded": "2.1.7"
"dub": "1.37.0",
"unit-threaded": "2.1.9"
}
}
4 changes: 2 additions & 2 deletions payload/reggae/backend/make.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct Makefile {

this(Build build, in Options options) @safe pure {
this.build = build;
this.options = options;
this.options = options.dup;
}

string fileName() @safe pure nothrow const {
Expand Down Expand Up @@ -55,7 +55,7 @@ struct Makefile {
return ret;
}

private static string replaceEnvVars(in string str) @safe {
private static string replaceEnvVars(string str) @safe {
import std.regex: regex, matchAll;
import std.algorithm: _sort = sort, uniq, map;
import std.array: array, replace;
Expand Down
10 changes: 5 additions & 5 deletions payload/reggae/backend/ninja.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct Ninja {

this(Build build, in Options options) @safe {
_build = build;
_options = options;
_options = options.dup;
_projectPath = _options.projectPath;

foreach(target; _build.range) {
Expand Down Expand Up @@ -190,7 +190,7 @@ private:
}
}

void explicitInOutRule(Target target, in string shellCommand, in string implicitInput = "") @safe {
void explicitInOutRule(Target target, string shellCommand, string implicitInput = "") @safe {
import std.regex: regex, match;
import std.algorithm.iteration: map;
import std.array: empty, join;
Expand Down Expand Up @@ -302,7 +302,7 @@ private:
//ordering. The first time we create a rule with the same name as the command.
//The subsequent times, if any, we append a number to the command to create
//a new rule
string getRuleName(in string cmd, in string ruleCmdLine, out bool haveToAdd) @safe nothrow {
string getRuleName(string cmd, in string ruleCmdLine, out bool haveToAdd) @safe nothrow {
import std.algorithm.searching: canFind, startsWith;
import std.algorithm.iteration: filter;
import std.array: array, empty, replace;
Expand Down Expand Up @@ -404,7 +404,7 @@ private:
}
}

private string escapePathInBuildLine(in string path) @safe pure {
private string escapePathInBuildLine(string path) @safe pure {
import std.array: replace;
return path.replace(":", "$:").replace(" ", "$ ");
}
Expand Down Expand Up @@ -549,7 +549,7 @@ private string cmdTypeToNinjaRuleName(CommandType commandType, Language language

//ninja doesn't like symbols in rule names
//@trusted because of replace
private string sanitizeCmd(in string cmd) @trusted pure nothrow {
private string sanitizeCmd(string cmd) @trusted pure nothrow {
import std.path: baseName;
import std.array: replace;
//only handles c++ compilers so far...
Expand Down
8 changes: 7 additions & 1 deletion payload/reggae/backend/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@ package string[] maybeAddDirDependencies(
return srcs
.map!(t => t.expandOutputs(projectPath)[0])
.map!dirName
.array;
.trustedArray;
}

// TODO: fix std.array.array
auto trustedArray(R)(auto ref scope R rng) @trusted {
import std.array: array;
return rng.array;
}
2 changes: 1 addition & 1 deletion payload/reggae/backend/tup.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct Tup {

this(Build build, in Options options) {
this.build = build;
this.options = options;
this.options = options.dup;
}

string output() pure {
Expand Down
51 changes: 28 additions & 23 deletions payload/reggae/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ struct Target {

enum Target[] noTargets = [];

this(string output) @safe pure nothrow {
this(in string output) @safe pure nothrow {
this(output, "", noTargets, noTargets);
}

Expand Down Expand Up @@ -277,19 +277,19 @@ struct Target {
/**
The outputs without expanding special variables
*/
@property inout(string)[] rawOutputs(in string projectPath = "") @safe pure inout {
@property inout(string)[] rawOutputs(in string projectPath = "") @safe pure inout return scope {
return _outputs;
}

@property inout(Target)[] dependencyTargets(in string projectPath = "") @safe pure nothrow inout {
@property inout(Target)[] dependencyTargets(in string projectPath = "") @safe pure nothrow inout return scope {
return _dependencies;
}

@property inout(Target)[] implicitTargets(in string projectPath = "") @safe pure nothrow inout {
return _implicits;
}

@property string[] dependenciesInProjectPath(in string projectPath) @safe pure const {
@property string[] dependenciesInProjectPath(in string projectPath) @safe pure const scope {
return depsInProjectPath(_dependencies, projectPath);
}

Expand Down Expand Up @@ -317,7 +317,7 @@ struct Target {
}

///Replace special variables and return a list of outputs thus modified
string[] expandOutputs(in string projectPath) @safe pure const {
string[] expandOutputs(in string projectPath) @safe pure return scope const {
return _outputs.map!(o => expandOutput(o, projectPath)).array;
}

Expand All @@ -340,11 +340,11 @@ struct Target {
return _command.isDefaultCommand;
}

CommandType getCommandType() @safe pure const nothrow {
CommandType getCommandType() @safe pure const nothrow scope {
return _command.getType;
}

string[] getCommandParams(in string projectPath, in string key, string[] ifNotFound) @safe pure const {
string[] getCommandParams(in string projectPath, in string key, string[] ifNotFound) @safe pure const return scope {
return _command.getParams(projectPath, key, ifNotFound);
}

Expand Down Expand Up @@ -437,7 +437,7 @@ struct Target {

private:

string[] depsInProjectPath(in Target[] deps, in string projectPath) @safe pure const {
string[] depsInProjectPath(in Target[] deps, in string projectPath) @safe pure const scope {
import reggae.range;
return deps.map!(a => a.expandOutputs(projectPath)).join;
}
Expand Down Expand Up @@ -511,7 +511,8 @@ struct Command {
this.function_ = func;
}

static Command phony(in string shellCommand) @safe pure nothrow {
// TODO: DIP100 bug? Why can't I return `cmd`?
static Command phony(in string shellCommand) @trusted pure nothrow scope {
Command cmd;
cmd.type = CommandType.phony;
cmd.command = shellCommand;
Expand All @@ -522,7 +523,7 @@ struct Command {
return params.keys;
}

CommandType getType() @safe pure const nothrow {
CommandType getType() @safe pure const nothrow scope {
return type;
}

Expand All @@ -532,7 +533,8 @@ struct Command {
return cast(bool) type.among(compile, link, compileAndLink);
}

string[] getParams(in string projectPath, in string key, string[] ifNotFound) @safe pure const {
// TODO: DIP1000 bug? Complaining about scope when there's scope on both `getParams` overloads
string[] getParams(in string projectPath, in string key, string[] ifNotFound) @trusted pure const return scope {
return getParams(projectPath, key, true, ifNotFound);
}

Expand Down Expand Up @@ -561,9 +563,12 @@ struct Command {
}

private string[] getParams(string projectPath, in string key,
bool useIfNotFound, string[] ifNotFound = []) @safe pure const {
bool useIfNotFound, string[] ifNotFound = []) @safe pure const return scope {
projectPath = buildPath(projectPath);
return params.get(key, ifNotFound).map!(a => a.replace(gProjdir, projectPath)).array;
return params
.get(key, ifNotFound)
.map!(a => a.replace(gProjdir, projectPath))
.array;
}

// Caution: never trust comments in code.
Expand All @@ -575,7 +580,7 @@ struct Command {
const(string)[] execute(
in Options options,
in Language language,
in string[] outputs,
const string[] outputs,
in string[] inputs
)
const @trusted
Expand Down Expand Up @@ -730,8 +735,8 @@ struct Command {
}

///Replace $in, $out, $project with values and remove $builddir
private static auto expandCmd(in string[] cmd, in string projectPath,
in string[] outputs, in string[] inputs)
private static auto expandCmd(const string[] cmd, const string projectPath,
const string[] outputs, const string[] inputs)
@safe pure
{
import std.array: replace;
Expand Down Expand Up @@ -792,12 +797,12 @@ struct Command {
final switch(language) with(Language) {
case D:
case unknown:
return options.dCompiler ~
return options.dCompiler.idup ~
["-of$out", "$flags", "$in"];
case Cplusplus:
return options.cppCompiler ~ cArgs;
return options.cppCompiler.idup ~ cArgs;
case C:
return options.cCompiler ~ cArgs;
return options.cCompiler.idup ~ cArgs;
}
}

Expand Down Expand Up @@ -859,15 +864,15 @@ struct Command {
const postfix = deps
? ["$in"]
: [output, "$in"];
auto meat = options.dCompiler ~
auto meat = options.dCompiler.idup ~
makeDeps ~
["$flags", "$includes", "$stringImports", output, colour, "-c"];
return meat ~ postfix;
}
case Cplusplus:
return options.cppCompiler ~ ccParams;
return options.cppCompiler.idup ~ ccParams;
case C:
return options.cCompiler ~ ccParams;
return options.cCompiler.idup ~ ccParams;
case unknown:
throw new Exception("Unsupported language for compiling");
}
Expand Down Expand Up @@ -987,7 +992,7 @@ private ubyte[] setUshort(in ushort length) @safe pure nothrow {
}


string replaceConcreteCompilersWithVars(in string cmd, in Options options) @safe pure nothrow {
string replaceConcreteCompilersWithVars(const string cmd, in Options options) @safe pure nothrow {
return cmd.
replace(options.dCompiler, "$(DC)").
replace(options.cppCompiler, "$(CXX)").
Expand Down
2 changes: 1 addition & 1 deletion payload/reggae/ctaa.d
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct AssocList(K, V) {
entries ~= AssocEntry!(K, V)(key, value);
}

T get(T)(in K key, T defaultValue) pure const {
T get(T)(in K key, T defaultValue) pure const scope {
import std.conv: to;
// workaround for a bug
if(__ctfe && _isEmpty) return defaultValue;
Expand Down
2 changes: 1 addition & 1 deletion payload/reggae/dependencies.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module reggae.dependencies;

// Get a D file's dependencies from a file generated with
// -makedeps=$filename
string[] parseDepFile(in string fileName) @safe {
string[] parseDepFile(const string fileName) @safe {
import std.string: chomp;
import std.algorithm: splitter, filter, canFind, among;
import std.array: array;
Expand Down
2 changes: 1 addition & 1 deletion payload/reggae/dub/info.d
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ struct DubInfo {
}


private string[] packagePaths(in DubPackage dubPackage, in string[] paths) @safe pure nothrow {
private string[] packagePaths(in DubPackage dubPackage, const string[] paths) @safe pure nothrow {
import std.algorithm: map;
import std.array: array;
import std.path: buildPath;
Expand Down
9 changes: 9 additions & 0 deletions payload/reggae/dub/interop/dublib.d
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,23 @@ package struct Dub {
const allConfigs = singleConfig == "";
// add the special `dub test` configuration (which doesn't require an existing `unittest` config)
const lookingForUnitTestsConfig = allConfigs || singleConfig == "unittest";
import reggae.io;
import std.stdio: output = stdout;
output.log("testConfig shenanigans");
const testConfig = lookingForUnitTestsConfig
? _dub.project.addTestRunnerConfiguration(_generatorSettings)
: null; // skip when requesting a single non-unittest config
output.log("testConfig shenanigans... done");

// error out if the test config is explicitly requested but not available
if(_options.dubConfig == "unittest" && testConfig == "") {
throw new Exception("No dub test configuration available (target type 'none'?)");
}

const haveSpecialTestConfig = testConfig.length && testConfig != "unittest";
output.log("Getting default config");
const defaultConfig = _dub.project.getDefaultConfiguration(_generatorSettings.platform);
output.log("as strings");

// A violation of the Law of Demeter caused by a dub bug.
// Otherwise _dub.project.configurations would do, but it fails for one
Expand All @@ -189,6 +195,7 @@ package struct Dub {
;

if (!allConfigs) { // i.e. one single config specified by the user
output.log("not all configs");
// translate `unittest` to the actual test configuration
const requestedConfig = haveSpecialTestConfig ? testConfig : singleConfig;

Expand All @@ -210,10 +217,12 @@ package struct Dub {
return DubConfigurations([actualConfig], actualConfig, testConfig);
}

output.log("filter array");
auto configurations = allConfigurationsAsStrings
// exclude unittest config if there's a derived special one
.filter!(n => !haveSpecialTestConfig || n != "unittest")
.array;
output.log("returning");

return DubConfigurations(configurations, defaultConfig, testConfig);
}
Expand Down
Loading

0 comments on commit 1d3b46e

Please sign in to comment.