Check-in [24cc34d5f9]
Overview
Comment:Updated to allow for the possibility of creating a DLL that is not a Tcl package
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 24cc34d5f90a4a7c7c230e0223b50bd8275b1ad6
User & Date: rkeene on 2014-06-18 18:05:59
Other Links: manifest | tags
Context
2014-06-18
19:04
Updated to use pointerSize to determine 32/64-bit library paths so that i386 code can be emitted when running a 32-bit Tcl on a 64-bit box check-in: 0d7d9afa0a user: rkeene tags: trunk
18:05
Updated to allow for the possibility of creating a DLL that is not a Tcl package check-in: 24cc34d5f9 user: rkeene tags: trunk
17:32
Fixed issue when using package versions check-in: 68ce1fca09 user: rkeene tags: trunk
Changes

Modified tcc4tcl.tcl from [16583ee9af] to [8ce88b67f0].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

		if {$output == ""} {
			set type "memory"
		} else {
			if {$pkgName == ""} {
				set type "exe"
			} else {
				set type "dll"
			}
		}

		array set $handle [list tcc $tcc_handle code "" type $type filename $output package $pkgName]

		proc $handle {cmd args} [string map [list @@HANDLE@@ $handle] {
			set handle {@@HANDLE@@}







|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

		if {$output == ""} {
			set type "memory"
		} else {
			if {$pkgName == ""} {
				set type "exe"
			} else {
				set type "package"
			}
		}

		array set $handle [list tcc $tcc_handle code "" type $type filename $output package $pkgName]

		proc $handle {cmd args} [string map [list @@HANDLE@@ $handle] {
			set handle {@@HANDLE@@}
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
		set state(code) "#include <tcl.h>\n\n$state(code)"

		# Append additional generated code to support the output type
		switch -- $state(type) {
			"memory" {
				# No additional code needed
			}
			"exe" {
				if {[info exists state(procs)] && [llength $state(procs)] > 0} {
					append state(code) "int _initProcs(Tcl_Interp *interp) \{\n"
					
					foreach {procname cname} $state(procs) {
						append state(code) "  Tcl_CreateObjCommand(interp, \"$procname\", $cname, NULL, NULL);"
					}

					append state(code) "\}"
				}
			}
			"dll" {
				set packageName [lindex $state(package) 0]
				set packageVersion [lindex $state(package) 1]
				if {$packageVersion == ""} {
					set packageVersion "0"
				}

				append state(code) "int [string totitle $packageName]_Init(Tcl_Interp *interp) \{\n"







|










|







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
		set state(code) "#include <tcl.h>\n\n$state(code)"

		# Append additional generated code to support the output type
		switch -- $state(type) {
			"memory" {
				# No additional code needed
			}
			"exe" - "dll" {
				if {[info exists state(procs)] && [llength $state(procs)] > 0} {
					append state(code) "int _initProcs(Tcl_Interp *interp) \{\n"
					
					foreach {procname cname} $state(procs) {
						append state(code) "  Tcl_CreateObjCommand(interp, \"$procname\", $cname, NULL, NULL);"
					}

					append state(code) "\}"
				}
			}
			"package" {
				set packageName [lindex $state(package) 0]
				set packageVersion [lindex $state(package) 1]
				if {$packageVersion == ""} {
					set packageVersion "0"
				}

				append state(code) "int [string totitle $packageName]_Init(Tcl_Interp *interp) \{\n"
117
118
119
120
121
122
123








124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
				append state(code) "Tcl_PkgProvide(interp, \"$packageName\", \"$packageVersion\");\n"
				append state(code) "  return(TCL_OK);\n"
				append state(code) "\}"
			}
		}

		# Generate output code








		tcc4tcl $dir $state(type) tcc

		switch -- $state(type) {
			"memory" {
				tcc compile $state(code)

				foreach {procname cname} $state(procs) {
					tcc command $procname $cname
				}
			}

			"dll" - "exe" {
				switch -glob -- $::tcl_platform(os)-$::tcl_platform(machine) {
					"Linux-x86_64" {
						tcc add_library_path "/lib64"
						tcc add_library_path "/usr/lib64"
						tcc add_library_path "/lib"
						tcc add_library_path "/usr/lib"
					}







>
>
>
>
>
>
>
>
|










|







117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
				append state(code) "Tcl_PkgProvide(interp, \"$packageName\", \"$packageVersion\");\n"
				append state(code) "  return(TCL_OK);\n"
				append state(code) "\}"
			}
		}

		# Generate output code
		switch -- $state(type) {
			"package" {
				set tcc_type "dll"
			}
			default {
				set tcc_type $state(type)
			}
		}
		tcc4tcl $dir $tcc_type tcc

		switch -- $state(type) {
			"memory" {
				tcc compile $state(code)

				foreach {procname cname} $state(procs) {
					tcc command $procname $cname
				}
			}

			"package" - "dll" - "exe" {
				switch -glob -- $::tcl_platform(os)-$::tcl_platform(machine) {
					"Linux-x86_64" {
						tcc add_library_path "/lib64"
						tcc add_library_path "/usr/lib64"
						tcc add_library_path "/lib"
						tcc add_library_path "/usr/lib"
					}