cxxproject 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile.rb +12 -2
- data/lib/cxxproject/toolchain/provider.rb +0 -1
- data/lib/cxxproject/torake.rb +7 -6
- data/lib/cxxproject/version.rb +1 -1
- data/lib/tools/Rakefile.rb.template +1 -1
- data/lib/tools/project_wizard.rb +82 -60
- metadata +3 -3
data/Rakefile.rb
CHANGED
@@ -15,6 +15,17 @@ begin
|
|
15
15
|
sh "gem install pkg/#{spec.name}-#{spec.version}.gem"
|
16
16
|
end
|
17
17
|
|
18
|
+
desc "deploy gem to rubygems"
|
19
|
+
task :deploy => :gem do
|
20
|
+
require 'highline/import'
|
21
|
+
new_gem = "pkg/#{spec.name}-#{spec.version}.gem"
|
22
|
+
say "This will deploy #{new_gem} to rubygems server"
|
23
|
+
if agree("Are you sure you want to continue? [y/n]") then
|
24
|
+
sh "gem push #{new_gem}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
18
29
|
|
19
30
|
begin
|
20
31
|
require 'rdoc'
|
@@ -47,7 +58,7 @@ begin
|
|
47
58
|
end
|
48
59
|
end
|
49
60
|
RoodiTask.new('roodi', spec.files)
|
50
|
-
task :
|
61
|
+
task :gem => [:roodi]
|
51
62
|
rescue LoadError # don't bail out when people do not have roodi installed!
|
52
63
|
puts 'please gem install roodi'
|
53
64
|
end
|
@@ -111,6 +122,5 @@ rescue LoadError => e
|
|
111
122
|
puts 'to build the version history please gem install grit'
|
112
123
|
end
|
113
124
|
|
114
|
-
|
115
125
|
require './rake_helper/perftools'
|
116
126
|
|
@@ -120,7 +120,6 @@ module Cxxproject
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def self.modify_cpp_compiler(based_on, h)
|
123
|
-
# chain = Marshal.load(Marshal.dump(@@settings[based_on]))
|
124
123
|
chain = @@settings[based_on]
|
125
124
|
raise "unknown toolchain: #{based_on}" unless chain
|
126
125
|
chain[:COMPILER][:CPP].update(h)
|
data/lib/cxxproject/torake.rb
CHANGED
@@ -21,8 +21,9 @@ module Cxxproject
|
|
21
21
|
class CxxProject2Rake
|
22
22
|
attr_accessor :base, :all_tasks
|
23
23
|
|
24
|
-
def initialize(projects, build_dir, toolchain_name, base='.')
|
24
|
+
def initialize(projects, build_dir, toolchain_name, base='.', &option_block)
|
25
25
|
load_cxx_plugins
|
26
|
+
option_block.call if option_block
|
26
27
|
toolchain = Provider[toolchain_name]
|
27
28
|
raise "no provider with name \"#{toolchain_name}\" found" unless toolchain
|
28
29
|
@base = base
|
@@ -31,10 +32,10 @@ module Cxxproject
|
|
31
32
|
end
|
32
33
|
|
33
34
|
# TODO: this should be cleaned up somehow...
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
if Utils::OS.linux?
|
36
|
+
toolchain[:LINKER][:LIB_PREFIX_FLAGS] = "-Wl,--whole-archive"
|
37
|
+
toolchain[:LINKER][:LIB_POSTFIX_FLAGS] = "-Wl,--no-whole-archive"
|
38
|
+
end
|
38
39
|
|
39
40
|
Rake::application.deriveIncludes = true
|
40
41
|
|
@@ -62,7 +63,7 @@ module Cxxproject
|
|
62
63
|
end
|
63
64
|
|
64
65
|
def load_plugin(gem, pluginContext)
|
65
|
-
begin
|
66
|
+
begin
|
66
67
|
path = File.join(gem.full_gem_path, 'lib', 'plugin.rb')
|
67
68
|
content = File.read(path)
|
68
69
|
pluginContext.eval_plugin(content)
|
data/lib/cxxproject/version.rb
CHANGED
@@ -5,6 +5,6 @@ unittest_flags = {
|
|
5
5
|
:DEFINES => ['UNIT_TEST','CPPUNIT_MAIN=main'],
|
6
6
|
:FLAGS => "-O0 -g3 -Wall"
|
7
7
|
}
|
8
|
-
toolchain = Provider.modify_cpp_compiler("<%=
|
8
|
+
toolchain = Provider.modify_cpp_compiler("<%= toolchain %>", unittest_flags)
|
9
9
|
dependent_projects = ['./project.rb']
|
10
10
|
CxxProject2Rake.new(dependent_projects, BuildDir, toolchain, './')
|
data/lib/tools/project_wizard.rb
CHANGED
@@ -2,90 +2,112 @@ require 'rake'
|
|
2
2
|
require 'erb'
|
3
3
|
require 'rubygems'
|
4
4
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
def prepare_project(dir_name)
|
6
|
+
begin
|
7
|
+
require 'highline/import'
|
8
|
+
|
9
|
+
say "This will create a new cxx-project in directory: '#{dir_name}'"
|
10
|
+
if confirm("Are you sure you want to continue") then
|
11
|
+
building_block = choose_building_block
|
12
|
+
generate_makefile = confirm("Do you also whant to generate a rakefile", building_block.eql?("exe"))
|
13
|
+
|
14
|
+
toolchain = nil
|
15
|
+
if generate_makefile then
|
16
|
+
toolchain = choose_toolchain
|
17
|
+
return unless toolchain
|
18
18
|
end
|
19
|
+
|
20
|
+
create_project(dir_name, building_block, toolchain, generate_makefile)
|
21
|
+
say "Completed project-setup ;-)"
|
22
|
+
else
|
23
|
+
say "Stopped project-setup!"
|
19
24
|
end
|
20
|
-
|
21
|
-
|
25
|
+
|
26
|
+
rescue Interrupt
|
27
|
+
say "\nStopped project-setup!"
|
28
|
+
rescue LoadError
|
29
|
+
say "Please run 'gem install highline'"
|
22
30
|
end
|
23
|
-
res
|
24
31
|
end
|
25
32
|
|
26
33
|
def choose_building_block
|
27
34
|
res = nil
|
28
35
|
choose do |menu|
|
29
|
-
|
30
|
-
|
36
|
+
say "What building-block do you whant to create?"
|
31
37
|
menu.choice(:exe) { res = "exe" }
|
32
38
|
menu.choice(:lib) { res = "source_lib" }
|
39
|
+
menu.prompt = "Select a building-block: "
|
33
40
|
end
|
34
41
|
res
|
35
42
|
end
|
36
43
|
|
37
|
-
def
|
38
|
-
res =
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
44
|
+
def choose_toolchain
|
45
|
+
res = nil
|
46
|
+
toolchains = []
|
47
|
+
toolchain_pattern = /cxxproject_(.*)toolchain/
|
48
|
+
Gem::Specification.find_all do |gem|
|
49
|
+
if gem.name =~ toolchain_pattern then
|
50
|
+
toolchains << $1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
if toolchains.length > 0 then
|
54
|
+
choose do |menu|
|
55
|
+
say "What toolchain do you whant to use?"
|
56
|
+
toolchains.each do |toolchain|
|
57
|
+
menu.choice(toolchain.to_sym) { res = toolchain }
|
58
|
+
end
|
59
|
+
menu.prompt = "Select a toolchain: "
|
60
|
+
end
|
61
|
+
else
|
62
|
+
say "No toolchains installed!"
|
63
|
+
candidates = `gem list --remote "cxxproject_.*toolchain"`
|
64
|
+
say "You need at least one toolchain-plugin,- candidates are:\n#{candidates}"
|
43
65
|
end
|
44
66
|
res
|
45
67
|
end
|
46
68
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
69
|
+
def create_project(dir_name, building_block, toolchain, generate_rakefile)
|
70
|
+
rakefile_template = IO.read(File.join(File.dirname(__FILE__),"..","tools","Rakefile.rb.template"))
|
71
|
+
project_template = IO.read(File.join(File.dirname(__FILE__),"..","tools","project.rb.template"))
|
72
|
+
binding = create_binding("new-item", building_block, toolchain)
|
73
|
+
|
74
|
+
if !File.directory?(dir_name) then
|
75
|
+
mkdir_p(dir_name, :verbose => false)
|
76
|
+
end
|
77
|
+
|
78
|
+
rakefile_file = "#{dir_name}/Rakefile.rb"
|
79
|
+
if generate_rakefile && (!File.exists?(rakefile_file) || confirm("Override existing '#{rakefile_file}'")) then
|
80
|
+
write_template(rakefile_file, rakefile_template, binding)
|
81
|
+
end
|
82
|
+
|
83
|
+
project_file = "#{dir_name}/project.rb"
|
84
|
+
if !File.exists?(project_file) || confirm("Override existing '#{project_file}'") then
|
85
|
+
write_template(project_file, project_template, binding)
|
63
86
|
end
|
64
87
|
end
|
65
88
|
|
89
|
+
def create_binding(name, building_block, toolchain)
|
90
|
+
return binding()
|
91
|
+
end
|
66
92
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
s2 = IO.read(projectrb_template)
|
72
|
-
name = "testme"
|
73
|
-
building_block = bb
|
74
|
-
toolchain_name = tc[/(.*?)toolchain/,1]
|
75
|
-
mkdir_p(d, :verbose => false)
|
76
|
-
cd(d,:verbose => false) do
|
77
|
-
if ((File.exists? "Rakefile.rb") || (File.exists? "project.rb"))
|
78
|
-
abort "cannot create project in this directory, existing files would be overwritten!"
|
79
|
-
end
|
80
|
-
if generate_rakefile
|
81
|
-
write_template('Rakefile.rb', s1, binding)
|
82
|
-
end
|
83
|
-
write_template('project.rb', s2, binding)
|
93
|
+
def write_template(file_name, template, binding)
|
94
|
+
say "...write: '#{file_name}'"
|
95
|
+
File.open(file_name, 'w') do |f|
|
96
|
+
f.write ERB.new(template).result(binding)
|
84
97
|
end
|
85
98
|
end
|
86
99
|
|
87
|
-
def
|
88
|
-
|
89
|
-
|
100
|
+
def confirm(question, default = true)
|
101
|
+
res = nil
|
102
|
+
while res == nil
|
103
|
+
confirm = ask("#{question}? ") { |q| q.default = default ? "Y/n" : "y/N" }
|
104
|
+
if confirm.eql?("Y/n") || confirm.downcase.eql?("yes") || confirm.downcase.eql?("y") then
|
105
|
+
res = true
|
106
|
+
elsif confirm.eql?("y/N") || confirm.downcase.eql?("no") || confirm.downcase.eql?("n") then
|
107
|
+
res = false
|
108
|
+
else
|
109
|
+
say "Please enter \"yes\" or \"no\"."
|
110
|
+
end
|
90
111
|
end
|
112
|
+
return res
|
91
113
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cxxproject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.6.
|
5
|
+
version: 0.6.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- oliver mueller
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-07-
|
13
|
+
date: 2012-07-06 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: highline
|
@@ -140,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
140
|
requirements:
|
141
141
|
- - ">="
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
hash:
|
143
|
+
hash: 2926216662613263501
|
144
144
|
segments:
|
145
145
|
- 0
|
146
146
|
version: "0"
|