-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
152 lines (114 loc) · 3.86 KB
/
Rakefile
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# ===========================================================================
# Project: Tiki Torch
# Copyright: ©2009 Apple Inc.
# ===========================================================================
require 'extlib'
require 'fileutils'
PROJECT_ROOT = File.expand_path(File.dirname(__FILE__))
ABBOT = File.expand_path(PROJECT_ROOT / '..' / 'abbot')
########################################################
## PROJECT UPDATE/MAINTENANCE
##
FRAMEWORKS = {
'tiki' => {
:visitor => 'git://github.com/sproutit/tiki.git',
:owner => '[email protected]:sproutit/tiki.git'
},
'core_test' => {
:visitor => 'git://github.com/sproutit/core_test.git',
:owner => '[email protected]:sproutit/core_test.git'
},
'sproutcore' => {
:visitor => 'git://github.com/sproutit/sproutcore.git',
:owner => '[email protected]:sproutit/sproutcore.git'
}
}
desc "Checkout any required frameworks"
task :init, [:mode] do |t, args|
args.with_defaults(:mode => :visitor)
mode = args.mode.to_sym
require 'fileutils'
FileUtils.mkdir_p(PROJECT_ROOT / 'frameworks')
FRAMEWORKS.each do |name, clone_url|
clone_url = clone_url[mode]
throw "mode=#{mode} is not supported for #{name}" if clone_url.nil?
puts "init: #{name} => #{clone_url}"
path = PROJECT_ROOT / 'frameworks' / name
FileUtils.mkdir_p(path) if !File.exist?(path)
throw "#{"frameworks" / name} cannot be a file" if !File.directory?(path)
# clone if needed...
if !File.exist?(path / '.git')
puts ">> git clone #{clone_url} #{path}"
puts `git clone #{clone_url} #{path}`
end
end
end
desc "update all git repositories"
task :pull do
`cd #{PROJECT_ROOT}; git pull`
FRAMEWORKS.each do |name, clone_url|
path = PROJECT_ROOT / 'frameworks' / name
`cd #{path}; git pull`
end
end
desc "show status of all git repositories"
task :status do
puts "#{PROJECT_ROOT}:"
puts `cd #{PROJECT_ROOT}; git status`
puts "\n"
FRAMEWORKS.each do |name, clone_url|
path = PROJECT_ROOT / 'frameworks' / name
puts "#{path}:"
puts `cd #{path}; git status`
puts "\n"
end
end
########################################################
## BUILDING
##
def build_tiki(target_name, output_filename, mode)
if ABBOT
sc_build = ABBOT / 'bin' / 'sc-build'
sc_build_number = ABBOT / 'bin' / 'sc-build-number'
else
sc_build = 'sc-build'
sc_build_number = 'sc-build-number'
end
if (mode.to_sym != :production)
output_filename = "#{output_filename}-#{mode}"
end
puts `cd #{PROJECT_ROOT}; #{sc_build} #{target_name} -rcv --environment=#{mode}`
build_number = `cd #{PROJECT_ROOT}; #{sc_build_number} #{target_name} --environment=#{mode}`
parts = target_name.to_s.split('/')
src_root = File.join(PROJECT_ROOT, 'tmp', mode.to_s, 'build', 'static', parts, 'en', build_number)
dst_root = PROJECT_ROOT / 'tmp' / 'tiki'
src_path = src_root / 'javascript-packed.js'
dst_path = dst_root / "#{output_filename}.js"
FileUtils.mkdir_p(dst_root)
FileUtils.cp(src_path, dst_path)
end
namespace :build do
namespace :tiki do
desc "builds all known versions of tiki"
task :all => ['build:tiki:system', 'build:tiki:system_debug', 'build:tiki:core', 'build:tiki:core_debug']
task :clean do
`rm -r #{PROJECT_ROOT/'tmp'/'tiki'}`
end
desc "builds a version of tiki for release."
task :system, [:mode] do |t, args|
args.with_defaults(:mode => :production)
build_tiki('tiki/system', "tiki", args.mode)
end
task :system_debug do
build_tiki('tiki/system', 'tiki', :debug)
end
desc "builds a version of tiki with only the core loader"
task :core, [:mode] do |t, args|
args.with_defaults(:mode => :production)
build_tiki('tiki', "tiki-core", args.mode)
end
task :core_debug do
build_tiki('tiki', 'tiki-core', :debug)
end
end
end