Skip to content

Commit 42effc7

Browse files
committed
add -dv
1 parent 7c94f26 commit 42effc7

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

examples/version.cal

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ version RM86
66
"Hello, RM86!\n" printstr
77
end
88

9+
# will execute on Linux86 backend
10+
version Linux86
11+
"Hello, Linux86!\n" printstr
12+
end
13+
914
# won't execute unless you set the Foo version
1015
version Foo
1116
"Hello, Foo!\n" printstr

source/app.d

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import std.file;
55
import std.stdio;
66
import std.string;
77
import std.process;
8+
import std.algorithm;
89
import callisto.compiler;
910
import callisto.language;
1011
import callisto.optimiser;
@@ -31,6 +32,7 @@ Flags:
3132
with the Callisto stack)
3233
-d - Enables debug symbols (if available)
3334
-l LIB - Links LIB with the linker (if available)
35+
-dv VER - Disables VER
3436
3537
Backends:
3638
rm86 - Real mode x86 and MS-DOS
@@ -60,6 +62,7 @@ int main(string[] args) {
6062
bool debugParser;
6163
bool exportSymbols;
6264
string[] link;
65+
string[] disabled;
6366

6467
for (size_t i = 1; i < args.length; ++ i) {
6568
if (args[i][0] == '-') {
@@ -178,6 +181,16 @@ int main(string[] args) {
178181
link ~= args[i];
179182
break;
180183
}
184+
case "-dv": {
185+
++ i;
186+
if (i >= args.length) {
187+
stderr.writeln("-dv expects VER argument");
188+
return 1;
189+
}
190+
191+
disabled ~= args[i];
192+
break;
193+
}
181194
default: {
182195
stderr.writefln("Unknown flag '%s'", args[i]);
183196
return 1;
@@ -220,6 +233,21 @@ int main(string[] args) {
220233

221234
versions ~= compiler.backend.GetVersions();
222235

236+
bool removing = true;
237+
while (removing) {
238+
foreach (ref ver ; disabled) {
239+
if (versions.canFind(ver)) {
240+
versions = versions.remove(versions.countUntil(ver));
241+
goto next;
242+
}
243+
}
244+
245+
removing = false;
246+
next:
247+
}
248+
writeln(disabled);
249+
writeln(versions);
250+
223251
auto preproc = new Preprocessor();
224252
preproc.includeDirs = includeDirs;
225253
preproc.versions = versions;

std

0 commit comments

Comments
 (0)