Check-in [ff53d13ed7]
Overview
Comment:Updated to produce working shared objects and executables (might need more stuff for Windows)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ff53d13ed7a11d4f9d5d49150aae458a9408f3a2
User & Date: rkeene on 2014-06-18 17:26:34
Other Links: manifest | tags
Context
2014-06-18
17:31
Updated to provide package version numbers check-in: 6ef06b043d user: rkeene tags: trunk
17:26
Updated to produce working shared objects and executables (might need more stuff for Windows) check-in: ff53d13ed7 user: rkeene tags: trunk
17:03
Updated to support output to exe check-in: 3c45d1d050 user: rkeene tags: trunk
Changes

Modified tcc4tcl.tcl from [54d1a42bf7] to [9fb3ac5d6d].

    74     74   		upvar #0 $handle state
    75     75   
    76     76   		if {[info exists state(tk)]} {
    77     77   			set state(code) "#include <tk.h>\n$state(code)"
    78     78   		}
    79     79   		set state(code) "#include <tcl.h>\n\n$state(code)"
    80     80   
    81         -		tcc4tcl $dir $state(type) tcc
    82         -
           81  +		# Append additional generated code to support the output type
    83     82   		switch -- $state(type) {
    84     83   			"memory" {
    85         -				tcc compile $state(code)
    86         -
    87         -				foreach {procname cname} $state(procs) {
    88         -					tcc command $procname $cname
    89         -				}
           84  +				# No additional code needed
    90     85   			}
    91     86   			"exe" {
    92     87   				if {[info exists state(procs)] && [llength $state(procs)] > 0} {
    93     88   					append state(code) "int _initProcs(Tcl_Interp *interp) \{\n"
    94     89   					
    95     90   					foreach {procname cname} $state(procs) {
    96     91   						append state(code) "  Tcl_CreateObjCommand(interp, \"$procname\", $cname, NULL, NULL);"
    97     92   					}
    98     93   
    99     94   					append state(code) "\}"
   100     95   				}
   101         -
   102         -				tcc compile $state(code)
   103         -
   104         -				tcc output_file $state(filename)
   105     96   			}
   106     97   			"dll" {
   107     98   				append state(code) "int [string totitle $state(package)]_Init(Tcl_Interp *interp) \{\n"
   108     99   				append state(code) "#ifdef USE_TCL_STUBS\n"
   109    100   				append state(code) "  if (Tcl_InitStubs(interp, \"8.4\" , 0) == 0L) \{\n"
   110    101   				append state(code) "    return TCL_ERROR;\n"
   111    102   				append state(code) "  \}\n"
   112    103   				append state(code) "#endif\n"
   113    104   
   114         -				foreach {procname cname} $state(procs) {
   115         -					append state(code) "  Tcl_CreateObjCommand(interp, \"$procname\", $cname, NULL, NULL);"
          105  +				if {[info exists state(procs)] && [llength $state(procs)] > 0} {
          106  +					foreach {procname cname} $state(procs) {
          107  +						append state(code) "  Tcl_CreateObjCommand(interp, \"$procname\", $cname, NULL, NULL);"
          108  +					}
   116    109   				}
   117    110   
   118    111   				append state(code) "Tcl_PkgProvide(interp, \"$state(package)\", \"0.0\");\n"
   119    112   				append state(code) "  return(TCL_OK);\n"
   120    113   				append state(code) "\}"
          114  +			}
          115  +		}
          116  +
          117  +		# Generate output code
          118  +		tcc4tcl $dir $state(type) tcc
          119  +
          120  +		switch -- $state(type) {
          121  +			"memory" {
          122  +				tcc compile $state(code)
          123  +
          124  +				foreach {procname cname} $state(procs) {
          125  +					tcc command $procname $cname
          126  +				}
          127  +			}
          128  +
          129  +			"dll" - "exe" {
          130  +				switch -glob -- $::tcl_platform(os)-$::tcl_platform(machine) {
          131  +					"Linux-x86_64" {
          132  +						tcc add_library_path "/lib64"
          133  +						tcc add_library_path "/usr/lib64"
          134  +						tcc add_library_path "/lib"
          135  +						tcc add_library_path "/usr/lib"
          136  +					}
          137  +					"Linux-*" {
          138  +						tcc add_library_path "/lib32"
          139  +						tcc add_library_path "/usr/lib32"
          140  +						tcc add_library_path "/lib"
          141  +						tcc add_library_path "/usr/lib"
          142  +					}
          143  +					default {
          144  +						if {$::tcl_platform(platform) == "unix"} {
          145  +							tcc add_library_path "/lib"
          146  +							tcc add_library_path "/usr/lib"
          147  +						}
          148  +					}
          149  +				}
   121    150   
   122    151   				tcc compile $state(code)
   123    152   
   124    153   				tcc output_file $state(filename)
   125    154   			}
   126    155   		}
   127    156   
          157  +		# Cleanup
   128    158   		rename $handle ""
   129    159   		unset $handle
   130    160   	}
   131    161   }
   132    162   
   133    163   proc ::tcc4tcl::checkname {n} {expr {[regexp {^[a-zA-Z0-9_]+$} $n] > 0}}
   134    164   proc ::tcc4tcl::cleanname {n} {regsub -all {[^a-zA-Z0-9_]+} $n _}