@@ -44,11 +44,11 @@ } else { set type "package" } } - array set $handle [list code "" type $type filename $output package $pkgName add_inc_path "" add_lib_path "" add_lib "" add_macros ""] + array set $handle [list code "" type $type filename $output package $pkgName add_inc_path "" add_lib_path "" add_lib "" add_cmdline ""] proc $handle {cmd args} [string map [list @@HANDLE@@ $handle] { set handle {@@HANDLE@@} if {$cmd == "go"} { @@ -157,47 +157,14 @@ upvar #0 $handle state set state(tk) 1 } - proc _process_command_line {handle cmdStr} { - # XXX:TODO: This needs to handle shell-quoted arguments + proc _process_command_line {handle args} { upvar #0 $handle state - set cmdStr [regsub -all { *} $cmdStr { }] - set work [split $cmdStr " "] - - foreach cmd $work { - switch -glob -- $cmd { - "-I*" { - set dir [string range $cmd 2 end] - _add_include_path $handle $dir - } - "-D*" { - set symbolval [string range $cmd 2 end] - set symbolval [split $symbolval =] - set symbol [lindex $symbolval 0] - set val [join [lrange $symbolval 1 end] =] - - dict set state(add_macros) $symbol $val - } - "-U*" { - set symbol [string range $cmd 2 end] - dict unset state(add_macros) $symbol $val - } - "-l*" { - set library [string range $cmd 2 end] - _add_library $handle $library - } - "-L*" { - set libraryDir [string range $cmd 2 end] - _add_library_path $handle $libraryDir - } - "-g" { - # Ignored - } - } - } + + lappend state(add_cmdline) {*}$args } proc _delete {handle} { rename $handle "" unset $handle @@ -462,14 +429,10 @@ upvar #0 $handle state set code "" - foreach {macroName macroVal} $state(add_macros) { - append code "#define [string trim "$macroName $macroVal"]\n" - } - append code $state(code) "\n" if {$state(type) == "exe" || $state(type) == "dll"} { if {[info exists state(procs)] && [llength $state(procs)] > 0} { set code "int _initProcs(Tcl_Interp *interp);\n\n$code" @@ -567,10 +530,14 @@ if {[info command ::tcc4tcl] == ""} { return -code error "Unable to load tcc4tcl library" } ::tcc4tcl $dir $tcc_type tcc + + if {$state(add_cmdline) ne ""} { + tcc parse_args {*}$state(add_cmdline) + } foreach path $state(add_inc_path) { tcc add_include_path $path }