rakish 0.9.01.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/RakishOverview.html +8 -0
- data/doc/SimpleJavaSamples.txt +448 -0
- data/doc/ToDoItems.txt +18 -0
- data/doc/UserGuide +15 -0
- data/doc/WhyIDidIt.txt +96 -0
- data/lib/rakish/ArchiveBuilder.rb +216 -0
- data/lib/rakish/BuildConfig.rb +254 -0
- data/lib/rakish/CppProjects.rb +696 -0
- data/lib/rakish/IntellijConfig.rb +123 -0
- data/lib/rakish/JavaProjects.rb +504 -0
- data/lib/rakish/PlatformTools.rb +299 -0
- data/lib/rakish/Rakish.rb +2049 -0
- data/lib/rakish/RakishProject.rb +539 -0
- data/lib/rakish/RubydocModule.rb +58 -0
- data/lib/rakish/TomcatProjects.rb +45 -0
- data/lib/rakish/VcprojBuilder.rb +256 -0
- data/lib/rakish/WindowsCppTools.rb +897 -0
- data/lib/rakish/ZipBuilder.rb +82 -0
- data/lib/rakish.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +94 -0
- metadata.gz.sig +0 -0
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
myPath = File.dirname(File.expand_path(__FILE__));
|
|
2
|
+
require "#{myPath}/RakishProject.rb"
|
|
3
|
+
|
|
4
|
+
module Rakish
|
|
5
|
+
|
|
6
|
+
# :nodoc: legacy only looked at in the
|
|
7
|
+
MAKEDIR = File.dirname(File.expand_path(__FILE__)); # :nodoc:
|
|
8
|
+
|
|
9
|
+
# C++ build module
|
|
10
|
+
# Not really part of public distributioin - too littered with local stuff
|
|
11
|
+
# specific to my main builds This needs to be converted to work in a more configurable way
|
|
12
|
+
# for multiple platforms
|
|
13
|
+
module CTools
|
|
14
|
+
include Rakish::Logger
|
|
15
|
+
include Rakish::Util
|
|
16
|
+
|
|
17
|
+
VALID_PLATFORMS = {
|
|
18
|
+
:Win32 => {
|
|
19
|
+
:module => "#{Rakish::MAKEDIR}/WindowsCppTools.rb",
|
|
20
|
+
},
|
|
21
|
+
:Win64 => {
|
|
22
|
+
:module => "#{Rakish::MAKEDIR}/WindowsCppTools.rb",
|
|
23
|
+
},
|
|
24
|
+
:iOS => {
|
|
25
|
+
:module => "#{Rakish::MAKEDIR}/IOSCTools.rb",
|
|
26
|
+
},
|
|
27
|
+
:Linux32 => {
|
|
28
|
+
:module => "#{Rakish::MAKEDIR}/GCCCTools.rb",
|
|
29
|
+
},
|
|
30
|
+
:Linux64 => {
|
|
31
|
+
:module => "#{Rakish::MAKEDIR}/GCCCTools.rb",
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
# parses and validates an unknown string configuration name
|
|
36
|
+
# of the format [TargetPlatform]-[Compiler]-(items specific to compiler type)
|
|
37
|
+
# and loads if possible an instance of a set of configured "CTools"
|
|
38
|
+
# for the specified "nativeConfigName" configuration.
|
|
39
|
+
def self.loadConfiguredTools(strCfg)
|
|
40
|
+
|
|
41
|
+
splitcfgs = strCfg.split('-');
|
|
42
|
+
platform = VALID_PLATFORMS[splitcfgs[0].to_sym];
|
|
43
|
+
|
|
44
|
+
unless platform
|
|
45
|
+
raise InvalidConfigError.new(strCfg, "unrecognized platform \"#{splitcfgs[0]}\"");
|
|
46
|
+
end
|
|
47
|
+
factory = LoadableModule.load(platform[:module]);
|
|
48
|
+
factory.getConfiguredTools(splitcfgs,strCfg);
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def writeLinkref(cfg,baseName,targetName)
|
|
53
|
+
|
|
54
|
+
defpath = "#{cfg.nativeLibDir}/#{baseName}-#{cfg.nativeConfigName}.linkref"
|
|
55
|
+
reltarget = getRelativePath(targetName,cfg.nativeLibDir);
|
|
56
|
+
File.open(defpath,'w') do |f|
|
|
57
|
+
f.puts("libs = [\'#{reltarget}\']")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# real bodge for now need to clean this up somehow.
|
|
62
|
+
def loadLinkref(libdir,cfg,baseName)
|
|
63
|
+
cd libdir, :verbose=>false do
|
|
64
|
+
libdef = File.expand_path("#{baseName}-#{cfg}.linkref");
|
|
65
|
+
begin
|
|
66
|
+
libpaths=nil
|
|
67
|
+
libs=nil
|
|
68
|
+
eval(File.new(libdef).read)
|
|
69
|
+
if(libpaths)
|
|
70
|
+
libpaths.collect! do |lp|
|
|
71
|
+
File.expand_path(lp)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
if(libs)
|
|
75
|
+
libs.collect! do |lp|
|
|
76
|
+
File.expand_path(lp)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
return({libpaths: libpaths, libs: libs});
|
|
80
|
+
rescue => e
|
|
81
|
+
log.debug("failed to load #{libdef} #{e}");
|
|
82
|
+
end
|
|
83
|
+
{}
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# given a list of dependencies will write out a '.raked' format dependencies file
|
|
88
|
+
# for the target task
|
|
89
|
+
def updateDependsFile(task, outName, dependencies)
|
|
90
|
+
|
|
91
|
+
srcfile = task.source
|
|
92
|
+
tempfile = "#{outName}.temp";
|
|
93
|
+
|
|
94
|
+
File.open(tempfile,'w') do |out|
|
|
95
|
+
if(dependencies.size > 0)
|
|
96
|
+
out.puts "t = Rake::Task[\'#{task.name}\'];"
|
|
97
|
+
out.puts 'if(t)'
|
|
98
|
+
out.puts ' t.enhance ['
|
|
99
|
+
out.puts " \'#{srcfile}\',"
|
|
100
|
+
dependencies.each do |f|
|
|
101
|
+
out.puts " \'#{f}\',"
|
|
102
|
+
end
|
|
103
|
+
out.puts ' ]'
|
|
104
|
+
out.puts 'end'
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# only touch file if new file differs from old one
|
|
109
|
+
if(textFilesDiffer(outName,tempfile))
|
|
110
|
+
# @#$#@$#@ messed up. set time of new file ahead by one second.
|
|
111
|
+
# seems rake time resolution is low enough that the comparison often says
|
|
112
|
+
# times are equal between depends files and depends.rb.
|
|
113
|
+
mv(tempfile, outName, :force=>true);
|
|
114
|
+
time = Time.at(Time.new.to_f + 1.0);
|
|
115
|
+
File.utime(time,time,outName);
|
|
116
|
+
else
|
|
117
|
+
rm(tempfile, :force=>true);
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## Overidables for specific toolsets to use or supply
|
|
123
|
+
|
|
124
|
+
# override to make sure options such as cppDefines, system library paths,
|
|
125
|
+
# system include paths and the like are enforced as needed for this toolset
|
|
126
|
+
def ensureConfigOptions(cfg)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def systemIncludePaths
|
|
130
|
+
[]
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
@@doNothingAction_ = lambda do |t|
|
|
134
|
+
log.debug("attempting to compile #{t.source} into\n #{t}\n in #{File.expand_path('.')}");
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# return the approriate compile action to creat an object files from
|
|
138
|
+
# a source file with the specified suffix.
|
|
139
|
+
# nil if not action is available in this toolset.
|
|
140
|
+
def getCompileActionForSuffix(suff)
|
|
141
|
+
@@doNothingAction_
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def createCompileTask(source,obj,cfg)
|
|
145
|
+
|
|
146
|
+
action = getCompileActionForSuffix(File.extname(source).downcase);
|
|
147
|
+
unless action
|
|
148
|
+
log.debug("unrecognized source file type \"#{source.pathmap('%f')}\"");
|
|
149
|
+
return(nil);
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
if(Rake::Task.task_defined? obj)
|
|
153
|
+
log.debug("Warning: task already defined for #{obj}")
|
|
154
|
+
return(nil);
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
tsk = Rake::FileTask.define_task obj
|
|
158
|
+
tsk.enhance(tsk.sources=[source], &action)
|
|
159
|
+
tsk.config = cfg;
|
|
160
|
+
tsk;
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def createCompileTasks(files,cfg)
|
|
164
|
+
# format object files name
|
|
165
|
+
|
|
166
|
+
mapstr = "#{cfg.nativeObjectPath()}/%n#{OBJEXT()}";
|
|
167
|
+
|
|
168
|
+
objs=FileList[];
|
|
169
|
+
files.each do |source|
|
|
170
|
+
obj = source.pathmap(mapstr);
|
|
171
|
+
task = createCompileTask(source,obj,cfg);
|
|
172
|
+
objs << obj if task; # will be the same as task.name
|
|
173
|
+
end
|
|
174
|
+
objs
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def initCompileTask(cfg)
|
|
178
|
+
cfg.project.addCleanFiles("#{cfg.nativeObjectPath()}/*#{OBJEXT()}");
|
|
179
|
+
Rake::Task.define_task :compile => [:includes,
|
|
180
|
+
cfg.nativeObjectPath(),
|
|
181
|
+
:depends]
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def initDependsTask(cfg) # :nodoc:
|
|
185
|
+
|
|
186
|
+
# create dependencies file by concatenating all .raked files
|
|
187
|
+
tsk = file "#{cfg.nativeObjectPath()}/depends.rb" => [ :includes, cfg.nativeObjectPath() ] do |t|
|
|
188
|
+
cd(cfg.nativeObjectPath(),:verbose=>false) do
|
|
189
|
+
File.open('depends.rb','w') do |out|
|
|
190
|
+
out.puts("# puts \"loading #{t.name}\"");
|
|
191
|
+
end
|
|
192
|
+
t.prerequisites.each do |dep|
|
|
193
|
+
next unless (dep.pathmap('%x') == '.raked')
|
|
194
|
+
system "cat \'#{dep}\' >> depends.rb"
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
# build and import the consolidated dependencies file
|
|
199
|
+
task :depends => [ "#{cfg.nativeObjectPath()}/depends.rb" ] do |t|
|
|
200
|
+
load("#{cfg.nativeObjectPath()}/depends.rb")
|
|
201
|
+
end
|
|
202
|
+
task :cleandepends do
|
|
203
|
+
depname = "#{cfg.nativeObjectPath()}/depends.rb";
|
|
204
|
+
deleteFiles("#{cfg.nativeObjectPath()}/*.raked");
|
|
205
|
+
|
|
206
|
+
# if there is no task defined for the 'raked' file then create a dummy
|
|
207
|
+
# that dos nothing so the prerequisites resolve - this is the case where the
|
|
208
|
+
# actual dependencies are built by compiling.
|
|
209
|
+
|
|
210
|
+
tsk.prerequisites.each do |dep|
|
|
211
|
+
next unless (dep.pathmap('%x') == '.raked')
|
|
212
|
+
next if(Rake::Task::task_defined?(dep))
|
|
213
|
+
file dep # a do nothing task
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# same here create a dummy file with nothing in it
|
|
217
|
+
if File.exist? depname
|
|
218
|
+
File.open(depname,'w') do |out|
|
|
219
|
+
out.puts("");
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
tsk
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def createLinkTask(objs,cfg)
|
|
227
|
+
log.debug("creating link task");
|
|
228
|
+
false
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
module CppProjectConfig
|
|
234
|
+
|
|
235
|
+
attr_reader :ctools
|
|
236
|
+
attr_reader :cppDefines
|
|
237
|
+
attr_reader :targetType
|
|
238
|
+
attr_reader :thirdPartyLibs
|
|
239
|
+
|
|
240
|
+
# attr_reader :cflags had this in old one for added VC flags.
|
|
241
|
+
|
|
242
|
+
addInitBlock do |pnt,opts|
|
|
243
|
+
@addedIncludePaths_=[]
|
|
244
|
+
@cppDefines={}
|
|
245
|
+
@incPaths_=nil;
|
|
246
|
+
|
|
247
|
+
if(pnt != nil)
|
|
248
|
+
@targetType = pnt.targetType;
|
|
249
|
+
@cppDefines.merge!(pnt.cppDefines);
|
|
250
|
+
@ctools = pnt.ctools;
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def INCDIR
|
|
255
|
+
@INCDIR||=getAnyAbove(:INCDIR)||"#{buildDir()}/include";
|
|
256
|
+
end
|
|
257
|
+
def binDir
|
|
258
|
+
@binDir||=getAnyAbove(:binDir)||"#{buildDir()}/bin";
|
|
259
|
+
end
|
|
260
|
+
def nativeLibDir
|
|
261
|
+
@nativeLibDir||=getAnyAbove(:nativeLibDir)||"#{buildDir()}/lib";
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def vcprojDir
|
|
265
|
+
@vcprojDir||=getAnyAbove(:vcprojDir)||"#{buildDir()}/vcproj";
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# add include paths in order to the current list of include paths.
|
|
269
|
+
def addIncludePaths(*defs)
|
|
270
|
+
defs.flatten!()
|
|
271
|
+
defs.each do |ip|
|
|
272
|
+
@addedIncludePaths_ << File.expand_path(ip);
|
|
273
|
+
end
|
|
274
|
+
@incPaths_=nil
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def addedIncludePaths
|
|
278
|
+
@addedIncludePaths_
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# define or re-define a preprocessor value
|
|
282
|
+
def cppDefine(*args)
|
|
283
|
+
args.flatten!()
|
|
284
|
+
args.each do |c|
|
|
285
|
+
spl = c.split('=',2);
|
|
286
|
+
# no value is nil, XXX= will have a value of empty string ""
|
|
287
|
+
@cppDefines[spl[0]] = spl[1];
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# test if name is defined or not.
|
|
292
|
+
def cppDefined(name)
|
|
293
|
+
@cppDefines.has_key?(name);
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
# only define the value if it is not already defined
|
|
297
|
+
def cppDefineIfNot(*args)
|
|
298
|
+
args.flatten!()
|
|
299
|
+
args.each do |c|
|
|
300
|
+
spl = c.split('=',2);
|
|
301
|
+
# no value is nil, XXX= will have a value of empty string ""
|
|
302
|
+
@cppDefines[spl[0]] = spl[1] unless @cppDefines.has_key?(spl[0]);
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
# undefine the values in the arguments
|
|
307
|
+
def cppUndefine(*args)
|
|
308
|
+
args.flatten!()
|
|
309
|
+
args.each do |c|
|
|
310
|
+
@cppDefines.delete(c)
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def addSourceFiles(*args)
|
|
315
|
+
opts = (Hash === args.last) ? args.pop : {}
|
|
316
|
+
@cppSourceFiles ||= FileSet.new;
|
|
317
|
+
@cppSourceFiles.include(args);
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
#returns include path "set" with parent's entries after this ones entries
|
|
321
|
+
# followed by the system include paths from the currently configured tools
|
|
322
|
+
def includePaths()
|
|
323
|
+
unless @incPaths_
|
|
324
|
+
s=FileSet.new;
|
|
325
|
+
ips=[];
|
|
326
|
+
pnt=self
|
|
327
|
+
s.add(project.projectDir); # covers for implicit './'
|
|
328
|
+
begin
|
|
329
|
+
pnt.addedIncludePaths.each do |ip|
|
|
330
|
+
ips << ip if s.add?(ip)
|
|
331
|
+
end
|
|
332
|
+
pnt = pnt.parent
|
|
333
|
+
end until !pnt
|
|
334
|
+
if(ctools)
|
|
335
|
+
ctools.systemIncludePaths.each do |ip|
|
|
336
|
+
ips << ip if s.add?(ip)
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
@incPaths_ = ips;
|
|
340
|
+
end
|
|
341
|
+
@incPaths_
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
def addThirdPartyLibs(*args)
|
|
345
|
+
@thirdPartyLibs||=[]
|
|
346
|
+
@thirdPartyLibs << args
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
module CppProjectModule
|
|
352
|
+
include CppProjectConfig
|
|
353
|
+
|
|
354
|
+
addInitBlock do
|
|
355
|
+
t = task :preBuild do
|
|
356
|
+
doCppPreBuild
|
|
357
|
+
end
|
|
358
|
+
@cppCompileTaskInitialized = false;
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
VCProjBuildAction_ = lambda do |t|
|
|
362
|
+
require "#{Rakish::MAKEDIR}/VcprojBuilder.rb"
|
|
363
|
+
VcprojBuilder.onVcprojTask(t.config);
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
VCProjCleanAction_ = lambda do |t|
|
|
367
|
+
require "#{Rakish::MAKEDIR}/VcprojBuilder.rb"
|
|
368
|
+
VcprojBuilder.onVcprojCleanTask(t.config);
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
LinkIncludeAction_ = lambda do |t|
|
|
372
|
+
config = t.config;
|
|
373
|
+
# if(config.verbose?)
|
|
374
|
+
puts "generating #{t.name} from #{t.source}"
|
|
375
|
+
# end
|
|
376
|
+
|
|
377
|
+
destfile = t.name;
|
|
378
|
+
srcpath = config.getRelativePath(t.source,File.dirname(t.name));
|
|
379
|
+
fname = File.basename(t.name);
|
|
380
|
+
File.open(destfile,'w') do |file|
|
|
381
|
+
file.puts("/* #{fname} - generated file - do not alter */");
|
|
382
|
+
file.puts("#include \"#{srcpath}\"");
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
# called after initializers on all projects and before rake
|
|
387
|
+
# starts executing tasks
|
|
388
|
+
|
|
389
|
+
def doCppPreBuild()
|
|
390
|
+
addIncludePaths( [ nativeObjectPath(),INCDIR() ] );
|
|
391
|
+
@cppBuildConfig = resolveConfiguration(nativeConfigName());
|
|
392
|
+
resolveConfiguredTasks();
|
|
393
|
+
if(@projectId)
|
|
394
|
+
ensureDirectoryTask(vcprojDir);
|
|
395
|
+
tsk = task :vcproj=>[vcprojDir], &VCProjBuildAction_;
|
|
396
|
+
tsk.config = self;
|
|
397
|
+
export(:vcproj);
|
|
398
|
+
|
|
399
|
+
tsk = task :vcprojclean, &VCProjCleanAction_;
|
|
400
|
+
tsk.config = self;
|
|
401
|
+
export(:vcprojclean);
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
def resolveConfiguredTasks()
|
|
406
|
+
|
|
407
|
+
cfg = @cppBuildConfig
|
|
408
|
+
tools = cfg.ctools;
|
|
409
|
+
|
|
410
|
+
objs = tools.createCompileTasks(getSourceFiles(),cfg);
|
|
411
|
+
|
|
412
|
+
unless tsk = Rake.application.lookup("#{@myNamespace}:compile") && @cppCompileTaskInitialized
|
|
413
|
+
cppCompileTaskInitialized = true;
|
|
414
|
+
tsk = tools.initCompileTask(self);
|
|
415
|
+
end
|
|
416
|
+
tsk.enhance(objs)
|
|
417
|
+
|
|
418
|
+
unless tsk = Rake.application.lookup("#{@nativeObjDir}/depends.rb")
|
|
419
|
+
tsk = tools.initDependsTask(self)
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
raked=[]
|
|
423
|
+
objs.each do |obj|
|
|
424
|
+
obj = obj.ext('.raked');
|
|
425
|
+
raked << obj if File.exist?(obj)
|
|
426
|
+
end
|
|
427
|
+
tsk.enhance(raked);
|
|
428
|
+
|
|
429
|
+
@objs = objs;
|
|
430
|
+
ensureDirectoryTask(nativeObjectPath());
|
|
431
|
+
|
|
432
|
+
## link tasks
|
|
433
|
+
tsk = tools.createLinkTask(objs,cfg);
|
|
434
|
+
if(tsk)
|
|
435
|
+
ensureDirectoryTask(cfg.nativeLibDir);
|
|
436
|
+
ensureDirectoryTask(cfg.binDir);
|
|
437
|
+
|
|
438
|
+
task :build => [ :compile, cfg.nativeLibDir, cfg.binDir, tsk ].flatten
|
|
439
|
+
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
# add tasks to ':includes' to place links to or copy source files to
|
|
445
|
+
# the specified 'stub' directory.
|
|
446
|
+
#
|
|
447
|
+
# Also adds removal of output files or links to task ':cleanincludes'
|
|
448
|
+
#
|
|
449
|
+
# <b>named args:</b>
|
|
450
|
+
# :destdir => destination directory to place output files, defaults to INCDIR/myPackage
|
|
451
|
+
#
|
|
452
|
+
def addPublicIncludes(*args)
|
|
453
|
+
|
|
454
|
+
opts = (Hash === args.last) ? args.pop : {}
|
|
455
|
+
|
|
456
|
+
files = FileSet.new(args);
|
|
457
|
+
|
|
458
|
+
unless(destdir = opts[:destdir])
|
|
459
|
+
destdir = myPackage;
|
|
460
|
+
end
|
|
461
|
+
destdir = File.join(INCDIR(),destdir || '');
|
|
462
|
+
ensureDirectoryTask(destdir);
|
|
463
|
+
flist = createCopyTasks(destdir,files,:config => self,&LinkIncludeAction_)
|
|
464
|
+
task :includes => flist
|
|
465
|
+
task :cleanincludes do |t|
|
|
466
|
+
deleteFiles(flist)
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
# asd a project local include directory so files will be listed
|
|
472
|
+
def addLocalIncludeDir(idir)
|
|
473
|
+
@cppLocalIncludeDirs_ ||= [];
|
|
474
|
+
@cppLocalIncludeDirs_ << idir;
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
# get all include files for generated projects
|
|
478
|
+
def getIncludeFiles()
|
|
479
|
+
unless @allIncludeFiles_;
|
|
480
|
+
files = FileSet.new();
|
|
481
|
+
(@cppLocalIncludeDirs_||=['.']).each do |dir|
|
|
482
|
+
dir = "#{projectDir}/#{dir}";
|
|
483
|
+
files.include( "#{dir}/*.h");
|
|
484
|
+
files.include( "#{dir}/*.hpp");
|
|
485
|
+
files.include( "#{dir}/*.inl");
|
|
486
|
+
files.include( "#{dir}/*.i");
|
|
487
|
+
@cppAllIncludeFiles_ = files;
|
|
488
|
+
end
|
|
489
|
+
end
|
|
490
|
+
@cppAllIncludeFiles_
|
|
491
|
+
end
|
|
492
|
+
|
|
493
|
+
def getSourceFiles()
|
|
494
|
+
@cppSourceFiles||=FileSet.new
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
# define a configurator to load a configuration for a specific ( string )
|
|
499
|
+
# configruation
|
|
500
|
+
|
|
501
|
+
def setupCppConfig(args={}, &b)
|
|
502
|
+
@targetType = args[:targetType];
|
|
503
|
+
@cppConfigurator_ = b;
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
class TargetConfig < BuildConfig
|
|
507
|
+
include CppProjectConfig
|
|
508
|
+
|
|
509
|
+
attr_reader :configName
|
|
510
|
+
attr_accessor :targetBaseName
|
|
511
|
+
attr_reader :libpaths
|
|
512
|
+
attr_reader :libs
|
|
513
|
+
attr_accessor :targetName
|
|
514
|
+
|
|
515
|
+
def initialize(pnt, cfgName, tools)
|
|
516
|
+
super(pnt);
|
|
517
|
+
@libpaths=[]; # ???
|
|
518
|
+
@libs=[];
|
|
519
|
+
@configName = cfgName;
|
|
520
|
+
@ctools = tools;
|
|
521
|
+
@targetBaseName = pnt.moduleName;
|
|
522
|
+
tools.ensureConfigOptions(self);
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
def addLibPaths(*lpaths)
|
|
526
|
+
@libpaths << lpaths
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
def addLibs(*l)
|
|
530
|
+
l.flatten.each do |lib|
|
|
531
|
+
lib = File.expand_path(lib) if(lib =~ /\.\//);
|
|
532
|
+
@libs << lib
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
def targetName
|
|
537
|
+
@targetName||="#{targetBaseName}-#{configName}";
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
def dependencyLibs
|
|
541
|
+
libs=[]
|
|
542
|
+
project.dependencies.each do |dep|
|
|
543
|
+
# TODO: should this check for the type of project?
|
|
544
|
+
if(dep.nativeLibDir != nil)
|
|
545
|
+
ldef = ctools.loadLinkref(dep.nativeLibDir,configName,dep.moduleName);
|
|
546
|
+
if(ldef != nil)
|
|
547
|
+
deflibs = ldef[:libs];
|
|
548
|
+
libs += deflibs if deflibs;
|
|
549
|
+
end
|
|
550
|
+
end
|
|
551
|
+
end
|
|
552
|
+
if(thirdPartyLibs)
|
|
553
|
+
thirdPartyLibs.flatten.each do |tpl|
|
|
554
|
+
ldef = ctools.loadLinkref("#{thirdPartyPath}/lib",configName,tpl);
|
|
555
|
+
if(ldef != nil)
|
|
556
|
+
deflibs = ldef[:libs];
|
|
557
|
+
libs += deflibs if deflibs;
|
|
558
|
+
end
|
|
559
|
+
end
|
|
560
|
+
end
|
|
561
|
+
libs
|
|
562
|
+
end
|
|
563
|
+
|
|
564
|
+
def objectFiles
|
|
565
|
+
[]
|
|
566
|
+
end
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
# for a specifc named configuraton, resolves the configration and loads it with the
|
|
570
|
+
# the project's specified values.
|
|
571
|
+
|
|
572
|
+
def resolveConfiguration(config)
|
|
573
|
+
|
|
574
|
+
if(ret = (@resolvedConfigs||={})[config])
|
|
575
|
+
return ret;
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
tools = CTools.loadConfiguredTools(config);
|
|
579
|
+
ret = @resolvedConfigs[config] = TargetConfig.new(self,config,tools);
|
|
580
|
+
|
|
581
|
+
if(defined? @cppConfigurator_)
|
|
582
|
+
@cppConfigurator_.call(ret);
|
|
583
|
+
end
|
|
584
|
+
ret
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
end
|
|
588
|
+
|
|
589
|
+
class BuildConfig
|
|
590
|
+
# ensure added global project task dependencies
|
|
591
|
+
task :autogen => [ :cleandepends, :includes, :vcproj ];
|
|
592
|
+
task :cleanautogen => [ :cleanincludes, :cleandepends, :vcprojclean ];
|
|
593
|
+
task :compile => [ :includes ];
|
|
594
|
+
task :depends => [ :includes ];
|
|
595
|
+
task :build => [ :compile ];
|
|
596
|
+
task :rebuild => [ :build, :autogen, :compile ];
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
# Create a new project
|
|
600
|
+
#
|
|
601
|
+
# <b>named args:</b>
|
|
602
|
+
#
|
|
603
|
+
# :name => name of this project, defaults to parent directory name
|
|
604
|
+
# :package => package name for this project defaults to nothing
|
|
605
|
+
# :config => explicit parent configuration, defaults to 'root'
|
|
606
|
+
# :dependsUpon => array of project directories or specific rakefile paths this project
|
|
607
|
+
# depends upon
|
|
608
|
+
# :id => uuid to assign to project in "uuid string format"
|
|
609
|
+
# '2CD0548E-6945-4b77-83B9-D0993009CD75'
|
|
610
|
+
#
|
|
611
|
+
# &block is always yielded to in the directory of the projects file, and the
|
|
612
|
+
# Rake namespace of the new project, and called in this instance's context
|
|
613
|
+
|
|
614
|
+
CppProject = getProjectClass( :includes=>[CppProjectModule] )
|
|
615
|
+
|
|
616
|
+
end # Rakish
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
#################################################
|
|
620
|
+
|
|
621
|
+
if false
|
|
622
|
+
|
|
623
|
+
def acquireBuildId(dir, map=nil) # :nodoc:
|
|
624
|
+
outOfSync = false;
|
|
625
|
+
rev = 'test'
|
|
626
|
+
count = 0
|
|
627
|
+
# dirs.each do |dir|
|
|
628
|
+
pdir = File.expand_path(dir).pathmap(map);
|
|
629
|
+
drev = `svnversion -n \"#{getRelativePath(pdir)}\"`
|
|
630
|
+
if(count == 0)
|
|
631
|
+
rev = drev;
|
|
632
|
+
end
|
|
633
|
+
if(drev =~ /[^0123456789]/)
|
|
634
|
+
outOfSync = true
|
|
635
|
+
msg = 'is out of sync'
|
|
636
|
+
if(drev =~ /M/)
|
|
637
|
+
msg = 'is modified'
|
|
638
|
+
end
|
|
639
|
+
puts("Preparing test build ** \"#{pdir}\" #{msg}") if verbose?
|
|
640
|
+
end
|
|
641
|
+
if(drev != rev)
|
|
642
|
+
outOfSync = true
|
|
643
|
+
end
|
|
644
|
+
rev = drev;
|
|
645
|
+
# end
|
|
646
|
+
if(outOfSync)
|
|
647
|
+
return('test')
|
|
648
|
+
end
|
|
649
|
+
puts("build ID is \##{rev}")
|
|
650
|
+
return(rev)
|
|
651
|
+
end
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
public
|
|
655
|
+
|
|
656
|
+
# Gets build ID based on subversion revision of BUILD_ROOT
|
|
657
|
+
# returns revision number if local copy is unmodified and
|
|
658
|
+
# represents a coherant revision. returns 'test' if the
|
|
659
|
+
# local copy is modified.
|
|
660
|
+
#
|
|
661
|
+
# this will cache the result and if no svn updates or commits
|
|
662
|
+
# have been made and the last ID is 'test' will not call svnversion
|
|
663
|
+
# again (which is very slow) but will return 'test'
|
|
664
|
+
|
|
665
|
+
def getBuildId # :nodoc:
|
|
666
|
+
unless defined? @@buildId_
|
|
667
|
+
idfile = "#{@buildDir}/obj/.rakishBuildId.txt"
|
|
668
|
+
|
|
669
|
+
if File.exists? idfile
|
|
670
|
+
File.open(idfile,'r') do |file|
|
|
671
|
+
file.each_line do |l|
|
|
672
|
+
if(l =~ /buildId = "/)
|
|
673
|
+
$' =~ /"/
|
|
674
|
+
@@buildId_ = $`
|
|
675
|
+
break;
|
|
676
|
+
end
|
|
677
|
+
end
|
|
678
|
+
end
|
|
679
|
+
if(@@buildId_ == 'test')
|
|
680
|
+
if(filetime("#{$BUILD_ROOT}/.svn") < filetime(idfile))
|
|
681
|
+
return @@buildId_
|
|
682
|
+
end
|
|
683
|
+
end
|
|
684
|
+
else
|
|
685
|
+
mkdir_p("#{@buildDir}/obj", :verbose=>false)
|
|
686
|
+
end
|
|
687
|
+
|
|
688
|
+
@@buildId_ = acquireBuildId($BUILD_ROOT);
|
|
689
|
+
File.open(idfile,'w') do |file|
|
|
690
|
+
file.puts("buildId = \"#{@@buildId_}\"")
|
|
691
|
+
end
|
|
692
|
+
end
|
|
693
|
+
@@buildId_
|
|
694
|
+
end
|
|
695
|
+
end # false
|
|
696
|
+
|