1
1
import argparse
2
2
import sys
3
+ from vba_stdlib .literal_factory import literal_from_string
3
4
from pathlib import Path
4
5
from vba_precompiler .compiler import Compiler
5
6
@@ -8,6 +9,8 @@ def main() -> None:
8
9
parser = argparse .ArgumentParser ()
9
10
parser .add_argument ("-s" , "--system" , default = "Win16" ,
10
11
help = "Mac, Win16, Win32, or Win64" )
12
+ parser .add_argument ("-D" , "--define" , default = "" ,
13
+ help = "Define an enviromnet variable" )
11
14
parser .add_argument ("-v" , "--version" , default = "6" ,
12
15
help = "VBA version, 6 or 7" )
13
16
parser .add_argument ("-o" , "--output" , default = "./build" ,
@@ -41,9 +44,17 @@ def main() -> None:
41
44
vba7 = True
42
45
else :
43
46
raise Exception ("VBA Version Unsupported: " + args .version )
44
-
45
47
env = {"WIN16" : win16 , "WIN32" : win32 , "WIN64" : win64 ,
46
48
"MAC" : mac , "VBA6" : vba6 , "VBA7" : vba7 , "MAC_OFFICE_VERSION" : 0 }
49
+ if args .define != "" :
50
+ params = args .define .split (',' )
51
+ for name_value in params :
52
+ pair = name_value .split ("=" )
53
+ key = pair [0 ].upper ()
54
+ value = pair [1 ]
55
+ if value [- 1 :1 ] == '""' :
56
+ value = value [1 :- 1 ]
57
+ env [key ] = literal_from_string (value )
47
58
compiler = Compiler (env )
48
59
Path (args .output ).mkdir (parents = True , exist_ok = True )
49
60
num_errors = 0
0 commit comments