From 75a5fe5334d8f6eda70ff168c09e5e1bc12bcb2f Mon Sep 17 00:00:00 2001 From: MoonlightSentinel Date: Tue, 8 Feb 2022 13:17:26 +0100 Subject: [PATCH] rdmd: Allow selection of default compiler independent from the host one Extends the `defaultCompiler` selection s.t. custom defaults can be selected at compile time via `-version=DefaultCompiler_XXX` (where `XXX` is either `DMD`, `LDC` or `GDC`). This allows the `rdmd` bundled with DMD to be built with LDC while still defaulting to DMD. --- rdmd.d | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rdmd.d b/rdmd.d index 720ea7e..51df6ee 100755 --- a/rdmd.d +++ b/rdmd.d @@ -47,7 +47,16 @@ immutable string[] defaultExclusions = ["std", "etc", "core"]; private string[] exclusions = defaultExclusions; // packages that are to be excluded private string[] extraFiles = []; -version (DigitalMars) +// Override compiler at build time +version (DefaultCompiler_DMD) + private enum defaultCompiler = "dmd"; +else version (DefaultCompiler_GDC) + private enum defaultCompiler = "gdmd"; +else version (DefaultCompiler_LDC) + private enum defaultCompiler = "ldmd2"; + +// Default to the current host compiler if no default was specified +else version (DigitalMars) private enum defaultCompiler = "dmd"; else version (GNU) private enum defaultCompiler = "gdmd";