cxxproject 0.5.48 → 0.5.59
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile.rb +116 -116
- data/bin/cxx +10 -10
- data/lib/cxxproject.rb +23 -23
- data/lib/cxxproject/buildingblocks/binary_library.rb +39 -39
- data/lib/cxxproject/buildingblocks/building_block.rb +251 -239
- data/lib/cxxproject/buildingblocks/command_line.rb +79 -79
- data/lib/cxxproject/buildingblocks/custom_building_block.rb +39 -41
- data/lib/cxxproject/buildingblocks/executable.rb +257 -249
- data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +83 -83
- data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -20
- data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +34 -34
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +371 -364
- data/lib/cxxproject/buildingblocks/makefile.rb +153 -153
- data/lib/cxxproject/buildingblocks/module.rb +35 -35
- data/lib/cxxproject/buildingblocks/single_source.rb +33 -33
- data/lib/cxxproject/buildingblocks/source_library.rb +124 -124
- data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -40
- data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +41 -33
- data/lib/cxxproject/errorparser/error_parser.rb +50 -50
- data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +35 -30
- data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +35 -29
- data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -30
- data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +30 -29
- data/lib/cxxproject/eval_context.rb +144 -136
- data/lib/cxxproject/ext/file.rb +71 -71
- data/lib/cxxproject/ext/filelist.rb +6 -6
- data/lib/cxxproject/ext/progressbar.rb +20 -20
- data/lib/cxxproject/ext/rake.rb +419 -397
- data/lib/cxxproject/ext/rake_dirty.rb +30 -30
- data/lib/cxxproject/ext/rake_listener.rb +59 -59
- data/lib/cxxproject/ext/stdout.rb +44 -44
- data/lib/cxxproject/ext/string.rb +9 -9
- data/lib/cxxproject/ide_interface.rb +187 -181
- data/lib/cxxproject/toolchain/clang.rb +39 -39
- data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -99
- data/lib/cxxproject/toolchain/diab.rb +3 -1
- data/lib/cxxproject/toolchain/gcc.rb +2 -1
- data/lib/cxxproject/toolchain/provider.rb +131 -128
- data/lib/cxxproject/toolchain/toolchain.rb +38 -38
- data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -23
- data/lib/cxxproject/torake.rb +218 -216
- data/lib/cxxproject/utils/cleanup.rb +20 -20
- data/lib/cxxproject/utils/console.rb +6 -6
- data/lib/cxxproject/utils/exit_helper.rb +40 -40
- data/lib/cxxproject/utils/graphstream.rb +154 -154
- data/lib/cxxproject/utils/optional.rb +16 -16
- data/lib/cxxproject/utils/printer.rb +50 -50
- data/lib/cxxproject/utils/process.rb +52 -52
- data/lib/cxxproject/utils/progress.rb +66 -66
- data/lib/cxxproject/utils/progress_helper.rb +77 -77
- data/lib/cxxproject/utils/rbcurse.rb +284 -284
- data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -14
- data/lib/cxxproject/utils/rbcurse_progress.rb +71 -71
- data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -51
- data/lib/cxxproject/utils/stats.rb +60 -60
- data/lib/cxxproject/utils/ubigraph.rb +228 -228
- data/lib/cxxproject/utils/utils.rb +60 -37
- data/lib/cxxproject/utils/valgrind.rb +11 -11
- data/lib/cxxproject/version.rb +7 -7
- data/lib/tools/Rakefile.rb.template +10 -10
- data/lib/tools/project.rb.template +6 -6
- data/lib/tools/project_wizard.rb +66 -66
- data/spec/building_block_spec.rb +56 -56
- data/spec/cxxproject_2_rake_spec.rb +186 -186
- data/spec/file_ext_spec.rb +30 -30
- data/spec/ide_interface_spec.rb +41 -41
- data/spec/object_dependency_spec.rb +83 -83
- data/spec/project_path_spec.rb +71 -71
- data/spec/rake_listener_ext_spec.rb +58 -58
- data/spec/spec_helper.rb +18 -18
- data/spec/string_spec.rb +11 -11
- data/spec/testdata/basic/exe12/project.rb +5 -5
- data/spec/testdata/basic/lib1/project.rb +5 -5
- data/spec/testdata/basic/lib2/project.rb +8 -8
- data/spec/testdata/multiple_levels/libs/lib1/project.rb +5 -5
- data/spec/testdata/multiple_levels/libs/lib2/project.rb +19 -19
- data/spec/testdata/multiple_levels/mainproject/basic/project.rb +8 -8
- data/spec/testdata/onlyOneHeader/Rakefile.rb +4 -4
- data/spec/testdata/onlyOneHeader/project.rb +4 -4
- data/spec/toolchain_spec.rb +29 -29
- metadata +58 -58
data/Rakefile.rb
CHANGED
@@ -1,116 +1,116 @@
|
|
1
|
-
require 'rake/clean'
|
2
|
-
require './rake_helper/spec.rb'
|
3
|
-
|
4
|
-
desc "Default Task"
|
5
|
-
task :default => [:install]
|
6
|
-
|
7
|
-
|
8
|
-
begin
|
9
|
-
require 'rubygems/package_task'
|
10
|
-
spec = Gem::Specification.load('cxx.gemspec')
|
11
|
-
Gem::PackageTask.new(spec){|pkg|}
|
12
|
-
|
13
|
-
desc "install gem globally"
|
14
|
-
task :install => [:gem] do
|
15
|
-
sh "gem install pkg/#{spec.name}-#{spec.version}.gem"
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
begin
|
20
|
-
require 'rdoc'
|
21
|
-
require 'rdoc/task'
|
22
|
-
RDoc::Task.new do |rd|
|
23
|
-
rd.rdoc_files.include(spec.files)
|
24
|
-
end
|
25
|
-
rescue LoadError => e
|
26
|
-
task :rdoc do
|
27
|
-
puts 'please gem install rdoc'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
begin
|
31
|
-
require 'roodi'
|
32
|
-
require 'roodi_task'
|
33
|
-
class RoodiTask
|
34
|
-
def define
|
35
|
-
# copied from roodi_task.rb
|
36
|
-
desc "Check for design issues in: #{patterns.join(', ')}"
|
37
|
-
task name do
|
38
|
-
runner = Roodi::Core::Runner.new
|
39
|
-
runner.config = config if config
|
40
|
-
patterns.each do |pattern|
|
41
|
-
Dir.glob(pattern).each { |file| runner.check_file(file) }
|
42
|
-
end
|
43
|
-
runner.errors.each {|error| puts error}
|
44
|
-
# raise "Found #{runner.errors.size} errors." unless runner.errors.empty?
|
45
|
-
end
|
46
|
-
self
|
47
|
-
end
|
48
|
-
end
|
49
|
-
RoodiTask.new('roodi', spec.files)
|
50
|
-
task :gem => [:roodi]
|
51
|
-
rescue LoadError # don't bail out when people do not have roodi installed!
|
52
|
-
puts 'please gem install roodi'
|
53
|
-
end
|
54
|
-
rescue LoadError => e
|
55
|
-
puts "please missing gems #{e}"
|
56
|
-
end
|
57
|
-
|
58
|
-
def two_digits(x)
|
59
|
-
if x.length > 1
|
60
|
-
x
|
61
|
-
else
|
62
|
-
"0#{x}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
begin
|
67
|
-
require 'grit'
|
68
|
-
include Grit
|
69
|
-
|
70
|
-
def git_history
|
71
|
-
repo = Repo.new('.')
|
72
|
-
tag_names = repo.tags.collect {|t| t.name }
|
73
|
-
relevant_tags = repo.tags.reject {|t| !t.name.start_with?("v_")}
|
74
|
-
sorted_tags = relevant_tags.sort_by.each do |t|
|
75
|
-
/v_(?<x>\d+)\.(?<y>\d+)\.(?<z>\d+)/ =~ t.name
|
76
|
-
"#{two_digits(x)}-#{two_digits(y)}-#{two_digits(z)}"
|
77
|
-
end
|
78
|
-
|
79
|
-
change_text = []
|
80
|
-
zipped = sorted_tags[0..-2].zip(sorted_tags[1..-1])
|
81
|
-
zipped.reverse.each do |a,b|
|
82
|
-
change_text << ""
|
83
|
-
change_text << "#{a.name} => #{b.name}"
|
84
|
-
change_text << ""
|
85
|
-
cs = repo.commits_between(a.commit, b.commit)
|
86
|
-
cm = cs.each do |c|
|
87
|
-
change_lines = c.message.lines.to_a
|
88
|
-
first = change_lines.first
|
89
|
-
change_text << " * " + first + "#{change_lines[1..-1].collect {|l| " #{l}"}.join("")}"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
change_text
|
93
|
-
end
|
94
|
-
|
95
|
-
desc 'generate version history'
|
96
|
-
task :generate_history do
|
97
|
-
puts git_history
|
98
|
-
end
|
99
|
-
|
100
|
-
desc 'generate and update version history'
|
101
|
-
task :update_version_history do
|
102
|
-
change_line = "## Change History:"
|
103
|
-
readme = 'README.md'
|
104
|
-
content = File.read(readme)
|
105
|
-
File.open(readme, 'w') do |f|
|
106
|
-
f.puts content.gsub(/^#{change_line}.*/m, ([change_line] << git_history).join("\n"))
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
rescue LoadError => e
|
111
|
-
puts 'to build the version history please gem install grit'
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
require './rake_helper/perftools'
|
116
|
-
|
1
|
+
require 'rake/clean'
|
2
|
+
require './rake_helper/spec.rb'
|
3
|
+
|
4
|
+
desc "Default Task"
|
5
|
+
task :default => [:install]
|
6
|
+
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'rubygems/package_task'
|
10
|
+
spec = Gem::Specification.load('cxx.gemspec')
|
11
|
+
Gem::PackageTask.new(spec){|pkg|}
|
12
|
+
|
13
|
+
desc "install gem globally"
|
14
|
+
task :install => [:gem] do
|
15
|
+
sh "gem install pkg/#{spec.name}-#{spec.version}.gem"
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
begin
|
20
|
+
require 'rdoc'
|
21
|
+
require 'rdoc/task'
|
22
|
+
RDoc::Task.new do |rd|
|
23
|
+
rd.rdoc_files.include(spec.files)
|
24
|
+
end
|
25
|
+
rescue LoadError => e
|
26
|
+
task :rdoc do
|
27
|
+
puts 'please gem install rdoc'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
begin
|
31
|
+
require 'roodi'
|
32
|
+
require 'roodi_task'
|
33
|
+
class RoodiTask
|
34
|
+
def define
|
35
|
+
# copied from roodi_task.rb
|
36
|
+
desc "Check for design issues in: #{patterns.join(', ')}"
|
37
|
+
task name do
|
38
|
+
runner = Roodi::Core::Runner.new
|
39
|
+
runner.config = config if config
|
40
|
+
patterns.each do |pattern|
|
41
|
+
Dir.glob(pattern).each { |file| runner.check_file(file) }
|
42
|
+
end
|
43
|
+
runner.errors.each {|error| puts error}
|
44
|
+
# raise "Found #{runner.errors.size} errors." unless runner.errors.empty?
|
45
|
+
end
|
46
|
+
self
|
47
|
+
end
|
48
|
+
end
|
49
|
+
RoodiTask.new('roodi', spec.files)
|
50
|
+
task :gem => [:roodi]
|
51
|
+
rescue LoadError # don't bail out when people do not have roodi installed!
|
52
|
+
puts 'please gem install roodi'
|
53
|
+
end
|
54
|
+
rescue LoadError => e
|
55
|
+
puts "please missing gems #{e}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def two_digits(x)
|
59
|
+
if x.length > 1
|
60
|
+
x
|
61
|
+
else
|
62
|
+
"0#{x}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
begin
|
67
|
+
require 'grit'
|
68
|
+
include Grit
|
69
|
+
|
70
|
+
def git_history
|
71
|
+
repo = Repo.new('.')
|
72
|
+
tag_names = repo.tags.collect {|t| t.name }
|
73
|
+
relevant_tags = repo.tags.reject {|t| !t.name.start_with?("v_")}
|
74
|
+
sorted_tags = relevant_tags.sort_by.each do |t|
|
75
|
+
/v_(?<x>\d+)\.(?<y>\d+)\.(?<z>\d+)/ =~ t.name
|
76
|
+
"#{two_digits(x)}-#{two_digits(y)}-#{two_digits(z)}"
|
77
|
+
end
|
78
|
+
|
79
|
+
change_text = []
|
80
|
+
zipped = sorted_tags[0..-2].zip(sorted_tags[1..-1])
|
81
|
+
zipped.reverse.each do |a,b|
|
82
|
+
change_text << ""
|
83
|
+
change_text << "#{a.name} => #{b.name}"
|
84
|
+
change_text << ""
|
85
|
+
cs = repo.commits_between(a.commit, b.commit)
|
86
|
+
cm = cs.each do |c|
|
87
|
+
change_lines = c.message.lines.to_a
|
88
|
+
first = change_lines.first
|
89
|
+
change_text << " * " + first + "#{change_lines[1..-1].collect {|l| " #{l}"}.join("")}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
change_text
|
93
|
+
end
|
94
|
+
|
95
|
+
desc 'generate version history'
|
96
|
+
task :generate_history do
|
97
|
+
puts git_history
|
98
|
+
end
|
99
|
+
|
100
|
+
desc 'generate and update version history'
|
101
|
+
task :update_version_history do
|
102
|
+
change_line = "## Change History:"
|
103
|
+
readme = 'README.md'
|
104
|
+
content = File.read(readme)
|
105
|
+
File.open(readme, 'w') do |f|
|
106
|
+
f.puts content.gsub(/^#{change_line}.*/m, ([change_line] << git_history).join("\n"))
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
rescue LoadError => e
|
111
|
+
puts 'to build the version history please gem install grit'
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
require './rake_helper/perftools'
|
116
|
+
|
data/bin/cxx
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
3
|
-
|
4
|
-
require 'tools/project_wizard'
|
5
|
-
|
6
|
-
if ARGV.size < 1
|
7
|
-
puts "usage: cxx project-dir"
|
8
|
-
exit 0
|
9
|
-
end
|
10
|
-
prepare_project(ARGV[0])
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
3
|
+
|
4
|
+
require 'tools/project_wizard'
|
5
|
+
|
6
|
+
if ARGV.size < 1
|
7
|
+
puts "usage: cxx project-dir"
|
8
|
+
exit 0
|
9
|
+
end
|
10
|
+
prepare_project(ARGV[0])
|
data/lib/cxxproject.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
# Just the default file wich is auto-required in the gem and which requires all needed stuff
|
2
|
-
require 'rubygems'
|
3
|
-
require 'yaml'
|
4
|
-
require 'rake/clean'
|
5
|
-
|
6
|
-
require 'cxxproject/utils/optional'
|
7
|
-
|
8
|
-
require 'cxxproject/ext/string'
|
9
|
-
require 'cxxproject/utils/utils'
|
10
|
-
require 'cxxproject/torake'
|
11
|
-
require 'cxxproject/utils/ubigraph'
|
12
|
-
require 'cxxproject/utils/graphstream'
|
13
|
-
require 'cxxproject/toolchain/provider'
|
14
|
-
|
15
|
-
require 'cxxproject/utils/progress'
|
16
|
-
require 'cxxproject/utils/rbcurse'
|
17
|
-
require 'cxxproject/utils/progress'
|
18
|
-
require 'cxxproject/utils/rbcurse'
|
19
|
-
require 'cxxproject/utils/stats'
|
20
|
-
|
21
|
-
include Cxxproject::Toolchain
|
22
|
-
CxxProject2Rake = Cxxproject::CxxProject2Rake
|
23
|
-
BinaryLibs = Cxxproject::BinaryLibs
|
1
|
+
# Just the default file wich is auto-required in the gem and which requires all needed stuff
|
2
|
+
require 'rubygems'
|
3
|
+
require 'yaml'
|
4
|
+
require 'rake/clean'
|
5
|
+
|
6
|
+
require 'cxxproject/utils/optional'
|
7
|
+
|
8
|
+
require 'cxxproject/ext/string'
|
9
|
+
require 'cxxproject/utils/utils'
|
10
|
+
require 'cxxproject/torake'
|
11
|
+
require 'cxxproject/utils/ubigraph'
|
12
|
+
require 'cxxproject/utils/graphstream'
|
13
|
+
require 'cxxproject/toolchain/provider'
|
14
|
+
|
15
|
+
require 'cxxproject/utils/progress'
|
16
|
+
require 'cxxproject/utils/rbcurse'
|
17
|
+
require 'cxxproject/utils/progress'
|
18
|
+
require 'cxxproject/utils/rbcurse'
|
19
|
+
require 'cxxproject/utils/stats'
|
20
|
+
|
21
|
+
include Cxxproject::Toolchain
|
22
|
+
CxxProject2Rake = Cxxproject::CxxProject2Rake
|
23
|
+
BinaryLibs = Cxxproject::BinaryLibs
|
@@ -1,39 +1,39 @@
|
|
1
|
-
require 'cxxproject/buildingblocks/building_block'
|
2
|
-
require 'cxxproject/buildingblocks/has_libraries_mixin'
|
3
|
-
require 'cxxproject/buildingblocks/has_includes_mixin'
|
4
|
-
|
5
|
-
module Cxxproject
|
6
|
-
|
7
|
-
class BinaryLibrary < BuildingBlock
|
8
|
-
include HasLibraries
|
9
|
-
include HasIncludes
|
10
|
-
|
11
|
-
def initialize(name, useNameAsLib = true)
|
12
|
-
super(name)
|
13
|
-
if useNameAsLib
|
14
|
-
@useNameAsLib = name
|
15
|
-
add_lib_element(HasLibraries::LIB, name, true)
|
16
|
-
else
|
17
|
-
@useNameAsLib = nil
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def get_task_name()
|
22
|
-
return @useNameAsLib if @useNameAsLib
|
23
|
-
@name
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
def convert_to_rake()
|
28
|
-
res = task get_task_name
|
29
|
-
def res.needed?
|
30
|
-
return false
|
31
|
-
end
|
32
|
-
res.transparent_timestamp = true
|
33
|
-
res.type = Rake::Task::BINARY
|
34
|
-
setup_rake_dependencies(res)
|
35
|
-
res
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
1
|
+
require 'cxxproject/buildingblocks/building_block'
|
2
|
+
require 'cxxproject/buildingblocks/has_libraries_mixin'
|
3
|
+
require 'cxxproject/buildingblocks/has_includes_mixin'
|
4
|
+
|
5
|
+
module Cxxproject
|
6
|
+
|
7
|
+
class BinaryLibrary < BuildingBlock
|
8
|
+
include HasLibraries
|
9
|
+
include HasIncludes
|
10
|
+
|
11
|
+
def initialize(name, useNameAsLib = true)
|
12
|
+
super(name)
|
13
|
+
if useNameAsLib
|
14
|
+
@useNameAsLib = name
|
15
|
+
add_lib_element(HasLibraries::LIB, name, true)
|
16
|
+
else
|
17
|
+
@useNameAsLib = nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_task_name()
|
22
|
+
return @useNameAsLib if @useNameAsLib
|
23
|
+
@name
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def convert_to_rake()
|
28
|
+
res = task get_task_name
|
29
|
+
def res.needed?
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
res.transparent_timestamp = true
|
33
|
+
res.type = Rake::Task::BINARY
|
34
|
+
setup_rake_dependencies(res)
|
35
|
+
res
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -1,239 +1,251 @@
|
|
1
|
-
require 'cxxproject/buildingblocks/has_dependencies_mixin'
|
2
|
-
require 'cxxproject/utils/exit_helper'
|
3
|
-
require 'cxxproject/ext/rake'
|
4
|
-
require 'cxxproject/ext/file'
|
5
|
-
require 'cxxproject/ide_interface'
|
6
|
-
require 'cxxproject/utils/printer'
|
7
|
-
|
8
|
-
# no deprecated warning for rake >= 0.9.x
|
9
|
-
include Rake::DSL if defined?(Rake::DSL)
|
10
|
-
module Cxxproject
|
11
|
-
|
12
|
-
# stores all defined buildingblocks by name (the name should be unique)
|
13
|
-
ALL_BUILDING_BLOCKS = {}
|
14
|
-
|
15
|
-
trap("INT") do
|
16
|
-
Rake.application.idei.set_abort(true)
|
17
|
-
end
|
18
|
-
|
19
|
-
class BuildingBlock
|
20
|
-
include HasDependencies
|
21
|
-
|
22
|
-
attr_reader :name
|
23
|
-
attr_reader :config_name
|
24
|
-
attr_reader :config_files
|
25
|
-
|
26
|
-
attr_reader :project_dir
|
27
|
-
attr_accessor :output_dir
|
28
|
-
attr_accessor :pre_step
|
29
|
-
attr_reader :output_dir_abs
|
30
|
-
|
31
|
-
def set_name(x)
|
32
|
-
@name = x
|
33
|
-
self
|
34
|
-
end
|
35
|
-
|
36
|
-
def set_tcs(x)
|
37
|
-
@tcs = x
|
38
|
-
self
|
39
|
-
end
|
40
|
-
|
41
|
-
def has_tcs?
|
42
|
-
@tcs != nil
|
43
|
-
end
|
44
|
-
|
45
|
-
def tcs()
|
46
|
-
raise "Toolchain settings must be set before!" if @tcs.nil?
|
47
|
-
@tcs
|
48
|
-
end
|
49
|
-
|
50
|
-
def set_config_files(x)
|
51
|
-
@config_files = x
|
52
|
-
@config_date = Time.now
|
53
|
-
self
|
54
|
-
end
|
55
|
-
|
56
|
-
def set_project_dir(x)
|
57
|
-
@project_dir = File.expand_path(x)
|
58
|
-
if @output_dir_abs
|
59
|
-
@output_dir_relPath = File.rel_from_to_project(@project_dir, @output_dir)
|
60
|
-
end
|
61
|
-
self
|
62
|
-
end
|
63
|
-
|
64
|
-
# if output dir is absolute, -L and -l is used for linker ("linux mode")
|
65
|
-
def set_output_dir(x)
|
66
|
-
return self if @output_dir
|
67
|
-
|
68
|
-
@output_dir = x
|
69
|
-
@output_dir_abs = File.is_absolute?(@output_dir)
|
70
|
-
if @project_dir
|
71
|
-
@output_dir_relPath = File.rel_from_to_project(@project_dir, @output_dir)
|
72
|
-
end
|
73
|
-
self
|
74
|
-
end
|
75
|
-
|
76
|
-
def complete_output_dir
|
77
|
-
@complete_output_dir ||= calc_complete_output_dir
|
78
|
-
end
|
79
|
-
|
80
|
-
def calc_complete_output_dir
|
81
|
-
if @output_dir_abs
|
82
|
-
@output_dir
|
83
|
-
else
|
84
|
-
File.join(@project_dir, @output_dir)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def initialize(name)
|
89
|
-
@name = name
|
90
|
-
@config_name = nil
|
91
|
-
@config_files = []
|
92
|
-
@config_date = nil
|
93
|
-
@project_dir = nil
|
94
|
-
@tcs = nil
|
95
|
-
@output_dir = nil
|
96
|
-
@output_dir_abs = false
|
97
|
-
@complete_output_dir = nil
|
98
|
-
@pre_step = nil
|
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
|
-
rescue
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
CLEAN.include(
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
if
|
166
|
-
|
167
|
-
exedIn = "
|
168
|
-
if
|
169
|
-
|
170
|
-
|
171
|
-
puts cmd + exedIn
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
1
|
+
require 'cxxproject/buildingblocks/has_dependencies_mixin'
|
2
|
+
require 'cxxproject/utils/exit_helper'
|
3
|
+
require 'cxxproject/ext/rake'
|
4
|
+
require 'cxxproject/ext/file'
|
5
|
+
require 'cxxproject/ide_interface'
|
6
|
+
require 'cxxproject/utils/printer'
|
7
|
+
|
8
|
+
# no deprecated warning for rake >= 0.9.x
|
9
|
+
include Rake::DSL if defined?(Rake::DSL)
|
10
|
+
module Cxxproject
|
11
|
+
|
12
|
+
# stores all defined buildingblocks by name (the name should be unique)
|
13
|
+
ALL_BUILDING_BLOCKS = {}
|
14
|
+
|
15
|
+
trap("INT") do
|
16
|
+
Rake.application.idei.set_abort(true)
|
17
|
+
end
|
18
|
+
|
19
|
+
class BuildingBlock
|
20
|
+
include HasDependencies
|
21
|
+
|
22
|
+
attr_reader :name
|
23
|
+
attr_reader :config_name
|
24
|
+
attr_reader :config_files
|
25
|
+
|
26
|
+
attr_reader :project_dir
|
27
|
+
attr_accessor :output_dir
|
28
|
+
attr_accessor :pre_step
|
29
|
+
attr_reader :output_dir_abs
|
30
|
+
|
31
|
+
def set_name(x)
|
32
|
+
@name = x
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_tcs(x)
|
37
|
+
@tcs = x
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def has_tcs?
|
42
|
+
@tcs != nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def tcs()
|
46
|
+
raise "Toolchain settings must be set before!" if @tcs.nil?
|
47
|
+
@tcs
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_config_files(x)
|
51
|
+
@config_files = x
|
52
|
+
@config_date = Time.now
|
53
|
+
self
|
54
|
+
end
|
55
|
+
|
56
|
+
def set_project_dir(x)
|
57
|
+
@project_dir = File.expand_path(x)
|
58
|
+
if @output_dir_abs
|
59
|
+
@output_dir_relPath = File.rel_from_to_project(@project_dir, @output_dir)
|
60
|
+
end
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
64
|
+
# if output dir is absolute, -L and -l is used for linker ("linux mode")
|
65
|
+
def set_output_dir(x)
|
66
|
+
return self if @output_dir
|
67
|
+
|
68
|
+
@output_dir = x
|
69
|
+
@output_dir_abs = File.is_absolute?(@output_dir)
|
70
|
+
if @project_dir
|
71
|
+
@output_dir_relPath = File.rel_from_to_project(@project_dir, @output_dir)
|
72
|
+
end
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
76
|
+
def complete_output_dir
|
77
|
+
@complete_output_dir ||= calc_complete_output_dir
|
78
|
+
end
|
79
|
+
|
80
|
+
def calc_complete_output_dir
|
81
|
+
if @output_dir_abs
|
82
|
+
@output_dir
|
83
|
+
else
|
84
|
+
File.join(@project_dir, @output_dir)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def initialize(name)
|
89
|
+
@name = name
|
90
|
+
@config_name = nil
|
91
|
+
@config_files = []
|
92
|
+
@config_date = nil
|
93
|
+
@project_dir = nil
|
94
|
+
@tcs = nil
|
95
|
+
@output_dir = nil
|
96
|
+
@output_dir_abs = false
|
97
|
+
@complete_output_dir = nil
|
98
|
+
@pre_step = nil
|
99
|
+
@printedCmdAlternate = false
|
100
|
+
@lastCommand = nil
|
101
|
+
|
102
|
+
if ALL_BUILDING_BLOCKS.include?(@name) and not self.instance_of?(BinaryLibrary)
|
103
|
+
raise "building block already exists: #{name}"
|
104
|
+
else
|
105
|
+
ALL_BUILDING_BLOCKS[@name] = self
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def set_config_name(x)
|
110
|
+
@config_name = x
|
111
|
+
end
|
112
|
+
|
113
|
+
def complete_init()
|
114
|
+
if self.respond_to?(:calc_compiler_strings)
|
115
|
+
calc_compiler_strings
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def get_task_name()
|
120
|
+
raise "this method must be implemented by decendants"
|
121
|
+
end
|
122
|
+
|
123
|
+
##
|
124
|
+
# convert all dependencies of a building block to rake task prerequisites (e.g. exe needs lib)
|
125
|
+
#
|
126
|
+
def setup_rake_dependencies(task, multitask = nil)
|
127
|
+
dependencies.reverse_each do |d|
|
128
|
+
begin
|
129
|
+
bb = ALL_BUILDING_BLOCKS[d]
|
130
|
+
raise "Error: tried to add the dependencies of \"#{d}\" to \"#{@name}\" but such a building block could not be found!" unless bb
|
131
|
+
|
132
|
+
if multitask and bb.pre_step
|
133
|
+
multitask.prerequisites.unshift(bb.get_task_name)
|
134
|
+
else
|
135
|
+
task.prerequisites.unshift(bb.get_task_name)
|
136
|
+
end
|
137
|
+
rescue ExitHelperException
|
138
|
+
raise
|
139
|
+
rescue Exception => e
|
140
|
+
Printer.printError e.message
|
141
|
+
ExitHelper.exit(1)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
task
|
146
|
+
end
|
147
|
+
|
148
|
+
def add_output_dir_dependency(file, taskOfFile, addDirToCleanTask)
|
149
|
+
d = File.dirname(file)
|
150
|
+
directory d
|
151
|
+
taskOfFile.enhance([d])
|
152
|
+
|
153
|
+
if addDirToCleanTask
|
154
|
+
CLOBBER.include(complete_output_dir)
|
155
|
+
if (@output_dir_abs)
|
156
|
+
CLEAN.include(file)
|
157
|
+
else
|
158
|
+
CLEAN.include(complete_output_dir)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def printCmd(cmd, alternate, showPath)
|
164
|
+
@lastCommand = cmd
|
165
|
+
if showPath or RakeFileUtils.verbose or (alternate.nil? and not Rake::application.options.silent)
|
166
|
+
@printedCmdAlternate = false
|
167
|
+
exedIn = ""
|
168
|
+
exedIn = " (executed in '#{@project_dir}')" if (showPath or RakeFileUtils.verbose)
|
169
|
+
puts "" if Rake::application.addEmptyLine
|
170
|
+
if cmd.is_a?(Array)
|
171
|
+
puts cmd.join(' ') + exedIn
|
172
|
+
else
|
173
|
+
puts cmd + exedIn
|
174
|
+
end
|
175
|
+
else
|
176
|
+
@printedCmdAlternate = true
|
177
|
+
puts alternate unless Rake::application.options.silent
|
178
|
+
end
|
179
|
+
@lastCommand = cmd
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
def process_result(cmd, console_output, error_parser, alternate)
|
184
|
+
hasError = ($?.success? == false)
|
185
|
+
if (cmd != @lastCommand) or (@printedCmdAlternate and hasError)
|
186
|
+
printCmd(cmd, alternate, hasError)
|
187
|
+
end
|
188
|
+
errorPrinted = process_console_output(console_output, error_parser)
|
189
|
+
|
190
|
+
if hasError
|
191
|
+
if not errorPrinted
|
192
|
+
Printer.printError "Error: system command failed"
|
193
|
+
res = ErrorDesc.new
|
194
|
+
res.file_name = @project_dir
|
195
|
+
res.line_number = 0
|
196
|
+
res.message = "Unknown error, see log output. Maybe the lake error parser has to be updated..."
|
197
|
+
res.severity = ErrorParser::SEVERITY_ERROR
|
198
|
+
Rake.application.idei.set_errors([res])
|
199
|
+
end
|
200
|
+
end
|
201
|
+
if hasError or errorPrinted
|
202
|
+
raise SystemCommandFailed.new
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def read_file_or_empty_string(filename)
|
207
|
+
begin
|
208
|
+
return File.read(filename)
|
209
|
+
rescue
|
210
|
+
return ""
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def typed_file_task(type, *args, &block)
|
215
|
+
t = file *args do
|
216
|
+
block.call
|
217
|
+
end
|
218
|
+
t.type = type
|
219
|
+
t.progress_count = 1
|
220
|
+
return t
|
221
|
+
end
|
222
|
+
|
223
|
+
def remove_empty_strings_and_join(a, j=' ')
|
224
|
+
return a.reject{|e|e.to_s.empty?}.join(j)
|
225
|
+
end
|
226
|
+
|
227
|
+
def catch_output(cmd)
|
228
|
+
new_command = "#{cmd} 2>&1"
|
229
|
+
# "/" does not work on windows with backticks, switch the separator on windows:
|
230
|
+
new_command.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
|
231
|
+
return `#{new_command}`
|
232
|
+
end
|
233
|
+
|
234
|
+
def check_config_file()
|
235
|
+
if @config_date
|
236
|
+
@config_files.each do |c|
|
237
|
+
err_msg = nil
|
238
|
+
if File.exists?(c) and File.mtime(c) > @config_date
|
239
|
+
@config_date = File.mtime(c)
|
240
|
+
begin
|
241
|
+
FileUtils.touch(c)
|
242
|
+
rescue Exception
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|