Merge remote-tracking branch 'upstream/master' into stable

This commit is contained in:
Iain Buclaw 2023-05-01 20:08:21 +00:00
commit 535dcb9793
3 changed files with 24 additions and 5 deletions

3
changelog/rdmd_shared.dd Normal file
View file

@ -0,0 +1,3 @@
rdmd supports `-shared`
rdmd now understands DMD's `-shared` switch, and sets the default output file name appropriately (`.dll`, `.so`, or `.dylib` depending on the platform), in the same way as `-lib`.

View file

@ -72,3 +72,9 @@ subPackage {
targetType "executable"
sourceFiles "catdoc.d"
}
subPackage {
name "dustmite"
targetType "executable"
sourcePaths "DustMite"
}

20
rdmd.d
View file

@ -27,6 +27,10 @@ version (Posix)
enum objExt = ".o";
enum binExt = "";
enum libExt = ".a";
version (OSX)
enum dllExt = ".dylib";
else
enum dllExt = ".so";
enum altDirSeparator = "";
}
else version (Windows)
@ -34,6 +38,7 @@ else version (Windows)
enum objExt = ".obj";
enum binExt = ".exe";
enum libExt = ".lib";
enum dllExt = ".dll";
enum altDirSeparator = "/";
}
else
@ -242,10 +247,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 +370,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", ".dylib", ".def", ".map", ".res") &&
args[i - 1] != "--eval")
{
return i;
@ -627,7 +637,7 @@ private string[string] getDependencies(string rootModule, string workDir,
string[] names = [libName ~ ".lib"];
else
{
string[] names = ["lib" ~ libName ~ ".a", "lib" ~ libName ~ ".so"];
string[] names = ["lib" ~ libName ~ ".a", "lib" ~ libName ~ ".so", "lib" ~ libName ~ ".dylib"];
dirs ~= ["/lib", "/usr/lib"];
}
foreach (dir; dirs)