cxxproject 0.6.30 → 0.6.31

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.
@@ -1,7 +1,9 @@
1
1
  require 'yaml'
2
2
 
3
3
  class Toolchain
4
+
4
5
  attr_reader :toolchain
6
+
5
7
  def initialize(toolchain_file)
6
8
  @toolchain = YAML::load(File.open(toolchain_file))
7
9
  if @toolchain.base
@@ -12,6 +14,7 @@ class Toolchain
12
14
  basechain = YAML::load(File.open(File.join(File.dirname(__FILE__),"#{@based_on}.json")))
13
15
  @toolchain = basechain.recursive_merge(@toolchain)
14
16
  end
17
+
15
18
  def method_missing(m, *args, &block)
16
19
  if @toolchain[m.to_s]
17
20
  self.class.send(:define_method, m) { @toolchain[m.to_s] }
@@ -0,0 +1,23 @@
1
+ # modified from http://www.seejohncode.com/2012/01/09/deprecating-methods-in-ruby/
2
+ module Deprecated
3
+ attr_accessor :deprecated_warnings
4
+
5
+ def reset
6
+ self.deprecated_warnings = {}
7
+ end
8
+
9
+ # Define a deprecated alias for a method
10
+ # @param [Symbol] name - name of method to define
11
+ # @param [Symbol] replacement - name of method to (alias)
12
+ def deprecated_alias(name, replacement)
13
+ define_method(name) do |*args, &block|
14
+ self.class.deprecated_warnings ||= {}
15
+ if self.class.deprecated_warnings.has_key?(name) == false
16
+ warn "#{self.class.name}##{name} deprecated (please use ##{replacement})"
17
+ self.class.deprecated_warnings[name] = true
18
+ end
19
+ send replacement, *args, &block
20
+ end
21
+ end
22
+
23
+ end
@@ -3,23 +3,29 @@ module Cxxproject
3
3
  # Simple helper query the operating system we are running in
4
4
  module OS
5
5
 
6
+ def self.os
7
+ return :OSX if mac?
8
+ return :WINDOWS if windows?
9
+ return :UNIX
10
+ end
11
+
6
12
  # Is it windows
7
- def OS.windows?
13
+ def self.windows?
8
14
  (RUBY_PLATFORM =~ /cygwin|mswin|mingw|bccwin|wince|emx/) != nil
9
15
  end
10
16
 
11
17
  # Is it osx
12
- def OS.mac?
18
+ def self.mac?
13
19
  (RUBY_PLATFORM =~ /darwin/) != nil
14
20
  end
15
21
 
16
22
  # Is it kind of unix
17
- def OS.unix?
23
+ def self.unix?
18
24
  !OS.windows?
19
25
  end
20
26
 
21
27
  # Is it linux
22
- def OS.linux?
28
+ def self.linux?
23
29
  OS.unix? and not OS.mac?
24
30
  end
25
31
 
@@ -1,5 +1,5 @@
1
1
  module Cxxproject
2
- VERSION = '0.6.30'
2
+ VERSION = '0.6.31'
3
3
 
4
4
  class Version
5
5
  def self.cxxproject
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cxxproject
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.30
4
+ version: 0.6.31
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-28 00:00:00.000000000 Z
12
+ date: 2013-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
@@ -51,55 +51,52 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
- - lib/cxxproject.rb
55
- - lib/cxxproject/context.rb
56
54
  - lib/cxxproject/errorparser/error_parser.rb
55
+ - lib/cxxproject/utils/optional.rb
56
+ - lib/cxxproject/utils/cleanup.rb
57
+ - lib/cxxproject/utils/exit_helper.rb
58
+ - lib/cxxproject/utils/rbcurse_progress.rb
59
+ - lib/cxxproject/utils/process.rb
60
+ - lib/cxxproject/utils/printer.rb
61
+ - lib/cxxproject/utils/rbcurse_executable_ext.rb
62
+ - lib/cxxproject/utils/utils.rb
63
+ - lib/cxxproject/utils/rbcurse_tasktable.rb
64
+ - lib/cxxproject/utils/graphstream.rb
65
+ - lib/cxxproject/utils/deprecated.rb
66
+ - lib/cxxproject/toolchain/provider.rb
67
+ - lib/cxxproject/toolchain/colorizing_formatter.rb
68
+ - lib/cxxproject/toolchain/toolchain.rb
57
69
  - lib/cxxproject/version.rb
58
- - lib/cxxproject/plugin_context.rb
59
70
  - lib/cxxproject/ide_interface.rb
60
- - lib/cxxproject/ext/file.rb
61
- - lib/cxxproject/ext/hash.rb
62
- - lib/cxxproject/ext/rake_dirty.rb
63
71
  - lib/cxxproject/ext/filelist.rb
64
- - lib/cxxproject/ext/rake_listener.rb
65
- - lib/cxxproject/ext/stdout.rb
66
72
  - lib/cxxproject/ext/rake.rb
67
- - lib/cxxproject/ext/progressbar.rb
73
+ - lib/cxxproject/ext/stdout.rb
74
+ - lib/cxxproject/ext/hash.rb
75
+ - lib/cxxproject/ext/rake_dirty.rb
76
+ - lib/cxxproject/ext/file.rb
77
+ - lib/cxxproject/context.rb
78
+ - lib/cxxproject/plugin_context.rb
79
+ - lib/cxxproject/buildingblocks/building_block.rb
68
80
  - lib/cxxproject/buildingblocks/has_libraries_mixin.rb
69
- - lib/cxxproject/buildingblocks/executable.rb
70
- - lib/cxxproject/buildingblocks/has_includes_mixin.rb
71
- - lib/cxxproject/buildingblocks/has_dependencies_mixin.rb
72
81
  - lib/cxxproject/buildingblocks/custom_building_block.rb
82
+ - lib/cxxproject/buildingblocks/static_library.rb
83
+ - lib/cxxproject/buildingblocks/makefile.rb
84
+ - lib/cxxproject/buildingblocks/has_includes_mixin.rb
85
+ - lib/cxxproject/buildingblocks/building_blocks.rb
86
+ - lib/cxxproject/buildingblocks/has_sources_mixin.rb
73
87
  - lib/cxxproject/buildingblocks/binary_library.rb
74
88
  - lib/cxxproject/buildingblocks/module.rb
75
- - lib/cxxproject/buildingblocks/building_block.rb
76
- - lib/cxxproject/buildingblocks/source_library.rb
77
- - lib/cxxproject/buildingblocks/building_blocks.rb
78
89
  - lib/cxxproject/buildingblocks/single_source.rb
79
- - lib/cxxproject/buildingblocks/makefile.rb
90
+ - lib/cxxproject/buildingblocks/linkable.rb
91
+ - lib/cxxproject/buildingblocks/shared_libs_helper.rb
92
+ - lib/cxxproject/buildingblocks/has_dependencies_mixin.rb
80
93
  - lib/cxxproject/buildingblocks/command_line.rb
81
- - lib/cxxproject/buildingblocks/has_sources_mixin.rb
82
- - lib/cxxproject/utils/rbcurse_progress.rb
83
- - lib/cxxproject/utils/ubigraph.rb
84
- - lib/cxxproject/utils/graphstream.rb
85
- - lib/cxxproject/utils/progress.rb
86
- - lib/cxxproject/utils/utils.rb
87
- - lib/cxxproject/utils/optional.rb
88
- - lib/cxxproject/utils/progress_helper.rb
89
- - lib/cxxproject/utils/exit_helper.rb
90
- - lib/cxxproject/utils/cleanup.rb
91
- - lib/cxxproject/utils/rbcurse_tasktable.rb
92
- - lib/cxxproject/utils/rbcurse_executable_ext.rb
93
- - lib/cxxproject/utils/rbcurse.rb
94
- - lib/cxxproject/utils/printer.rb
95
- - lib/cxxproject/utils/process.rb
96
- - lib/cxxproject/toolchain/provider.rb
97
- - lib/cxxproject/toolchain/toolchain.rb
98
- - lib/cxxproject/toolchain/colorizing_formatter.rb
94
+ - lib/cxxproject.rb
99
95
  - LICENSE
100
96
  - README.md
101
97
  homepage: https://github.com/marcmo/cxxproject
102
- licenses: []
98
+ licenses:
99
+ - BSD-2
103
100
  post_install_message:
104
101
  rdoc_options: []
105
102
  require_paths:
@@ -118,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
115
  version: '0'
119
116
  requirements: []
120
117
  rubyforge_project:
121
- rubygems_version: 1.8.24
118
+ rubygems_version: 1.8.25
122
119
  signing_key:
123
120
  specification_version: 3
124
121
  summary: Cpp Support for Rake.
@@ -1,227 +0,0 @@
1
- require 'cxxproject/buildingblocks/building_block'
2
- require 'cxxproject/buildingblocks/has_libraries_mixin'
3
- require 'cxxproject/buildingblocks/has_sources_mixin'
4
- require 'cxxproject/buildingblocks/has_includes_mixin'
5
- require 'cxxproject/utils/process'
6
- require 'cxxproject/utils/utils'
7
- require 'cxxproject/ext/stdout'
8
-
9
- require 'tmpdir'
10
- require 'set'
11
- require 'etc'
12
-
13
- module Cxxproject
14
-
15
- class Executable < BuildingBlock
16
- include HasLibraries
17
- include HasSources
18
- include HasIncludes
19
-
20
- def set_linker_script(x)
21
- @linker_script = x
22
- self
23
- end
24
-
25
- def set_mapfile(x)
26
- @mapfile = x
27
- self
28
- end
29
-
30
- def initialize(name)
31
- super(name)
32
- @linker_script = nil
33
- @mapfile = nil
34
- end
35
-
36
- def set_executable_name(name) # ensure it's relative
37
- @exe_name = name
38
- end
39
-
40
- def get_executable_name() # relative path
41
- return @exe_name if @exe_name
42
-
43
- parts = [@output_dir]
44
-
45
- if @output_dir_abs
46
- parts = [@output_dir_relPath] if @output_dir_relPath
47
- end
48
-
49
- parts << "#{@name}#{@tcs[:LINKER][:OUTPUT_ENDING]}"
50
-
51
- @exe_name = File.join(parts)
52
- @exe_name
53
- end
54
-
55
- def get_task_name() # full path
56
- @project_dir + "/" + get_executable_name
57
- end
58
-
59
- def collect_unique(array, set)
60
- ret = []
61
- array.each do |v|
62
- if set.add?(v)
63
- ret << v
64
- end
65
- end
66
- ret
67
- end
68
-
69
- def adapt_path(v, d, prefix)
70
- tmp = nil
71
- if File.is_absolute?(v)
72
- tmp = v
73
- else
74
- prefix ||= File.rel_from_to_project(@project_dir, d.project_dir)
75
- tmp = File.add_prefix(prefix, v)
76
- end
77
- [tmp, prefix]
78
- end
79
-
80
- def linker_lib_string(linker)
81
- lib_path_set = Set.new
82
- deps = collect_dependencies
83
- res = []
84
- deps.each do |d|
85
- handle_whole_archive(d, res, linker, :START_OF_WHOLE_ARCHIVE)
86
- if HasLibraries === d
87
- d.lib_elements.each do |elem|
88
- case elem[0]
89
- when HasLibraries::LIB
90
- res.push("#{linker[:LIB_FLAG]}#{elem[1]}")
91
- when HasLibraries::USERLIB
92
- res.push("#{linker[:USER_LIB_FLAG]}#{elem[1]}")
93
- when HasLibraries::LIB_WITH_PATH
94
- tmp, prefix = adapt_path(elem[1], d, prefix)
95
- res.push(tmp)
96
- when HasLibraries::SEARCH_PATH
97
- tmp, prefix = adapt_path(elem[1], d, prefix)
98
- if not lib_path_set.include?(tmp)
99
- lib_path_set << tmp
100
- res.push("#{linker[:LIB_PATH_FLAG]}#{tmp}")
101
- end
102
- end
103
- end
104
- end
105
- handle_whole_archive(d, res, linker, :END_OF_WHOLE_ARCHIVE)
106
- end
107
- res
108
- end
109
-
110
- # res the array with command line arguments that is used as result
111
- # linker the linker hash
112
- # sym the symbol that is used to fish out a value from the linker
113
- def handle_whole_archive(building_block, res, linker, sym)
114
- if building_block.instance_of?(SourceLibrary)
115
- if building_block.whole_archive
116
- res.push(linker[sym]) if linker[sym] and !linker[sym].empty?
117
- end
118
- end
119
- end
120
-
121
- # create a task that will link an executable from a set of object files
122
- #
123
- def convert_to_rake()
124
- object_multitask = prepare_tasks_for_objects()
125
-
126
- linker = @tcs[:LINKER]
127
-
128
- res = typed_file_task Rake::Task::EXECUTABLE, get_task_name => object_multitask do
129
- Dir.chdir(@project_dir) do
130
-
131
- cmd = [linker[:COMMAND]] # g++
132
- cmd += linker[:MUST_FLAGS].split(" ")
133
- cmd += linker[:FLAGS]
134
- cmd << linker[:EXE_FLAG]
135
- cmd << get_executable_name # -o debug/x.exe
136
- cmd += @objects
137
- cmd << linker[:SCRIPT] if @linker_script # -T
138
- cmd << @linker_script if @linker_script # xy/xy.dld
139
- cmd << linker[:MAP_FILE_FLAG] if @mapfile # -Wl,-m6
140
- cmd += linker[:LIB_PREFIX_FLAGS].split(" ") # TODO ... is this still needed e.g. for diab
141
- cmd += linker_lib_string(@tcs[:LINKER])
142
- cmd += linker[:LIB_POSTFIX_FLAGS].split(" ") # TODO ... is this still needed e.g. for diab
143
-
144
- mapfileStr = @mapfile ? " >#{@mapfile}" : ""
145
- rd, wr = IO.pipe
146
- cmdLinePrint = cmd
147
- printCmd(cmdLinePrint, "Linking #{get_executable_name}", false)
148
- cmd << {
149
- :out=> @mapfile ? "#{@mapfile}" : wr, # > xy.map
150
- :err=>wr
151
- }
152
- sp = spawn(*cmd)
153
- cmd.pop
154
-
155
- # for console print
156
- cmd << " >#{@mapfile}" if @mapfile
157
- consoleOutput = ProcessHelper.readOutput(sp, rd, wr)
158
-
159
- process_result(cmdLinePrint, consoleOutput, linker[:ERROR_PARSER], nil)
160
- check_config_file()
161
- end
162
- end
163
- res.immediate_output = true
164
- res.enhance(@config_files)
165
- res.enhance([@project_dir + "/" + @linker_script]) if @linker_script
166
-
167
- add_output_dir_dependency(get_task_name, res, true)
168
- add_grouping_tasks(get_task_name)
169
- setup_rake_dependencies(res, object_multitask)
170
-
171
- # check that all source libs are checked even if they are not a real rake dependency (can happen if "build this project only")
172
- begin
173
- libChecker = task get_task_name+"LibChecker" do
174
- if File.exists?(get_task_name) # otherwise the task will be executed anyway
175
- all_dependencies.each do |bb|
176
- if bb and SourceLibrary === bb
177
- f = bb.get_task_name # = abs path of library
178
- if not File.exists?(f) or File.mtime(f) > File.mtime(get_task_name)
179
- def res.needed?
180
- true
181
- end
182
- break
183
- end
184
- end
185
- end
186
- end
187
- end
188
- rescue
189
- def res.needed?
190
- true
191
- end
192
- end
193
- libChecker.transparent_timestamp = true
194
- res.enhance([libChecker])
195
-
196
- return res
197
- end
198
-
199
- def add_grouping_tasks(executable)
200
- namespace 'exe' do
201
- desc executable
202
- task @name => executable
203
- end
204
- create_run_task(executable, @name)
205
- end
206
-
207
- def create_run_task(executable, name)
208
- namespace 'run' do
209
- desc "run executable #{executable}"
210
- res = task name => executable do |t|
211
- args = ENV['args'] ? ' ' + ENV['args'] : ''
212
- sh "\"#{executable}\"#{args}"
213
- end
214
- res.type = Rake::Task::RUN
215
- res
216
- end
217
- end
218
-
219
- def get_temp_filename
220
- Dir.tmpdir + "/lake.tmp"
221
- end
222
-
223
- def no_sources_found()
224
- end
225
-
226
- end
227
- end
@@ -1,20 +0,0 @@
1
- class ::ProgressBar
2
- attr_writer :title
3
-
4
- def title_width=(w)
5
- @title_width = w
6
- @format = "%-#{@title_width}s #{'%3d%%'.red} #{'%s'.green} #{'%s'.blue}"
7
- end
8
-
9
- show_original = self.instance_method(:show)
10
- define_method(:show) do
11
- if @unblocked && !RakeFileUtils.verbose
12
- show_original.bind(self).call
13
- end
14
- end
15
-
16
- def unblock
17
- @unblocked = true
18
- show
19
- end
20
- end
@@ -1,57 +0,0 @@
1
- require 'rake'
2
-
3
- module Rake
4
-
5
- def self.add_listener(l)
6
- get_listener() << l
7
- end
8
-
9
- def self.get_listener
10
- @listener ||= []
11
- end
12
-
13
- def self.remove_listener(l)
14
- get_listener().delete(l)
15
- end
16
-
17
- def self.notify_listener(symbol, name)
18
- Rake::get_listener().each do |l|
19
- if l.respond_to?(symbol)
20
- l.send(symbol, name)
21
- end
22
- end
23
- end
24
-
25
- def self.augmented_invoke_prerequisites(o, name, invoke_prerequisites_original, obj, task_args, invocation_chain)
26
- Rake::notify_listener(:before_prerequisites, name)
27
- invoke_prerequisites_original.bind(obj).call(task_args, invocation_chain)
28
- Rake::notify_listener(:after_prerequisites, name)
29
- if !o.needed?
30
- Rake::notify_listener(:after_execute, name)
31
- end
32
- end
33
-
34
- class MultiTask
35
- invoke_prerequisites_original = self.instance_method(:invoke_prerequisites)
36
- define_method(:invoke_prerequisites) do |task_args, invocation_chain|
37
- Rake::augmented_invoke_prerequisites(self, name, invoke_prerequisites_original, self, task_args, invocation_chain)
38
- end
39
- end
40
-
41
- class Task
42
- invoke_prerequisites_original = self.instance_method(:invoke_prerequisites)
43
- define_method (:invoke_prerequisites) do |task_args, invocation_chain|
44
- Rake::augmented_invoke_prerequisites(self, name, invoke_prerequisites_original, self, task_args, invocation_chain)
45
- end
46
-
47
- execute_original = self.instance_method(:execute)
48
- define_method(:execute) do |args|
49
- Rake::notify_listener(:before_execute, name)
50
- execute_original.bind(self).call(args)
51
- Rake::notify_listener(:after_execute, name)
52
- end
53
-
54
- end
55
-
56
- end
57
-