Check-in [2ec364d475]
Overview
Comment:Add support for fetching the SDK over the API
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2ec364d4758bac0dac5b61d23028add6c30de1b0
User & Date: rkeene on 2019-09-17 16:16:39
Other Links: manifest | tags
Context
2019-09-17
16:31
Better handling of the case where no SDK is available check-in: feb20a3126 user: rkeene tags: trunk
16:16
Add support for fetching the SDK over the API check-in: 2ec364d475 user: rkeene tags: trunk
2019-08-26
14:27
Ignore more parameters while building tcllux check-in: f9d652be14 user: rkeene tags: trunk
Changes

Modified build/utils/download-api-client from [e4f8c366e4] to [3a69b30ec1].

21
22
23
24
25
26
27

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45



46
47
48
49
50
51
52
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56







+


















+
+
+








nextArg=''
kit_filename=''
options=()
packages=()
internalOptionsVerbose='false'
noPackages='false'
downloadSDK='false'
for arg in "$@"; do
	if [ -n "${nextArg}" ]; then
		jsonArgs["${nextArg}"]="${arg}"
		nextArg=''
		continue
	fi

	case "${arg}" in
		--verbose)
			internalOptionsVerbose='true'
			;;
		--platform|--tcl-version|--kitcreator-version)
			nextArg="${arg:2}"
			nextArg="${nextArg//-/_}"
			;;
		--kitdll|--threaded|--debug|--dynamictk|--staticpkgs)
			options+=("${arg:2}")
			;;
		--sdk)
			downloadSDK='true'
			;;
		--opt-*)
			options+=("${arg:6}")
			;;
		--pkg-*)
			packages+=("${arg:6}")
			noPackages='false'
			;;
140
141
142
143
144
145
146

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163

















164
165
166







167



168
169
144
145
146
147
148
149
150
151

















152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169


170
171
172
173
174
175
176
177
178
179
180
181
182







+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
+
+
+
+
+
+
+

+
+
+


	if [ "${internalOptionsVerbose}" = 'true' ]; then
		curl -sSL "${build_log_url}" >&2
	fi

	exit 1
fi

if [ "${downloadSDK}" = 'false' ]; then
kit_url="$(jq -crM .kit_url <<<"${info}")"
if [ -z "${kit_filename}" ]; then
	kit_filename="${kit_url//*\//}"
	case "${kit_filename}" in
		*.*)
			kit_filename_base="${kit_filename//.*/}"
			kit_filename_ext=".${kit_filename//*./}"
			;;
		*)
			kit_filename_base="${kit_filename}"
			kit_filename_ext=''
			;;
	esac
	kit_filename_platform="$(jq -crM .platform <<<"${info}")"
	kit_filename_tcl_version="$(jq -crM .tcl_version <<<"${info}")"
	kit_filename="${kit_filename_base}-${kit_filename_platform}-${kit_filename_tcl_version}${kit_filename_ext}"
fi
	kit_url="$(jq -crM .kit_url <<<"${info}")"
	if [ -z "${kit_filename}" ]; then
		kit_filename="${kit_url//*\//}"
		case "${kit_filename}" in
			*.*)
				kit_filename_base="${kit_filename//.*/}"
				kit_filename_ext=".${kit_filename//*./}"
				;;
			*)
				kit_filename_base="${kit_filename}"
				kit_filename_ext=''
				;;
		esac
		kit_filename_platform="$(jq -crM .platform <<<"${info}")"
		kit_filename_tcl_version="$(jq -crM .tcl_version <<<"${info}")"
		kit_filename="${kit_filename_base}-${kit_filename_platform}-${kit_filename_tcl_version}${kit_filename_ext}"
	fi

curl -sSL "${kit_url}" > "${kit_filename}"
chmod 755 "${kit_filename}"
	curl -sSL "${kit_url}" > "${kit_filename}"
	chmod 755 "${kit_filename}"
else
	kit_sdk_url="$(jq -crM .kit_sdk_url <<<"${info}")"
	if [ -z "${kit_filename}" ]; then
		kit_filename="${kit_sdk_url//*\//}"
	fi

	curl -sSL "${kit_sdk_url}" > "${kit_filename}"
fi

echo "Wrote: ${kit_filename}"
exit 0

Modified build/web/building.cgi from [536bf400ea] to [9e4625490c].

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
151
152
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
151
152
153
154
155
156
157
158
159







+
+
+

















+
+
+
+







if {[info exists outfile]} {
	set build_log_url "${base_url}/${filename}.log"
	if {[file exists $outfile]} {
		set status "Complete"
		set terminal 1

		set url "${base_url}/$filename"
		if {[info exists buildinfo(sdkfilename)]} {
			set sdk_url "${base_url}/$buildinfo(sdkfilename)"
		}
	} elseif {[file exists "${outfile}.buildfail"]} {
		set status "Failed"
		set terminal 1
	} else {
		set status "Building"
	}
}

if {$resultFormat in {json dict}} {
	set terminalBoolean [lindex {false true} $terminal]

	set resultsDict [dict create \
		status [string tolower $status] \
		terminal $terminalBoolean \
	]
	if {[string tolower $status] eq "complete"} {
		dict set resultsDict kit_url $url

		if {[info exists sdk_url]} {
			dict set resultsDict kit_sdk_url $sdk_url
		}
	}
	if {[string tolower $status] in {complete building failed}} {
		dict set resultsDict build_log_url $build_log_url
		catch {
			dict set resultsDict tcl_version $buildinfo(tcl_version)
		}
		catch {

Modified build/web/kitcreator.vfs/index.rvt from [5654b19e1c] to [607487820f].

429
430
431
432
433
434
435

436
437
438
439
440
441
442
443
444
445
446
447
448


449
450
451
452
453
454
455
456
457
458
459
460
461

462
463
464
465
466
467
468
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463

464
465
466
467
468
469
470
471







+













+
+












-
+







			lappend key [list "option:$option" $build_options($option)]
		}

		## Convert key to a user-consumable string via hashing
		set key [string tolower [sha1::sha1 -hex $key]]

		# Determine filename
		set extra_keys [list]
		if {$build_options(kitdll)} {
			set extension "so"
			switch -- $build_platform {
				"win32" - "win64" {
					set extension "dll"
				}
				"hpux-hppa64" {
					set extension "sl"
				}
			}

			## XXX: TODO: The version here needs to match what's in the SONAME
			set filename "libtclkit[string map [list "." ""] ${cache_tcl_version}].${extension}"
			set sdkfilename "libtclkit[string map [list "." ""] ${cache_tcl_version}]-${build_platform}-sdk.tar.gz"
			lappend extra_keys sdkfilename $sdkfilename
		} else {
			set filename "tclkit"

			switch -- $build_platform {
				"win32" - "win64" {
					append filename ".exe"
				}
			}
		}

		# Queue build up and wait for it to complete
		set fd [open $queue a+]
		puts $fd [list filename $filename key $key platform $build_platform tcl_version $build_tcl_version kitcreator_version $build_kitcreator_version packages $build_packages options [array get build_options]]
		puts $fd [list filename $filename key $key platform $build_platform tcl_version $build_tcl_version kitcreator_version $build_kitcreator_version packages $build_packages options [array get build_options] {*}$extra_keys]
		close $fd

		set url "http://kitcreator.rkeene.org/kits/building/$key/"

		if {!$resultIsAPI} {
			headers redirect $url
?><html>

Modified build/web/process_queue from [92bcf20d68] to [3c4d307b06].

14
15
16
17
18
19
20




















21
22
23
24
25
26
27

28
29
30
31



32
33
34
35
36
37
38
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







+




+
+
+







set queue "${queue}.old"

set fd [open $queue r]
set data [read $fd]
close $fd

set ::env(TCLKIT) "/home/rkeene/bin/tclkit"

proc handleSDK {workdir input output} {
	set workdir [file join $workdir "sdk-rewrite"]
	set dirNewName [regsub {\.tar\.gz$} [file tail $output] {}]

	file mkdir $workdir
	exec gzip -dc $input | tar -C $workdir -xf -

	set dirName [glob -nocomplain -directory $workdir *]
	if {[llength $dirName] != 1} {
		return -code error "Multiple directories found: $dirName"
	}

	set dirName [lindex $dirName 0]

	file rename $dirName [file join $workdir $dirNewName]
	exec tar -C $workdir -cf - $dirNewName | gzip -9c > [file join $workdir sdk.tar.gz]

	file copy [file join $workdir sdk.tar.gz] $output
}

foreach line [split $data "\n"] {
	if {$line == ""} {
		continue
	}

	unset -nocomplain buildinfo
	unset -nocomplain outsdkfile

	array set buildinfo $line

	set outfile [file join $outdir $buildinfo(key) $buildinfo(filename)]
	if {[info exists buildinfo(sdkfilename)]} {
		set outsdkfile [file join $outdir $buildinfo(key) $buildinfo(sdkfilename)]
	}

	# Skip if build completed
	if {[file exists $outfile]} {
		continue
	}

	# Skip if build failed
159
160
161
162
163
164
165

166
167
168



169
170
171
172












173
174
175
176
177
178
179
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219







+



+
+
+




+
+
+
+
+
+
+
+
+
+
+
+







	}

	catch {
		exec grep ^ {*}[lsort -dictionary [glob */build.log]] >> "${outfile}.log"
	}

	foreach file [list tclkit-$buildinfo(tcl_version) {*}[glob -nocomplain libtclkit*]] {
		set isSDK false
		switch -glob -- $file {
			"*.dylib" - "*.so" - "*.sl" - "*.dll" { }
			"tclkit-*" {}
			"libtclkit-sdk-*.tar.gz" {
				set isSDK true
			}
			default {
				continue
			}
		}

		if {$isSDK} {
			if {[info exists outsdkfile]} {
				if {[catch {
					handleSDK $workdir $file $outsdkfile
				}]} {
					puts stderr "Error creating SDK: $::errorInfo"
				}
			}

			continue
		}

		if {[file exists $file]} {
			file rename $file $outfile

			break
		}
	}