cxxproject 0.4.6 → 0.5.47
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/Rakefile.rb +101 -54
- data/bin/cxx +4 -4
- data/lib/cxxproject/buildingblocks/binary_library.rb +32 -9
- data/lib/cxxproject/buildingblocks/building_block.rb +220 -74
- data/lib/cxxproject/buildingblocks/command_line.rb +70 -21
- data/lib/cxxproject/buildingblocks/custom_building_block.rb +33 -9
- data/lib/cxxproject/buildingblocks/executable.rb +228 -33
- data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +69 -43
- data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -0
- data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +29 -30
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +343 -64
- data/lib/cxxproject/buildingblocks/makefile.rb +142 -24
- data/lib/cxxproject/buildingblocks/module.rb +27 -6
- data/lib/cxxproject/buildingblocks/single_source.rb +26 -4
- data/lib/cxxproject/buildingblocks/source_library.rb +113 -20
- data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -0
- data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +33 -0
- data/lib/cxxproject/errorparser/error_parser.rb +50 -0
- data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +30 -0
- data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +29 -0
- data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -0
- data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +29 -0
- data/lib/cxxproject/eval_context.rb +136 -0
- data/lib/cxxproject/ext/file.rb +71 -0
- data/lib/cxxproject/ext/filelist.rb +6 -0
- data/lib/cxxproject/ext/progressbar.rb +20 -0
- data/lib/cxxproject/ext/rake.rb +397 -0
- data/lib/cxxproject/{extensions/rake_listener_ext.rb → ext/rake_listener.rb} +18 -12
- data/lib/cxxproject/ext/stdout.rb +44 -0
- data/lib/cxxproject/ide_interface.rb +181 -0
- data/lib/cxxproject/toolchain/clang.rb +39 -0
- data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -0
- data/lib/cxxproject/toolchain/diab.rb +36 -33
- data/lib/cxxproject/toolchain/gcc.rb +16 -8
- data/lib/cxxproject/toolchain/provider.rb +112 -2
- data/lib/cxxproject/toolchain/ti.rb +50 -0
- data/lib/cxxproject/toolchain/toolchain.rb +38 -0
- data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -0
- data/lib/cxxproject/torake.rb +181 -123
- data/lib/cxxproject/utils/cleanup.rb +20 -0
- data/lib/cxxproject/utils/console.rb +6 -0
- data/lib/cxxproject/utils/exit_helper.rb +40 -0
- data/lib/cxxproject/utils/graphstream.rb +154 -0
- data/lib/cxxproject/utils/optional.rb +16 -0
- data/lib/cxxproject/utils/printer.rb +50 -0
- data/lib/cxxproject/utils/process.rb +53 -0
- data/lib/cxxproject/utils/progress.rb +66 -0
- data/lib/cxxproject/utils/progress_helper.rb +77 -0
- data/lib/cxxproject/utils/rbcurse.rb +284 -0
- data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -0
- data/lib/cxxproject/utils/rbcurse_progress.rb +71 -0
- data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -0
- data/lib/cxxproject/utils/stats.rb +60 -0
- data/lib/cxxproject/utils/ubigraph.rb +179 -188
- data/lib/cxxproject/utils/utils.rb +29 -25
- data/lib/cxxproject/version.rb +7 -0
- data/lib/cxxproject.rb +13 -7
- data/lib/tools/project_wizard.rb +66 -0
- data/spec/building_block_spec.rb +50 -6
- data/spec/{build_dependencies_spec.rb → cxxproject_2_rake_spec.rb} +82 -65
- data/spec/file_ext_spec.rb +30 -0
- data/spec/ide_interface_spec.rb +41 -0
- data/spec/object_dependency_spec.rb +83 -0
- data/spec/project_path_spec.rb +14 -16
- data/spec/rake_listener_ext_spec.rb +38 -5
- data/spec/spec_helper.rb +18 -0
- data/spec/testdata/basic/lib2/project.rb +1 -1
- data/spec/testdata/multiple_levels/libs/lib2/project.rb +1 -1
- data/spec/toolchain_spec.rb +29 -0
- metadata +91 -58
- data/lib/cxxproject/extensions/file_ext.rb +0 -47
- data/lib/cxxproject/extensions/rake_ext.rb +0 -158
- data/lib/cxxproject/extensions/stdout_ext.rb +0 -35
- data/lib/cxxproject/task_maker.rb +0 -418
- data/lib/cxxproject/testinstanceeval.rb +0 -65
- data/lib/cxxproject/toolchain/base.rb +0 -98
- data/lib/cxxproject/torake/compiler.rb +0 -10
- data/lib/cxxproject/torake/gcccompiler.rb +0 -7
- data/lib/cxxproject/torake/osxcompiler.rb +0 -7
- data/lib/cxxproject/utils/dot/building_block_graph_writer.rb +0 -19
- data/lib/cxxproject/utils/dot/graph_writer.rb +0 -53
- data/lib/cxxproject/utils/dot/task_graph_writer.rb +0 -34
- data/lib/tools/projectWizard.rb +0 -44
- data/spec/dir_spec.rb +0 -13
- /data/lib/cxxproject/{extensions/rake_dirty_ext.rb → ext/rake_dirty.rb} +0 -0
- /data/lib/cxxproject/{extensions/string_ext.rb → ext/string.rb} +0 -0
data/Rakefile.rb
CHANGED
|
@@ -1,69 +1,116 @@
|
|
|
1
|
-
require 'rake/
|
|
2
|
-
|
|
3
|
-
require 'roodi'
|
|
4
|
-
require 'roodi_task'
|
|
5
|
-
rescue LoadError # don't bail out when people do not have roodi installed!
|
|
6
|
-
warn "roodi not installed...will not be checked!"
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
begin
|
|
10
|
-
require 'spec/rake/spectask' # old rspec
|
|
11
|
-
rescue LoadError
|
|
12
|
-
begin
|
|
13
|
-
require 'rspec/core/rake_task' # rspec 2.5.x
|
|
14
|
-
rescue LoadError
|
|
15
|
-
warn "spec not installed...will not be checked!"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
require 'rake/clean'
|
|
2
|
+
require './rake_helper/spec.rb'
|
|
20
3
|
|
|
21
4
|
desc "Default Task"
|
|
22
5
|
task :default => [:install]
|
|
23
6
|
|
|
24
|
-
PKG_FILES = FileList[
|
|
25
|
-
'lib/**/*.rb',
|
|
26
|
-
'lib/tools/**/*.template',
|
|
27
|
-
'Rakefile.rb',
|
|
28
|
-
'spec/**/*.rb'
|
|
29
|
-
]
|
|
30
7
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
34
17
|
|
|
35
|
-
if self.class.const_defined?(:RoodiTask) then
|
|
36
|
-
RoodiTask.new 'roodi', PKG_FILES, 'roodi.yml'
|
|
37
|
-
task :gem => [:roodi]
|
|
38
|
-
end
|
|
39
18
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
45
29
|
end
|
|
46
|
-
|
|
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}"
|
|
47
56
|
end
|
|
48
57
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
t.pattern = 'spec/**/*_spec.rb'
|
|
58
|
+
def two_digits(x)
|
|
59
|
+
if x.length > 1
|
|
60
|
+
x
|
|
61
|
+
else
|
|
62
|
+
"0#{x}"
|
|
55
63
|
end
|
|
56
|
-
# task :gem => [:spec]
|
|
57
|
-
rescue
|
|
58
64
|
end
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
mv FileList["*.gem"], "pkg"
|
|
64
|
-
end
|
|
66
|
+
begin
|
|
67
|
+
require 'grit'
|
|
68
|
+
include Grit
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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'
|
|
69
112
|
end
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
require './rake_helper/perftools'
|
|
116
|
+
|
data/bin/cxx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#!/usr/bin/ruby
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
2
|
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
|
3
3
|
|
|
4
|
-
require 'tools/
|
|
4
|
+
require 'tools/project_wizard'
|
|
5
5
|
|
|
6
|
-
if ARGV.size < 1
|
|
7
|
-
puts "usage: cxx project-dir"
|
|
6
|
+
if ARGV.size < 1
|
|
7
|
+
puts "usage: cxx project-dir"
|
|
8
8
|
exit 0
|
|
9
9
|
end
|
|
10
10
|
prepare_project(ARGV[0])
|
|
@@ -1,16 +1,39 @@
|
|
|
1
1
|
require 'cxxproject/buildingblocks/building_block'
|
|
2
2
|
require 'cxxproject/buildingblocks/has_libraries_mixin'
|
|
3
|
+
require 'cxxproject/buildingblocks/has_includes_mixin'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
include HasLibraries
|
|
5
|
+
module Cxxproject
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
end
|
|
7
|
+
class BinaryLibrary < BuildingBlock
|
|
8
|
+
include HasLibraries
|
|
9
|
+
include HasIncludes
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
15
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
|
|
16
39
|
end
|
|
@@ -1,93 +1,239 @@
|
|
|
1
1
|
require 'cxxproject/buildingblocks/has_dependencies_mixin'
|
|
2
|
-
require 'cxxproject/utils/
|
|
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'
|
|
3
7
|
|
|
4
|
-
#
|
|
5
|
-
|
|
8
|
+
# no deprecated warning for rake >= 0.9.x
|
|
9
|
+
include Rake::DSL if defined?(Rake::DSL)
|
|
10
|
+
module Cxxproject
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
# stores all defined buildingblocks by name (the name should be unique)
|
|
13
|
+
ALL_BUILDING_BLOCKS = {}
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
attr_reader :config_files
|
|
13
|
-
attr_reader :project_dir
|
|
14
|
-
attr_reader :output_dir
|
|
15
|
-
attr_reader :complete_output_dir
|
|
16
|
-
|
|
17
|
-
def set_name(x)
|
|
18
|
-
@name = x
|
|
19
|
-
self
|
|
15
|
+
trap("INT") do
|
|
16
|
+
Rake.application.idei.set_abort(true)
|
|
20
17
|
end
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
self
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def has_tcs?
|
|
28
|
-
@tcs != nil
|
|
29
|
-
end
|
|
19
|
+
class BuildingBlock
|
|
20
|
+
include HasDependencies
|
|
30
21
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
end
|
|
22
|
+
attr_reader :name
|
|
23
|
+
attr_reader :config_name
|
|
24
|
+
attr_reader :config_files
|
|
35
25
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
attr_reader :project_dir
|
|
27
|
+
attr_accessor :output_dir
|
|
28
|
+
attr_accessor :pre_step
|
|
29
|
+
attr_reader :output_dir_abs
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
end
|
|
31
|
+
def set_name(x)
|
|
32
|
+
@name = x
|
|
33
|
+
self
|
|
34
|
+
end
|
|
46
35
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
calc_complete_output_dir
|
|
52
|
-
self
|
|
53
|
-
end
|
|
36
|
+
def set_tcs(x)
|
|
37
|
+
@tcs = x
|
|
38
|
+
self
|
|
39
|
+
end
|
|
54
40
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
@complete_output_dir = @output_dir
|
|
58
|
-
else
|
|
59
|
-
@complete_output_dir = @project_dir + "/" + @output_dir
|
|
41
|
+
def has_tcs?
|
|
42
|
+
@tcs != nil
|
|
60
43
|
end
|
|
61
|
-
end
|
|
62
44
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
def tcs()
|
|
46
|
+
raise "Toolchain settings must be set before!" if @tcs.nil?
|
|
47
|
+
@tcs
|
|
48
|
+
end
|
|
67
49
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
@project_dir = "."
|
|
73
|
-
@output_dir = "."
|
|
74
|
-
@complete_output_dir = "."
|
|
75
|
-
@tcs = nil
|
|
76
|
-
@output_dir_abs = false
|
|
77
|
-
|
|
78
|
-
begin
|
|
79
|
-
raise "building block already exists: #{name}" if ALL_BUILDING_BLOCKS.include?@name
|
|
80
|
-
ALL_BUILDING_BLOCKS[@name] = self
|
|
81
|
-
rescue Exception => e
|
|
82
|
-
puts e
|
|
50
|
+
def set_config_files(x)
|
|
51
|
+
@config_files = x
|
|
52
|
+
@config_date = Time.now
|
|
53
|
+
self
|
|
83
54
|
end
|
|
84
|
-
end
|
|
85
55
|
|
|
86
|
-
|
|
87
|
-
|
|
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
|
|
88
63
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
if ALL_BUILDING_BLOCKS.include?(@name) and not self.instance_of?(BinaryLibrary)
|
|
101
|
+
raise "building block already exists: #{name}"
|
|
102
|
+
else
|
|
103
|
+
ALL_BUILDING_BLOCKS[@name] = self
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def set_config_name(x)
|
|
108
|
+
@config_name = x
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def complete_init()
|
|
112
|
+
if self.respond_to?(:calc_compiler_strings)
|
|
113
|
+
calc_compiler_strings
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def get_task_name()
|
|
118
|
+
raise "this method must be implemented by decendants"
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
##
|
|
122
|
+
# convert all dependencies of a building block to rake task prerequisites (e.g. exe needs lib)
|
|
123
|
+
#
|
|
124
|
+
def setup_rake_dependencies(task, multitask = nil)
|
|
125
|
+
dependencies.reverse_each do |d|
|
|
126
|
+
begin
|
|
127
|
+
bb = ALL_BUILDING_BLOCKS[d]
|
|
128
|
+
raise "Error: tried to add the dependencies of \"#{d}\" to \"#{@name}\" but such a building block could not be found!" unless bb
|
|
129
|
+
|
|
130
|
+
if multitask and bb.pre_step
|
|
131
|
+
multitask.prerequisites.unshift(bb.get_task_name)
|
|
132
|
+
else
|
|
133
|
+
task.prerequisites.unshift(bb.get_task_name)
|
|
134
|
+
end
|
|
135
|
+
rescue ExitHelperException
|
|
136
|
+
raise
|
|
137
|
+
rescue Exception => e
|
|
138
|
+
Printer.printError e.message
|
|
139
|
+
ExitHelper.exit(1)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
task
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def add_output_dir_dependency(file, taskOfFile, addDirToCleanTask)
|
|
147
|
+
d = File.dirname(file)
|
|
148
|
+
directory d
|
|
149
|
+
taskOfFile.enhance([d])
|
|
150
|
+
|
|
151
|
+
if addDirToCleanTask
|
|
152
|
+
CLOBBER.include(complete_output_dir)
|
|
153
|
+
if (@output_dir_abs)
|
|
154
|
+
CLEAN.include(file)
|
|
155
|
+
else
|
|
156
|
+
CLEAN.include(complete_output_dir)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def process_result(cmd, console_output, error_parser, alternate)
|
|
162
|
+
|
|
163
|
+
hasError = ($?.success? == false)
|
|
164
|
+
|
|
165
|
+
if hasError or RakeFileUtils.verbose or (alternate.nil? and not Rake::application.options.silent)
|
|
166
|
+
exedIn = ""
|
|
167
|
+
exedIn = " (executed in '#{@project_dir}')" if (hasError or RakeFileUtils.verbose)
|
|
168
|
+
if cmd.is_a?(Array)
|
|
169
|
+
puts cmd.join(' ') + exedIn
|
|
170
|
+
else
|
|
171
|
+
puts cmd + exedIn
|
|
172
|
+
end
|
|
173
|
+
else
|
|
174
|
+
puts alternate unless Rake::application.options.silent
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
errorPrinted = process_console_output(console_output, error_parser)
|
|
178
|
+
|
|
179
|
+
if hasError
|
|
180
|
+
if not errorPrinted
|
|
181
|
+
Printer.printError "Error: system command failed"
|
|
182
|
+
res = ErrorDesc.new
|
|
183
|
+
res.file_name = @project_dir
|
|
184
|
+
res.line_number = 0
|
|
185
|
+
res.message = "Unknown error, see log output. Maybe the lake error parser has to be updated..."
|
|
186
|
+
res.severity = ErrorParser::SEVERITY_ERROR
|
|
187
|
+
Rake.application.idei.set_errors([res])
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
raise SystemCommandFailed.new
|
|
191
|
+
end
|
|
192
|
+
end
|
|
92
193
|
|
|
194
|
+
def read_file_or_empty_string(filename)
|
|
195
|
+
begin
|
|
196
|
+
return File.read(filename)
|
|
197
|
+
rescue
|
|
198
|
+
return ""
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def typed_file_task(type, *args, &block)
|
|
203
|
+
t = file *args do
|
|
204
|
+
block.call
|
|
205
|
+
end
|
|
206
|
+
t.type = type
|
|
207
|
+
t.progress_count = 1
|
|
208
|
+
return t
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def remove_empty_strings_and_join(a, j=' ')
|
|
212
|
+
return a.reject{|e|e.to_s.empty?}.join(j)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def catch_output(cmd)
|
|
216
|
+
new_command = "#{cmd} 2>&1"
|
|
217
|
+
# "/" does not work on windows with backticks, switch the separator on windows:
|
|
218
|
+
new_command.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
|
|
219
|
+
return `#{new_command}`
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def check_config_file()
|
|
223
|
+
if @config_date
|
|
224
|
+
@config_files.each do |c|
|
|
225
|
+
err_msg = nil
|
|
226
|
+
if File.exists?(c) and File.mtime(c) > @config_date
|
|
227
|
+
@config_date = File.mtime(c)
|
|
228
|
+
begin
|
|
229
|
+
FileUtils.touch(c)
|
|
230
|
+
rescue Exception
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
end
|
|
238
|
+
|
|
93
239
|
end
|
|
@@ -1,30 +1,79 @@
|
|
|
1
1
|
require 'cxxproject/buildingblocks/building_block'
|
|
2
|
+
require 'cxxproject/utils/process'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
module Cxxproject
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
@line = x
|
|
7
|
-
self
|
|
8
|
-
end
|
|
6
|
+
class CommandLine < BuildingBlock
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
def set_command_line(x)
|
|
9
|
+
@line = x
|
|
10
|
+
self
|
|
11
|
+
end
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
def get_command_line
|
|
14
|
+
@line
|
|
15
|
+
end
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@@command_line_num = @@command_line_num + 1
|
|
23
|
-
@num = @@command_line_num
|
|
24
|
-
end
|
|
17
|
+
def set_defined_in_file(x)
|
|
18
|
+
@defined_in_file = x
|
|
19
|
+
self
|
|
20
|
+
end
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
def get_defined_in_file
|
|
23
|
+
@defined_in_file
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def set_defined_in_line(x)
|
|
27
|
+
@defined_in_line = x
|
|
28
|
+
self
|
|
29
|
+
end
|
|
29
30
|
|
|
31
|
+
def get_defined_in_line
|
|
32
|
+
@defined_in_line
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def initialize(name)
|
|
36
|
+
set_command_line(name)
|
|
37
|
+
@num = Rake.application.command_line_number
|
|
38
|
+
super(get_task_name)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def get_task_name()
|
|
42
|
+
"command line (#{@num}): " + get_command_line
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def convert_to_rake()
|
|
46
|
+
res = task get_task_name do
|
|
47
|
+
Dir.chdir(@project_dir) do
|
|
48
|
+
check_config_file
|
|
49
|
+
cmd = get_command_line
|
|
50
|
+
puts cmd + (RakeFileUtils.verbose ? " (executed in '#{@project_dir}')" : "")
|
|
51
|
+
cmd_result = false
|
|
52
|
+
begin
|
|
53
|
+
cmd_result = ProcessHelper.spawnProcess(cmd + " 2>&1")
|
|
54
|
+
rescue
|
|
55
|
+
end
|
|
56
|
+
if (cmd_result == false)
|
|
57
|
+
if Rake.application.idei
|
|
58
|
+
err_res = ErrorDesc.new
|
|
59
|
+
err_res.file_name = (@defined_in_file ? @defined_in_file : @project_dir)
|
|
60
|
+
err_res.line_number = (@defined_in_line ? @defined_in_line : 0)
|
|
61
|
+
err_res.severity = ErrorParser::SEVERITY_ERROR
|
|
62
|
+
err_res.message = "Command \"#{get_command_line}\" failed"
|
|
63
|
+
Rake.application.idei.set_errors([err_res])
|
|
64
|
+
end
|
|
65
|
+
Printer.printError "Error: command \"#{get_command_line}\" failed" + (RakeFileUtils.verbose ? "" : " (executed in '#{@project_dir}')")
|
|
66
|
+
raise SystemCommandFailed.new
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
res.immediate_output = true
|
|
71
|
+
res.transparent_timestamp = true
|
|
72
|
+
res.type = Rake::Task::COMMANDLINE
|
|
73
|
+
setup_rake_dependencies(res)
|
|
74
|
+
res
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
end
|
|
30
79
|
end
|
|
@@ -1,17 +1,41 @@
|
|
|
1
1
|
require 'cxxproject/buildingblocks/building_block'
|
|
2
2
|
|
|
3
3
|
# todo...
|
|
4
|
+
module Cxxproject
|
|
4
5
|
|
|
5
|
-
class CustomBuildingBlock < BuildingBlock
|
|
6
|
-
|
|
6
|
+
class CustomBuildingBlock < BuildingBlock
|
|
7
|
+
attr_reader :custom_command, :actions
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
def set_custom_command(c)
|
|
10
|
+
@custom_command = c
|
|
11
|
+
self
|
|
12
|
+
end
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
def get_task_name()
|
|
15
|
+
name
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def set_actions(actions)
|
|
19
|
+
if actions.kind_of?(Array)
|
|
20
|
+
@actions = actions
|
|
21
|
+
else
|
|
22
|
+
@actions = [actions]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def convert_to_rake()
|
|
27
|
+
desc get_task_name
|
|
28
|
+
res = task get_task_name do
|
|
29
|
+
actions.each do |a|
|
|
30
|
+
a.call
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
res.type = Rake::Task::CUSTOM
|
|
34
|
+
setup_rake_dependencies(res)
|
|
35
|
+
res
|
|
36
|
+
end
|
|
16
37
|
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
end
|
|
17
41
|
end
|