[arch-commits] Commit in dtools/trunk (PKGBUILD autodetect.diff)
Михаил Страшун
dicebot at archlinux.org
Sat Mar 28 20:09:39 UTC 2015
Date: Saturday, March 28, 2015 @ 21:09:39
Author: dicebot
Revision: 130174
upgpkg: dtools 2.067.0-2
Patch rdmd to auto-detect available *dmd binary
Added:
dtools/trunk/autodetect.diff
Modified:
dtools/trunk/PKGBUILD
-----------------+
PKGBUILD | 5 ++++-
autodetect.diff | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletion(-)
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2015-03-28 17:51:07 UTC (rev 130173)
+++ PKGBUILD 2015-03-28 20:09:39 UTC (rev 130174)
@@ -2,7 +2,7 @@
pkgname=('dtools')
pkgver=2.067.0
-pkgrel=1
+pkgrel=2
pkgdesc="Ancilliary tools for the D programming language"
license=("custom")
groups=('dlang')
@@ -17,11 +17,13 @@
"git+http://github.com/D-Programming-Language/tools#tag=v$pkgver"
"git+https://github.com/Dicebot/Arch-PKGBUILDs.git"
"http://www.boost.org/LICENSE_1_0.txt"
+ "autodetect.diff"
)
sha1sums=(
'SKIP'
'SKIP'
'3cba29011be2b9d59f6204d6fa0a386b1b2dbd90'
+ '7fb5bd71d6c4e90c0ca49b292454e11169afdee8'
)
build()
@@ -30,6 +32,7 @@
DMD=ldmd
cd $srcdir/tools
+ git apply $srcdir/autodetect.diff
# rdmd is used to build others
$DMD -od. -ofdtools-rdmd rdmd.d
Added: autodetect.diff
===================================================================
--- autodetect.diff (rev 0)
+++ autodetect.diff 2015-03-28 20:09:39 UTC (rev 130174)
@@ -0,0 +1,47 @@
+diff --git a/rdmd.d b/rdmd.d
+index 5d66c9f..61fb86a 100644
+--- a/rdmd.d
++++ b/rdmd.d
+@@ -51,7 +51,32 @@ else version (LDC)
+ else
+ static assert(false, "Unknown compiler");
+
+-private string compiler = defaultCompiler;
++private string compiler;
++
++void chooseCompiler(ref string compiler)
++{
++ import std.stdio;
++
++ // if compiler is set explicitly, don't interefer
++ // otherwise find one that exists in PATH
++ if (!compiler.length)
++ {
++ import std.process : executeShell;
++ auto compilers = [ defaultCompiler, "dmd", "ldmd2", "gdmd2", "ldmd", "gdmd" ];
++
++ foreach (candidate; compilers)
++ {
++ // dirty hack, no-arg dmd invocation will return 1
++ if (executeShell(candidate ~ "| grep Usage").status == 0)
++ {
++ compiler = candidate;
++ return;
++ }
++ }
++
++ throw new Exception("Couldn't find any D compiler");
++ }
++}
+
+ int main(string[] args)
+ {
+@@ -141,6 +166,8 @@ int main(string[] args)
+ if (bailout) return 0;
+ if (dryRun) chatty = true; // dry-run implies chatty
+
++ chooseCompiler(compiler);
++
+ /* Only -of is supported because Make is very susceptible to file names, and
+ * it doesn't do a good job resolving them. One option would be to use
+ * std.path.buildNormalizedPath(), but some corner cases will break, so it
More information about the arch-commits
mailing list