forked from brianleroux/xui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build
executable file
·36 lines (30 loc) · 957 Bytes
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env ruby
require 'YAML'
# TODO: print out build command line if no args provided.
# usage: ./build profile=whatever --minify
# man I sure love Windows! --alunny
is_windows = Dir.getwd[0,1] != "/"
echo_dot = is_windows ? "echo." : "echo"
mkdir = is_windows ? "mkdir" : "mkdir -p"
profile_matcher = /^profile=(.*)$/
profile_path = "util/profiles/"
# defaults
profile = "core"
minify = false
$*.each do |arg|
minify = true if arg == "--minify"
profile = arg.match(profile_matcher)[1] if arg.match(profile_matcher)
end
hash = YAML.load_file "#{ profile_path }#{ profile }.js"
# clear previous file
`#{ mkdir } lib`
`#{ echo_dot } > #{ hash["out"] }`
hash["include"].each do |include|
# a bit of overhead since not all files end in a newline
`cat #{ include }.js >> #{ hash["out"] }`
`#{ echo_dot } >> #{ hash["out"] }`
end
if minify
`java -jar util/compiler.jar --js=#{ hash["out"] } \
--js_output_file=#{ hash["out"] }.min`
end