-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
186 lines (155 loc) · 3.75 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
require 'pp'
class Find
def initialize(block)
@include = []
@exclude = []
instance_eval &block
end
def include(files)
files = [files] if not files.is_a? Array
@include += files
end
def exclude(files)
files = [files] if not files.is_a? Array
@exclude += files
end
def find
files = []
@include.each do |path|
if path =~ /\.\.\.\//
(0...10).each do |i|
files += Dir.glob(path.sub '.../', ('*/'*i))
end
elsif path =~ /\*/
files += Dir.glob path
else
files += [path]
end
end
files.map! do |file|
if @exclude.map do |exclude|
if file[0...exclude.size] == exclude then true
else false
end
end.include? true
nil
else file
end
end
files.compact
end
end
def find(&block)
Find.new(block).find
end
def cs(out, flags=[], files=[], &block)
if block != nil
files += find &block
end
deps = files
files = files.map { |x| x.gsub '/', '\\' }
target =
if out =~ /\.dll$/ then 'library'
elsif out =~ /\.win\.exe$/ then 'winexe'
else 'exe'
end
references = files.map do |file|
if file =~ /\.dll$/ then file
else nil
end
end.compact
files = files.map do |file|
if references.include? file then nil
else file
end
end.compact
references.map! { |file| "/reference:#{file}" }
deps.reject! { |file| file.index('System.') == 0 }
file out => deps do
sh 'csc', "/out:#{out}", "/target:#{target}", *references, *flags, *files
end
Rake::Task[out].invoke
end
def boo(out, flags=[], files=[], &block)
if block != nil
files += find &block
end
deps = files
target =
if out =~ /\.dll$/ then 'library'
elsif out =~ /\.win\.exe$/ then 'winexe'
else 'exe'
end
references = files.map do |file|
if file =~ /\.dll$/ then file
else nil
end
end.compact
files = files.map do |file|
if references.include? file then nil
else file
end
end.compact
references.map! { |file| "-reference:#{file}" }
deps.reject! { |file| file.index('System.') == 0 }
file out => deps do
sh 'booc', "-o:#{out}", "-target:#{target}", *references, *flags, *files
end
Rake::Task[out].invoke
end
task :default => [:dotpack, :tests]
task :obj do
Dir::mkdir 'Obj' if not FileTest::directory? 'Obj'
Dir::mkdir 'Obj/Tests' if not FileTest::directory? 'Obj/Tests'
end
task :cecil => [:obj] do
cs 'Obj/Mono.Cecil.dll', ['-keyfile:Mono.Cecil/mono.snk'] do
include 'Mono.Cecil/.../*.cs'
end
end
task :prelinker => [:obj, :cecil] do
boo 'Obj/Prelinker.exe' do
include 'Obj/Mono.Cecil.dll'
include 'Prelinker/.../*.boo'
end
end
task :dotpack => [:obj, :cecil, :prelinker] do
cs 'Obj/LZMA.dll' do
include '7zip/.../*.cs'
end
csflags = ['/o', '/nowin32manifest', '/win32res:Small.res', '/warn:4']
cs 'Obj/Stage1.Deflate.exe', csflags do
include 'Stages/Stage1.Executable.Deflate.cs'
end
cs 'Obj/Stage1.Deflate.Params.exe', csflags + ['/define:WITHARGS'] do
include 'Stages/Stage1.Executable.Deflate.cs'
end
csflags = ['/o', '/nowin32manifest', '/win32res:Empty.res', '/warn:4']
cs 'Obj/Stage2.Deflate.dll', csflags do
include 'Stages/Stage2.Deflate.cs'
end
cs 'Obj/Stage2.LZMA.dll', csflags do
include 'Stages/Stage2.LZMA.cs'
end
sldir = 'C:\Program Files (x86)\Microsoft Silverlight\4.0.50303.0'
sllibs = %w{mscorlib system System.Windows}
sllibs.map! {|x| '/r:' + sldir + '\\' + x + '.dll' }
csflags += ['/nostdlib+', '/noconfig'] + sllibs
cs 'Obj/Stage1.Silverlight.LZMA.dll', csflags do
include 'Stages/Stage1.Silverlight.LZMA.cs'
end
boo 'Obj/DotPack.exe' do
include 'Obj/LZMA.dll'
include 'Obj/Mono.Cecil.dll'
include 'Ionic.Zip.dll'
include '.../*.boo'
exclude 'Prelinker'
exclude 'Tests'
exclude 'Stages'
end
end
task :tests => [:obj] do
boo 'Obj/Tests/HelloWorld.exe' do
include 'Tests/HelloWorld.boo'
end
end