3 # Copyright (C) 2014 Apple Inc. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 # THE POSSIBILITY OF SUCH DAMAGE.
30 DIRECTORY_NAME = "JetStream-#{VERSION}"
32 raise unless system("rm -rf " + DIRECTORY_NAME)
33 raise unless system("mkdir -p " + DIRECTORY_NAME)
34 raise unless system("mkdir -p #{DIRECTORY_NAME}/sunspider")
35 raise unless system("mkdir -p #{DIRECTORY_NAME}/sources")
36 raise unless system("cp sunspider/*.js #{DIRECTORY_NAME}/sunspider")
37 raise unless system("cp -r JetStream.css JetStreamDriver.js LLVM-test-suite-LICENSE.txt simple Octane2 Octane2Setup.js SimpleSetup.js SunSpiderSetup.js Octane OctaneSetup.js Reference.js TestingSetup.js JetStream-Logo.png JetStream-Logo@2x.png Swoosh.png Swoosh@2x.png " + DIRECTORY_NAME)
39 def detemplatize(basename)
40 File.open(DIRECTORY_NAME + "/#{basename}.html", "w") {
42 outp.write(IO::read("#{basename}-TEMPLATE.html").gsub(/@VERSION@/, VERSION.to_s))
46 detemplatize("in-depth")
48 def transferSource(benchmarkName, *files)
51 pathname = Pathname.new(filename)
53 originalBasename = pathname.basename
54 extname = originalBasename.extname
55 basename = originalBasename.basename(extname)
57 if basename.to_s.start_with? benchmarkName
58 resultPathname = Pathname.new(DIRECTORY_NAME) + "sources" + "#{basename}"
59 resultName = basename.to_s
61 resultPathname = Pathname.new(DIRECTORY_NAME) + "sources" + "#{benchmarkName}-#{basename}"
62 resultName = "#{benchmarkName} / #{basename}"
65 raise unless system("cp #{Shellwords.shellescape(pathname.to_s)} #{Shellwords.shellescape(resultPathname.to_s + extname)}")
69 File.open(DIRECTORY_NAME + "/SimplePayload.js", "w") {
71 outp.puts "// THIS IS AUTO-GENERATED BY create.rb"
72 outp.puts "var SimplePayload = ["
73 directory = Pathname.new("simple")
74 Dir.foreach(directory) {
76 next unless filename =~ /\.js$/
77 baseName = $~.pre_match
78 outp.puts " {name: #{baseName.inspect}, content:#{IO::read(directory + filename).inspect}},"
79 if filename.to_s =~ /\.(cp*)\.js/
80 transferSource($~.pre_match, directory + ($~.pre_match + "." + $1), directory + filename)
82 transferSource(baseName, directory + filename)
88 File.open(DIRECTORY_NAME + "/SunSpiderPayload.js", "w") {
90 outp.puts "// THIS IS AUTO-GENERATED BY create.rb"
91 outp.puts "var SunSpiderPayload = ["
92 directory = Pathname.new("sunspider")
93 Dir.foreach(directory) {
95 next unless filename =~ /\.js$/
96 baseName = $~.pre_match
97 outp.puts " {name: #{baseName.inspect}, content:#{IO::read(directory + filename).inspect}},"
98 transferSource(baseName, directory + filename)
103 transferSource("code-multi-load", "Octane/code-load.js")
104 transferSource("richards", "Octane2/richards.js")
105 transferSource("deltablue", "Octane2/deltablue.js")
106 transferSource("crypto", "Octane2/crypto.js")
107 transferSource("raytrace", "Octane2/raytrace.js")
108 transferSource("earley-boyer", "Octane2/earley-boyer.js")
109 transferSource("regexp", "Octane2/regexp.js")
110 transferSource("splay", "Octane2/splay.js")
111 transferSource("navier-stokes", "Octane2/navier-stokes.js")
112 transferSource("pdfjs", "Octane2/pdfjs.js")
113 transferSource("mandreel", "Octane2/mandreel.js")
114 transferSource("gbemu", "Octane2/gbemu-part1.js", "Octane2/gbemu-part2.js")
115 transferSource("code-first-load", "Octane2/code-load.js")
116 transferSource("box2d", "Octane2/box2d.js")
117 transferSource("zlib", "Octane2/zlib.js", "Octane2/zlib-data.js")
118 transferSource("typescript", "Octane2/typescript.js", "Octane2/typescript-compiler.js", "Octane2/typescript-input.js")
120 puts "You can now run JetStream by navigating to file://" + (Pathname.new(DIRECTORY_NAME) + "index.html").realpath.to_s