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

Adapt default sc.ini to MsCoff by default #13611

Merged
merged 2 commits into from
Feb 8, 2022
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
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