Skip to content

Commit

Permalink
fix #2618
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Mar 9, 2023
1 parent ab12c51 commit c230c12
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 33 deletions.
26 changes: 16 additions & 10 deletions source/dub/compilers/dmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,13 @@ config /etc/dmd.conf
string getTargetFileName(in BuildSettings settings, in BuildPlatform platform)
const {
import std.conv: text;
assert(settings.targetName.length > 0, "No target name set.");

string targetName()
{
assert(settings.targetName.length > 0, "No target name set.");
return settings.targetName.idup;
}

final switch (settings.targetType) {
case TargetType.autodetect:
assert(false,
Expand All @@ -315,23 +321,23 @@ config /etc/dmd.conf
case TargetType.sourceLibrary: return null;
case TargetType.executable:
if (platform.isWindows())
return settings.targetName ~ ".exe";
else return settings.targetName.idup;
return targetName ~ ".exe";
else return targetName;
case TargetType.library:
case TargetType.staticLibrary:
if (platform.isWindows())
return settings.targetName ~ ".lib";
else return "lib" ~ settings.targetName ~ ".a";
return targetName ~ ".lib";
else return "lib" ~ targetName ~ ".a";
case TargetType.dynamicLibrary:
if (platform.isWindows())
return settings.targetName ~ ".dll";
return targetName ~ ".dll";
else if (platform.platform.canFind("darwin"))
return "lib" ~ settings.targetName ~ ".dylib";
else return "lib" ~ settings.targetName ~ ".so";
return "lib" ~ targetName ~ ".dylib";
else return "lib" ~ targetName ~ ".so";
case TargetType.object:
if (platform.isWindows())
return settings.targetName ~ ".obj";
else return settings.targetName ~ ".o";
return targetName ~ ".obj";
else return targetName ~ ".o";
}
}

Expand Down
30 changes: 20 additions & 10 deletions source/dub/compilers/gdc.d
Original file line number Diff line number Diff line change
Expand Up @@ -160,28 +160,38 @@ class GDCCompiler : Compiler {

string getTargetFileName(in BuildSettings settings, in BuildPlatform platform)
const {
assert(settings.targetName.length > 0, "No target name set.");
import std.conv: text;

string targetName()
{
assert(settings.targetName.length > 0, "No target name set.");
return settings.targetName.idup;
}

final switch (settings.targetType) {
case TargetType.autodetect: assert(false, "Configurations must have a concrete target type.");
case TargetType.autodetect:
assert(false,
text("Configurations must have a concrete target type, ", settings.targetName,
" has ", settings.targetType));
case TargetType.none: return null;
case TargetType.sourceLibrary: return null;
case TargetType.executable:
if (platform.isWindows())
return settings.targetName ~ ".exe";
else return settings.targetName.idup;
return targetName ~ ".exe";
else return targetName;
case TargetType.library:
case TargetType.staticLibrary:
return "lib" ~ settings.targetName ~ ".a";
return "lib" ~ targetName ~ ".a";
case TargetType.dynamicLibrary:
if (platform.isWindows())
return settings.targetName ~ ".dll";
return targetName ~ ".dll";
else if (platform.platform.canFind("darwin"))
return "lib" ~ settings.targetName ~ ".dylib";
else return "lib" ~ settings.targetName ~ ".so";
return "lib" ~ targetName ~ ".dylib";
else return "lib" ~ targetName ~ ".so";
case TargetType.object:
if (platform.isWindows())
return settings.targetName ~ ".obj";
else return settings.targetName ~ ".o";
return targetName ~ ".obj";
else return targetName ~ ".o";
}
}

Expand Down
33 changes: 21 additions & 12 deletions source/dub/compilers/ldc.d
Original file line number Diff line number Diff line change
Expand Up @@ -192,34 +192,43 @@ config /etc/ldc2.conf (x86_64-pc-linux-gnu)

string getTargetFileName(in BuildSettings settings, in BuildPlatform platform)
const {
assert(settings.targetName.length > 0, "No target name set.");
import std.conv: text;

string targetName()
{
assert(settings.targetName.length > 0, "No target name set.");
return settings.targetName.idup;
}

const p = platform.platform;
final switch (settings.targetType) {
case TargetType.autodetect: assert(false, "Configurations must have a concrete target type.");
case TargetType.autodetect:
assert(false,
text("Configurations must have a concrete target type, ", settings.targetName,
" has ", settings.targetType));
case TargetType.none: return null;
case TargetType.sourceLibrary: return null;
case TargetType.executable:
if (p.canFind("windows"))
return settings.targetName ~ ".exe";
return targetName ~ ".exe";
else if (p.canFind("wasm"))
return settings.targetName ~ ".wasm";
else return settings.targetName.idup;
return targetName ~ ".wasm";
else return targetName;
case TargetType.library:
case TargetType.staticLibrary:
if (p.canFind("windows") && !p.canFind("mingw"))
return settings.targetName ~ ".lib";
else return "lib" ~ settings.targetName ~ ".a";
return targetName ~ ".lib";
else return "lib" ~ targetName ~ ".a";
case TargetType.dynamicLibrary:
if (p.canFind("windows"))
return settings.targetName ~ ".dll";
return targetName ~ ".dll";
else if (p.canFind("darwin"))
return "lib" ~ settings.targetName ~ ".dylib";
else return "lib" ~ settings.targetName ~ ".so";
return "lib" ~ targetName ~ ".dylib";
else return "lib" ~ targetName ~ ".so";
case TargetType.object:
if (p.canFind("windows"))
return settings.targetName ~ ".obj";
else return settings.targetName ~ ".o";
return targetName ~ ".obj";
else return targetName ~ ".o";
}
}

Expand Down
6 changes: 5 additions & 1 deletion source/dub/generators/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,11 @@ private NativePath getMainSourceFile(in Package prj)

private NativePath getTargetPath(const scope ref BuildSettings bs, const scope ref GeneratorSettings settings)
{
return NativePath(bs.targetPath) ~ settings.compiler.getTargetFileName(bs, settings.platform);
auto targetFileName = settings.compiler.getTargetFileName(bs, settings.platform);

if (!targetFileName.length)
return NativePath.init;
return NativePath(bs.targetPath) ~ targetFileName;
}

private string shrinkPath(NativePath path, NativePath base)
Expand Down

0 comments on commit c230c12

Please sign in to comment.