BuildS48.boo 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. // Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. //
  3. // Authors: Robert Ransom
  4. //
  5. // Semi-automatic Windows build script for Scheme 48.
  6. // To prepare to run this script:
  7. // - Download Boo 0.9.2.3383 (from http://dist.codehaus.org/boo/distributions/)
  8. // and unpack the distribution.
  9. // - Compile this script with booc, and put the resulting EXE in the root
  10. // directory of the source tree. For example:
  11. // ..\..\path\to\booc.exe build\BuildS48.boo
  12. // - Put Boo.Lang.dll in the root directory of the source tree.
  13. // To run this script:
  14. // - Open a Windows command prompt in the root directory of the source tree.
  15. // - Set the RUNNABLE environment variable to the (possibly relative) path to
  16. // the scheme48.bat file in a working Scheme 48 installation.
  17. // - Run BuildS48.exe.
  18. // - If odd messages appear (errors or unusual warnings), press Control-C to
  19. // stop the build process, then press Control-C again so that CMD.EXE will
  20. // print another prompt. This script currently does not detect most errors.
  21. namespace BuildS48
  22. import System
  23. import System.Diagnostics
  24. import System.IO
  25. import System.Text
  26. // Ensure that current directory contains scheme48.sln and autogen.sh
  27. // (and is therefore probably the root directory of a Scheme 48
  28. // development source tree).
  29. filesThatShouldExist = [
  30. 'autogen.sh',
  31. 'scheme48.sln',
  32. 'scheme48.vcproj',
  33. 'README',
  34. 'WINDOWS.txt',
  35. 'build/scheme48.wxs']
  36. for fileName in filesThatShouldExist:
  37. unless File.Exists(fileName):
  38. raise "${fileName} is not here - this should be run from the root directory of a Scheme 48 development source tree"
  39. // Define utility functions.
  40. def makeArgs(*args as (string)):
  41. cmdline = StringBuilder()
  42. for arg in args:
  43. cmdline.Append('"')
  44. for ch in arg:
  45. if ch == '"':
  46. cmdline.Append("\"\"")
  47. else:
  48. cmdline.Append(ch)
  49. cmdline.Append("\" ")
  50. return cmdline.ToString()
  51. def dequote(s as string):
  52. unless s.StartsWith("\"") and s.EndsWith("\""):
  53. return s
  54. s2 = s.Substring(1, s.Length - 2)
  55. if s2.IndexOf("\"") != -1: // FIXME?
  56. return s
  57. return s2
  58. def runWithInput(name as string, *args as (string)):
  59. si = ProcessStartInfo(name, makeArgs(*args))
  60. si.UseShellExecute = false
  61. si.RedirectStandardInput = true
  62. return Process.Start(si)
  63. def runAndWait(name as string, *args as (string)):
  64. si = ProcessStartInfo(name, makeArgs(*args))
  65. si.UseShellExecute = false
  66. Process.Start(si).WaitForExit()
  67. def stuffProcessInputFromFile(process as Process, inputFileName as string):
  68. inputFile = StreamReader(inputFileName)
  69. output = process.StandardInput
  70. buffer = array(char, 4096)
  71. rv = 1
  72. while rv > 0:
  73. rv = inputFile.Read(buffer, 0, buffer.Length)
  74. output.Write(buffer, 0, rv)
  75. def closeProcessInput(process as Process):
  76. process.StandardInput.Close()
  77. def herald(msg as string):
  78. print
  79. s = '********'
  80. s = string.Concat(s, s)
  81. s = string.Concat(s, s)
  82. s = string.Concat(s, s)
  83. print s
  84. print "**** ${msg}"
  85. print
  86. // Find an existing (runnable) copy of Scheme 48.
  87. runnable = Environment.GetEnvironmentVariable("RUNNABLE")
  88. if runnable != null:
  89. print "Found RUNNABLE environment variable"
  90. // TODO? - use Microsoft Installer to find an installed binary distribution?
  91. // Does Boo have an equivalent to the C# extern keyword?
  92. if runnable == null:
  93. raise "No runnable specified - please set the RUNNABLE environment variable"
  94. unless File.Exists(runnable):
  95. if runnable.StartsWith("\""):
  96. runnableDequoted = dequote(runnable)
  97. if File.Exists(runnableDequoted):
  98. runnable = runnableDequoted
  99. print "Using runnable: ${runnable}"
  100. unless File.Exists(runnable):
  101. raise "Runnable does not exist"
  102. // Build Unicode information, but only if it's *really* necessary.
  103. herald('build/generate-unicode-info.bat')
  104. inputsOfGenUnicodeInfo = [
  105. "build/UnicodeData.txt",
  106. "build/PropList.txt",
  107. "build/SpecialCasing.txt",
  108. "build/CaseFolding.txt",
  109. "build/CompositionExclusions.txt"]
  110. outputsOfGenUnicodeInfo = [
  111. "scheme/env/unicode-info.scm",
  112. "scheme/rts/syntax-info.scm",
  113. "scheme/big/unicode-normalization-info.scm",
  114. "scheme/srfi/srfi-14-base-char-sets.scm"]
  115. guiInputLastMTime = DateTime.FromFileTimeUtc(0)
  116. for input in inputsOfGenUnicodeInfo:
  117. unless File.Exists(input):
  118. raise "Required input file ${input} is missing"
  119. inputMTime = File.GetLastWriteTimeUtc(input)
  120. if inputMTime > guiInputLastMTime:
  121. guiInputLastMTime = inputMTime
  122. mustRunGenUnicodeInfo = false
  123. for output in outputsOfGenUnicodeInfo:
  124. unless File.Exists(output):
  125. print "Running build/generate-unicode-info.bat because ${output} is missing"
  126. mustRunGenUnicodeInfo = true
  127. break
  128. unless File.GetLastWriteTimeUtc(output) > guiInputLastMTime:
  129. print "Running build/generate-unicode-info.bat because ${output} is older than an input file"
  130. mustRunGenUnicodeInfo = true
  131. break
  132. if mustRunGenUnicodeInfo:
  133. runAndWait('build/generate-unicode-info.bat', runnable)
  134. else:
  135. print "Skipping build/generate-unicode-info.bat"
  136. // Build initial image.
  137. herald('%RUNNABLE% -a batch <build/extract-filenames.scm')
  138. p = runWithInput(runnable, '-a', 'batch')
  139. stuffProcessInputFromFile(p, 'build/extract-filenames.scm')
  140. p.StandardInput.Write(',exit\n') // not in extract-filenames.scm because it's portable
  141. closeProcessInput(p)
  142. p.WaitForExit()
  143. herald('build/build-initial-image.bat')
  144. runAndWait("build/build-initial-image.bat", runnable)
  145. // Compile Scheme 48 VM to C code.
  146. herald('build/generate-c-header.bat')
  147. runAndWait('build/generate-c-header.bat', runnable)
  148. herald('build/compile-vm.bat')
  149. runAndWait('build/compile-vm.bat', runnable)
  150. herald('build/compile-bibop-gc.bat')
  151. runAndWait('build/compile-bibop-gc.bat', runnable)
  152. // This isn't actually necessary, but it should be kept working for now.
  153. herald('build/compile-twospace-gc.bat')
  154. runAndWait('build/compile-twospace-gc.bat', runnable)
  155. File.Copy('c/win32/scheme48arch.h', 'c/scheme48arch.h', true)
  156. // Compile Scheme 48 VM to native code.
  157. // TODO - find MSBuild.exe in a way that is more likely to work on other
  158. // developers' computers
  159. herald('msbuild scheme48.sln')
  160. runAndWait(
  161. "C:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5\\MSBuild.exe",
  162. "/target:Rebuild",
  163. "/property:Configuration=Release",
  164. "/property:Platform=Win32",
  165. "scheme48.sln")
  166. // Build the usual image.
  167. // The directory of this source tree will be hardcoded into the image.
  168. cwdWithTrailingBackslash = Directory.GetCurrentDirectory()
  169. unless cwdWithTrailingBackslash.EndsWith("\\"):
  170. cwdWithTrailingBackslash = cwdWithTrailingBackslash + "\\"
  171. herald('build/build-usual-image.bat')
  172. runAndWait(
  173. 'build/build-usual-image.bat',
  174. cwdWithTrailingBackslash,
  175. cwdWithTrailingBackslash + "scheme",
  176. Directory.GetCurrentDirectory(),
  177. 'scheme48.image',
  178. 'scheme48vm.exe',
  179. 'build/initial.image-32')
  180. // Build the startup script.
  181. herald('build/generate-go.bat')
  182. runAndWait(
  183. 'build/generate-go.bat',
  184. 'scheme48.bat',
  185. "${cwdWithTrailingBackslash}scheme48vm.exe",
  186. "${cwdWithTrailingBackslash}scheme48.image")
  187. // Run the test suite.
  188. // Not really necessary when building the system, but I've been burned
  189. // every time I skipped this part.
  190. herald('build/check.bat')
  191. runAndWait(
  192. 'build/check.bat',
  193. 'scheme48.bat')