Skip to content

Commit

Permalink
WIP: Drop Phobos dependency for compiler tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Jun 15, 2024
1 parent bed5228 commit 6bda4c1
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions compiler/test/run.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import std.algorithm, std.conv, std.datetime, std.exception, std.file, std.forma
import tools.paths;

const scriptDir = __FILE_FULL_PATH__.dirName.buildNormalizedPath;
immutable testDirs = ["runnable", "runnable_cxx", "dshell", "compilable", "fail_compilation"];
immutable testDirs = ["runnable", "runnable_cxx", /*"dshell",*/ "compilable", "fail_compilation"];
shared bool verbose; // output verbose logging
shared bool force; // always run all tests (ignores timestamp checking)
shared string hostDMD; // path to host DMD binary (used for building the tools)
Expand Down Expand Up @@ -55,7 +55,7 @@ enum TestTool testRunnerUnittests = { name: "d_do_test-ut",
extraArgs: testRunner.extraArgs ~ ["-g", "-unittest"],
runAfterBuild: true };
enum TestTool jsonSanitizer = { name: "sanitize_json" };
enum TestTool dshellPrebuilt = { name: "dshell_prebuilt", linksWithTests: true };
//enum TestTool dshellPrebuilt = { name: "dshell_prebuilt", linksWithTests: true };

immutable struct TestTool
{
Expand Down Expand Up @@ -153,7 +153,7 @@ Options:
return spawnProcess(unitTestRunnerCommand ~ args, env, Config.none, scriptDir).wait();
}

ensureToolsExists(env, unitTestRunner, testRunner, testRunnerUnittests, jsonSanitizer, dshellPrebuilt);
ensureToolsExists(env, unitTestRunner, testRunner, testRunnerUnittests, jsonSanitizer/*, dshellPrebuilt*/);

if (args == ["tools"])
return 0;
Expand Down Expand Up @@ -539,27 +539,24 @@ string[string] getEnvironment()
env["DMD"] = dmdPath;
env.setDefault("DMD_TEST_COVERAGE", "0");

const generatedSuffix = "generated/%s/%s/%s".format(os, build, model);
const druntimePath = environment.get("DRUNTIME_PATH", projectRootDir.buildPath("druntime"));
const druntimeLibDir = generatedDir.buildPath(os, build, model);

version(Windows)
{
env.setDefault("ARGS", "-inline -release -g -O");
env["OBJ"] = ".obj";
env["DSEP"] = `\\`;
env["SEP"] = `\`;
auto druntimePath = environment.get("DRUNTIME_PATH", testPath(`..\..\druntime`));
auto phobosPath = environment.get("PHOBOS_PATH", testPath(`..\..\..\phobos`));
env["DFLAGS"] = `-I"%s\import" -I"%s"`.format(druntimePath, phobosPath);
env["LIB"] = phobosPath ~ ";" ~ environment.get("LIB");
env["DFLAGS"] = `-conf= -I"%s\import" -defaultlib=druntime.lib`.format(druntimePath);
env["LIB"] = druntimeLibDir ~ ";" ~ environment.get("LIB");
}
else
{
env.setDefault("ARGS", "-inline -release -g -O -fPIC");
env["OBJ"] = ".o";
env["DSEP"] = "/";
env["SEP"] = "/";
auto druntimePath = environment.get("DRUNTIME_PATH", testPath(`../../druntime`));
auto phobosPath = environment.get("PHOBOS_PATH", testPath(`../../../phobos`));

// default to PIC, use PIC=1/0 to en-/disable PIC.
// Note that shared libraries and C files are always compiled with PIC.
Expand All @@ -568,11 +565,13 @@ string[string] getEnvironment()
pic = false;

env["PIC_FLAG"] = pic ? "-fPIC" : "";
env["DFLAGS"] = "-I%s/import -I%s".format(druntimePath, phobosPath)
~ " -L-L%s/%s".format(phobosPath, generatedSuffix);
bool isShared = environment.get("SHARED") != "0" && os.among("linux", "freebsd") > 0;

const isShared = environment.get("SHARED") != "0" && os.among("linux", "freebsd") > 0;

env["DFLAGS"] = "-conf= -I%s/import -defaultlib=libdruntime.%s".format(druntimePath, isShared ? "so" : "a")
~ " -L-L" ~ druntimeLibDir;
if (isShared)
env["DFLAGS"] = env["DFLAGS"] ~ " -defaultlib=libphobos2.so -L-rpath=%s/%s".format(phobosPath, generatedSuffix);
env["DFLAGS"] = env["DFLAGS"] ~ " -L-rpath=" ~ druntimeLibDir;

if (pic)
env["REQUIRED_ARGS"] = environment.get("REQUIRED_ARGS") ~ " " ~ env["PIC_FLAG"];
Expand Down

0 comments on commit 6bda4c1

Please sign in to comment.