ritsu 0.4.1 → 0.5.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/VERSION +1 -1
- data/lib/ritsu/ext/cuda/project.rb +31 -0
- data/lib/ritsu/ext/cuda/src_files/cu_file.rb +47 -0
- data/lib/ritsu/ext/cuda/src_files/target_cmake_lists.rb +71 -0
- data/lib/ritsu/ext/cuda.rb +3 -0
- data/lib/ritsu/ext/glsl/src_files/frag_file.rb +5 -9
- data/lib/ritsu/ext/glsl/src_files/vert_file.rb +6 -10
- data/lib/ritsu/src_file.rb +1 -1
- data/lib/ritsu/src_files/cpp_file.rb +8 -3
- data/lib/ritsu/src_files/header_file.rb +14 -5
- data/lib/ritsu/src_files/project_cmake_lists.rb +1 -1
- data/lib/ritsu/src_files/project_config_header_file.rb +1 -1
- data/lib/ritsu/src_files/project_config_header_template_file.rb +1 -2
- data/lib/ritsu/src_files/target_cmake_lists.rb +2 -2
- data/lib/ritsu/src_files.rb +0 -2
- metadata +9 -7
- data/lib/ritsu/src_files/cpp_file_mixin.rb +0 -13
- data/lib/ritsu/src_files/header_file_mixin.rb +0 -20
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../project")
|
2
|
+
|
3
|
+
module Ritsu
|
4
|
+
class Project
|
5
|
+
def setup_cuda
|
6
|
+
add_external_library("cuda") do |e|
|
7
|
+
e.cmake_find_script "FIND_PACKAGE(CUDA REQUIRED)"
|
8
|
+
e.cmake_depend_script "INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})"
|
9
|
+
e.cmake_name "${CUDA_LIBRARIES}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_cuda_executable(name)
|
14
|
+
executable = Ritsu::Targets::Executable.new(name, :project=>self)
|
15
|
+
executable.add_external_library "cuda"
|
16
|
+
yield executable if block_given?
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_cuda_shared_library(name)
|
20
|
+
shared_library = Ritsu::Targets::SharedLibrary.new(name, :project=>self)
|
21
|
+
shared_library.add_external_library "cuda"
|
22
|
+
yield shared_library if block_given?
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_cuda_static_library(name)
|
26
|
+
static_library = Ritsu::Targets::StaticLibrary.new(name, :project=>self)
|
27
|
+
static_library.add_external_library "cuda"
|
28
|
+
yield static_library if block_given?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../project")
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../src_file")
|
3
|
+
|
4
|
+
module Ritsu
|
5
|
+
module SrcFiles
|
6
|
+
class CuFile < Ritsu::SrcFile
|
7
|
+
def initialize(src_path, owner)
|
8
|
+
super(src_path, owner)
|
9
|
+
end
|
10
|
+
|
11
|
+
def header_file?
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def cpp_file?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
def cu_file?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module AddCuFile
|
25
|
+
def add_cu_file(path, options={})
|
26
|
+
src_path = compute_src_path(path, options)
|
27
|
+
CuFile.new(src_path, self)
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_cu_files(*paths)
|
31
|
+
paths.each do |path|
|
32
|
+
add_cu_file(path)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
module Ritsu
|
40
|
+
class Target
|
41
|
+
include Ritsu::SrcFiles::AddCuFile
|
42
|
+
end
|
43
|
+
|
44
|
+
class Project
|
45
|
+
include Ritsu::SrcFiles::AddCuFile
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'active_support/core_ext/string/starts_ends_with'
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../src_files/target_cmake_lists')
|
4
|
+
|
5
|
+
module Ritsu
|
6
|
+
module SrcFiles
|
7
|
+
class TargetCmakeLists
|
8
|
+
class CudaCompileTemplate < Ritsu::Template
|
9
|
+
attr_reader :target
|
10
|
+
|
11
|
+
def initialize(target)
|
12
|
+
super("TargetCmakeLists -- #{target.name} -- CudaCompile")
|
13
|
+
@target = target
|
14
|
+
end
|
15
|
+
|
16
|
+
def cuda_generate_files_var_name
|
17
|
+
"#{target.name.upcase}_CUDA_GENERATED_FILES"
|
18
|
+
end
|
19
|
+
|
20
|
+
def update_block(block, options = {})
|
21
|
+
block.clear_contents
|
22
|
+
|
23
|
+
cu_files = target.src_files.select { |x| x.respond_to?(:cu_file?) && x.cu_file? }
|
24
|
+
if cu_files.length == 0
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
block.add_line "CUDA_COMPILE(#{cuda_generate_files_var_name}"
|
29
|
+
block.indent
|
30
|
+
cu_files.each do |cu_file|
|
31
|
+
block.add_line("${CMAKE_SOURCE_DIR}/#{cu_file.src_path}")
|
32
|
+
end
|
33
|
+
block.outdent
|
34
|
+
#if target.static_library?
|
35
|
+
# block.add_line("STATIC")
|
36
|
+
#elsif target.shared_library?
|
37
|
+
# block.add_line("SHARED")
|
38
|
+
#end
|
39
|
+
block.add_line ")"
|
40
|
+
block.add_new_line
|
41
|
+
block.add_line "SET(#{target.name.upcase}_SRC_FILES ${#{target.name.upcase}_SRC_FILES} ${#{cuda_generate_files_var_name}})"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Template
|
46
|
+
attr_reader :cuda_compile_template
|
47
|
+
|
48
|
+
alias_method :initialize_before_cuda, :initialize
|
49
|
+
|
50
|
+
def initialize(target, id = nil)
|
51
|
+
initialize_before_cuda(target, id)
|
52
|
+
|
53
|
+
@cuda_compile_template = CudaCompileTemplate.new(target)
|
54
|
+
position = child_template_with_id_position(source_files_template.id) + 1
|
55
|
+
contents.insert(position, @cuda_compile_template)
|
56
|
+
contents.insert(position, "")
|
57
|
+
end
|
58
|
+
|
59
|
+
alias_method :position_to_insert_before_cuda, :position_to_insert
|
60
|
+
|
61
|
+
def position_to_insert(block, new_block)
|
62
|
+
if new_block.id == cuda_compile_template.id
|
63
|
+
block.child_block_with_id_position(source_files_template.id) + 1
|
64
|
+
else
|
65
|
+
position_to_insert_before_cuda(block, new_block)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -3,7 +3,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../src_file")
|
|
3
3
|
|
4
4
|
module Ritsu
|
5
5
|
module SrcFiles
|
6
|
-
|
6
|
+
class FragFile < Ritsu::SrcFile
|
7
|
+
def initialize(src_path, owner)
|
8
|
+
super(src_path, owner)
|
9
|
+
end
|
10
|
+
|
7
11
|
def glsl_file?
|
8
12
|
true
|
9
13
|
end
|
@@ -32,14 +36,6 @@ module Ritsu
|
|
32
36
|
src_path.gsub(/[.\/]+/,'_') + "_code"
|
33
37
|
end
|
34
38
|
end
|
35
|
-
|
36
|
-
class FragFile < Ritsu::SrcFile
|
37
|
-
include FragFileMixin
|
38
|
-
|
39
|
-
def initialize(src_path, owner)
|
40
|
-
super(src_path, owner)
|
41
|
-
end
|
42
|
-
end
|
43
39
|
|
44
40
|
module AddFragFile
|
45
41
|
def add_frag_file(path, options={})
|
@@ -2,8 +2,12 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../project")
|
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + "/../../../src_file")
|
3
3
|
|
4
4
|
module Ritsu
|
5
|
-
module SrcFiles
|
6
|
-
|
5
|
+
module SrcFiles
|
6
|
+
class VertFile < Ritsu::SrcFile
|
7
|
+
def initialize(src_path, owner)
|
8
|
+
super(src_path, owner)
|
9
|
+
end
|
10
|
+
|
7
11
|
def glsl_file?
|
8
12
|
true
|
9
13
|
end
|
@@ -32,14 +36,6 @@ module Ritsu
|
|
32
36
|
src_path.gsub(/[.\/]+/,'_') + "_code"
|
33
37
|
end
|
34
38
|
end
|
35
|
-
|
36
|
-
class VertFile < Ritsu::SrcFile
|
37
|
-
include VertFileMixin
|
38
|
-
|
39
|
-
def initialize(src_path, owner)
|
40
|
-
super(src_path, owner)
|
41
|
-
end
|
42
|
-
end
|
43
39
|
|
44
40
|
module AddVertFile
|
45
41
|
def add_vert_file(path, options={})
|
data/lib/ritsu/src_file.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../src_file')
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + '/../project')
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../utility/instance_set')
|
4
|
-
require File.expand_path(File.dirname(__FILE__) + '/cpp_file_mixin')
|
5
4
|
|
6
5
|
module Ritsu
|
7
6
|
module SrcFiles
|
8
7
|
class CppFile < Ritsu::SrcFile
|
9
|
-
include CppFileMixin
|
10
|
-
|
11
8
|
def initialize(src_path, owner)
|
12
9
|
super(src_path, owner)
|
13
10
|
end
|
11
|
+
|
12
|
+
def header_file?
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def cpp_file?
|
17
|
+
true
|
18
|
+
end
|
14
19
|
end
|
15
20
|
|
16
21
|
module AddCppFile
|
@@ -2,13 +2,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../src_file')
|
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + '/../project')
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../utility/instance_set')
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + '/../utility/file_robot')
|
5
|
-
require File.expand_path(File.dirname(__FILE__) + '/header_file_mixin')
|
6
5
|
|
7
6
|
module Ritsu
|
8
7
|
module SrcFiles
|
9
|
-
class HeaderFile < Ritsu::SrcFile
|
10
|
-
include HeaderFileMixin
|
11
|
-
|
8
|
+
class HeaderFile < Ritsu::SrcFile
|
12
9
|
def initialize(src_path, owner)
|
13
10
|
super(src_path, owner)
|
14
11
|
end
|
@@ -23,7 +20,19 @@ module Ritsu
|
|
23
20
|
"////////////////////\n" +
|
24
21
|
"\n" +
|
25
22
|
"#endif\n")
|
26
|
-
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def include_guard
|
26
|
+
'__' + project.name.underscore.upcase + '_' + src_path.gsub(/[.\/]+/,'_').upcase + '__'
|
27
|
+
end
|
28
|
+
|
29
|
+
def header_file?
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def cpp_file?
|
34
|
+
false
|
35
|
+
end
|
27
36
|
end
|
28
37
|
|
29
38
|
module AddHeaderFile
|
@@ -4,7 +4,6 @@ require File.expand_path(File.dirname(__FILE__) + "/templated_src_file")
|
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + "/../template_policies")
|
5
5
|
require File.expand_path(File.dirname(__FILE__) + "/../template")
|
6
6
|
require File.expand_path(File.dirname(__FILE__) + "/../utility/platform")
|
7
|
-
require File.expand_path(File.dirname(__FILE__) + "/header_file_mixin")
|
8
7
|
|
9
8
|
module Ritsu
|
10
9
|
module SrcFiles
|
@@ -38,7 +37,7 @@ module Ritsu
|
|
38
37
|
self.template = Template.new(self)
|
39
38
|
end
|
40
39
|
|
41
|
-
def
|
40
|
+
def include_in_source_files?
|
42
41
|
false
|
43
42
|
end
|
44
43
|
end
|
@@ -75,7 +75,7 @@ module Ritsu
|
|
75
75
|
src_files = target.src_files.to_a
|
76
76
|
src_files.sort! {|x,y| x.src_path <=> y.src_path}
|
77
77
|
src_files.each do |src_file|
|
78
|
-
block.contents << " ${CMAKE_SOURCE_DIR}/#{src_file.src_path}" if src_file.
|
78
|
+
block.contents << " ${CMAKE_SOURCE_DIR}/#{src_file.src_path}" if src_file.include_in_source_files?
|
79
79
|
end
|
80
80
|
|
81
81
|
block.contents << ")"
|
@@ -182,7 +182,7 @@ module Ritsu
|
|
182
182
|
:block_end_prefix=>'##>>')
|
183
183
|
end
|
184
184
|
|
185
|
-
def
|
185
|
+
def include_in_source_files?
|
186
186
|
false
|
187
187
|
end
|
188
188
|
end
|
data/lib/ritsu/src_files.rb
CHANGED
@@ -2,9 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/src_files/project_cmake_list
|
|
2
2
|
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/src_files/templated_src_file')
|
4
4
|
|
5
|
-
require File.expand_path(File.dirname(__FILE__) + '/src_files/cpp_file_mixin')
|
6
5
|
require File.expand_path(File.dirname(__FILE__) + '/src_files/cpp_file')
|
7
|
-
require File.expand_path(File.dirname(__FILE__) + '/src_files/header_file_mixin')
|
8
6
|
require File.expand_path(File.dirname(__FILE__) + '/src_files/header_file')
|
9
7
|
require File.expand_path(File.dirname(__FILE__) + '/src_files/target_cmake_lists')
|
10
8
|
require File.expand_path(File.dirname(__FILE__) + '/src_files/executable_cmake_lists')
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ritsu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- dragonmeteor
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-23 00:00:00 +07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -117,6 +117,10 @@ files:
|
|
117
117
|
- bin/ritsu
|
118
118
|
- lib/ritsu.rb
|
119
119
|
- lib/ritsu/block.rb
|
120
|
+
- lib/ritsu/ext/cuda.rb
|
121
|
+
- lib/ritsu/ext/cuda/project.rb
|
122
|
+
- lib/ritsu/ext/cuda/src_files/cu_file.rb
|
123
|
+
- lib/ritsu/ext/cuda/src_files/target_cmake_lists.rb
|
120
124
|
- lib/ritsu/ext/fake_install.rb
|
121
125
|
- lib/ritsu/ext/fake_install/project.rb
|
122
126
|
- lib/ritsu/ext/fake_install/src_files/project_cmake_lists.rb
|
@@ -134,10 +138,8 @@ files:
|
|
134
138
|
- lib/ritsu/src_file.rb
|
135
139
|
- lib/ritsu/src_files.rb
|
136
140
|
- lib/ritsu/src_files/cpp_file.rb
|
137
|
-
- lib/ritsu/src_files/cpp_file_mixin.rb
|
138
141
|
- lib/ritsu/src_files/executable_cmake_lists.rb
|
139
142
|
- lib/ritsu/src_files/header_file.rb
|
140
|
-
- lib/ritsu/src_files/header_file_mixin.rb
|
141
143
|
- lib/ritsu/src_files/project_cmake_lists.rb
|
142
144
|
- lib/ritsu/src_files/project_config_header_file.rb
|
143
145
|
- lib/ritsu/src_files/project_config_header_template_file.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'active_support/core_ext/string/inflections'
|
3
|
-
|
4
|
-
module Ritsu
|
5
|
-
module SrcFiles
|
6
|
-
module HeaderFileMixin
|
7
|
-
def include_guard
|
8
|
-
'__' + project.name.underscore.upcase + '_' + src_path.gsub(/[.\/]+/,'_').upcase + '__'
|
9
|
-
end
|
10
|
-
|
11
|
-
def header_file?
|
12
|
-
true
|
13
|
-
end
|
14
|
-
|
15
|
-
def cpp_file?
|
16
|
-
false
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|