mirror of
https://github.com/dlang/tools.git
synced 2025-04-28 06:00:37 +03:00
rdmd: support --eval <arg> to make it Makefile friendly
This commit is contained in:
parent
9d414d2e30
commit
e88c44d181
4 changed files with 49 additions and 5 deletions
12
changelog/rdmdMakefiles.dd
Normal file
12
changelog/rdmdMakefiles.dd
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
rdmd can now be used as a shell in makefiles
|
||||||
|
|
||||||
|
With gnu make(3.82 or higher), rdmd can now be used in makefiles.
|
||||||
|
This is accomplished by setting the SHELL and .SHELLFLAGS to /usr/bin/rdmd and --eval respectively.
|
||||||
|
---
|
||||||
|
.ONESHELL:
|
||||||
|
SHELL = /usr/bin/rdmd
|
||||||
|
.SHELLFLAGS = --eval
|
||||||
|
hello.txt:
|
||||||
|
$(TAB)import std.file;
|
||||||
|
$(TAB)write("$@","hello world\n");
|
||||||
|
---
|
8
rdmd.d
8
rdmd.d
|
@ -329,12 +329,14 @@ int main(string[] args)
|
||||||
|
|
||||||
size_t indexOfProgram(string[] args)
|
size_t indexOfProgram(string[] args)
|
||||||
{
|
{
|
||||||
foreach(i, arg; args[1 .. $])
|
foreach(i; 1 .. args.length)
|
||||||
{
|
{
|
||||||
|
auto arg = args[i];
|
||||||
if (!arg.startsWith('-', '@') &&
|
if (!arg.startsWith('-', '@') &&
|
||||||
!arg.endsWith(".obj", ".o", ".lib", ".a", ".def", ".map", ".res"))
|
!arg.endsWith(".obj", ".o", ".lib", ".a", ".def", ".map", ".res") &&
|
||||||
|
args[i - 1] != "--eval")
|
||||||
{
|
{
|
||||||
return i + 1;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
rdmd_test.d
23
rdmd_test.d
|
@ -614,6 +614,29 @@ void runTests(string rdmdApp, string compiler, string model)
|
||||||
res = execute(rdmdArgs ~ [src1]);
|
res = execute(rdmdArgs ~ [src1]);
|
||||||
assert(res.status == 1, res.output);
|
assert(res.status == 1, res.output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
import std.format : format;
|
||||||
|
|
||||||
|
auto textOutput = tempDir().buildPath("rdmd_makefile_test.txt");
|
||||||
|
if (exists(textOutput))
|
||||||
|
{
|
||||||
|
remove(textOutput);
|
||||||
|
}
|
||||||
|
enum makefileFormatter = `.ONESHELL:
|
||||||
|
SHELL = %s
|
||||||
|
.SHELLFLAGS = %-(%s %) --eval
|
||||||
|
%s:
|
||||||
|
import std.file;
|
||||||
|
write("$@","hello world\n");`;
|
||||||
|
string makefileString = format!makefileFormatter(rdmdArgs[0], rdmdArgs[1 .. $], textOutput);
|
||||||
|
auto makefilePath = tempDir().buildPath("rdmd_makefile_test.mak");
|
||||||
|
std.file.write(makefilePath, makefileString);
|
||||||
|
auto make = environment.get("MAKE") is null ? "make" : environment.get("MAKE");
|
||||||
|
res = execute([make, "-f", makefilePath]);
|
||||||
|
assert(res.status == 0, res.output);
|
||||||
|
assert(std.file.read(textOutput) == "hello world\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void runConcurrencyTest(string rdmdApp, string compiler, string model)
|
void runConcurrencyTest(string rdmdApp, string compiler, string model)
|
||||||
|
|
11
travis.sh
11
travis.sh
|
@ -10,8 +10,15 @@ set -uexo pipefail
|
||||||
GDMD=$(find ~/dlang -type f -name "gdmd")
|
GDMD=$(find ~/dlang -type f -name "gdmd")
|
||||||
LDMD2=$(find ~/dlang -type f -name "ldmd2")
|
LDMD2=$(find ~/dlang -type f -name "ldmd2")
|
||||||
|
|
||||||
make -f posix.mak all DMD="$(which dmd)"
|
curl https://ftp.gnu.org/gnu/make/make-4.2.tar.gz | tar -xz
|
||||||
make -f posix.mak test DMD="$(which dmd)" \
|
cd make-4.2
|
||||||
|
./configure
|
||||||
|
./build.sh
|
||||||
|
cd ..
|
||||||
|
export MAKE=$(pwd)/make-4.2/make
|
||||||
|
|
||||||
|
$MAKE -f posix.mak all DMD="$(which dmd)"
|
||||||
|
$MAKE -f posix.mak test DMD="$(which dmd)" \
|
||||||
RDMD_TEST_COMPILERS=dmd,"$GDMD","$LDMD2" \
|
RDMD_TEST_COMPILERS=dmd,"$GDMD","$LDMD2" \
|
||||||
VERBOSE_RDMD_TEST=1
|
VERBOSE_RDMD_TEST=1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue