forked from cappuccino/cappuccino
-
Notifications
You must be signed in to change notification settings - Fork 5
/
common.rb
83 lines (61 loc) · 2.26 KB
/
common.rb
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
require 'rake'
# Read in and set up development environment variables.
if !ENV['BUILD_DIR']
# Global Cappuccino build directory
if ENV['CAPP_BUILD']
ENV['BUILD_DIR'] = ENV['CAPP_BUILD']
# Maintain backwards compatibility with steam.
elsif ENV['STEAM_BUILD']
ENV['BUILD_DIR'] = ENV['STEAM_BUILD']
# Just build here.
else
ENV['BUILD_DIR'] = File.join(File.dirname(__FILE__), 'Build')
end
end
if !ENV['CONFIG']
ENV['CONFIG'] = 'Release'
end
$CONFIGURATION = ENV['CONFIG']
$BUILD_DIR = File.expand_path(ENV['BUILD_DIR'])
$PRODUCT_DIR = File.join($BUILD_DIR, $CONFIGURATION)
$ENVIRONMENT_DIR = File.join($BUILD_DIR, $CONFIGURATION, 'env')
$ENVIRONMENT_BIN_DIR = File.join($ENVIRONMENT_DIR, 'bin')
$ENVIRONMENT_LIB_DIR = File.join($ENVIRONMENT_DIR, 'lib')
$ENVIRONMENT_FRAMEWORKS_DIR = File.join($ENVIRONMENT_LIB_DIR, 'Frameworks')
$HOME_DIR = File.expand_path(File.dirname(__FILE__))
$LICENSE_FILE = File.expand_path(File.join(File.dirname(__FILE__), 'LICENSE'))
if !(defined? COMMON_DO_ONCE)
COMMON_DO_ONCE = true
$LOAD_PATH << File.join($HOME_DIR, 'Rake')
ENV['PATH'] = $ENVIRONMENT_BIN_DIR + ':' + ENV['PATH']
end
require 'objective-j'
$env = ""
$env += %{CONFIG="#{ENV['CONFIG']}" } if ENV['CONFIG']
$env += %{BUILD_DIR="#{ENV['BUILD_DIR']}" } if ENV['BUILD_DIR']
def subrake(directories)
directories.each do |directory|
system %{cd #{directory} && #{$env} #{$0}}
end
end
# Shared Resrouces in env
$JSJAR_PATH = File.expand_path(File.join($HOME_DIR, 'Tools/Utilities/js.jar'))
$ENVIRONMENT_JS = File.join($ENVIRONMENT_LIB_DIR, 'js.jar')
file_d $ENVIRONMENT_JS do
cp($JSJAR_PATH, $ENVIRONMENT_JS)
end
def js2java(inputfile, className, debug)
debugString = '-nosource -debug' if debug
IO.popen("java -classpath #{$JSJAR_PATH}:. #{debugString} org.mozilla.javascript.tools.jsc.Main -o #{className} #{inputfile}") do |shrinksafe|
puts shrinksafe.read
end
end
def cat(files, outfile)
File.open(outfile, "w") do |concated|
files.each do |file|
concated.write IO.read(file)
end
end
end
task :build => [$ENVIRONMENT_JS]
task :default => [:build]