6 import sb.args sb.blob_from_cstring sb.compile_executable \
7 sb.compile_executable_to_voodoo sb.compile_module \
8 sb.compile_module_to_voodoo sb.init_voodoo_translator sb.transmute_stream
10 function namespace_from_path path base_path {
12 if (ne base_path -1) {
13 set base_path concatenate_blobs base_path "/"
14 if (blob_starts_with path base_path) {
15 let prefix_len blob_length base_path
16 set path copy_blob_part path prefix_len (sub (blob_length path) prefix_len)
20 let path_len blob_length path
27 if (eq end path_len) {
30 let c blob_nth path end
33 } else if (eq c 46) { # .
39 if (eq got_part true) {
43 var len = sub dot start
45 let part copy_blob_part path start len
46 if (eq namespace -1) {
47 set namespace get_namespace_absolute part
49 set namespace get_namespace (namespace_intern namespace part)
55 while (lt end path_len)
68 var library_path = dynarray 0 0
72 var len = array_length args
75 set arg array_nth args i
76 if (gt (blob_length arg) 0) {
77 var c = blob_nth arg 0
78 if (blobs_equal arg "-L") {
80 dynarray_add library_path (array_nth args i)
81 } else if (blobs_equal arg "-b") {
83 set base_path (array_nth args i)
84 } else if (blobs_equal arg "-f") {
86 set format (array_nth args i)
87 } else if (blobs_equal arg "-o") {
89 set target (array_nth args i)
90 } else if (blobs_equal arg "-t") {
92 set type (array_nth args i)
93 } else if (eq c 45) { # -
94 error (concatenate_blobs "Flag not recognized: " arg)
104 # Old behavior, used to bootstrap Antimony.
105 set namespace symbol_namespace #`true
106 sb.transmute_stream namespace standard_input standard_output
108 error "Target specified, but no source"
110 } else if (eq target -1) {
111 error "Source specified, but no target"
112 } else if (blobs_equal type "exe") {
113 set namespace (namespace_from_path source base_path)
115 sb.compile_executable namespace source target (dynarray_to_array library_path)
116 } else if (blobs_equal format "voodoo") {
118 sb.compile_executable_to_voodoo namespace source target
120 error (concatenate_blobs "Format not supported: " format)
122 } else if (blobs_equal type "module") {
123 set namespace (namespace_from_path source base_path)
125 sb.compile_module namespace source target
126 } else if (blobs_equal format "voodoo") {
128 sb.compile_module_to_voodoo namespace source target
130 error (concatenate_blobs "Format not supported: " format)
133 error (concatenate_blobs "Format not supported: " format)
139 sb.init_voodoo_translator