diff --git a/changelog/rdmd_shared.dd b/changelog/rdmd_shared.dd new file mode 100644 index 0000000..4242240 --- /dev/null +++ b/changelog/rdmd_shared.dd @@ -0,0 +1,3 @@ +rdmd supports `-shared` + +rdmd now understands DMD's `-shared` switch, and sets the default output file name appropriately (`.dll` or `so` depending on the platform), in the same way as `-lib`. diff --git a/rdmd.d b/rdmd.d index d02cacc..5eeb373 100755 --- a/rdmd.d +++ b/rdmd.d @@ -27,6 +27,7 @@ version (Posix) enum objExt = ".o"; enum binExt = ""; enum libExt = ".a"; + enum dllExt = ".so"; enum altDirSeparator = ""; } else version (Windows) @@ -34,6 +35,7 @@ else version (Windows) enum objExt = ".obj"; enum binExt = ".exe"; enum libExt = ".lib"; + enum dllExt = ".dll"; enum altDirSeparator = "/"; } else @@ -242,10 +244,15 @@ int main(string[] args) bool obj = compilerFlags.canFind("-c"); bool lib = compilerFlags.canFind("-lib"); - string outExt = lib ? libExt : obj ? objExt : binExt; + bool dll = compilerFlags.canFind("-shared"); + string outExt = + dll ? dllExt : + lib ? libExt : + obj ? objExt : + binExt; - // Assume --build-only for -c and -lib. - buildOnly |= obj || lib; + // Assume --build-only for -c / -lib / -shared. + buildOnly |= obj || lib || dll; // --build-only implies the user would like a binary in the program's directory if (buildOnly && !exe.ptr) @@ -360,7 +367,7 @@ size_t indexOfProgram(string[] args) { auto arg = args[i]; if (!arg.startsWith('-', '@') && - !arg.endsWith(".obj", ".o", ".lib", ".a", ".def", ".map", ".res") && + !arg.endsWith(".obj", ".o", ".lib", ".a", ".dll", ".so", ".def", ".map", ".res") && args[i - 1] != "--eval") { return i;