Skip to content

Commit

Permalink
Add support for reggae build.
Browse files Browse the repository at this point in the history
Note that this breaks the (never used?) arm32 build
  • Loading branch information
Guillaume Piolat committed Nov 19, 2024
1 parent 60a51e2 commit 2ed022b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tools/dplug-build/source/arch.d
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ string convertArchToDUBFlag(Arch arch, OS targetOS) pure
{
final switch(arch) with (Arch)
{
case x86: return "--arch=x86 ";
case x86_64: return "--arch=x86_64 ";
case x86: return "x86 ";
case x86_64: return "x86_64 ";

// Explanation: the dub and ldc2 bundled on Raspberry Pi OS build to the right arch by default
// aka: arm-linux-gnueabihf
Expand All @@ -68,9 +68,9 @@ string convertArchToDUBFlag(Arch arch, OS targetOS) pure
case arm64:
{
if (targetOS == OS.macOS)
return "--arch=arm64-apple-macos ";
return "arm64-apple-macos ";
else
return "--arch=aarch64 ";
return "aarch64 ";
}

case universalBinary: assert(false);
Expand Down
51 changes: 48 additions & 3 deletions tools/dplug-build/source/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void usage()
flag("--no-color", "Disable colored output", null, null);
flag("--parallel", "Use dub --parallel", null, null);
flag("--redub", "Use redub instead of dub", null, null);
flag("--reggae", "Use reggae+ninja instead of dub (must be in PATH)", null, null);
flag("--root", "Path where plugin.json is", null, "current working directory");
flag("--installer", "Make an installer " ~ " (Windows, macOS)".lred, null, null);
flag("--notarize", "Notarize the installer " ~ " (macOS)".lred, null, null);
Expand Down Expand Up @@ -163,6 +164,7 @@ int main(string[] args)
bool skipRegistry = false;
bool parallel = false;
bool redub = false;
bool reggae = false;
bool legacyPT10 = false;
bool finalFlag = false;
string prettyName = null;
Expand Down Expand Up @@ -299,6 +301,8 @@ int main(string[] args)
publish = true;
else if (arg == "--redub")
redub = true;
else if (arg == "--reggae")
reggae = true;
else if (arg == "--auval")
{
publish = true; // Need publishing to use auval
Expand Down Expand Up @@ -589,7 +593,7 @@ int main(string[] args)
pathOverriden = false;
}

buildPlugin(targetOS, compilerPath, pathOverriden, config, build, arch, rootDir, verbose, force, combined, quiet, skipRegistry, parallel, redub);
buildPlugin(targetOS, compilerPath, pathOverriden, config, build, arch, rootDir, verbose, force, combined, quiet, skipRegistry, parallel, redub, reggae);
double bytes = getSize(plugin.dubOutputFileName()) / (1024.0 * 1024.0);
cwritefln(" => Build OK, binary size = %0.1f mb, available in %s".lgreen, bytes, normalizedPath("./" ~ path));
cwriteln();
Expand Down Expand Up @@ -1504,7 +1508,7 @@ void buildPlugin(OS targetOS,
string compiler, bool pathOverriden, string config, string build, Arch arch,
string rootDir,
bool verbose, bool force, bool combined, bool quiet,
bool skipRegistry, bool parallel, bool useRedub)
bool skipRegistry, bool parallel, bool useRedub, bool useReggae)
{
cwritefln("*** Building configuration %s with %s%s, %s arch...",
config,
Expand Down Expand Up @@ -1532,9 +1536,50 @@ void buildPlugin(OS targetOS,
environment["DFLAGS"] = "-fvisibility=hidden -dllimport=none";
}

if (useReggae && useRedub)
throw new Exception("Can't use --redub and --reggae at the same time");

if (useReggae)
{
// force reggae and ninja build
if (force)
{
rmdirRecurse(rootDir ~ "/.reggae");
std.file.remove(rootDir ~ "/.ninja_log");
}

// Note: reggae doesn't seem to have a --root argument
{
auto cwd = getcwd;
rootDir.chdir;
scope(exit) cwd.chdir;

string cmd = format("reggae --dub-build-type %s --dflags=\"--flto=thin\" --dc %s --dub-arch %s%s%s %s",
build,
compiler,
convertArchToDUBFlag(arch, targetOS),
(combined ? " --all-at-once" : ""),
(config ? " --dub-config " ~ config : ""),
escapeShellArgument(rootDir)
);
safeCommand(cmd);
}

// Call ninja. Normally reggae is like a cmake that generates ninja files, so you'd just need to
// call "ninja" to rebuild your plugin. That can work, but you would only get the plugin binary, which
// is not sufficient.
{
string cmd = format("ninja %s%s",
(rootDir != "." ? " -C " ~ escapeShellArgument(rootDir) : ""),
(verbose ? " -v" : "") );
safeCommand(cmd);
}
return;
}

string dubBinary = useRedub ? "redub" : "dub";

string cmd = format("%s build --build=%s %s--compiler=%s%s%s%s%s%s%s%s%s",
string cmd = format("%s build --build=%s --arch=%s--compiler=%s%s%s%s%s%s%s%s%s",
dubBinary,
build,
convertArchToDUBFlag(arch, targetOS),
Expand Down

0 comments on commit 2ed022b

Please sign in to comment.