Skip to content

Commit

Permalink
Merge pull request #13611 from MoonlightSentinel/config-windows
Browse files Browse the repository at this point in the history
Adapt default `sc.ini` to MsCoff by default

Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
  • Loading branch information
dlang-bot authored Feb 8, 2022
2 parents f688e34 + b1470ac commit f794d74
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 4 deletions.
7 changes: 4 additions & 3 deletions ini/windows/bin/sc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ version=7.51 Build 020
DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import"

; optlink only reads from the Environment section so we need this redundancy
; from the Environment32 section (bugzilla 11302)
; from the Environment32omf section (bugzilla 11302)
LIB="%@P%\..\lib"


[Environment32]
LIB=%@P%\..\lib32mscoff

[Environment32omf]
LIB="%@P%\..\lib"
LINKCMD=%@P%\optlink.exe


[Environment64]
LIB=%@P%\..\lib64

Expand Down
3 changes: 3 additions & 0 deletions src/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ alias dmdConf = makeRule!((builder, rule) {
DFLAGS="-I%@P%\..\..\..\..\..\druntime\import" "-I%@P%\..\..\..\..\..\phobos"
LIB="%@P%\..\..\..\..\..\phobos"
[Environment32]
DFLAGS=%DFLAGS% -L/OPT:NOICF
[Environment64]
DFLAGS=%DFLAGS% -L/OPT:NOICF
Expand Down
78 changes: 78 additions & 0 deletions test/dshell/defaults.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/// Verifies that DMD using default settings work as expected
/// when using the default configuration + some example programs
module defaults;

import std.algorithm;
import std.file;
import std.path;
import std.stdio;

import dshell;

int main(const string[] args)
{
// dshellPrebuiltInit("dshell", "defaults");

try
{
testConfigurations();
return 0;
}
catch (Throwable t)
{
writeln(t.msg);
return 1;
}
}

void testConfigurations()
{
// Compilation targets
const string[] targets = [ MODEL ];

// Configuration file
version (Windows)
const string config = `bin\sc.ini`;
else version (OSX)
const string config = `bin/dmd.conf`;
else
const string config = `bin` ~ MODEL ~ `/dmd.conf`;

// Static configuration file for the final release
string configPath = buildNormalizedPath(dirName(__FILE_FULL_PATH__), "..", "..", "ini", OS, config);

// Flag sets to test
string[] extraFlags = [
// Minimal configuration generated by build.d
"",
// Predefined, full configuration located in ini
"-conf=" ~ configPath
];

version (Windows) if (MODEL == "32omf")
{
// 32-OMF tries to use `optlink.exe` located next to `sc.ini`
// and also doesn't like the LIB setup, so skip it for now
extraFlags = [""];
}

foreach (const target; targets)
{
foreach (const flags; extraFlags)
{
run(
`$DMD ` ~ flags ~ ` -g -m` ~ target
~ ` -I$EXTRA_FILES/defaults `
~ DFLAGS
~ ` $EXTRA_FILES/defaults/hello.d `
~ ` -of=$OUTPUT_BASE/hello$EXE `,
);

auto pipe = std.process.pipe();
run(`$OUTPUT_BASE/hello$EXE`, pipe.writeEnd, stderr);
const output = cast(string) pipe.readEnd.byChunk(4096).join();
stdout.writeln(output);
assert(output.canFind("Hello, World from D!"));
}
}
}
9 changes: 9 additions & 0 deletions test/dshell/extra-files/defaults/hello.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// A common yet underrated D program
module defaults.hello;

import std.stdio;

void main()
{
writeln("Hello, World from D!");
}
4 changes: 3 additions & 1 deletion test/tools/d_do_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,7 @@ static this()
testScriptPath,
];
outfile.writeln("[COMPILE_TEST] ", escapeShellCommand(compile));
outfile.flush();
// Note that spawnprocess closes the file, so it will need to be re-opened
// below when we run the test
auto compileProc = std.process.spawnProcess(compile, stdin, outfile, outfile, null, keepFilesOpen);
Expand All @@ -2088,7 +2089,8 @@ static this()
//
{
const runTest = [testScriptExe];
outfile.writeln("[RUN_TEST] ", escapeShellCommand(runTest));
outfile.writeln("\n[RUN_TEST] ", escapeShellCommand(runTest));
outfile.flush();
auto runTestProc = std.process.spawnProcess(runTest, stdin, outfile, outfile, null, keepFilesOpen);
const exitCode = wait(runTestProc);

Expand Down
4 changes: 4 additions & 0 deletions test/tools/dshell_prebuilt/dshell_prebuilt.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct Vars
return result;
}
static string opDispatch(string name)() { return get(name); }
static void opDispatch(string name)(string value) { set(name, value); }
}

private alias requiredEnvVars = AliasSeq!(
Expand Down Expand Up @@ -169,8 +170,11 @@ auto tryRun(scope const(char[])[] args, File stdout = std.stdio.stdout,
{
std.stdio.stdout.write(" > ", stdout.name);
}
// "Commit" all output from the tester
std.stdio.stdout.writeln();
std.stdio.stdout.flush();
std.stdio.stderr.writeln();
std.stdio.stderr.flush();
auto proc = spawnProcess(args, stdin, stdout, stderr, env);
return wait(proc);
}
Expand Down

0 comments on commit f794d74

Please sign in to comment.