Skip to content
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
36 changes: 18 additions & 18 deletions src/mars.d
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ Where:
-gs always emit stack frame
-gx add stack stomp code
-H generate 'header' file
-Hd<directory> write 'header' file to directory
-Hf<filename> write 'header' file to filename
-Hd=<directory> write 'header' file to directory
-Hf=<filename> write 'header' file to filename
--help print help and exit
-I<directory> look for imports also in directory
-I=<directory> look for imports also in directory
-ignore ignore unsupported pragmas
-inline do function inlining
-J<directory> look for string imports also in directory
-L<linkerflag> pass linkerflag to link
-J=<directory> look for string imports also in directory
-L=<linkerflag> pass linkerflag to link
-lib generate library rather than object files
-m32 generate 32 bit code" ~
"%s" /* placeholder for m32mscoff */ ~ "
Expand All @@ -148,8 +148,8 @@ Where:
-noboundscheck no array bounds checking (deprecated, use -boundscheck=off)
-O optimize
-o- do not write object file
-od<directory> write object & library files to directory
-of<filename> name output file to filename
-od=<directory> write object & library files to directory
-of=<filename> name output file to filename
-op preserve source path for output files
-profile profile runtime performance of generated code
-profile=gc profile runtime allocations
Expand All @@ -169,7 +169,7 @@ Where:
-w warnings as errors (compilation will halt)
-wi warnings as messages (compilation will continue)
-X generate JSON file
-Xf<filename> write JSON file to filename
-Xf=<filename> write JSON file to filename
", FileName.canonicalName(global.inifilename), fpic, m32mscoff);
}

Expand Down Expand Up @@ -620,7 +620,7 @@ Language changes listed by -transition=id:
case 'd':
if (!p[3])
goto Lnoarg;
path = p + 3;
path = p + 3 + (p[3] == '=');
version (Windows)
{
path = toWinPath(path);
Expand All @@ -630,7 +630,7 @@ Language changes listed by -transition=id:
case 'f':
if (!p[3])
goto Lnoarg;
path = p + 3;
path = p + 3 + (p[3] == '=');
version (Windows)
{
path = toWinPath(path);
Expand All @@ -657,12 +657,12 @@ Language changes listed by -transition=id:
case 'd':
if (!p[3])
goto Lnoarg;
global.params.docdir = p + 3;
global.params.docdir = p + 3 + (p[3] == '=');
break;
case 'f':
if (!p[3])
goto Lnoarg;
global.params.docname = p + 3;
global.params.docname = p + 3 + (p[3] == '=');
break;
case 0:
break;
Expand All @@ -678,12 +678,12 @@ Language changes listed by -transition=id:
case 'd':
if (!p[3])
goto Lnoarg;
global.params.hdrdir = p + 3;
global.params.hdrdir = p + 3 + (p[3] == '=');
break;
case 'f':
if (!p[3])
goto Lnoarg;
global.params.hdrname = p + 3;
global.params.hdrname = p + 3 + (p[3] == '=');
break;
case 0:
break;
Expand All @@ -699,7 +699,7 @@ Language changes listed by -transition=id:
case 'f':
if (!p[3])
goto Lnoarg;
global.params.jsonfilename = p + 3;
global.params.jsonfilename = p + 3 + (p[3] == '=');
break;
case 0:
break;
Expand Down Expand Up @@ -764,13 +764,13 @@ Language changes listed by -transition=id:
{
if (!global.params.imppath)
global.params.imppath = new Strings();
global.params.imppath.push(p + 2);
global.params.imppath.push(p + 2 + (p[2] == '='));
}
else if (p[1] == 'J')
{
if (!global.params.fileImppath)
global.params.fileImppath = new Strings();
global.params.fileImppath.push(p + 2);
global.params.fileImppath.push(p + 2 + (p[2] == '='));
}
else if (memcmp(p + 1, cast(char*)"debug", 5) == 0 && p[6] != 'l')
{
Expand Down Expand Up @@ -847,7 +847,7 @@ Language changes listed by -transition=id:
global.params.debugy = true;
else if (p[1] == 'L')
{
global.params.linkswitches.push(p + 2);
global.params.linkswitches.push(p + 2 + (p[2] == '='));
}
else if (memcmp(p + 1, cast(char*)"defaultlib=", 11) == 0)
{
Expand Down
66 changes: 66 additions & 0 deletions test/runnable/test_switches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

# tests various --opt=<value> switches:
#
# -Dd=<directory>
# -Df=<filename>
# -Hd=<directory>
# -Hf=<filename>
# -I=<directory>
# -J=<directory>
# -L=<linkerflag>
# -od=<dirname>
# -of=<objname>
# -Xf=<filename>

out_dir=${RESULTS_DIR}/runnable/test_switches
src_file=${out_dir}/src.d

clean()
{
rm -rf ${out_dir} || true
}

prepare()
{
clean;
mkdir ${out_dir}
echo "module mymod;" > ${out_dir}/mymod.d
echo "module src; import mymod;" > ${src_file}
}

die()
{
echo "test_switches.sh error: Output file $1 not found"
exit 1
}

checkFile()
{
if [ ! -f $1 ]; then die $1; fi
}

checkFiles()
{
checkFile ${out_dir}/json.json
checkFile ${out_dir}/mymod.d
checkFile ${out_dir}/src.d
checkFile ${out_dir}/src.di
checkFile ${out_dir}/src.html
}

# @BUG@: -Df doesn't take -Dd into account when it's set
# @BUG@: -Hf doesn't take -Hd into account when it's set
# Workaround: Call DMD twice, first with -Df / -Hf, then with -Dh and -Hd
# Note: -L linker flag not explicitly checked (using -c to compile only)
# as there's no common linker switch which all linkers support

prepare;
$DMD -c -of=mymod.o -od=${out_dir} -D -Df=${out_dir}/src.html -Hf=${out_dir}/src.di -I=${out_dir} -L=-v -Xf=${out_dir}/json.json ${src_file}
checkFiles;

prepare;
$DMD -c -of=mymod.o -od=${out_dir} -D -Dd=${out_dir} -Hd=${out_dir} -I=${out_dir} -L=-v -Xf=${out_dir}/json.json ${src_file}
checkFiles;

clean;