ritsu 0.1.0 → 0.2.0

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/Thorfile CHANGED
@@ -17,7 +17,7 @@ end.to_a + ['Thorfile']
17
17
 
18
18
  class Default < Thor
19
19
  include Thor::RakeCompat
20
-
20
+
21
21
  Rake::TestTask.new do |t|
22
22
  t.libs << 'lib'
23
23
  test_files = FileList['test/**/*_test.rb']
@@ -88,7 +88,14 @@ class Default < Thor
88
88
  s.add_development_dependency 'maruku', '>= 0.5.9'
89
89
  end
90
90
 
91
- Jeweler::GemcutterTasks.new
91
+ Jeweler::GemcutterTasks.new
92
+
93
+ desc "fast_install", "Install gem without RI and RDoc"
94
+ def fast_install
95
+ build
96
+ version = File.read(File.dirname(__FILE__) + '/VERSION').strip
97
+ sh "gem install pkg/ritsu-#{version}.gem --no-ri --no-rdoc"
98
+ end
92
99
  rescue LoadError
93
100
  puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
94
101
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + "/../../project"
2
+
3
+ module Ritsu
4
+ class Project
5
+ def performs_fake_install?
6
+ @fake_install ||= false
7
+ end
8
+
9
+ def fake_install=(value)
10
+ @fake_install = value
11
+ end
12
+
13
+ def setup_fake_install
14
+ @fake_install = true
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + "/../../../src_files/project_cmake_lists"
2
+
3
+ module Ritsu
4
+ module SrcFiles
5
+ class ProjectCmakeLists
6
+ class FakeInstallTemplate < Ritsu::Template
7
+ attr_reader :project
8
+
9
+ def initialize(project)
10
+ super("ProjectCmakeLists -- Fake Install")
11
+ @project = project
12
+ end
13
+
14
+ def update_block(block, options={})
15
+ block.contents.clear
16
+
17
+ to_install = project.targets.select { |x| x.install? }
18
+
19
+ if project.performs_fake_install? && to_install.length > 0
20
+ block.add_line "ADD_CUSTOM_TARGET(fake_install"
21
+ block.add_line " ALL"
22
+ block.add_line " \"${CMAKE_COMMAND}\""
23
+ block.add_line " -D CMAKE_INSTALL_PREFIX:string=${CMAKE_SOURCE_DIR}/../"
24
+ block.add_line " -P \"${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake\""
25
+ block.add_line " DEPENDS"
26
+ to_install.each do |target|
27
+ block.add_line " #{target.name}"
28
+ end
29
+ block.add_line ")"
30
+ end
31
+ end
32
+ end
33
+
34
+ class Template
35
+ alias_method :initialize_before_fake_install, :initialize
36
+
37
+ def initialize(project)
38
+ initialize_before_fake_install(project)
39
+ add_new_line
40
+ add_template FakeInstallTemplate.new(project)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,2 @@
1
+ require File.dirname(__FILE__) + "/fake_install/project"
2
+ require File.dirname(__FILE__) + "/fake_install/src_files/project_cmake_lists"
@@ -18,6 +18,12 @@ module Ritsu
18
18
  src_path = compute_src_path(path, options)
19
19
  CppFile.new(src_path, self)
20
20
  end
21
+
22
+ def add_cpp_files(*paths)
23
+ paths.each do |path|
24
+ add_cpp_file(path)
25
+ end
26
+ end
21
27
  end
22
28
  end
23
29
  end
@@ -31,6 +31,12 @@ module Ritsu
31
31
  src_path = compute_src_path(path, options)
32
32
  HeaderFile.new(src_path, self)
33
33
  end
34
+
35
+ def add_header_files(*paths)
36
+ paths.each do |path|
37
+ add_header_file(path)
38
+ end
39
+ end
34
40
  end
35
41
  end
36
42
  end
@@ -115,7 +115,29 @@ module Ritsu
115
115
  block.contents << ")"
116
116
  end
117
117
  end
118
-
118
+
119
+ class InstallTemplate < Ritsu::Template
120
+ attr_reader :target
121
+
122
+ def initialize(target)
123
+ super("TargetCmakeLists -- #{target.name} -- Install")
124
+ @target = target
125
+
126
+ end
127
+
128
+ def update_block(block, options = {})
129
+ block.contents.clear
130
+
131
+ if target.install?
132
+ block.add_line "INSTALL(TARGETS #{target.name}"
133
+ block.add_line " RUNTIME DESTINATION bin"
134
+ block.add_line " LIBRARY DESTINATION lib"
135
+ block.add_line ")"
136
+ end
137
+ end
138
+
139
+ end
140
+
119
141
  class Template < Ritsu::Template
120
142
  include Ritsu::TemplatePolicies::FlexibleBlockMatchingAndCreateMissingBlockButLeaveUserTextBe
121
143
  attr_reader :target
@@ -123,6 +145,7 @@ module Ritsu
123
145
  attr_reader :custom_commands_template
124
146
  attr_reader :source_files_template
125
147
  attr_reader :dependencies_template
148
+ attr_reader :install_template
126
149
 
127
150
  def initialize(target, id = nil)
128
151
  super(id)
@@ -142,6 +165,10 @@ module Ritsu
142
165
 
143
166
  @dependencies_template = DependenciesTemplate.new(@target)
144
167
  contents << @dependencies_template
168
+ contents << ""
169
+
170
+ @install_template = InstallTemplate.new(@target)
171
+ contents << @install_template
145
172
  end
146
173
  end
147
174
 
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + '/../src_file'
2
+ require File.dirname(__FILE__) + '/cpp_file'
3
+ require File.dirname(__FILE__) + '/header_file'
4
+
5
+ module Ritsu
6
+ module SrcFiles
7
+ module AddUnit
8
+ include AddCppFile
9
+ include AddHeaderFile
10
+
11
+ def add_unit(name, options={})
12
+ add_cpp_file(name + ".cpp")
13
+ add_header_file(name + ".h")
14
+ end
15
+
16
+ def add_units(*names)
17
+ paths.each do |path|
18
+ add_unit(name)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ module Ritsu
26
+ class Target
27
+ include Ritsu::SrcFiles::AddUnit
28
+ end
29
+
30
+ class Project
31
+ include Ritsu::SrcFiles::AddUnit
32
+ end
33
+ end
@@ -11,4 +11,5 @@ require File.dirname(__FILE__) + '/src_files/executable_cmake_lists'
11
11
  require File.dirname(__FILE__) + '/src_files/shared_library_cmake_lists'
12
12
  require File.dirname(__FILE__) + '/src_files/static_library_cmake_lists'
13
13
  require File.dirname(__FILE__) + '/src_files/project_config_header_file'
14
- require File.dirname(__FILE__) + '/src_files/project_config_header_template_file'
14
+ require File.dirname(__FILE__) + '/src_files/project_config_header_template_file'
15
+ require File.dirname(__FILE__) + "/src_files/unit"
data/lib/ritsu/target.rb CHANGED
@@ -38,6 +38,7 @@ module Ritsu
38
38
  @src_files = Set.new
39
39
  @custom_commands = []
40
40
  @topological_order = 0
41
+ @install = false
41
42
 
42
43
  Target.instances << self
43
44
  @project.targets << self
@@ -48,6 +49,14 @@ module Ritsu
48
49
  raise "target with name '#{instance.name}' already exists"
49
50
  end
50
51
  end
52
+
53
+ def install?
54
+ @install
55
+ end
56
+
57
+ def setup_install
58
+ @install = true
59
+ end
51
60
 
52
61
  def src_dir
53
62
  self.name
@@ -103,6 +112,12 @@ module Ritsu
103
112
  end
104
113
  end
105
114
 
115
+ def add_external_libraries(*names)
116
+ names.each do |name|
117
+ add_external_library(name)
118
+ end
119
+ end
120
+
106
121
  def add_dependency_target(target_or_target_name)
107
122
  if target_or_target_name.kind_of?(String)
108
123
  dependency = Target.find_by_name(target_or_target_name)
@@ -115,6 +130,12 @@ module Ritsu
115
130
  dependency_targets << dependency
116
131
  end
117
132
 
133
+ def add_dependency_targets(*target_or_target_names)
134
+ target_or_target_names.each do |target|
135
+ add_dependency_target(target)
136
+ end
137
+ end
138
+
118
139
  def dependency_targets_sorted_by_topological_order
119
140
  Target.compute_topological_orders
120
141
  result = dependency_targets.to_a
@@ -13,9 +13,9 @@ module Ritsu::Thors
13
13
  method_option :generator, :type => :string
14
14
  def cmake
15
15
  prepare_cmake_generator
16
-
17
- if !File.exists?(File.dirname(__FILE__) + "/build")
18
- FileUtils.mkdir_p(File.dirname(__FILE__) + "/build")
16
+
17
+ if !File.exists?(Ritsu::Project.instance.project_dir + "/build")
18
+ FileUtils.mkdir_p(Ritsu::Project.instance.project_dir + "/build")
19
19
  end
20
20
 
21
21
  FileUtils.chdir("build", :verbose => true)
@@ -45,6 +45,47 @@ ADD_EXECUTABLE(abc ${ABC_SRC_FILES})
45
45
 
46
46
  ##<< TargetCmakeLists -- abc -- Dependencies
47
47
  ##>> TargetCmakeLists -- abc -- Dependencies
48
+
49
+ ##<< TargetCmakeLists -- abc -- Install
50
+ ##>> TargetCmakeLists -- abc -- Install
51
+ CMAKE
52
+
53
+ assert_file_content(expected_content, abc.cmake_lists.abs_path)
54
+ end
55
+
56
+ file_test "install" do
57
+ abc = Ritsu::Targets::Executable.new("abc", :project=>@project)
58
+ abc.setup_install
59
+ FileRobot.quietly do
60
+ abc.cmake_lists.create
61
+ end
62
+ assert_file_exists(abc.cmake_lists.abs_path)
63
+
64
+ expected_content = <<-CMAKE
65
+ ##<< TargetCmakeLists -- abc -- Libraries
66
+ ##>> TargetCmakeLists -- abc -- Libraries
67
+
68
+ ##<< TargetCmakeLists -- abc -- Custom Commands
69
+ ##>> TargetCmakeLists -- abc -- Custom Commands
70
+
71
+ ##<< TargetCmakeLists -- abc -- Source Files
72
+ SET(ABC_SRC_FILES
73
+ )
74
+ ##>> TargetCmakeLists -- abc -- Source Files
75
+
76
+ ##<< ExecutableCmakeLists -- abc -- Executable
77
+ ADD_EXECUTABLE(abc ${ABC_SRC_FILES})
78
+ ##>> ExecutableCmakeLists -- abc -- Executable
79
+
80
+ ##<< TargetCmakeLists -- abc -- Dependencies
81
+ ##>> TargetCmakeLists -- abc -- Dependencies
82
+
83
+ ##<< TargetCmakeLists -- abc -- Install
84
+ INSTALL(TARGETS abc
85
+ RUNTIME DESTINATION bin
86
+ LIBRARY DESTINATION lib
87
+ )
88
+ ##>> TargetCmakeLists -- abc -- Install
48
89
  CMAKE
49
90
 
50
91
  assert_file_content(expected_content, abc.cmake_lists.abs_path)
@@ -45,6 +45,9 @@ ADD_LIBRARY(abc SHARED ${ABC_SRC_FILES})
45
45
 
46
46
  ##<< TargetCmakeLists -- abc -- Dependencies
47
47
  ##>> TargetCmakeLists -- abc -- Dependencies
48
+
49
+ ##<< TargetCmakeLists -- abc -- Install
50
+ ##>> TargetCmakeLists -- abc -- Install
48
51
  CMAKE
49
52
 
50
53
  assert_file_content(expected_content, abc.cmake_lists.abs_path)
@@ -45,6 +45,9 @@ ADD_LIBRARY(abc STATIC ${ABC_SRC_FILES})
45
45
 
46
46
  ##<< TargetCmakeLists -- abc -- Dependencies
47
47
  ##>> TargetCmakeLists -- abc -- Dependencies
48
+
49
+ ##<< TargetCmakeLists -- abc -- Install
50
+ ##>> TargetCmakeLists -- abc -- Install
48
51
  CMAKE
49
52
 
50
53
  assert_file_content(expected_content, abc.cmake_lists.abs_path)
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ritsu
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 1
8
+ - 2
8
9
  - 0
9
- version: 0.1.0
10
+ version: 0.2.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - dragonmeteor
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-23 00:00:00 +07:00
18
+ date: 2010-07-19 00:00:00 +07:00
18
19
  default_executable: ritsu
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: thor
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 35
27
30
  segments:
28
31
  - 0
29
32
  - 13
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: activesupport
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 9
41
46
  segments:
42
47
  - 2
43
48
  - 3
@@ -49,9 +54,11 @@ dependencies:
49
54
  name: jeweler
50
55
  prerelease: false
51
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
52
58
  requirements:
53
59
  - - ">="
54
60
  - !ruby/object:Gem::Version
61
+ hash: 7
55
62
  segments:
56
63
  - 1
57
64
  - 4
@@ -63,9 +70,11 @@ dependencies:
63
70
  name: yard
64
71
  prerelease: false
65
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
66
74
  requirements:
67
75
  - - ">="
68
76
  - !ruby/object:Gem::Version
77
+ hash: 13
69
78
  segments:
70
79
  - 0
71
80
  - 5
@@ -77,9 +86,11 @@ dependencies:
77
86
  name: maruku
78
87
  prerelease: false
79
88
  requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
80
90
  requirements:
81
91
  - - ">="
82
92
  - !ruby/object:Gem::Version
93
+ hash: 25
83
94
  segments:
84
95
  - 0
85
96
  - 5
@@ -104,6 +115,9 @@ files:
104
115
  - bin/ritsu
105
116
  - lib/ritsu.rb
106
117
  - lib/ritsu/block.rb
118
+ - lib/ritsu/ext/fake_install.rb
119
+ - lib/ritsu/ext/fake_install/project.rb
120
+ - lib/ritsu/ext/fake_install/src_files/project_cmake_lists.rb
107
121
  - lib/ritsu/ext/test_case.rb
108
122
  - lib/ritsu/external_library.rb
109
123
  - lib/ritsu/project.rb
@@ -126,6 +140,7 @@ files:
126
140
  - lib/ritsu/src_files/static_library_cmake_lists.rb
127
141
  - lib/ritsu/src_files/target_cmake_lists.rb
128
142
  - lib/ritsu/src_files/templated_src_file.rb
143
+ - lib/ritsu/src_files/unit.rb
129
144
  - lib/ritsu/target.rb
130
145
  - lib/ritsu/targets.rb
131
146
  - lib/ritsu/targets/executable.rb
@@ -148,6 +163,28 @@ files:
148
163
  - lib/ritsu/utility/simple_io.rb
149
164
  - lib/ritsu/utility/single_instance.rb
150
165
  - lib/ritsu/utility/strings.rb
166
+ - test/ritsu/block_test.rb
167
+ - test/ritsu/external_library_test.rb
168
+ - test/ritsu/project_generators/default_generator_test.rb
169
+ - test/ritsu/project_test.rb
170
+ - test/ritsu/src_file_test.rb
171
+ - test/ritsu/src_files/cpp_file_test.rb
172
+ - test/ritsu/src_files/executable_cmake_lists_test.rb
173
+ - test/ritsu/src_files/header_file_test.rb
174
+ - test/ritsu/src_files/project_cmake_lists_test.rb
175
+ - test/ritsu/src_files/shared_library_cmake_lists_test.rb
176
+ - test/ritsu/src_files/static_library_cmake_lists_test.rb
177
+ - test/ritsu/src_files/target_cmake_lists_test.rb
178
+ - test/ritsu/target_test.rb
179
+ - test/ritsu/targets/executable_test.rb
180
+ - test/ritsu/targets/shared_library_test.rb
181
+ - test/ritsu/targets/static_library_test.rb
182
+ - test/ritsu/template_policies_test.rb
183
+ - test/ritsu/utility/accessors_test.rb
184
+ - test/ritsu/utility/check_upon_add_set_test.rb
185
+ - test/ritsu/utility/file_robot_test.rb
186
+ - test/ritsu/utility/strings_test.rb
187
+ - test/test_helpers.rb
151
188
  has_rdoc: true
152
189
  homepage: http://github.com/dragonmeteor/ritsu
153
190
  licenses: []
@@ -164,23 +201,27 @@ rdoc_options:
164
201
  require_paths:
165
202
  - lib
166
203
  required_ruby_version: !ruby/object:Gem::Requirement
204
+ none: false
167
205
  requirements:
168
206
  - - ">="
169
207
  - !ruby/object:Gem::Version
208
+ hash: 3
170
209
  segments:
171
210
  - 0
172
211
  version: "0"
173
212
  required_rubygems_version: !ruby/object:Gem::Requirement
213
+ none: false
174
214
  requirements:
175
215
  - - ">="
176
216
  - !ruby/object:Gem::Version
217
+ hash: 3
177
218
  segments:
178
219
  - 0
179
220
  version: "0"
180
221
  requirements: []
181
222
 
182
223
  rubyforge_project: ritsu
183
- rubygems_version: 1.3.6
224
+ rubygems_version: 1.3.7
184
225
  signing_key:
185
226
  specification_version: 3
186
227
  summary: A code generation system that facilitates building C/C++ software with the help of CMake and Doxygen