diff --git a/build.cmd b/build.cmd index eb9a023..a184915 100644 --- a/build.cmd +++ b/build.cmd @@ -7,7 +7,7 @@ echo module dub.version_; enum dubVersion = "%GITVER%"; > source\dub\version_.d echo Executing %DC%... -%DC% -ofbin\dub.exe -g -debug -w -Isource curl.lib %* @build-files.txt +%DC% -ofbin\dub.exe -g -debug -w -version=DubUseCurl -Isource curl.lib %* @build-files.txt if errorlevel 1 exit /b 1 echo DUB has been built. You probably also want to add the following entry to your diff --git a/build.sh b/build.sh index 5e70556..6f98537 100755 --- a/build.sh +++ b/build.sh @@ -35,7 +35,7 @@ echo Running $DC... -$DC -ofbin/dub -g -debug -w -Isource $* $LIBS @build-files.txt +$DC -ofbin/dub -g -debug -w -version=DubUseCurl -Isource $* $LIBS @build-files.txt echo DUB has been built as bin/dub. echo echo You may want to run diff --git a/package.json b/package.json index c6ed736..f565728 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,27 @@ "Matthias Dondorff", "Sönke Ludwig" ], - "libs": ["curl"], - "copyFiles-windows": ["curllib.dll", "libeay32.dll", "openldap.dll", "ssleay32.dll"], - "targetPath": "bin" + "targetPath": "bin", + "configurations": [ + { + "name": "application", + "targetType": "executable", + "libs": ["curl"], + "copyFiles-windows": ["curllib.dll", "libeay32.dll", "openldap.dll", "ssleay32.dll"], + "versions": ["DubUseCurl"] + }, + { + "name": "library", + "targetType": "library", + "excludedSourceFiles": ["source/app.d"], + "libs": ["curl"], + "copyFiles-windows": ["curllib.dll", "libeay32.dll", "openldap.dll", "ssleay32.dll"], + "versions": ["DubUseCurl"] + }, + { + "name": "library-nonet", + "targetType": "library", + "excludedSourceFiles": ["source/app.d"] + } + ] } \ No newline at end of file diff --git a/source/dub/internal/utils.d b/source/dub/internal/utils.d index 97ebe8d..df9d5c0 100644 --- a/source/dub/internal/utils.d +++ b/source/dub/internal/utils.d @@ -19,11 +19,11 @@ import std.conv; import std.exception; import std.file; -import std.net.curl; import std.process; import std.string; import std.typecons; import std.zip; +version(DubUseCurl) import std.net.curl; Path getTempDir() @@ -110,9 +110,11 @@ */ void download(string url, string filename) { - auto conn = setupHTTPClient(); - logDebug("Storing %s...", url); - std.net.curl.download(url, filename, conn); + version(DubUseCurl) { + auto conn = setupHTTPClient(); + logDebug("Storing %s...", url); + std.net.curl.download(url, filename, conn); + } else assert(false); } /// ditto void download(Url url, Path filename) @@ -122,9 +124,11 @@ /// ditto char[] download(string url) { - auto conn = setupHTTPClient(); - logDebug("Getting %s...", url); - return get(url, conn); + version(DubUseCurl) { + auto conn = setupHTTPClient(); + logDebug("Getting %s...", url); + return get(url, conn); + } else assert(false); } /// ditto char[] download(Url url) @@ -132,20 +136,22 @@ return download(url.toString()); } -private HTTP setupHTTPClient() -{ - auto conn = HTTP(); - static if( is(typeof(&conn.verifyPeer)) ) - conn.verifyPeer = false; +version(DubUseCurl) { + private HTTP setupHTTPClient() + { + auto conn = HTTP(); + static if( is(typeof(&conn.verifyPeer)) ) + conn.verifyPeer = false; - // convert version string to valid SemVer format - auto verstr = dubVersion; - if (verstr.startsWith("v")) verstr = verstr[1 .. $]; - auto idx = verstr.indexOf("-"); - if (idx >= 0) verstr = verstr[0 .. idx] ~ "+" ~ verstr[idx+1 .. $].split("-").join("."); + // convert version string to valid SemVer format + auto verstr = dubVersion; + if (verstr.startsWith("v")) verstr = verstr[1 .. $]; + auto idx = verstr.indexOf("-"); + if (idx >= 0) verstr = verstr[0 .. idx] ~ "+" ~ verstr[idx+1 .. $].split("-").join("."); - conn.addRequestHeader("User-Agent", "dub/"~verstr~" (std.net.curl; +https://github.com/rejectedsoftware/dub)"); - return conn; + conn.addRequestHeader("User-Agent", "dub/"~verstr~" (std.net.curl; +https://github.com/rejectedsoftware/dub)"); + return conn; + } } private string stripUTF8Bom(string str)