Skip to content

Commit

Permalink
Merge pull request #10 from jacob-carlborg/snap-config-issue8
Browse files Browse the repository at this point in the history
Fix #8: How to avoid "No valid config found." with snap?
  • Loading branch information
jacob-carlborg authored Jan 23, 2021
2 parents ff01efe + 5341219 commit 1293be1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### New/Changed Features

* Added support for locating DMD/LDC config when they're installed via Snap
* Updated the D frontend DLP is using to DMD 2.095.0
* Added the flag `--target-architecture` for all commands, which specifies the
target architecture
Expand All @@ -14,6 +15,7 @@ configuration file

#### Bugs Fixed

* [Issue 8](https://github.com/jacob-carlborg/dlp/issues/8): How to avoid "No valid config found." with snap?
* [Issue 9](https://github.com/jacob-carlborg/dlp/issues/9): Test fails on FreeBSD using DMD 2.095.0
* [Issue 7](https://github.com/jacob-carlborg/dlp/issues/7): DLP always runs as a 32 bit compiler

Expand Down
2 changes: 1 addition & 1 deletion dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license "BSL-1.0"

targetType "executable"
mainSourceFile "source/dlp/driver/main.d"
dependency "ddc" version="0.0.5"
dependency "ddc" version="0.0.6"

preGenerateCommands "$$DC -run $PACKAGE_DIR/tools/generate_version.d" platform="posix"
preGenerateCommands "%DC% -run $PACKAGE_DIR/tools/generate_version.d" platform="windows"
Expand Down
2 changes: 1 addition & 1 deletion dub.selections.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"fileVersion": 1,
"versions": {
"ddc": "0.0.5+2.095.0"
"ddc": "0.0.6+2.095.0"
}
}
9 changes: 4 additions & 5 deletions source/dlp/driver/command.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ abstract class BaseCommand
// Not part of the public API.
bool start(string[] rawArgs)
{
beforeRun();
return _run(rawArgs);
}

protected void beforeRun()
{

}
protected void beforeCommandLineParsing(string[] rawArgs) {}
protected void afterCommandLineParsing(string[] remainingArgs) {}

// Not part of the public API.
protected abstract bool _run(string[] rawArgs);
Expand All @@ -40,7 +37,9 @@ abstract class Command(Arguments = void) : BaseCommand
import std.format : format;
import dlp.driver.cli : parseCommandLine, printHelp;

beforeCommandLineParsing(rawArgs);
auto result = parseCommandLine(rawArgs, arguments);
afterCommandLineParsing(rawArgs[1 .. $]);

if (result.helpWanted)
{
Expand Down
14 changes: 9 additions & 5 deletions source/dlp/driver/commands/dlp_command.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,22 @@ mixin template StandardArguments()

abstract class DlpCommand(Arguments) : Command!Arguments
{
override void beforeRun()
protected override void beforeCommandLineParsing(string[] rawArgs)
{
import dmd.frontend : findConfigFilename;

static struct TempConfig
{
import dlp.commands.utility : StandardConfig;

mixin StandardConfig;
}

arguments.configFilename = findConfigFilename();
arguments.architecture = TempConfig().architecture;
}

protected override void afterCommandLineParsing(string[] remainingArgs)
{
import dmd.frontend : findConfigFilename;

if (arguments.configFilename.length == 0)
arguments.configFilename = findConfigFilename();
}
}

0 comments on commit 1293be1

Please sign in to comment.