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     21   
    22     22   nextArg=''
    23     23   kit_filename=''
    24     24   options=()
    25     25   packages=()
    26     26   internalOptionsVerbose='false'
    27     27   noPackages='false'
           28  +downloadSDK='false'
    28     29   for arg in "$@"; do
    29     30   	if [ -n "${nextArg}" ]; then
    30     31   		jsonArgs["${nextArg}"]="${arg}"
    31     32   		nextArg=''
    32     33   		continue
    33     34   	fi
    34     35   
................................................................................
    39     40   		--platform|--tcl-version|--kitcreator-version)
    40     41   			nextArg="${arg:2}"
    41     42   			nextArg="${nextArg//-/_}"
    42     43   			;;
    43     44   		--kitdll|--threaded|--debug|--dynamictk|--staticpkgs)
    44     45   			options+=("${arg:2}")
    45     46   			;;
           47  +		--sdk)
           48  +			downloadSDK='true'
           49  +			;;
    46     50   		--opt-*)
    47     51   			options+=("${arg:6}")
    48     52   			;;
    49     53   		--pkg-*)
    50     54   			packages+=("${arg:6}")
    51     55   			noPackages='false'
    52     56   			;;
................................................................................
   140    144   	if [ "${internalOptionsVerbose}" = 'true' ]; then
   141    145   		curl -sSL "${build_log_url}" >&2
   142    146   	fi
   143    147   
   144    148   	exit 1
   145    149   fi
   146    150   
   147         -kit_url="$(jq -crM .kit_url <<<"${info}")"
   148         -if [ -z "${kit_filename}" ]; then
   149         -	kit_filename="${kit_url//*\//}"
   150         -	case "${kit_filename}" in
   151         -		*.*)
   152         -			kit_filename_base="${kit_filename//.*/}"
   153         -			kit_filename_ext=".${kit_filename//*./}"
   154         -			;;
   155         -		*)
   156         -			kit_filename_base="${kit_filename}"
   157         -			kit_filename_ext=''
   158         -			;;
   159         -	esac
   160         -	kit_filename_platform="$(jq -crM .platform <<<"${info}")"
   161         -	kit_filename_tcl_version="$(jq -crM .tcl_version <<<"${info}")"
   162         -	kit_filename="${kit_filename_base}-${kit_filename_platform}-${kit_filename_tcl_version}${kit_filename_ext}"
   163         -fi
          151  +if [ "${downloadSDK}" = 'false' ]; then
          152  +	kit_url="$(jq -crM .kit_url <<<"${info}")"
          153  +	if [ -z "${kit_filename}" ]; then
          154  +		kit_filename="${kit_url//*\//}"
          155  +		case "${kit_filename}" in
          156  +			*.*)
          157  +				kit_filename_base="${kit_filename//.*/}"
          158  +				kit_filename_ext=".${kit_filename//*./}"
          159  +				;;
          160  +			*)
          161  +				kit_filename_base="${kit_filename}"
          162  +				kit_filename_ext=''
          163  +				;;
          164  +		esac
          165  +		kit_filename_platform="$(jq -crM .platform <<<"${info}")"
          166  +		kit_filename_tcl_version="$(jq -crM .tcl_version <<<"${info}")"
          167  +		kit_filename="${kit_filename_base}-${kit_filename_platform}-${kit_filename_tcl_version}${kit_filename_ext}"
          168  +	fi
          169  +
          170  +	curl -sSL "${kit_url}" > "${kit_filename}"
          171  +	chmod 755 "${kit_filename}"
          172  +else
          173  +	kit_sdk_url="$(jq -crM .kit_sdk_url <<<"${info}")"
          174  +	if [ -z "${kit_filename}" ]; then
          175  +		kit_filename="${kit_sdk_url//*\//}"
          176  +	fi
   164    177   
   165         -curl -sSL "${kit_url}" > "${kit_filename}"
   166         -chmod 755 "${kit_filename}"
          178  +	curl -sSL "${kit_sdk_url}" > "${kit_filename}"
          179  +fi
   167    180   
   168    181   echo "Wrote: ${kit_filename}"
   169    182   exit 0

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

   122    122   if {[info exists outfile]} {
   123    123   	set build_log_url "${base_url}/${filename}.log"
   124    124   	if {[file exists $outfile]} {
   125    125   		set status "Complete"
   126    126   		set terminal 1
   127    127   
   128    128   		set url "${base_url}/$filename"
          129  +		if {[info exists buildinfo(sdkfilename)]} {
          130  +			set sdk_url "${base_url}/$buildinfo(sdkfilename)"
          131  +		}
   129    132   	} elseif {[file exists "${outfile}.buildfail"]} {
   130    133   		set status "Failed"
   131    134   		set terminal 1
   132    135   	} else {
   133    136   		set status "Building"
   134    137   	}
   135    138   }
................................................................................
   139    142   
   140    143   	set resultsDict [dict create \
   141    144   		status [string tolower $status] \
   142    145   		terminal $terminalBoolean \
   143    146   	]
   144    147   	if {[string tolower $status] eq "complete"} {
   145    148   		dict set resultsDict kit_url $url
          149  +
          150  +		if {[info exists sdk_url]} {
          151  +			dict set resultsDict kit_sdk_url $sdk_url
          152  +		}
   146    153   	}
   147    154   	if {[string tolower $status] in {complete building failed}} {
   148    155   		dict set resultsDict build_log_url $build_log_url
   149    156   		catch {
   150    157   			dict set resultsDict tcl_version $buildinfo(tcl_version)
   151    158   		}
   152    159   		catch {

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

   429    429   			lappend key [list "option:$option" $build_options($option)]
   430    430   		}
   431    431   
   432    432   		## Convert key to a user-consumable string via hashing
   433    433   		set key [string tolower [sha1::sha1 -hex $key]]
   434    434   
   435    435   		# Determine filename
          436  +		set extra_keys [list]
   436    437   		if {$build_options(kitdll)} {
   437    438   			set extension "so"
   438    439   			switch -- $build_platform {
   439    440   				"win32" - "win64" {
   440    441   					set extension "dll"
   441    442   				}
   442    443   				"hpux-hppa64" {
   443    444   					set extension "sl"
   444    445   				}
   445    446   			}
   446    447   
   447    448   			## XXX: TODO: The version here needs to match what's in the SONAME
   448    449   			set filename "libtclkit[string map [list "." ""] ${cache_tcl_version}].${extension}"
          450  +			set sdkfilename "libtclkit[string map [list "." ""] ${cache_tcl_version}]-${build_platform}-sdk.tar.gz"
          451  +			lappend extra_keys sdkfilename $sdkfilename
   449    452   		} else {
   450    453   			set filename "tclkit"
   451    454   
   452    455   			switch -- $build_platform {
   453    456   				"win32" - "win64" {
   454    457   					append filename ".exe"
   455    458   				}
   456    459   			}
   457    460   		}
   458    461   
   459    462   		# Queue build up and wait for it to complete
   460    463   		set fd [open $queue a+]
   461         -		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]]
          464  +		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]
   462    465   		close $fd
   463    466   
   464    467   		set url "http://kitcreator.rkeene.org/kits/building/$key/"
   465    468   
   466    469   		if {!$resultIsAPI} {
   467    470   			headers redirect $url
   468    471   ?><html>

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

    14     14   set queue "${queue}.old"
    15     15   
    16     16   set fd [open $queue r]
    17     17   set data [read $fd]
    18     18   close $fd
    19     19   
    20     20   set ::env(TCLKIT) "/home/rkeene/bin/tclkit"
           21  +
           22  +proc handleSDK {workdir input output} {
           23  +	set workdir [file join $workdir "sdk-rewrite"]
           24  +	set dirNewName [regsub {\.tar\.gz$} [file tail $output] {}]
           25  +
           26  +	file mkdir $workdir
           27  +	exec gzip -dc $input | tar -C $workdir -xf -
           28  +
           29  +	set dirName [glob -nocomplain -directory $workdir *]
           30  +	if {[llength $dirName] != 1} {
           31  +		return -code error "Multiple directories found: $dirName"
           32  +	}
           33  +
           34  +	set dirName [lindex $dirName 0]
           35  +
           36  +	file rename $dirName [file join $workdir $dirNewName]
           37  +	exec tar -C $workdir -cf - $dirNewName | gzip -9c > [file join $workdir sdk.tar.gz]
           38  +
           39  +	file copy [file join $workdir sdk.tar.gz] $output
           40  +}
    21     41   
    22     42   foreach line [split $data "\n"] {
    23     43   	if {$line == ""} {
    24     44   		continue
    25     45   	}
    26     46   
    27     47   	unset -nocomplain buildinfo
           48  +	unset -nocomplain outsdkfile
    28     49   
    29     50   	array set buildinfo $line
    30     51   
    31     52   	set outfile [file join $outdir $buildinfo(key) $buildinfo(filename)]
           53  +	if {[info exists buildinfo(sdkfilename)]} {
           54  +		set outsdkfile [file join $outdir $buildinfo(key) $buildinfo(sdkfilename)]
           55  +	}
    32     56   
    33     57   	# Skip if build completed
    34     58   	if {[file exists $outfile]} {
    35     59   		continue
    36     60   	}
    37     61   
    38     62   	# Skip if build failed
................................................................................
   159    183   	}
   160    184   
   161    185   	catch {
   162    186   		exec grep ^ {*}[lsort -dictionary [glob */build.log]] >> "${outfile}.log"
   163    187   	}
   164    188   
   165    189   	foreach file [list tclkit-$buildinfo(tcl_version) {*}[glob -nocomplain libtclkit*]] {
          190  +		set isSDK false
   166    191   		switch -glob -- $file {
   167    192   			"*.dylib" - "*.so" - "*.sl" - "*.dll" { }
   168    193   			"tclkit-*" {}
          194  +			"libtclkit-sdk-*.tar.gz" {
          195  +				set isSDK true
          196  +			}
   169    197   			default {
   170    198   				continue
   171    199   			}
   172    200   		}
          201  +
          202  +		if {$isSDK} {
          203  +			if {[info exists outsdkfile]} {
          204  +				if {[catch {
          205  +					handleSDK $workdir $file $outsdkfile
          206  +				}]} {
          207  +					puts stderr "Error creating SDK: $::errorInfo"
          208  +				}
          209  +			}
          210  +
          211  +			continue
          212  +		}
   173    213   
   174    214   		if {[file exists $file]} {
   175    215   			file rename $file $outfile
   176    216   
   177    217   			break
   178    218   		}
   179    219   	}