rakepp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +38 -0
- data/lib/rakepp/BinaryLib.rb +21 -0
- data/lib/rakepp/Compiler.rb +12 -0
- data/lib/rakepp/CompilerHelper.rb +38 -0
- data/lib/rakepp/DependencyHandler.rb +37 -0
- data/lib/rakepp/Exe.rb +28 -0
- data/lib/rakepp/Files.rb +5 -0
- data/lib/rakepp/Framework.rb +23 -0
- data/lib/rakepp/Gcc.rb +115 -0
- data/lib/rakepp/Lib.rb +20 -0
- data/lib/rakepp/LibHelper.rb +46 -0
- data/lib/rakepp/Msvt.rb +80 -0
- data/lib/rakepp/RakeHelper.rb +82 -0
- data/lib/rakepp/SourceLib.rb +38 -0
- data/lib/rakepp/Sources2Objects.rb +35 -0
- data/lib/rakepp/TaskDebug.rb +18 -0
- data/lib/rakepp/Tests.rb +45 -0
- data/lib/rakepp.rb +9 -0
- metadata +64 -0
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
desc "Default Task"
|
5
|
+
task :default => :package
|
6
|
+
|
7
|
+
PKG_VERSION = '0.0.1'
|
8
|
+
PKG_FILES = FileList[
|
9
|
+
'lib/**/*.rb',
|
10
|
+
'*.xml',
|
11
|
+
'Rakefile'
|
12
|
+
# 'test/**/*.rb',
|
13
|
+
# 'doc/**/*'
|
14
|
+
]
|
15
|
+
|
16
|
+
spec = Gem::Specification.new do |s|
|
17
|
+
s.name = 'rakepp'
|
18
|
+
s.version = PKG_VERSION
|
19
|
+
s.summary = "Cpp Support for Rake."
|
20
|
+
s.description = <<-EOF
|
21
|
+
Some more high level building blocks for cpp projects.
|
22
|
+
EOF
|
23
|
+
s.files = PKG_FILES.to_a
|
24
|
+
s.require_path = 'lib'
|
25
|
+
s.autorequire = 'rakepp'
|
26
|
+
# s.has_rdoc = true
|
27
|
+
s.author = "Christian Koestlin"
|
28
|
+
s.email = 'gizmoATflopcodeDOTcom'
|
29
|
+
s.homepage = "[http address which can't be saved due to external link blocker...]"
|
30
|
+
s.rubyforge_project = "rakepp"
|
31
|
+
s.add_dependency('progressbar', '>=0.0.3')
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
36
|
+
# pkg.need_tar = true
|
37
|
+
# pkg.need_zip = true
|
38
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rakepp/Lib'
|
2
|
+
|
3
|
+
class BinaryLib < Lib
|
4
|
+
attr_reader :libs
|
5
|
+
|
6
|
+
def initialize(libName, includes, libs)
|
7
|
+
super(libName)
|
8
|
+
|
9
|
+
@artifact = nil
|
10
|
+
@includes = includes
|
11
|
+
libs.each do | lib |
|
12
|
+
@includes |= lib.includes
|
13
|
+
end
|
14
|
+
@libs = libs
|
15
|
+
end
|
16
|
+
|
17
|
+
def exeContribution
|
18
|
+
return @libName
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#require 'rakepp/Msvt'
|
2
|
+
#require 'rakepp/Gcc'
|
3
|
+
|
4
|
+
class CompilerHelper
|
5
|
+
|
6
|
+
# def self.new(outputDir)
|
7
|
+
# defines = ['_LIB', 'DEBUG', '_COMMAND']
|
8
|
+
# defines += ['JAS_WIN_MSVC_BUILD', '_MBCS']
|
9
|
+
# defines += ['EXCLUDE_JPG_SUPPORT']
|
10
|
+
# defines += ['EXCLUDE_PGX_SUPPORT']
|
11
|
+
# defines += ['EXCLUDE_MIF_SUPPORT']
|
12
|
+
|
13
|
+
# defines += ['JPEG_SUPPORT']
|
14
|
+
|
15
|
+
# defines += ['HAVE_LIBPNG']
|
16
|
+
# defines += ['HAVE_LIBZ']
|
17
|
+
|
18
|
+
# if windows?
|
19
|
+
# defines += ['WIN32', '_WINDOWS']
|
20
|
+
# return Msvt.new(outputDir, defines, [])
|
21
|
+
# return Gcc.new(outputDir, defines, [])
|
22
|
+
# elsif osx?
|
23
|
+
# defines += ['WORDS_BIGENDIAN']
|
24
|
+
# defines += ['LINUX', 'OSX']
|
25
|
+
# else
|
26
|
+
# defines += ['LINUX']
|
27
|
+
# end
|
28
|
+
# return Gcc.new(outputDir, defines, [])
|
29
|
+
# end
|
30
|
+
|
31
|
+
def self.windows?
|
32
|
+
return RUBY_PLATFORM =~ /win32/i
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.osx?
|
36
|
+
return RUBY_PLATFORM.index('darwin') != nil
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class DependencyHandler
|
2
|
+
def DependencyHandler.setup(compiler)
|
3
|
+
|
4
|
+
depTask = task :dep do
|
5
|
+
compiler.calcDependencies
|
6
|
+
end
|
7
|
+
|
8
|
+
depFile = DependencyHandler.getDepFile(compiler)
|
9
|
+
if (File.exists?(depFile) == false) then
|
10
|
+
depTask.invoke
|
11
|
+
end
|
12
|
+
|
13
|
+
if (File.exists?(depFile)) then
|
14
|
+
dependencies = Marshal.load(File.open(depFile, 'rb'))
|
15
|
+
|
16
|
+
dependencies.each do | object, deps |
|
17
|
+
task = Rake::Task[object]
|
18
|
+
task.enhance(deps)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def DependencyHandler.storeDependencies(compiler, allDependencies)
|
26
|
+
FileUtils.mkdir_p(compiler.outputDir)
|
27
|
+
File.open(DependencyHandler.getDepFile(compiler), 'wb') do | file |
|
28
|
+
Marshal.dump(allDependencies, file)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def DependencyHandler.getDepFile(compiler)
|
34
|
+
return File.join(compiler.outputDir, 'dependencies')
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/lib/rakepp/Exe.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rakepp/Sources2Objects'
|
2
|
+
|
3
|
+
class Exe
|
4
|
+
|
5
|
+
def Exe.new(compiler, name, sources, includes, libs, baseDir)
|
6
|
+
artifacts = Array.new
|
7
|
+
libs.each do | lib |
|
8
|
+
# puts "working on #{lib.libName}"
|
9
|
+
if (lib.artifact != nil) then
|
10
|
+
artifacts << lib.artifact
|
11
|
+
else
|
12
|
+
puts 'no artifact'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
files = Sources2Objects.do(compiler, name, baseDir, sources, includes, libs)
|
17
|
+
objects = files.values
|
18
|
+
|
19
|
+
exeName = File.join(compiler.outputDir, 'exes', "#{name}.exe")
|
20
|
+
res = file exeName => artifacts + objects do | task |
|
21
|
+
FileUtils.mkdir_p(File.dirname(task.name))
|
22
|
+
compiler.createExe(task.name, objects, libs)
|
23
|
+
end
|
24
|
+
return res
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/lib/rakepp/Files.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rakepp/Lib'
|
2
|
+
|
3
|
+
class Framework < Lib
|
4
|
+
|
5
|
+
attr_reader :libs
|
6
|
+
|
7
|
+
def initialize(frameworkName, libraries)
|
8
|
+
super(frameworkName)
|
9
|
+
# @frameworkName = frameworkName
|
10
|
+
@libs = libraries
|
11
|
+
@includes = Array.new
|
12
|
+
@artifact = nil#"Framework/#{frameworkName}"
|
13
|
+
end
|
14
|
+
|
15
|
+
# def libName()
|
16
|
+
# return @frameworkName
|
17
|
+
# end
|
18
|
+
|
19
|
+
def exeContribution
|
20
|
+
return "-framework #{@libName}"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/rakepp/Gcc.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require_gem 'progressbar'
|
3
|
+
|
4
|
+
require 'rakepp/Compiler'
|
5
|
+
|
6
|
+
class Gcc < Compiler
|
7
|
+
def initialize(outputDir, defines, includes)
|
8
|
+
super(outputDir)
|
9
|
+
@defines = defines
|
10
|
+
@includes = includes
|
11
|
+
end
|
12
|
+
|
13
|
+
def calcDependencies()
|
14
|
+
flags = "-MM"
|
15
|
+
flags = addDefines(flags, @defines)
|
16
|
+
|
17
|
+
allDependencies = Hash.new
|
18
|
+
progress = ProgressBar.new('calc deps', Sources2Objects.all.length)
|
19
|
+
Sources2Objects.all.each do | s |
|
20
|
+
addIncludes(flags, s.includes)
|
21
|
+
dependencies = `gcc #{flags} #{s.source}`.gsub(/\\\n/, '').split[1..-1]
|
22
|
+
allDependencies[s.object] = dependencies
|
23
|
+
progress.inc
|
24
|
+
end
|
25
|
+
progress.finish
|
26
|
+
|
27
|
+
DependencyHandler.storeDependencies(self, allDependencies)
|
28
|
+
end
|
29
|
+
|
30
|
+
def compile(src, obj, includes, libs)
|
31
|
+
raise 'includes == nil' if includes == nil
|
32
|
+
|
33
|
+
FileUtils.mkdir_p(File.dirname(obj))
|
34
|
+
|
35
|
+
flags = '-c -exceptions -Wall'
|
36
|
+
flags = addDefines(flags, @defines)
|
37
|
+
|
38
|
+
flags = addIncludes(flags, @includes)
|
39
|
+
flags = addIncludes(flags, includes)
|
40
|
+
# puts 'adding includes'
|
41
|
+
# libs.each do | lib |
|
42
|
+
# puts lib.libName
|
43
|
+
# end
|
44
|
+
|
45
|
+
flags = addIncludes(flags, LibHelper.getIncludes(libs))
|
46
|
+
puts flags
|
47
|
+
command = "gcc #{flags} -o #{obj} #{src}"
|
48
|
+
sh command
|
49
|
+
end
|
50
|
+
|
51
|
+
def addDefines(start, defines)
|
52
|
+
help = start
|
53
|
+
defines.each do | define |
|
54
|
+
newOne = " -D#{define}"
|
55
|
+
help << newOne unless help.include?(newOne)
|
56
|
+
end
|
57
|
+
return help
|
58
|
+
end
|
59
|
+
|
60
|
+
def addIncludes(start, includes)
|
61
|
+
help = start
|
62
|
+
includes.each do | include |
|
63
|
+
newOne = " -I#{include} "
|
64
|
+
help << newOne unless help.include?(newOne)
|
65
|
+
end
|
66
|
+
return help
|
67
|
+
end
|
68
|
+
|
69
|
+
def linkLib(objects, artifact, libName)
|
70
|
+
command = "ar -r #{artifact}"
|
71
|
+
objects.each do | o |
|
72
|
+
command += " #{o}"
|
73
|
+
end
|
74
|
+
sh command
|
75
|
+
end
|
76
|
+
|
77
|
+
def createExe(name, objects, libs)
|
78
|
+
flatLibs = LibHelper.getLibs(libs)
|
79
|
+
libArtifacts = Array.new
|
80
|
+
flatLibs.each do |l|
|
81
|
+
libArtifacts << l.artifact unless l.artifact == nil
|
82
|
+
end
|
83
|
+
exeTask = file name => libArtifacts + objects do | t |
|
84
|
+
command = "g++ -stdc++ -o #{name}"
|
85
|
+
|
86
|
+
objects.each do | o |
|
87
|
+
command += " #{o}"
|
88
|
+
end
|
89
|
+
|
90
|
+
flatLibs.each do | l |
|
91
|
+
if (l.instance_of?(SourceLib))
|
92
|
+
libAndPath = l.exeContribution
|
93
|
+
path = libAndPath[0...libAndPath.rindex('/')]
|
94
|
+
lib = l.libName
|
95
|
+
command += " -L#{path} -l#{lib}"
|
96
|
+
elsif (l.instance_of?(Framework))
|
97
|
+
command += " #{l.exeContribution}"
|
98
|
+
else
|
99
|
+
command += " -l#{l.exeContribution}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
sh command
|
104
|
+
|
105
|
+
if (CompilerHelper.osx?())
|
106
|
+
sh "/Developer/Tools/Rez -o #{name} appResources.r"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def getSourceLibArtifact(lib)
|
112
|
+
return File.join(@outputDir, 'libs', "lib#{lib.libName}.a")
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
data/lib/rakepp/Lib.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
class Lib
|
2
|
+
attr_reader :artifact, :includes
|
3
|
+
|
4
|
+
def initialize(libName)
|
5
|
+
# puts "creating lib with name #{libName}"
|
6
|
+
@libName = libName
|
7
|
+
end
|
8
|
+
|
9
|
+
def path
|
10
|
+
return LibHelper.path(@artifact)
|
11
|
+
end
|
12
|
+
|
13
|
+
def libName
|
14
|
+
@libName#raise 'not imlpemented exception'
|
15
|
+
end
|
16
|
+
|
17
|
+
def exeContribution
|
18
|
+
return artifact
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class LibHelper
|
2
|
+
# adds the element to the end of the lib
|
3
|
+
def self.addUnique(res, lib)
|
4
|
+
res.delete(lib)
|
5
|
+
res.push(lib)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.getLibs(libs)
|
9
|
+
res = Array.new
|
10
|
+
libs.each do | lib |
|
11
|
+
self.addUnique(res, lib)
|
12
|
+
self.getLibs(lib.libs).each do | lib |
|
13
|
+
self.addUnique(res, lib)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
return res
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.getIncludes(libs)
|
20
|
+
res = Array.new
|
21
|
+
|
22
|
+
libs.each do | lib |
|
23
|
+
res |= [lib.includes] if lib.includes.size > 0
|
24
|
+
res += LibHelper.getIncludes(lib.libs)
|
25
|
+
end
|
26
|
+
return res
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def self.getArtifacts(libs)
|
31
|
+
res = Array.new
|
32
|
+
libs.each do |l|
|
33
|
+
res.push(l.artifact) unless l.artifact == nil
|
34
|
+
end
|
35
|
+
return res
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.libName(artifactPath)
|
39
|
+
return artifactPath[artifactPath.rindex('/')+1...artifactPath.size]
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.path(artifactPath)
|
43
|
+
return artifactPath[0...artifactPath.rindex('/')]
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/lib/rakepp/Msvt.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'rakepp/Compiler'
|
2
|
+
require 'rakepp/LibHelper'
|
3
|
+
|
4
|
+
class Msvt < Compiler
|
5
|
+
def initialize(baseDir, defines, includes)
|
6
|
+
super(baseDir)
|
7
|
+
@defines = defines + ['MSVT']
|
8
|
+
@includes = includes
|
9
|
+
end
|
10
|
+
|
11
|
+
def calcDependencies()
|
12
|
+
# dont know how to do this
|
13
|
+
end
|
14
|
+
|
15
|
+
def compile(src, obj, includes, libs)
|
16
|
+
raise 'includes == nil' if includes == nil
|
17
|
+
flags = '/GR /EHsc /MT /nologo /Zi /EHsc /c /FD /Y-'
|
18
|
+
FileUtils.mkdir_p(File.dirname(obj))
|
19
|
+
|
20
|
+
@defines.each do | define |
|
21
|
+
flags << " /D \"#{define}\""
|
22
|
+
end
|
23
|
+
|
24
|
+
flags = addIncludes(flags, @includes)
|
25
|
+
flags = addIncludes(flags, includes)
|
26
|
+
flags = addIncludes(flags, LibHelper.getIncludes(libs))
|
27
|
+
|
28
|
+
command = "cl #{flags} /Fo#{obj} #{src}"
|
29
|
+
sh command
|
30
|
+
end
|
31
|
+
|
32
|
+
def addIncludes(start, includes)
|
33
|
+
help = start
|
34
|
+
includes.each do | include |
|
35
|
+
help << " /I#{include}"
|
36
|
+
end
|
37
|
+
return help
|
38
|
+
end
|
39
|
+
|
40
|
+
def linkLib(objects, artifact, libName)
|
41
|
+
command = "link -lib /out:#{artifact}"
|
42
|
+
objects.each do | o |
|
43
|
+
command += " #{o}"
|
44
|
+
end
|
45
|
+
command += " /machine:i386"
|
46
|
+
sh command
|
47
|
+
end
|
48
|
+
|
49
|
+
def createExe(name, objects, libs)
|
50
|
+
flatLibs = LibHelper.getLibs(libs)
|
51
|
+
exeTask = file name => flatLibs.collect {| l | l.artifact} + objects do | t |
|
52
|
+
command = "link /NODEFAULTLIB libcpmt.lib kernel32.lib libcmt.lib mscoree.lib oldnames.lib user32.lib"
|
53
|
+
|
54
|
+
flatLibs.each do | l |
|
55
|
+
if (l.instance_of?(SourceLib))
|
56
|
+
libAndPath = l.exeContribution
|
57
|
+
idx = libAndPath.rindex('/')
|
58
|
+
path = libAndPath[0...idx]
|
59
|
+
lib = libAndPath[idx+1..-1]
|
60
|
+
command += " /LIBPATH:#{path} #{lib}"
|
61
|
+
else
|
62
|
+
command += " #{l.exeContribution}.lib"
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
command += " /out:#{name}"
|
68
|
+
objects.each do | o |
|
69
|
+
command += " #{o}"
|
70
|
+
end
|
71
|
+
sh command
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def getSourceLibArtifact(lib)
|
76
|
+
return File.join(@outputDir, 'libs', "#{lib.libName}.lib")
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
class RakeHelper
|
2
|
+
|
3
|
+
@@TARGET = 'release/'
|
4
|
+
|
5
|
+
def self.to_o(s)
|
6
|
+
# nach letztem punkt suchen und dann wort ende
|
7
|
+
return s.sub(/\.[^.]+$/, '.o')
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.get_source_files(base, lib, ending)
|
11
|
+
return Dir["#{base}#{lib}/**/*#{ending}"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.remove_from_front(stuff, s)
|
15
|
+
idx = s.index(stuff)
|
16
|
+
if (idx == nil) then
|
17
|
+
raise 'matching front not found'
|
18
|
+
elsif (idx != 0) then
|
19
|
+
raise 'match not found at front'
|
20
|
+
else
|
21
|
+
return s.slice(stuff.length..-1)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get_pairs(base, lib, ending) s
|
26
|
+
sources = get_source_files(base, lib, ending)
|
27
|
+
pairs = Hash.new
|
28
|
+
sources.each do | file |
|
29
|
+
pairs[file] = @@TARGET + RakeHelper::remove_from_front(base, RakeHelper::to_o(file))
|
30
|
+
end
|
31
|
+
return pairs
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.create_compile_tasks(base, lib, ending, compiler, defines, includes)
|
35
|
+
# puts 'create_compile_tasks'
|
36
|
+
pairs = RakeHelper.get_pairs(base, lib, ending)
|
37
|
+
|
38
|
+
pairs.each do |src, obj|
|
39
|
+
file obj => [src] do |task|
|
40
|
+
compiler.compile(src, task.name, defines, includes)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.lib(libName, baseDir, includes, compiler, &proc)
|
46
|
+
globber = "#{baseDir}/#{libName}/**/*.cpp"
|
47
|
+
srcFiles = Dir[globber].reject do | f |
|
48
|
+
proc.call f
|
49
|
+
end
|
50
|
+
|
51
|
+
cAndOFiles = Hash.new
|
52
|
+
srcFiles.each do | cFile |
|
53
|
+
objectFile = RakeHelper::to_o(cFile)
|
54
|
+
outFile = RakeHelper::remove_from_front(baseDir, objectFile)
|
55
|
+
outFile = @@TARGET + outFile
|
56
|
+
cAndOFiles[cFile] = outFile
|
57
|
+
file outFile => [cFile] do | task |
|
58
|
+
compiler.compile(cFile, task.name)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
# file "#{libName}" => cAndOFiles.values do | task |
|
62
|
+
# puts task
|
63
|
+
# end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.includeCleaner(s)
|
67
|
+
parts = s.split(File::SEPARATOR)
|
68
|
+
if (parts.length > 1)
|
69
|
+
if (parts[-1] == '..')
|
70
|
+
if (parts[-2] != '..')
|
71
|
+
parts = parts[0...-2]
|
72
|
+
end
|
73
|
+
elsif (parts[-1] == '.')
|
74
|
+
parts = parts[0...-1]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
res = File.join(parts)
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rakepp/Lib'
|
2
|
+
require 'rakepp/LibHelper'
|
3
|
+
require 'rakepp/Sources2Objects'
|
4
|
+
|
5
|
+
class SourceLib < Lib
|
6
|
+
attr_accessor :libs
|
7
|
+
|
8
|
+
def self.getBaseDir(libName)
|
9
|
+
return File.join('..', libName)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(compiler, libName, includes, sources, libs, baseDir=nil)
|
13
|
+
super(libName)
|
14
|
+
|
15
|
+
if baseDir != nil then
|
16
|
+
@baseDir = baseDir
|
17
|
+
else
|
18
|
+
@baseDir = SourceLib.getBaseDir(libName)
|
19
|
+
end
|
20
|
+
|
21
|
+
@artifact = compiler.getSourceLibArtifact(self)
|
22
|
+
@includes = includes.collect do |i|
|
23
|
+
res = File.join(@baseDir, i)
|
24
|
+
RakeHelper.includeCleaner(res)
|
25
|
+
end
|
26
|
+
@libs = libs
|
27
|
+
files = Sources2Objects.do(compiler, libName, @baseDir, sources, @includes, libs)
|
28
|
+
file @artifact => files.values + LibHelper.getArtifacts(libs) do | task |
|
29
|
+
FileUtils.mkdir_p(File.dirname(task.name))
|
30
|
+
compiler.linkLib(files.values, task.name, @libName)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def baseDir
|
35
|
+
return @baseDir
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rakepp/RakeHelper'
|
2
|
+
|
3
|
+
class SourceAndObjectAndIncludes
|
4
|
+
attr_reader :source, :object, :includes
|
5
|
+
def initialize(source, object, includes)
|
6
|
+
@source = source
|
7
|
+
@object = object
|
8
|
+
@includes = includes
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Sources2Objects
|
13
|
+
@@all = Array.new
|
14
|
+
|
15
|
+
def Sources2Objects.all
|
16
|
+
return @@all
|
17
|
+
end
|
18
|
+
|
19
|
+
def Sources2Objects.do(compiler, libName, baseDir, sources, includes, libs)
|
20
|
+
files = Hash.new
|
21
|
+
sources.each do | file |
|
22
|
+
source = File.join(baseDir, file)
|
23
|
+
# puts "source #{source}"
|
24
|
+
object = File.join(compiler.outputDir, libName, RakeHelper.to_o(file))
|
25
|
+
files[source] = object
|
26
|
+
end
|
27
|
+
files.each do | source, object |
|
28
|
+
file object => source do | task |
|
29
|
+
compiler.compile(source, object, includes, libs)
|
30
|
+
end
|
31
|
+
@@all << SourceAndObjectAndIncludes.new(source, object, includes)
|
32
|
+
end
|
33
|
+
return files
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Task
|
2
|
+
def investigation
|
3
|
+
result = "------------------------------\n"
|
4
|
+
result << "Investigating #{name}\n"
|
5
|
+
result << "class: #{self.class}\n"
|
6
|
+
result << "task needed: #{needed?}\n"
|
7
|
+
result << "pre-requisites: \n"
|
8
|
+
result << @prerequisites.to_s
|
9
|
+
#prereqs = @prerequisites.collect {|name| Task[name]}
|
10
|
+
#prereqs.sort! {|a,b| a.timestamp <=> b.timestamp}
|
11
|
+
#prereqs.each do |p|
|
12
|
+
# result << "--#{p.name} (#{p.timestamp})\n"
|
13
|
+
#end
|
14
|
+
#latest_prereq = @prerequisites.collect{|n| Task[n].timestamp}.max
|
15
|
+
#result << "latest-prerequisite time: #{latest_prereq}\n"
|
16
|
+
return result
|
17
|
+
end
|
18
|
+
end
|
data/lib/rakepp/Tests.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'RakeHelper'
|
3
|
+
|
4
|
+
class TestStringStuff < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def testToO
|
7
|
+
s = '../libpng128/test.c'
|
8
|
+
s = RakeHelper::to_o(s)
|
9
|
+
assert_equal('../libpng128/test.o', s)
|
10
|
+
end
|
11
|
+
|
12
|
+
def testRemoveStringFromFront
|
13
|
+
s = '../libpng/test.c'
|
14
|
+
s = RakeHelper::remove_from_front('../', s)
|
15
|
+
assert_equal('libpng/test.c', s)
|
16
|
+
end
|
17
|
+
|
18
|
+
def testRemoveStringFromFrontException
|
19
|
+
s = '../libpng/test.c'
|
20
|
+
assert_raise (RuntimeError) {s = RakeHelper::remove_from_front(',,/', s) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def testRemoveStringFromNotFront
|
24
|
+
s = '../libpng/test.c'
|
25
|
+
assert_raise (RuntimeError) {s = RakeHelper::remove_from_front('lib', s) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def testIncludeCleanerWithDoublePoint
|
29
|
+
res = RakeHelper.includeCleaner(File.join('..', 'lang', '..'))
|
30
|
+
assert_equal('..', res)
|
31
|
+
end
|
32
|
+
|
33
|
+
def testIncludeCleanderWithSinglePoint
|
34
|
+
res = RakeHelper.includeCleaner(File.join('..', 'lang', '.'))
|
35
|
+
assert_equal('../lang', res)
|
36
|
+
end
|
37
|
+
|
38
|
+
def testDoublePoint
|
39
|
+
res = RakeHelper.includeCleaner(File.join('..'))
|
40
|
+
assert_equal('..', res)
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
|
data/lib/rakepp.rb
ADDED
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.10
|
3
|
+
specification_version: 1
|
4
|
+
name: rakepp
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2006-01-23
|
8
|
+
summary: Cpp Support for Rake.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: gizmoATflopcodeDOTcom
|
12
|
+
homepage: "[http address which can't be saved due to external link blocker...]"
|
13
|
+
rubyforge_project: rakepp
|
14
|
+
description: Some more high level building blocks for cpp projects.
|
15
|
+
autorequire: rakepp
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
25
|
+
version:
|
26
|
+
platform: ruby
|
27
|
+
authors:
|
28
|
+
- Christian Koestlin
|
29
|
+
files:
|
30
|
+
- lib/rakepp.rb
|
31
|
+
- lib/rakepp/BinaryLib.rb
|
32
|
+
- lib/rakepp/Compiler.rb
|
33
|
+
- lib/rakepp/CompilerHelper.rb
|
34
|
+
- lib/rakepp/DependencyHandler.rb
|
35
|
+
- lib/rakepp/Exe.rb
|
36
|
+
- lib/rakepp/Files.rb
|
37
|
+
- lib/rakepp/Framework.rb
|
38
|
+
- lib/rakepp/Gcc.rb
|
39
|
+
- lib/rakepp/Lib.rb
|
40
|
+
- lib/rakepp/LibHelper.rb
|
41
|
+
- lib/rakepp/Msvt.rb
|
42
|
+
- lib/rakepp/RakeHelper.rb
|
43
|
+
- lib/rakepp/SourceLib.rb
|
44
|
+
- lib/rakepp/Sources2Objects.rb
|
45
|
+
- lib/rakepp/TaskDebug.rb
|
46
|
+
- lib/rakepp/Tests.rb
|
47
|
+
- Rakefile
|
48
|
+
test_files: []
|
49
|
+
rdoc_options: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
executables: []
|
52
|
+
extensions: []
|
53
|
+
requirements: []
|
54
|
+
dependencies:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: progressbar
|
57
|
+
version_requirement:
|
58
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
59
|
+
requirements:
|
60
|
+
-
|
61
|
+
- ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.0.3
|
64
|
+
version:
|