rakepp 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/gempackagetask'
4
4
  desc "Default Task"
5
5
  task :default => :package
6
6
 
7
- PKG_VERSION = '0.1.4'
7
+ PKG_VERSION = '0.1.5'
8
8
  PKG_FILES = FileList[
9
9
  'lib/**/*.rb',
10
10
  '*.xml',
data/lib/rakepp.rb CHANGED
@@ -15,6 +15,7 @@ require 'rakepp/sourcefile'
15
15
  require 'rakepp/binarylib'
16
16
  require 'rakepp/framework'
17
17
  require 'rakepp/files'
18
+ require 'rakepp/crosstools'
18
19
 
19
20
  def dir(d)
20
21
  file_create d do |t|
@@ -1,9 +1,10 @@
1
1
  class Compiler
2
- attr_reader :targetDir
2
+ attr_reader :targetDir, :compileflags
3
3
 
4
- def initialize(targetDir, defines)
4
+ def initialize(targetDir, defines, compileflags)
5
5
  @targetDir = targetDir
6
6
  @defines = defines
7
+ @compileflags = compileflags
7
8
  end
8
9
 
9
10
  def addTasks(artifact)
@@ -0,0 +1,50 @@
1
+ class CrossTools
2
+
3
+ def initialize(compilerHash)
4
+ @compilerHash = compilerHash
5
+ end
6
+
7
+ def sourceLib(compilers, base, name, sources, dependencies, includes, privateDefines=[], forceLib=false)
8
+ todo = get_compilers(compilers)
9
+ return todo.inject(Hash.new) do |memo, pair|
10
+ key = pair[0]
11
+ compiler = pair[1]
12
+ deps = dependencies[key]
13
+ if deps == nil
14
+ if dependencies.size == 0
15
+ deps = Array.new
16
+ else
17
+ raise "missing deps for sourcelib: '#{name}' and compiler: '#{key}'"
18
+ end
19
+ end
20
+ memo[key] = [SourceLib.new(compiler, base, name, sources, deps, includes, privateDefines, forceLib)]
21
+ memo
22
+ end
23
+ end
24
+
25
+ def exe(compilers, base, name, sources, libs, includes)
26
+ todo = get_compilers(compilers)
27
+ return todo.inject(Hash.new) do |memo, pair|
28
+ key = pair[0]
29
+ compiler = pair[1]
30
+ l = libs[key]
31
+ if l == nil
32
+ raise "missing libs for exe: '#{name}' and compiler: '#{key}'"
33
+ end
34
+ memo[key] = Exe.new(compiler, base, name, sources, l, includes)
35
+ memo
36
+ end
37
+ end
38
+
39
+ def get_compilers(compilers)
40
+ if compilers == nil
41
+ return @compilerHash
42
+ else
43
+ return compilers.inject(Hash.new) do |memo, i|
44
+ memo[i] = @compilerHash[i]
45
+ memo
46
+ end
47
+ end
48
+ end
49
+
50
+ end
@@ -12,16 +12,26 @@ class GccCompiler < Compiler
12
12
  calcDependencies(artifact, depFile)
13
13
  end
14
14
 
15
- outFile = file outName => depFile do |task|
15
+ recreateDepFileTask = task "#{depFile}.recreate" do | task |
16
+ puts "wird immer gemacht"
17
+ if (!File.exists?(depFile))
18
+ calcDependencies(artifact, depFile)
19
+ end
20
+ deps = YAML.load_file(depFile)
21
+ if (deps)
22
+ depFileTask.enhance(deps)
23
+ end
24
+ end
25
+
26
+ outFile = file outName => ["#{depFile}.recreate", depFile] do | task |
16
27
  command = "#{compiler(artifact)} -c #{defines(artifact)} #{includes(artifact)} -o #{outName} #{artifact.source.fullPath}"
17
28
  sh command
18
29
  end
19
-
20
- applyTask = task "#{depFile}.apply" => depFile do |task|
30
+
31
+ applyTask = task "#{outFile}.apply" => recreateDepFileTask do |task|
21
32
  deps = YAML.load_file(depFile)
22
33
  if (deps)
23
34
  outFile.enhance(deps)
24
- depFileTask.enhance(deps[1..-1])
25
35
  end
26
36
  end
27
37
 
@@ -33,25 +43,18 @@ class GccCompiler < Compiler
33
43
  dirs = [artifact.targetDir, File.dirname(outName)]
34
44
  outFile.enhance(dirs)
35
45
  depFileTask.enhance(dirs)
46
+ recreateDepFileTask.enhance(dirs)
36
47
 
37
48
  All.addObject(artifact)
38
49
  All.addDepFile(depFile)
39
50
  end
40
51
 
41
- def arch
42
- if ARCH.length > 0
43
- return "-arch #{ARCH}"
44
- end
45
- return ''
46
- end
47
-
48
52
  def compiler(artifact)
49
-
50
53
  if ((artifact.source.fullPath.index(".cpp") != nil) ||
51
54
  (artifact.source.fullPath.index(".cxx") != nil)) then
52
- return "g++ #{arch} #{OPTIMIZE} -Wall"
55
+ return "g++ #{compileflags}"
53
56
  else
54
- return "gcc #{arch} #{OPTIMIZE} -Wall"
57
+ return "gcc #{compileflags}"
55
58
  end
56
59
  end
57
60
 
@@ -85,37 +88,38 @@ class GccCompiler < Compiler
85
88
  f.write(deps.to_yaml)
86
89
  end
87
90
  end
91
+
88
92
  def startOfSourceLibCommand(outName, artifact)
89
93
  return "ar -r #{outName}"
90
94
  end
91
95
 
92
- def addSourceLibTasks(artifact)
93
- outDir = File.join(@targetDir, artifact.name)
96
+ def addSourceLibTasks(artifact)
97
+ outDir = File.join(@targetDir, artifact.name)
94
98
 
95
- objects = []
96
- artifact.sources.each do |source|
97
- objects << ObjectFile.new(self, source, outDir, artifact.tr_includes, artifact.privateDefines).outFile
98
- end
99
+ objects = []
100
+ artifact.sources.each do |source|
101
+ objects << ObjectFile.new(self, source, outDir, artifact.tr_includes, artifact.privateDefines).outFile
102
+ end
99
103
 
100
- libsName = File.join(@targetDir, 'libs')
101
- outName = File.join(libsName, "lib#{artifact.name}.a")
104
+ libsName = File.join(@targetDir, 'libs')
105
+ outName = File.join(libsName, "lib#{artifact.name}.a")
102
106
 
103
- artifact.outFile = outName
104
- desc "Create SourceLib #{outName}"
105
- theTask = file outName => objects do | task |
106
- command = startOfSourceLibCommand(outName, artifact)
107
- objects.each do | o |
108
- command += " #{o}"
107
+ artifact.outFile = outName
108
+ desc "Create SourceLib #{outName}"
109
+ theTask = file outName => objects do | task |
110
+ command = startOfSourceLibCommand(outName, artifact)
111
+ objects.each do | o |
112
+ command += " #{o}"
113
+ end
114
+ sh command
109
115
  end
110
- sh command
111
- end
112
116
 
113
- addTransitiveLibraryPrerequisites(theTask, artifact)
117
+ addTransitiveLibraryPrerequisites(theTask, artifact)
114
118
 
115
- file outName => [libsName]
116
- All.add(outName)
117
- directory libsName
118
- end
119
+ file outName => [libsName]
120
+ All.add(outName)
121
+ directory libsName
122
+ end
119
123
 
120
124
  def addSharedLibTasks(artifact)
121
125
  outDir = File.join(@targetDir, artifact.name)
@@ -169,7 +173,7 @@ def addExeTasks(artifact)
169
173
  artifact.outFile = File.join(exesName, artifact.name + '.exe')
170
174
  desc "Create Exe #{artifact.outFile}"
171
175
  theTask = file artifact.outFile => objects do | task |
172
- command = "g++ #{arch} -o #{artifact.outFile}"
176
+ command = "g++ #{compileflags} -o #{artifact.outFile}"
173
177
  objects.each do |o|
174
178
  command += " #{o}"
175
179
  end
@@ -198,13 +202,13 @@ end
198
202
  end
199
203
  def doAdditionalWorkForExe(artifact)
200
204
  end
201
-
205
+
202
206
  def addTransitiveLibraryPrerequisites(theTask, artifact)
203
207
  LibHelper.tr_libs(artifact.libs).each do |lib|
204
208
  theTask.prerequisites << lib.outFile unless lib.kind_of?(BinaryLib)
205
209
  end
206
210
  end
207
-
211
+
208
212
  def addLib(task, lib)
209
213
  if (lib.instance_of?(BinaryLib)) then
210
214
  return " -L#{lib.path||'/usr/lib'} -l#{lib.name} "
@@ -1,7 +1,7 @@
1
1
  class LinuxCompiler < GccCompiler
2
2
 
3
- def initialize(defines, output_suffix='')
4
- super("linux#{output_suffix}", defines)
3
+ def initialize(defines, compileflags, output_suffix='')
4
+ super("linux#{output_suffix}", defines, compileflags)
5
5
  end
6
6
 
7
7
  def startOfSharedLibCommand(libName, artifact)
@@ -1,12 +1,13 @@
1
1
  class OsxCompiler < GccCompiler
2
2
 
3
- def initialize(defines, gui=true, output_suffix='')
4
- super("osx#{output_suffix}", defines)
3
+ def initialize(defines, compileflags, architecture, gui=true, output_suffix='')
4
+ super("osx#{output_suffix}", defines, "#{compileflags} -arch #{architecture}")
5
+ @architecture = architecture
5
6
  @gui = gui
6
7
  end
7
8
 
8
9
  def startOfSourceLibCommand(outname, artifact)
9
- return "libtool -static -arch_only #{ARCH} -o #{outname}"
10
+ return "libtool -static -arch_only #{@architecture} -o #{outname}"
10
11
  end
11
12
 
12
13
  def startOfSharedLibCommand(libName, artifact)
@@ -14,7 +15,7 @@ class OsxCompiler < GccCompiler
14
15
  if name == nil
15
16
  name = File.basename(libName)
16
17
  end
17
- return "g++ -arch #{ARCH} -dynamiclib -install_name #{name}"
18
+ return "g++ -arch #{@architecture} -dynamiclib -install_name #{name}"
18
19
  end
19
20
 
20
21
  def sharedExtension
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rakepp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Koestlin
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-09 00:00:00 +01:00
12
+ date: 2010-03-30 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -35,6 +35,7 @@ files:
35
35
  - lib/rakepp/binarylib.rb
36
36
  - lib/rakepp/cleaner.rb
37
37
  - lib/rakepp/compiler.rb
38
+ - lib/rakepp/crosstools.rb
38
39
  - lib/rakepp/exe.rb
39
40
  - lib/rakepp/files.rb
40
41
  - lib/rakepp/framework.rb