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 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 :agem => [:roodi]
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)
@@ -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
- # if Utils::OS.linux?
35
- # toolchain[:LINKER][:LIB_PREFIX_FLAGS] = "-Wl,--whole-archive"
36
- # toolchain[:LINKER][:LIB_POSTFIX_FLAGS] = "-Wl,--no-whole-archive"
37
- # end
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)
@@ -1,7 +1,7 @@
1
1
  module Cxxproject
2
2
  class Version
3
3
  def self.cxxproject
4
- "0.6.4"
4
+ "0.6.5"
5
5
  end
6
6
  end
7
7
  end
@@ -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("<%= toolchain_name %>", unittest_flags)
8
+ toolchain = Provider.modify_cpp_compiler("<%= toolchain %>", unittest_flags)
9
9
  dependent_projects = ['./project.rb']
10
10
  CxxProject2Rake.new(dependent_projects, BuildDir, toolchain, './')
@@ -2,90 +2,112 @@ require 'rake'
2
2
  require 'erb'
3
3
  require 'rubygems'
4
4
 
5
- def choose_toolchain
6
- res = nil
7
- toolchains = []
8
- prefix = "cxxproject_"
9
- toolchain_gems = Gem::Specification.find_all do |gem|
10
- gem.name.start_with?(prefix)
11
- end
12
- if toolchain_gems.length > 0
13
- choose do |menu|
14
- menu.prompt = "choose a toolchain:"
15
- toolchain_gems.each do |gem|
16
- name = gem.name[prefix.length..-1]
17
- menu.choice(name.to_sym) { res = name }
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
- else
21
- say "no toolchains found...you need to install toolchain-gems in order to use cxxproject"
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
- menu.prompt = "what building block do you want to start with?"
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 choose_generate_makefile
38
- res = true
39
- choose do |menu|
40
- menu.prompt = 'generate rakefile?'
41
- menu.choice(:yes) { res = true }
42
- menu.choice(:no) { res = false }
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 prepare_project(d)
48
- begin
49
- require 'highline/import'
50
-
51
- if agree("This will create a new cxx-project config in dir \"#{d}\" \nAre you sure you want to continue? [yn] ")
52
- tc = choose_toolchain
53
- return unless tc
54
- bb = choose_building_block
55
- generate_makefile = choose_generate_makefile
56
-
57
- create_project(d, bb, tc, generate_makefile)
58
- else
59
- say "stopped project creation"
60
- end
61
- rescue LoadError
62
- puts "Please 'gem install highline'"
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 create_project(d, bb, tc, generate_rakefile)
68
- rakefile_template = File.join(File.dirname(__FILE__),"..","tools","Rakefile.rb.template")
69
- projectrb_template = File.join(File.dirname(__FILE__),"..","tools","project.rb.template")
70
- s1 = IO.read(rakefile_template)
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 write_template(name, template_string, b)
88
- File.open(name, 'w') do |f|
89
- f.write ERB.new(template_string).result(b)
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.4
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-05 00:00:00 Z
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: 1495580368314725504
143
+ hash: 2926216662613263501
144
144
  segments:
145
145
  - 0
146
146
  version: "0"