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
21 let max sub path_len 1
27 if (eq end path_len) {
29 } else if (eq (blob_nth path end) 47) {
32 if (eq got_part true) {
33 var len = sub end start
35 let part copy_blob_part path start len
36 if (eq namespace -1) {
37 set namespace get_namespace_absolute part
39 set namespace get_namespace (namespace_intern namespace part)
44 while (lt end path_len)
57 var library_path = dynarray 0 0
61 var len = array_length args
64 set arg array_nth args i
65 if (gt (blob_length arg) 0) {
66 var c = blob_nth arg 0
67 if (blobs_equal arg "-L") {
69 dynarray_add library_path (array_nth args i)
70 } else if (blobs_equal arg "-b") {
72 set base_path (array_nth args i)
73 } else if (blobs_equal arg "-f") {
75 set format (array_nth args i)
76 } else if (blobs_equal arg "-o") {
78 set target (array_nth args i)
79 } else if (blobs_equal arg "-t") {
81 set type (array_nth args i)
82 } else if (eq c 45) { # -
83 error (concatenate_blobs "Flag not recognized: " arg)
93 # Old behavior, used to bootstrap Antimony.
94 set namespace symbol_namespace #`true
95 sb.transmute_stream namespace standard_input standard_output
97 error "Target specified, but no source"
99 } else if (eq target -1) {
100 error "Source specified, but no target"
101 } else if (blobs_equal type "exe") {
102 set namespace (namespace_from_path source base_path)
104 sb.compile_executable namespace source target (dynarray_to_array library_path)
105 } else if (blobs_equal format "voodoo") {
107 sb.compile_executable_to_voodoo namespace source target
109 error (concatenate_blobs "Format not supported: " format)
111 } else if (blobs_equal type "module") {
112 set namespace (namespace_from_path source base_path)
114 sb.compile_module namespace source target
115 } else if (blobs_equal format "voodoo") {
117 sb.compile_module_to_voodoo namespace source target
119 error (concatenate_blobs "Format not supported: " format)
122 error (concatenate_blobs "Format not supported: " format)
128 sb.init_voodoo_translator