Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The default compiler should not depend on DUB's own build environment #678

Merged
merged 1 commit into from
Sep 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@for /f %%i in ('git describe') do @set GITVER=%%i
@echo module dub.version_; > source\dub\version_.d
@echo enum dubVersion = "%GITVER%"; >> source\dub\version_.d
@echo enum initialCompilerBinary = "%DC%"; >> source\dub\version_.d

@echo Executing %DC%...
@%DC% -ofbin\dub.exe -g -debug -w -version=DubUseCurl -Isource curl.lib %* @build-files.txt
Expand Down
1 change: 0 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ echo Generating version file...
GITVER=$(git describe) || GITVER=unknown
echo "module dub.version_;" > source/dub/version_.d
echo "enum dubVersion = \"$GITVER\";" >> source/dub/version_.d
echo "enum initialCompilerBinary = \"$DMD\";" >> source/dub/version_.d


echo Running $DMD...
Expand Down
11 changes: 2 additions & 9 deletions source/dub/compilers/compiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,14 @@ string defaultCompiler()
private string findCompiler()
{
import std.process : env=environment;
import dub.version_ : initialCompilerBinary;
version (Windows) enum sep = ";", exe = ".exe";
version (Posix) enum sep = ":", exe = "";

auto def = Path(initialCompilerBinary);
if (def.absolute && existsFile(def))
return initialCompilerBinary;

auto compilers = ["dmd", "gdc", "gdmd", "ldc2", "ldmd2"];
if (!def.absolute)
compilers = initialCompilerBinary ~ compilers;

auto paths = env.get("PATH", "").splitter(sep).map!Path;
auto res = compilers.find!(bin => paths.canFind!(p => existsFile(p ~ (bin~exe))));
return res.empty ? initialCompilerBinary : res.front;
return res.empty ? compilers[0] : res.front;
}

void registerCompiler(Compiler c)
Expand Down Expand Up @@ -312,7 +305,7 @@ struct BuildPlatform {
bool matchesSpecification(const(char)[] specification)
const {
import std.string : format;

if (specification.empty) return true;
if (this == any) return true;

Expand Down
1 change: 0 additions & 1 deletion source/dub/version_.d
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
module dub.version_;
enum dubVersion = "v0.9.23";
enum initialCompilerBinary = "dmd";