dub: Add possibility to switch D compiler and compile with ldc per default instead of dmd

This commit is contained in:
Thomas Mader 2021-03-06 16:42:06 +01:00 committed by adisbladis
parent 8048be48a9
commit 4b68e4f968
No known key found for this signature in database
GPG Key ID: 110BFAD44C6249B7

View File

@ -1,4 +1,6 @@
{ lib, stdenv, fetchFromGitHub, curl, dmd, libevent, rsync }: { lib, stdenv, fetchFromGitHub, curl, libevent, rsync, ldc, dcompiler ? ldc }:
assert dcompiler != null;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "dub"; pname = "dub";
@ -24,12 +26,23 @@ stdenv.mkDerivation rec {
--replace "dub remove" "\"${dubvar}\" remove" --replace "dub remove" "\"${dubvar}\" remove"
''; '';
nativeBuildInputs = [ dmd libevent rsync ]; nativeBuildInputs = [ dcompiler libevent rsync ];
buildInputs = [ curl ]; buildInputs = [ curl ];
buildPhase = '' buildPhase = ''
export DMD=${dmd.out}/bin/dmd for dc_ in dmd ldmd2 gdmd; do
./build.sh echo "... check for D compiler $dc_ ..."
dc=$(type -P $dc_ || echo "")
if [ ! "$dc" == "" ]; then
break
fi
done
if [ "$dc" == "" ]; then
exit "Error: could not find D compiler"
fi
echo "$dc_ found and used as D compiler to build $pname"
$dc ./build.d
./build
''; '';
doCheck = !stdenv.isDarwin; doCheck = !stdenv.isDarwin;
@ -37,7 +50,8 @@ stdenv.mkDerivation rec {
checkPhase = '' checkPhase = ''
export DUB=$NIX_BUILD_TOP/source/bin/dub export DUB=$NIX_BUILD_TOP/source/bin/dub
export PATH=$PATH:$NIX_BUILD_TOP/source/bin/ export PATH=$PATH:$NIX_BUILD_TOP/source/bin/
export DC=${dmd.out}/bin/dmd export DC=${dcompiler.out}/bin/${dcompiler.pname}
echo "DC out --> $DC"
export HOME=$TMP export HOME=$TMP
rm -rf test/issue502-root-import rm -rf test/issue502-root-import
@ -46,7 +60,6 @@ stdenv.mkDerivation rec {
rm test/issue990-download-optional-selected.sh rm test/issue990-download-optional-selected.sh
rm test/issue877-auto-fetch-package-on-run.sh rm test/issue877-auto-fetch-package-on-run.sh
rm test/issue1037-better-dependency-messages.sh rm test/issue1037-better-dependency-messages.sh
rm test/issue1040-run-with-ver.sh
rm test/issue1416-maven-repo-pkg-supplier.sh rm test/issue1416-maven-repo-pkg-supplier.sh
rm test/issue1180-local-cache-broken.sh rm test/issue1180-local-cache-broken.sh
rm test/issue1574-addcommand.sh rm test/issue1574-addcommand.sh
@ -62,13 +75,73 @@ stdenv.mkDerivation rec {
rm test/version-spec.sh rm test/version-spec.sh
rm test/0-init-multi.sh rm test/0-init-multi.sh
rm test/0-init-multi-json.sh rm test/0-init-multi-json.sh
rm test/4-describe-data-1-list.sh
rm test/4-describe-data-3-zero-delim.sh
rm test/4-describe-import-paths.sh
rm test/4-describe-string-import-paths.sh
rm test/4-describe-json.sh
rm test/5-convert-stdout.sh
rm test/issue1003-check-empty-ld-flags.sh
rm test/issue103-single-file-package.sh
rm test/issue1040-run-with-ver.sh
rm test/issue1091-bogus-rebuild.sh
rm test/issue1194-warn-wrong-subconfig.sh
rm test/issue1277.sh
rm test/issue1372-ignore-files-in-hidden-dirs.sh
rm test/issue1447-build-settings-vars.sh
rm test/issue1531-toolchain-requirements.sh
rm test/issue346-redundant-flags.sh
rm test/issue361-optional-deps.sh
rm test/issue564-invalid-upgrade-dependency.sh
rm test/issue586-subpack-dep.sh
rm test/issue616-describe-vs-generate-commands.sh
rm test/issue686-multiple-march.sh
rm test/issue813-fixed-dependency.sh
rm test/issue813-pure-sub-dependency.sh
rm test/issue820-extra-fields-after-convert.sh
rm test/issue923-subpackage-deps.sh
rm test/single-file-sdl-default-name.sh
rm test/subpackage-common-with-sourcefile-globbing.sh
rm test/issue934-path-dep.sh
rm -r test/1-dynLib-simple
rm -r test/1-exec-simple-package-json
rm -r test/1-exec-simple
rm -r test/1-staticLib-simple
rm -r test/2-dynLib-dep
rm -r test/2-staticLib-dep
rm -r test/2-dynLib-with-staticLib-dep
rm -r test/2-sourceLib-dep/
rm -r test/3-copyFiles
rm -r test/custom-source-main-bug487
rm -r test/custom-unittest
rm -r test/issue1262-version-inheritance-diamond
rm -r test/issue1003-check-empty-ld-flags
rm -r test/ignore-hidden-1
rm -r test/ignore-hidden-2
rm -r test/issue1427-betterC
rm -r test/issue130-unicode-*
rm -r test/issue1262-version-inheritance
rm -r test/issue1372-ignore-files-in-hidden-dirs
rm -r test/issue1350-transitive-none-deps
rm -r test/issue1775
rm -r test/issue1447-build-settings-vars
rm -r test/issue1408-inherit-linker-files
rm -r test/issue1551-var-escaping
rm -r test/issue754-path-selection-fail
rm -r test/issue1788-incomplete-string-import-override
rm -r test/subpackage-ref
rm -r test/issue777-bogus-path-dependency
rm -r test/issue959-path-based-subpack-dep
rm -r test/issue97-targettype-none-nodeps
rm -r test/issue97-targettype-none-onerecipe
rm -r test/path-subpackage-ref
rm -r test/sdl-package-simple
./test/run-unittest.sh ./test/run-unittest.sh
''; '';
installPhase = '' installPhase = ''
mkdir $out mkdir -p $out/bin
mkdir $out/bin
cp bin/dub $out/bin cp bin/dub $out/bin
''; '';