Skip to content

Platform probing can be replaced with dmd -Xi=compilerInfo -Xf=- for newer compilers #1317

@wilzbach

Description

@wilzbach

Flow:

dub/source/dub/commandline.d

Lines 1012 to 1032 in cea2f15

override int execute(Dub dub, string[] free_args, string[] app_args)
{
enforceUsage(
!(m_importPaths && m_stringImportPaths),
"--import-paths and --string-import-paths may not be used together."
);
enforceUsage(
!(m_data && (m_importPaths || m_stringImportPaths)),
"--data may not be used together with --import-paths or --string-import-paths."
);
// disable all log output to stdout and use "writeln" to output the JSON description
auto ll = getLogLevel();
setLogLevel(max(ll, LogLevel.warn));
scope (exit) setLogLevel(ll);
string package_name;
enforceUsage(free_args.length <= 1, "Expected one or zero arguments.");
if (free_args.length >= 1) package_name = free_args[0];
setupPackage(dub, package_name);

protected void setupPackage(Dub dub, string package_name, string default_build_type = "debug")
{
if (!m_compilerName.length) m_compilerName = dub.defaultCompiler;
m_compiler = getCompiler(m_compilerName);
m_buildPlatform = m_compiler.determinePlatform(m_buildSettings, m_compilerName, m_arch);

BuildPlatform determinePlatform(ref BuildSettings settings, string compiler_binary, string arch_override)
{
string[] arch_flags;
switch (arch_override) {
default: throw new Exception("Unsupported architecture: "~arch_override);
case "": break;
case "x86": arch_flags = ["-m32"]; break;
case "x86_64": arch_flags = ["-m64"]; break;
case "x86_mscoff": arch_flags = ["-m32mscoff"]; break;
}
settings.addDFlags(arch_flags);
return probePlatform(compiler_binary, arch_flags ~ ["-quiet", "-c", "-o-"], arch_override);

protected final BuildPlatform probePlatform(string compiler_binary, string[] args, string arch_override)
{
import std.string : format;
import dub.compilers.utils : generatePlatformProbeFile, readPlatformProbe;
auto fil = generatePlatformProbeFile();

NativePath generatePlatformProbeFile()
{
import dub.internal.vibecompat.core.file;
import dub.internal.vibecompat.data.json;
import dub.internal.utils;
auto path = getTempFile("dub_platform_probe", ".d");

Probably it could be something simple as the timestamp of the compiler binary.
How about ~/.dub/compilers/<dmd|ldc|gdc>_timestamp?

Related PRs:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions