@@ -46,6 +46,70 @@ namespace :stylesheets do
46
46
end
47
47
end
48
48
49
+ BUILDTOOLS_DIR = "buildtools"
50
+ JS_TEST_DRIVER_DIR = File ::join ( BUILDTOOLS_DIR , "js-test-driver/JsTestDriver" )
51
+ JS_TEST_DRIVER_JAR = File ::join ( JS_TEST_DRIVER_DIR , "target/bin/JsTestDriver.jar" )
52
+ CLOSURE_COMPILER_DIR = File ::join ( BUILDTOOLS_DIR , "closure-compiler" )
53
+ CLOSURE_JAR = File ::join ( CLOSURE_COMPILER_DIR , "build" , "compiler.jar" )
54
+ CLOSURE_DIR = File ::join ( BUILDTOOLS_DIR , "google-closure-library/closure" )
55
+ CLOSURE_DEPSWRITER = File ::join ( CLOSURE_DIR , "bin/build/depswriter.py" )
56
+ CLOSURE_LIBRARY_DIR = File ::join ( CLOSURE_DIR , "goog" )
57
+ CLOSURE_DOTS = File ::join ( *( %w{ .. } * CLOSURE_LIBRARY_DIR . split ( File ::Separator ) . length ) )
58
+
59
+ namespace :test do
60
+ desc "Run JSTestDriver Server"
61
+ task :server => 'jsTestDriver.conf' do
62
+ puts %x{/bin/env java -jar #{ JS_TEST_DRIVER_JAR } --port 9876 &}
63
+ end
64
+
65
+ desc "Run chrome against server"
66
+ task :chromium do
67
+ %x{/bin/env chromium --new-window localhost:9876/capture &}
68
+ end
69
+
70
+ desc "Run firefox against server"
71
+ task :firefox do
72
+ %x{/bin/env firefox localhost:9876/capture &}
73
+ end
74
+
75
+ desc "Run tests against JSTestDriver"
76
+ task :run , [ :tests ] => %w' src/deps.js jsTestDriver.conf ' do |task , args |
77
+ if args [ :tests ]
78
+ tests = args [ :tests ]
79
+ else
80
+ "all"
81
+ end
82
+ sh %{/bin/env java -jar #{ JS_TEST_DRIVER_JAR } --captureConsole --runnerMode DEBUG --tests "#{ tests } "}
83
+ end
84
+
85
+ end
86
+
87
+ task :buildtools => %w{ buildtools:jstestdriver buildtools:jstestdriver_coverage buildtools:closure_compiler }
88
+
89
+ namespace :buildtools do
90
+ task :jstestdriver do
91
+ chdir JS_TEST_DRIVER_DIR do
92
+ puts "Running ant"
93
+ puts %x{ant jstestdriver}
94
+ end
95
+ end
96
+
97
+ task :jstestdriver_coverage do
98
+ chdir JS_TEST_DRIVER_DIR do
99
+ puts "Running ant"
100
+ puts %x{ant jstestdriver-coverage}
101
+ end
102
+ end
103
+
104
+
105
+ task :closure_compiler do
106
+ chdir CLOSURE_COMPILER_DIR do
107
+ puts "Running ant"
108
+ puts %x{ant jar}
109
+ end
110
+ end
111
+ end
112
+
49
113
namespace :build do
50
114
51
115
directory "generated/javascript"
@@ -79,6 +143,24 @@ namespace :build do
79
143
end
80
144
end
81
145
146
+ file "src/deps.js" => sourcefiles do |file |
147
+ %x{/bin/env #{ CLOSURE_DEPSWRITER } --root_with_prefix="src/javascript #{ CLOSURE_DOTS } /src/javascript" > #{ file } }
148
+ end
149
+
150
+ file "dependency.MF" => sourcefiles do |file |
151
+ sh %{/bin/env java -jar #{ CLOSURE_JAR } #{ sourcefiles . map { |src | "--js #{ src } " } . join ( " " ) } --output_manifest #{ file } }
152
+ end
153
+
154
+ file 'jsTestDriver.conf' => [ 'jsTestDriver.yaml' , 'dependency.MF' ] do |cfg |
155
+ require 'yaml'
156
+ jstd_conf = YAML ::load ( File ::read ( 'jsTestDriver.yaml' ) )
157
+ deps = File ::read ( "dependency.MF" ) . lines . map { |line | line . chomp }
158
+ jstd_conf [ 'load' ] += deps
159
+ File ::open ( cfg . name , 'w' ) do |file |
160
+ file . write ( YAML ::dump ( jstd_conf ) )
161
+ end
162
+ end
163
+
82
164
task :clobber_header_comments do
83
165
rm_f 'tmp/header-comments.js'
84
166
end
@@ -99,22 +181,6 @@ namespace :build do
99
181
desc "Build Ninjascript & assets"
100
182
task :project => %w{ stylesheets:generate clobber_header_comments generated/javascript/ninjascript.js generated/javascript/ns.min.js }
101
183
102
- task :sprockets => %w{ stylesheets:generate generated/javascript constants } do
103
- raise "This is an old task, scheduled for deletion"
104
- require 'sprockets'
105
-
106
- sec = Sprockets ::Secretary . new (
107
- :root => '.' ,
108
- :asset_root => ASSET_ROOT ,
109
- :load_path => %w[ src/javascript vendor auto-constants ] ,
110
- :source_files => %w[ src/javascript/main.js ]
111
- )
112
-
113
- puts "Saving concatentated javascript"
114
- sec . concatenation . save_to ( "#{ ASSET_ROOT } /javascript/ninjascript.js" )
115
- sec . install_assets
116
- end
117
-
118
184
require 'rake/packagetask'
119
185
Rake ::PackageTask . new ( 'ninjascript' , PACKAGE_CONFIG [ "VERSION" ] ) do |t |
120
186
t . need_zip = true
0 commit comments