Skip to content

Commit

Permalink
Adapt to generic Makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Dec 17, 2023
1 parent 796554b commit 2db36a3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 32 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ name: test_release
on:
pull_request:
push:
branches:
- master

jobs:
build_release:
Expand Down
2 changes: 1 addition & 1 deletion create_dmd_release/build_all.d
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void cloneSources(string gitTag, string dubTag, bool isBranch, bool skipDocs, st
run(fmt.format(gitTag, proj));
}
enforce(nfallback < allProjects.length, "Branch " ~ gitTag ~ " not found in any dlang repo.");
run(fmt.format(dubTag, "dub"));
run(fmt.format(isBranch && !branchExists(prefix ~ "dub", dubTag) ? "master" : dubTag, "dub"));
}

bool branchExists(string gitRepo, string branch)
Expand Down
52 changes: 23 additions & 29 deletions create_dmd_release/create_dmd_release.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Prerequisites to Run:
LDC_VSDIR: Visual Studio directory containing the MSVC toolchains
Examples:
set LDC_VSDIR="C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\"
- Windows: A GNU make, found in PATH as mingw32-make.
- Windows: A version of OPTLINK with the /LA[RGEADDRESSAWARE] flag:
<https://github.com/DigitalMars/optlink/commit/475bc5c1fa28eaf899ba4ac1dcfe2ab415db16c6>
- Windows: Microsoft's HTML Help Workshop on the PATH.
Expand Down Expand Up @@ -79,8 +80,6 @@ version(Windows)
// Cannot start with a period or MS's HTML Help Workshop will fail
immutable defaultWorkDirName = "create_dmd_release";

immutable makefile = "win32.mak";
immutable makefile64 = "win64.mak";
immutable exe = ".exe";
immutable lib = ".lib";
immutable obj = ".obj";
Expand All @@ -90,15 +89,13 @@ version(Windows)
immutable build64BitTools = false;

immutable osDirName = "windows";
immutable make = "make";
immutable make = "mingw32-make";
immutable suffix32 = ""; // bin/lib TODO: adapt scripts to use 32
immutable suffix64 = "64"; // bin64/lib64
}
else version(Posix)
{
immutable defaultWorkDirName = ".create_dmd_release";
immutable makefile = "posix.mak";
immutable makefile64 = "posix.mak";
immutable exe = "";
immutable lib = ".a";
immutable obj = ".o";
Expand Down Expand Up @@ -337,13 +334,13 @@ void buildAll(Bits bits, string branch)
msvcVars = bits == Bits.bits64 ? msvcVarsX64 : msvcVarsX86;
}

auto targetMakefile = bits == Bits.bits32? makefile : makefile64;
auto libPhobos = bits == Bits.bits32? libPhobos32 : libPhobos64;
auto bitsStr = bits == Bits.bits32? "32" : "64";
auto bitsDisplay = toString(bits);
auto makeModel = " MODEL="~bitsStr;
version (Windows)
{
if (bits == Bits.bits32)
makeModel = " MODEL=32omf";
auto jobs = "";
auto dmdEnv = ` "DMD=`~cloneDir~`\dmd\generated\`~osDirName~`\release\32\dmd`~exe~`"`;
enum dmdConf = "sc.ini";
Expand Down Expand Up @@ -371,15 +368,12 @@ void buildAll(Bits bits, string branch)
auto pic = "";

// common make arguments
auto makecmd = make~jobs~makeModel~dmdEnv~hostDMDEnv~isRelease~ltoOption~latest~" -f "~targetMakefile;
const makecmd = make~jobs~makeModel~dmdEnv~hostDMDEnv~isRelease~ltoOption~latest;
const makecmd_no_omf = makecmd.replace(makeModel, " MODEL="~bitsStr); // maps MODEL=32omf to MODEL=32

info("Building DMD "~bitsDisplay);
changeDir(cloneDir~"/dmd");
run(hostDMD~" -g compiler/src/build.d -ofgenerated/build"~exe);
version(Windows)
run(msvcVars~`generated\build.exe`~jobs~makeModel~hostDMDEnv~isRelease~ltoOption~latest~" dmd");
else
run("generated/build"~jobs~makeModel~hostDMDEnv~isRelease~ltoOption~latest~" dmd");
run(msvcVars~makecmd_no_omf~" dmd");

// Add libraries to the LIB variable in sc.ini
version(Windows)
Expand Down Expand Up @@ -407,17 +401,19 @@ void buildAll(Bits bits, string branch)
version(Windows)
copyFile(customExtrasDir~"/dmd2/windows/bin/optlink.exe", cloneDir~"/dmd/generated/"~osDirName~"/release/"~bitsStr~"/optlink.exe");

string makeTargetDruntime;
version(Windows)
if (bits == Bits.bits32)
makeTargetDruntime = " target implibs";

info("Building Druntime "~bitsDisplay);
changeDir(cloneDir~"/dmd/druntime");
run(msvcVars~makecmd~pic~makeTargetDruntime);
run(msvcVars~makecmd~pic);
removeFiles(cloneDir~"/dmd/druntime", "*{"~obj~"}", SpanMode.depth,
file => !file.baseName.startsWith("minit"));

version(Windows) if (bits == Bits.bits32)
{
info("Building OMF import libraries");
changeDir(cloneDir~"/dmd/druntime/def");
run(make~jobs);
}

info("Building Phobos "~bitsDisplay);
changeDir(cloneDir~"/phobos");
run(msvcVars~makecmd~pic);
Expand All @@ -427,13 +423,13 @@ void buildAll(Bits bits, string branch)
{
info("Building Druntime 32mscoff");
changeDir(cloneDir~"/dmd/druntime");
run(msvcVarsX86~makecmd.replace(makeModel, " MODEL=32mscoff"));
run(msvcVarsX86~makecmd.replace(makeModel, " MODEL=32"));
removeFiles(cloneDir~"/dmd/druntime", "*{"~obj~"}", SpanMode.depth,
file => !file.baseName.startsWith("minit"));

info("Building Phobos 32mscoff");
changeDir(cloneDir~"/phobos");
run(msvcVarsX86~makecmd.replace(makeModel, " MODEL=32mscoff"));
run(msvcVarsX86~makecmd.replace(makeModel, " MODEL=32"));
removeFiles(cloneDir~"/phobos", "*{"~obj~"}", SpanMode.depth);
}

Expand All @@ -445,7 +441,7 @@ void buildAll(Bits bits, string branch)
if (bits == Bits.bits64)
{
changeDir(cloneDir~"/dlang.org");
run(makecmd~" DOC_OUTPUT_DIR="~origDir~"/docs release");
run(makecmd~" DOC_OUTPUT_DIR="~origDir~"/docs -f posix.mak release");
// copy generated man pages to docs/man which gets copied to all other platforms
copyDir(cloneDir~"/dmd/generated/docs/man", origDir~"/docs/man");
}
Expand All @@ -454,17 +450,15 @@ void buildAll(Bits bits, string branch)

if(build64BitTools || bits == Bits.bits32)
{

// Build the tools using the host compiler
makecmd = makecmd.replace(dmdEnv, " DMD=" ~ hostDMD);
auto tools_makecmd = makecmd_no_omf.replace(dmdEnv, " DMD=" ~ hostDMD);

// Override DFLAGS because we're using the host compiler rather than
// the freshly built one (posix.mak defaults to the generated dmd)
makecmd ~= ` DFLAGS="-O -release -m` ~ bitsStr ~ ` -version=DefaultCompiler_DMD"`;
// Override DFLAGS for a release build defaulting to DMD.
tools_makecmd ~= ` DFLAGS="-O -release -m` ~ bitsStr ~ ` -version=DefaultCompiler_DMD"`;

info("Building Tools "~bitsDisplay);
changeDir(cloneDir~"/tools");
run(makecmd~" rdmd ddemangle dustmite");
run(tools_makecmd~" rdmd ddemangle dustmite");

removeFiles(cloneDir~"/tools", "*.{"~obj~"}", SpanMode.depth);
}
Expand Down Expand Up @@ -553,7 +547,7 @@ void createRelease(string branch)
if(do32Bit)
{
copyFile(cloneDir~"/phobos/phobos.lib", osDir~"/lib/phobos.lib");
copyDir(cloneDir~"/dmd/druntime/lib/win32/", osDir~"/lib/", file => file.endsWith(".lib"));
copyDir(cloneDir~"/dmd/druntime/def/", osDir~"/lib/", file => file.endsWith(".lib"));
}
if(do64Bit)
{
Expand Down

0 comments on commit 2db36a3

Please sign in to comment.