cxxproject 0.4.6 → 0.5.47
Sign up to get free protection for your applications and to get access to all the features.
- 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/lib/cxxproject/torake.rb
CHANGED
@@ -1,152 +1,210 @@
|
|
1
1
|
require 'logger'
|
2
2
|
require 'pp'
|
3
3
|
require 'pathname'
|
4
|
-
require 'cxxproject/
|
5
|
-
require 'cxxproject/
|
6
|
-
require 'cxxproject/
|
7
|
-
|
8
|
-
|
4
|
+
require 'cxxproject/ext/rake'
|
5
|
+
require 'cxxproject/buildingblocks/module'
|
6
|
+
require 'cxxproject/buildingblocks/makefile'
|
7
|
+
require 'cxxproject/buildingblocks/executable'
|
8
|
+
require 'cxxproject/buildingblocks/source_library'
|
9
|
+
require 'cxxproject/buildingblocks/single_source'
|
10
|
+
require 'cxxproject/buildingblocks/binary_library'
|
11
|
+
require 'cxxproject/buildingblocks/custom_building_block'
|
12
|
+
require 'cxxproject/buildingblocks/command_line'
|
13
|
+
require 'cxxproject/toolchain/colorizing_formatter'
|
14
|
+
require 'cxxproject/eval_context'
|
15
|
+
|
16
|
+
module Cxxproject
|
17
|
+
class CxxProject2Rake
|
18
|
+
|
19
|
+
attr_accessor :base, :all_tasks
|
20
|
+
|
21
|
+
def initialize(projects, build_dir, toolchain, base='.')
|
22
|
+
@projects = projects
|
23
|
+
@base = base
|
24
|
+
@build_dir = build_dir
|
25
|
+
@toolchain = toolchain
|
26
|
+
@rel_projects = @projects.map { |p| File.join(@base, p) }
|
27
|
+
|
28
|
+
# TODO: this should be cleaned up somehow...
|
29
|
+
if Utils::OS.linux?
|
30
|
+
toolchain[:LINKER][:LIB_PREFIX_FLAGS] = "-Wl,--whole-archive"
|
31
|
+
toolchain[:LINKER][:LIB_POSTFIX_FLAGS] = "-Wl,--no-whole-archive"
|
32
|
+
end
|
33
|
+
|
34
|
+
Rake::application.deriveIncludes = true
|
35
|
+
|
36
|
+
initialize_logging
|
37
|
+
@all_tasks = instantiate_tasks
|
38
|
+
|
39
|
+
create_generic_tasks
|
40
|
+
create_console_colorization
|
41
|
+
create_multitask
|
42
|
+
create_bail_on_first_task
|
43
|
+
describe_clean_task
|
44
|
+
create_console_task
|
45
|
+
end
|
9
46
|
|
10
|
-
|
47
|
+
def create_console_task
|
48
|
+
require 'cxxproject/utils/console'
|
49
|
+
end
|
11
50
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
51
|
+
def initialize_logging
|
52
|
+
@log = Logger.new(STDOUT)
|
53
|
+
@log.formatter = proc { |severity, datetime, progname, msg|
|
54
|
+
"#{severity}: #{msg}\n"
|
55
|
+
}
|
56
|
+
# Logger loglevels: fatal, error, warn, info, debug
|
57
|
+
# Rake --verbose -> info
|
58
|
+
# Rake --trace -> debug
|
59
|
+
@log.level = Logger::ERROR
|
60
|
+
@log.level = Logger::INFO if RakeFileUtils.verbose == true
|
61
|
+
@log.level = Logger::DEBUG if Rake::application.options.trace
|
62
|
+
@log.debug "initializing for build_dir: \"#{@build_dir}\", base: \"#{@base}\""
|
63
|
+
end
|
64
|
+
def describe_clean_task
|
65
|
+
Rake::Task[:clean].add_description('clean')
|
66
|
+
end
|
67
|
+
def create_bail_on_first_task
|
68
|
+
desc 'set bail on first error'
|
69
|
+
task :bail_on_first_error do
|
70
|
+
Rake::Task.bail_on_first_error = true
|
71
|
+
end
|
72
|
+
end
|
18
73
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
74
|
+
def create_multitask
|
75
|
+
desc 'set parallelization of multitask'
|
76
|
+
task :multitask, :threads do |t, args|
|
77
|
+
arg = args.threads
|
78
|
+
if arg
|
79
|
+
Rake::application.max_parallel_tasks = arg.to_i
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
24
83
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
84
|
+
def create_console_colorization
|
85
|
+
# default is on
|
86
|
+
Cxxproject::ColorizingFormatter.enabled = true
|
87
|
+
desc 'Toggle colorization of console output (use true|t|yes|y|1|on for true ... everything else is false)'
|
88
|
+
task :toggle_colorize, :on_off do |t, args|
|
89
|
+
arg = args[:on_off] || 'false'
|
90
|
+
on_off = arg.match(/(true|t|yes|y|1|on)$/) != nil
|
91
|
+
Cxxproject::ColorizingFormatter.enabled = on_off
|
29
92
|
end
|
30
93
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
@gcc = toolchain
|
35
|
-
task_maker = TaskMaker.new(@log)
|
36
|
-
task_maker.set_loglevel(@log.level);
|
37
|
-
tasks = []
|
38
|
-
|
39
|
-
#todo: sort ALL_BUILDING_BLOCKS (circular deps)
|
40
|
-
|
41
|
-
ALL_BUILDING_BLOCKS.each do |name,block|
|
42
|
-
block.set_tcs(@gcc) unless block.has_tcs?
|
43
|
-
block.set_output_dir(Dir.pwd + "/" + build_dir)
|
44
|
-
rel_projects = project_configs.collect { |p| File.join(base,p) }
|
45
|
-
block.set_config_files(rel_projects)
|
46
|
-
block.complete_init()
|
94
|
+
|
95
|
+
def create_generic_tasks
|
96
|
+
[:lib, :exe, :run, nil].each { |i| create_filter_task_with_namespace(i) }
|
47
97
|
end
|
48
98
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
99
|
+
def create_filter_task_with_namespace(basename)
|
100
|
+
if basename
|
101
|
+
desc "invoke #{basename} with filter"
|
102
|
+
namespace basename do
|
103
|
+
create_filter_task("#{basename}:")
|
104
|
+
end
|
105
|
+
else
|
106
|
+
desc 'invoke with filter'
|
107
|
+
create_filter_task('')
|
54
108
|
end
|
55
109
|
end
|
56
|
-
tasks
|
57
|
-
end
|
58
110
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
if p.sources.instance_of?(Rake::FileList)
|
73
|
-
p.set_sources(p.sources.to_a)
|
111
|
+
def create_filter_task(basename)
|
112
|
+
task :filter, :filter do |t, args|
|
113
|
+
filter = ".*"
|
114
|
+
if args[:filter]
|
115
|
+
filter = "#{args[:filter]}"
|
116
|
+
end
|
117
|
+
filter = Regexp.new("#{basename}#{filter}")
|
118
|
+
Rake::Task.tasks.each do |to_check|
|
119
|
+
name = to_check.name
|
120
|
+
if ("#{basename}:filter" != name)
|
121
|
+
match = filter.match(name)
|
122
|
+
if match
|
123
|
+
to_check.invoke
|
74
124
|
end
|
75
125
|
end
|
76
126
|
end
|
77
127
|
end
|
78
128
|
end
|
79
|
-
end
|
80
|
-
def define_project_info_task
|
81
|
-
desc "shows your defined projects"
|
82
|
-
task :project_info do
|
83
|
-
p "ProjectBase: #{@base}"
|
84
|
-
ALL_BUILDING_BLOCKS.each_value do |bb|
|
85
|
-
pp bb
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
129
|
|
90
|
-
|
91
|
-
|
92
|
-
class EvalContext
|
93
|
-
|
94
|
-
attr_accessor :myblock, :all_blocks
|
130
|
+
def instantiate_tasks
|
131
|
+
check_for_project_configs
|
95
132
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
133
|
+
if @log.debug?
|
134
|
+
@log.debug "project_configs:"
|
135
|
+
@projects.each { |c| @log.debug " * #{c}" }
|
136
|
+
end
|
137
|
+
register_projects()
|
138
|
+
ALL_BUILDING_BLOCKS.values.each do |block|
|
139
|
+
prepare_block(block)
|
140
|
+
end
|
141
|
+
ALL_BUILDING_BLOCKS.values.inject([]) do |memo,block|
|
142
|
+
@log.debug "creating tasks for block: #{block.name}/taskname: #{block.get_task_name} (#{block})"
|
143
|
+
memo << block.convert_to_rake()
|
144
|
+
end
|
145
|
+
end
|
110
146
|
|
111
|
-
|
112
|
-
|
113
|
-
|
147
|
+
def check_for_project_configs
|
148
|
+
cd(@base, :verbose => false) do
|
149
|
+
@projects.each do |p|
|
150
|
+
abort "project config #{p} cannot be found!" unless File.exists?(p)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
114
154
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
bblock.set_includes(hash[:includes]) if hash.has_key?(:includes)
|
121
|
-
bblock.set_dependencies(hash[:dependencies]) if hash.has_key?(:dependencies)
|
155
|
+
def prepare_block(block)
|
156
|
+
block.set_tcs(@toolchain) unless block.has_tcs?
|
157
|
+
block.set_output_dir(Dir.pwd + "/" + @build_dir)
|
158
|
+
block.complete_init()
|
159
|
+
end
|
122
160
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
161
|
+
def register_projects()
|
162
|
+
cd(@base,:verbose => false) do |b|
|
163
|
+
@projects.each_with_index do |project_file, i|
|
164
|
+
@log.debug "register project #{project_file}"
|
165
|
+
dirname = File.dirname(project_file)
|
166
|
+
@log.debug "dirname for project was: #{dirname}"
|
167
|
+
cd(dirname,:verbose => false) do | base_dir |
|
168
|
+
@log.debug "register project #{project_file} from within directory: #{Dir.pwd}"
|
169
|
+
eval_file(b, File.basename(project_file))
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
127
173
|
end
|
128
|
-
|
129
|
-
|
174
|
+
def eval_file(b, project_file)
|
175
|
+
loadContext = EvalContext.new
|
176
|
+
begin
|
177
|
+
loadContext.eval_project(File.read(File.basename(project_file)), project_file, Dir.pwd)
|
178
|
+
rescue Exception => e
|
179
|
+
puts "problems with #{File.join(b, project_file)} in dir: #{Dir.pwd}"
|
180
|
+
raise e
|
181
|
+
end
|
182
|
+
begin
|
183
|
+
loadContext.myblock.call()
|
184
|
+
rescue Exception => e
|
185
|
+
error_string = "error while evaluating \"#{Dir.pwd}/#{project_file}\""
|
186
|
+
puts error_string
|
187
|
+
raise e
|
188
|
+
end
|
130
189
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
190
|
+
loadContext.all_blocks.each do |block|
|
191
|
+
block.
|
192
|
+
set_project_dir(Dir.pwd).
|
193
|
+
set_config_files([Dir.pwd + "/" + project_file])
|
194
|
+
if block.respond_to?(:sources) && block.sources.instance_of?(Rake::FileList)
|
195
|
+
block.set_sources(block.sources.to_a)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
def define_project_info_task
|
200
|
+
desc "shows your defined projects"
|
201
|
+
task :project_info do
|
202
|
+
p "ProjectBase: #{@base}"
|
203
|
+
ALL_BUILDING_BLOCKS.each_value do |bb|
|
204
|
+
pp bb
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
142
208
|
|
143
|
-
def compile(name, hash)
|
144
|
-
raise "not a hash" unless hash.is_a?(Hash)
|
145
|
-
check_hash hash,[:sources,:includes]
|
146
|
-
bblock = SingleSource.new(name)
|
147
|
-
bblock.set_sources(hash[:sources]) if hash.has_key?(:sources)
|
148
|
-
bblock.set_includes(hash[:includes]) if hash.has_key?(:includes)
|
149
|
-
all_blocks << bblock
|
150
209
|
end
|
151
|
-
|
152
210
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'cxxproject/ext/filelist'
|
4
|
+
|
5
|
+
module Cxxproject
|
6
|
+
module Utils
|
7
|
+
|
8
|
+
def self.cleanup_rake()
|
9
|
+
ALL_BUILDING_BLOCKS.clear
|
10
|
+
Rake.application.clear
|
11
|
+
Rake.application.idei.set_abort(false)
|
12
|
+
CLEAN.pending_add.clear
|
13
|
+
CLEAN.items.clear
|
14
|
+
task :clean do
|
15
|
+
CLEAN.each { |fn| rm_r fn rescue nil }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Cxxproject
|
2
|
+
class ExitHelperException < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
class ExitHelper
|
6
|
+
@@exit_code = 0
|
7
|
+
@@exit_test = false
|
8
|
+
|
9
|
+
def self.set_exit_code(val)
|
10
|
+
@@exit_code = val
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.exit_code()
|
14
|
+
@@exit_code
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.reset_exit_code()
|
18
|
+
@@exit_code = 0
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.enable_exit_test()
|
22
|
+
@@exit_test = true
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.disable_exit_test()
|
26
|
+
@@exit_test = false
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.exit(val)
|
30
|
+
raise ExitHelperException.new if @@exit_test
|
31
|
+
@@exit_code = val
|
32
|
+
Kernel::exit
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
at_exit do
|
39
|
+
exit(Cxxproject::ExitHelper.exit_code)
|
40
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
module Cxxproject
|
2
|
+
module Utils
|
3
|
+
define_graphstream = lambda do
|
4
|
+
require 'socket'
|
5
|
+
require 'thread'
|
6
|
+
|
7
|
+
class GraphStream
|
8
|
+
def initialize
|
9
|
+
begin
|
10
|
+
@server = TCPSocket.open('localhost', 31217)
|
11
|
+
@queue = Queue.new
|
12
|
+
Thread.new do
|
13
|
+
while true
|
14
|
+
command = @queue.pop
|
15
|
+
@server.puts(command)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
rescue Exception => bang
|
19
|
+
puts bang
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def send(command)
|
23
|
+
@queue << command
|
24
|
+
end
|
25
|
+
|
26
|
+
def clear
|
27
|
+
send('Clear()')
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_stylesheet(s)
|
31
|
+
send("SetStylesheet(#{s})")
|
32
|
+
end
|
33
|
+
def add_vertex(id)
|
34
|
+
send("AddVertex(#{id})")
|
35
|
+
end
|
36
|
+
def add_edge(from, to)
|
37
|
+
send("AddEdge(#{from},#{to})")
|
38
|
+
end
|
39
|
+
def set_class(id, clazz)
|
40
|
+
send("SetClass(#{id},#{clazz})")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class GraphStreamSupport
|
45
|
+
|
46
|
+
def object?(name)
|
47
|
+
name.match(/.*\.o\Z/) != nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def exe?(name)
|
51
|
+
name.match(/.*\.exe\Z/) != nil
|
52
|
+
end
|
53
|
+
def library?(name)
|
54
|
+
name.match(/.*\.a\Z/) != nil
|
55
|
+
end
|
56
|
+
def multitask?(name)
|
57
|
+
name.index("Objects of") == 0
|
58
|
+
end
|
59
|
+
def interesting?(name)
|
60
|
+
exe?(name) || object?(name) || library?(name) || multitask?(name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def initialize(gs)
|
64
|
+
@gs = gs
|
65
|
+
|
66
|
+
@interesting_tasks = Rake::Task.tasks.select { |i| interesting?(i.name) }
|
67
|
+
create_vertices
|
68
|
+
create_edges
|
69
|
+
|
70
|
+
@vertices.each do |name, task|
|
71
|
+
set_attributes(name, task)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_vertices
|
77
|
+
@vertices = {}
|
78
|
+
@interesting_tasks.each do |task|
|
79
|
+
@vertices[task.name] = task
|
80
|
+
@gs.add_vertex(task.name)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def create_edges
|
85
|
+
@interesting_tasks.each do |task|
|
86
|
+
from = task.name
|
87
|
+
task.prerequisites.each do |to|
|
88
|
+
@gs.add_edge(from, to)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def set_attributes(name, task)
|
94
|
+
@gs.set_class(name, state2color(task))
|
95
|
+
end
|
96
|
+
|
97
|
+
def state2color(t)
|
98
|
+
begin
|
99
|
+
if t.dirty?
|
100
|
+
return 'dirty'
|
101
|
+
else
|
102
|
+
return 'ready'
|
103
|
+
end
|
104
|
+
rescue StandardError => bang
|
105
|
+
puts bang
|
106
|
+
return '#ff00ff'
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def update(name, color)
|
111
|
+
@gs.set_class(name, color)
|
112
|
+
end
|
113
|
+
|
114
|
+
def before_prerequisites(name)
|
115
|
+
update(name, 'before_prerequisites')
|
116
|
+
end
|
117
|
+
|
118
|
+
def after_prerequisites(name)
|
119
|
+
update(name, 'after_prerequisites')
|
120
|
+
end
|
121
|
+
|
122
|
+
def before_execute(name)
|
123
|
+
update(name, 'before_execute')
|
124
|
+
end
|
125
|
+
|
126
|
+
def after_execute(name)
|
127
|
+
update(name, 'after_execute')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
namespace :graphstream do
|
132
|
+
gs = nil
|
133
|
+
task :init do
|
134
|
+
gs = GraphStream.new
|
135
|
+
end
|
136
|
+
|
137
|
+
desc 'clear graphstream'
|
138
|
+
task :clear => :init do
|
139
|
+
gs.clear
|
140
|
+
end
|
141
|
+
|
142
|
+
desc 'update graphstream'
|
143
|
+
task :update => :init do
|
144
|
+
gs.set_stylesheet('node {fill-color:green;}node.dirty{fill-color:red;}node.before_prerequisites{fill-color:yellow;}node.after_prerequisites{fill-color:orange;}node.before_execute{fill-color:blue;}node.after_execute{fill-color:green;}node.ready{fill-color:yellow;}')
|
145
|
+
require 'cxxproject/ext/rake_listener'
|
146
|
+
require 'cxxproject/ext/rake_dirty'
|
147
|
+
Rake::add_listener(GraphStreamSupport.new(gs))
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
optional_package(define_graphstream, nil)
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'cxxproject/toolchain/colorizing_formatter'
|
2
|
+
|
3
|
+
module Cxxproject
|
4
|
+
|
5
|
+
class Printer
|
6
|
+
@@cf = ColorizingFormatter.new
|
7
|
+
|
8
|
+
def self.printInfo(str)
|
9
|
+
if @@cf.enabled?
|
10
|
+
puts @@cf.printInfo(str)
|
11
|
+
else
|
12
|
+
puts str
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.printAdditionalInfo(str)
|
17
|
+
if @@cf.enabled?
|
18
|
+
puts @@cf.printAdditionalInfo(str)
|
19
|
+
else
|
20
|
+
puts str
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.printWarning(str)
|
25
|
+
if @@cf.enabled?
|
26
|
+
puts @@cf.printWarning(str)
|
27
|
+
else
|
28
|
+
puts str
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.printError(str)
|
33
|
+
if @@cf.enabled?
|
34
|
+
puts @@cf.printError(str)
|
35
|
+
else
|
36
|
+
puts str
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.printSuccess(str)
|
41
|
+
if @@cf.enabled?
|
42
|
+
puts @@cf.printSuccess(str)
|
43
|
+
else
|
44
|
+
puts str
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Cxxproject
|
2
|
+
|
3
|
+
class ProcessHelper
|
4
|
+
@@pid = nil
|
5
|
+
|
6
|
+
def self.readOutput(sp, rd, wr)
|
7
|
+
wr.close
|
8
|
+
|
9
|
+
consoleOutput = ""
|
10
|
+
begin
|
11
|
+
while not rd.eof?
|
12
|
+
tmp = rd.read(1000)
|
13
|
+
if (tmp != nil)
|
14
|
+
consoleOutput << tmp
|
15
|
+
end
|
16
|
+
end
|
17
|
+
rescue Exception=>e
|
18
|
+
# Seems to be a bug in ruby: sometimes there is a bad file descriptor on Windows instead of eof, which causes
|
19
|
+
# an exception on read(). However, this happens not before everything is read, so there is no practical difference
|
20
|
+
# how to "break" the loop.
|
21
|
+
# This problem occurs on Windows command shell and Cygwin.
|
22
|
+
end
|
23
|
+
|
24
|
+
Process.wait(sp)
|
25
|
+
rd.close
|
26
|
+
|
27
|
+
# seems that pipe cannot handle non-ascii characters right on windows (even with correct encoding)
|
28
|
+
consoleOutput.gsub!(/\xE2\x80\x98/,"`") # ���
|
29
|
+
consoleOutput.gsub!(/\xE2\x80\x99/,"'") # ���
|
30
|
+
|
31
|
+
consoleOutput
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.spawnProcess(cmdLine)
|
35
|
+
return system cmdLine if Cxxproject::Utils.old_ruby?
|
36
|
+
|
37
|
+
@@pid = spawn(cmdLine)
|
38
|
+
pid, status = Process.wait2(@@pid)
|
39
|
+
@@pid = nil
|
40
|
+
status.success?
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.killProcess
|
44
|
+
begin
|
45
|
+
Process.kill("KILL",@@pid)
|
46
|
+
rescue
|
47
|
+
end
|
48
|
+
@@pid = nil
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|