build-tclkit.tcl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #!/usr/bin/env tclsh
  2. #
  3. # Build tclkit for the current platform.
  4. #
  5. # Copyright 2015-2017 OpenIndex.de.
  6. # Distributed under the MIT License.
  7. # See accompanying LICENSE.txt file or at http://opensource.org/licenses/MIT
  8. #
  9. # ------------------------------------------------------------------------------
  10. #
  11. # GENERAL NOTES
  12. #
  13. # - This script is used to create tclkit binaries for Linux and Mac OS X.
  14. #
  15. # - Windows should also work with some modifications to this script. But it
  16. # will require some preparations beforehand (some kind of MinGW environment).
  17. #
  18. set BASE_DIR [file normalize [file dirname $argv0]]
  19. set BUILD_DIR [file join $BASE_DIR "build"]
  20. set TARGET_DIR [file join $BASE_DIR "target" "tclkit"]
  21. set KITCREATOR_DIR [file join $BUILD_DIR "kitcreator-0.10.0"]
  22. set KITCREATOR_URL "http://www.rkeene.org/devel/kitcreator-0.10.0.tar.gz"
  23. proc download {url} {
  24. if {![catch {exec which wget} wget]} {
  25. exec wget -q $url >@ stdout
  26. return 1
  27. }
  28. if {![catch {exec which curl} curl]} {
  29. exec curl -L -O -s $url >@ stdout
  30. return 1
  31. }
  32. error "Can't download '$url'! Neither wget nor curl is available."
  33. }
  34. proc is_darwin {} {
  35. global tcl_platform
  36. set os [string tolower $tcl_platform(os)]
  37. return [string match "darwin*" $os]
  38. }
  39. proc is_linux {} {
  40. global tcl_platform
  41. set os [string tolower $tcl_platform(os)]
  42. return [string match "linux*" $os]
  43. }
  44. proc is_windows {} {
  45. global tcl_platform
  46. set os [string tolower $tcl_platform(os)]
  47. return [string match "windows*" $os]
  48. }
  49. fconfigure stdout -buffering none
  50. fconfigure stderr -buffering none
  51. if {![file exists $BUILD_DIR]} {
  52. file mkdir $BUILD_DIR
  53. }
  54. # download
  55. if {![file exists $KITCREATOR_DIR]} {
  56. puts ""
  57. puts [string repeat "-" 50]
  58. puts " Download kitcreator."
  59. puts [string repeat "-" 50]
  60. cd $BUILD_DIR
  61. download $KITCREATOR_URL
  62. exec -ignorestderr tar xvfz "kitcreator-0.10.0.tar.gz" >@ stdout
  63. }
  64. cd $KITCREATOR_DIR
  65. # cleanup
  66. puts ""
  67. puts [string repeat "-" 50]
  68. puts " Cleanup tclkit."
  69. puts [string repeat "-" 50]
  70. if {[file exists $TARGET_DIR]} {
  71. file delete -force $TARGET_DIR
  72. }
  73. exec bash kitcreator clean >@ stdout
  74. # make
  75. puts ""
  76. puts [string repeat "-" 50]
  77. puts " Build tclkit."
  78. puts [string repeat "-" 50]
  79. set ::env(STATICTK) "1"
  80. set options {}
  81. lappend options "--disable-xss"
  82. lappend options "--disable-threads"
  83. if {[is_darwin]} {
  84. lappend options "--enable-aqua"
  85. }
  86. exec bash kitcreator {*}$options >@ stdout
  87. # finish
  88. puts ""
  89. puts [string repeat "-" 50]
  90. puts " Finish build process."
  91. puts [string repeat "-" 50]
  92. set files {}
  93. foreach f [glob -nocomplain -directory $KITCREATOR_DIR -type f "tclkit-*"] {
  94. lappend files $f
  95. }
  96. if {[llength $files] < 1} {
  97. puts "ERROR: No compiled binary was found!"
  98. exit 1
  99. }
  100. if {![file exists $TARGET_DIR]} {
  101. file mkdir $TARGET_DIR
  102. }
  103. foreach f $files {
  104. file copy $f $TARGET_DIR
  105. }
  106. puts "Compiled binaries were saved to:"
  107. puts "$TARGET_DIR"
  108. puts [string repeat "-" 50]
  109. puts ""
  110. exit 0