ritsu 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +95 -95
- data/bin/define_cpp_string +54 -54
- data/bin/ritsu +31 -31
- data/lib/ritsu.rb +16 -16
- data/lib/ritsu/block.rb +258 -258
- data/lib/ritsu/ext/cuda.rb +5 -5
- data/lib/ritsu/ext/cuda/external_library.rb +15 -15
- data/lib/ritsu/ext/cuda/project.rb +31 -31
- data/lib/ritsu/ext/cuda/src_files/cu_file.rb +46 -46
- data/lib/ritsu/ext/cuda/src_files/target_cmake_lists.rb +110 -110
- data/lib/ritsu/ext/cuda/target.rb +16 -16
- data/lib/ritsu/ext/cuda/targets/library.rb +16 -16
- data/lib/ritsu/ext/fake_install.rb +2 -2
- data/lib/ritsu/ext/fake_install/project.rb +16 -16
- data/lib/ritsu/ext/fake_install/src_files/project_cmake_lists.rb +45 -45
- data/lib/ritsu/ext/glsl.rb +1 -1
- data/lib/ritsu/ext/glsl/src_files/frag_file.rb +70 -70
- data/lib/ritsu/ext/glsl/src_files/vert_file.rb +70 -70
- data/lib/ritsu/ext/qt.rb +4 -4
- data/lib/ritsu/ext/qt/project.rb +47 -47
- data/lib/ritsu/ext/qt/src_files/header_file.rb +60 -60
- data/lib/ritsu/ext/qt/src_files/target_cmake_lists.rb +106 -106
- data/lib/ritsu/ext/qt/src_files/ui_file.rb +46 -46
- data/lib/ritsu/ext/test_case.rb +19 -19
- data/lib/ritsu/external_library.rb +46 -46
- data/lib/ritsu/project.rb +93 -93
- data/lib/ritsu/project_generator.rb +33 -33
- data/lib/ritsu/project_generators/default_generator.rb +72 -72
- data/lib/ritsu/project_generators/default_generator_files/Thorfile.erb +8 -8
- data/lib/ritsu/project_generators/default_generator_files/meta/project.rb.erb +10 -10
- data/lib/ritsu/src_file.rb +79 -79
- data/lib/ritsu/src_files.rb +12 -12
- data/lib/ritsu/src_files/cpp_file.rb +43 -43
- data/lib/ritsu/src_files/executable_cmake_lists.rb +39 -39
- data/lib/ritsu/src_files/header_file.rb +60 -60
- data/lib/ritsu/src_files/project_cmake_lists.rb +133 -133
- data/lib/ritsu/src_files/project_config_header_file.rb +14 -14
- data/lib/ritsu/src_files/project_config_header_template_file.rb +44 -44
- data/lib/ritsu/src_files/shared_library_cmake_lists.rb +39 -39
- data/lib/ritsu/src_files/static_library_cmake_lists.rb +39 -39
- data/lib/ritsu/src_files/target_cmake_lists.rb +189 -189
- data/lib/ritsu/src_files/templated_src_file.rb +47 -47
- data/lib/ritsu/src_files/unit.rb +32 -32
- data/lib/ritsu/target.rb +154 -154
- data/lib/ritsu/targets.rb +3 -3
- data/lib/ritsu/targets/executable.rb +44 -44
- data/lib/ritsu/targets/library.rb +29 -29
- data/lib/ritsu/targets/shared_library.rb +38 -38
- data/lib/ritsu/targets/static_library.rb +32 -32
- data/lib/ritsu/template.rb +68 -68
- data/lib/ritsu/template_policies.rb +132 -132
- data/lib/ritsu/test_helpers.rb +123 -123
- data/lib/ritsu/thors/default_thor.rb +1 -1
- data/lib/ritsu/utility.rb +7 -7
- data/lib/ritsu/utility/accessors.rb +29 -29
- data/lib/ritsu/utility/check_upon_add_set.rb +34 -34
- data/lib/ritsu/utility/file_robot.rb +128 -128
- data/lib/ritsu/utility/files.rb +12 -12
- data/lib/ritsu/utility/instance_dependencies.rb +112 -112
- data/lib/ritsu/utility/instance_set.rb +28 -28
- data/lib/ritsu/utility/platform.rb +20 -20
- data/lib/ritsu/utility/simple_io.rb +64 -64
- data/lib/ritsu/utility/single_instance.rb +33 -33
- data/lib/ritsu/utility/strings.rb +40 -40
- data/test/ritsu/block_test.rb +196 -196
- data/test/ritsu/ext/cuda/src_files/cuda_static_library_cmake_lists_test.rb +63 -63
- data/test/ritsu/external_library_test.rb +41 -41
- data/test/ritsu/project_generators/default_generator_test.rb +34 -34
- data/test/ritsu/project_test.rb +127 -127
- data/test/ritsu/src_file_test.rb +69 -69
- data/test/ritsu/src_files/cpp_file_test.rb +42 -42
- data/test/ritsu/src_files/executable_cmake_lists_test.rb +92 -92
- data/test/ritsu/src_files/header_file_test.rb +57 -57
- data/test/ritsu/src_files/project_cmake_lists_test.rb +159 -159
- data/test/ritsu/src_files/shared_library_cmake_lists_test.rb +54 -54
- data/test/ritsu/src_files/static_library_cmake_lists_test.rb +54 -54
- data/test/ritsu/src_files/target_cmake_lists_test.rb +15 -15
- data/test/ritsu/target_test.rb +105 -105
- data/test/ritsu/targets/executable_test.rb +10 -10
- data/test/ritsu/targets/shared_library_test.rb +10 -10
- data/test/ritsu/targets/static_library_test.rb +10 -10
- data/test/ritsu/utility/accessors_test.rb +14 -14
- data/test/ritsu/utility/check_upon_add_set_test.rb +31 -31
- data/test/ritsu/utility/file_robot_test.rb +175 -175
- data/test/ritsu/utility/strings_test.rb +28 -28
- data/test/test_helpers.rb +3 -3
- metadata +72 -124
- data/Thorfile +0 -104
- data/VERSION +0 -1
@@ -1,64 +1,64 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../../../test_helpers"
|
2
|
-
require File.dirname(__FILE__) + "/../../../../../lib/ritsu/ext/cuda"
|
3
|
-
|
4
|
-
class CudaStaticLibraryCMakeListsTest < Test::Unit::TestCase
|
5
|
-
include Ritsu::SetupProjectAndClearEverythingElse
|
6
|
-
include Ritsu::TestCaseWithFileTestData
|
7
|
-
include Ritsu::Utility
|
8
|
-
|
9
|
-
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
10
|
-
|
11
|
-
def setup
|
12
|
-
setup_project('mio')
|
13
|
-
@project.project_dir = output_dir
|
14
|
-
@project.setup_cuda
|
15
|
-
end
|
16
|
-
|
17
|
-
file_test "must be present" do
|
18
|
-
abc = Ritsu::Targets::StaticLibrary.new("abc", :project=>@project, :cuda_target=>true)
|
19
|
-
abc.add_external_library "cuda"
|
20
|
-
assert abc.respond_to?(:cmake_lists)
|
21
|
-
assert abc.cmake_lists.kind_of?(Ritsu::SrcFiles::StaticLibraryCmakeLists)
|
22
|
-
assert_equal 1,
|
23
|
-
abc.src_files.select {|x| x.kind_of?(Ritsu::SrcFiles::StaticLibraryCmakeLists)}.length
|
24
|
-
end
|
25
|
-
|
26
|
-
file_test "create" do
|
27
|
-
abc = Ritsu::Targets::StaticLibrary.new("abc", :project=>@project, :cuda_target=>true)
|
28
|
-
FileRobot.quietly do
|
29
|
-
abc.cmake_lists.create
|
30
|
-
end
|
31
|
-
assert_file_exists(abc.cmake_lists.abs_path)
|
32
|
-
|
33
|
-
expected_content = <<-CMAKE
|
34
|
-
##<< TargetCmakeLists -- abc -- Libraries
|
35
|
-
##>> TargetCmakeLists -- abc -- Libraries
|
36
|
-
|
37
|
-
##<< TargetCmakeLists -- abc -- CudaIncludeDirectories
|
38
|
-
##>> TargetCmakeLists -- abc -- CudaIncludeDirectories
|
39
|
-
|
40
|
-
##<< TargetCmakeLists -- abc -- Custom Commands
|
41
|
-
##>> TargetCmakeLists -- abc -- Custom Commands
|
42
|
-
|
43
|
-
##<< TargetCmakeLists -- abc -- Source Files
|
44
|
-
SET(ABC_SRC_FILES
|
45
|
-
)
|
46
|
-
##>> TargetCmakeLists -- abc -- Source Files
|
47
|
-
|
48
|
-
##<< TargetCmakeLists -- abc -- CudaCompile
|
49
|
-
##>> TargetCmakeLists -- abc -- CudaCompile
|
50
|
-
|
51
|
-
##<< StaticLibraryCmakeLists -- abc -- Static Library
|
52
|
-
ADD_LIBRARY(abc STATIC ${ABC_SRC_FILES})
|
53
|
-
##>> StaticLibraryCmakeLists -- abc -- Static Library
|
54
|
-
|
55
|
-
##<< TargetCmakeLists -- abc -- Dependencies
|
56
|
-
##>> TargetCmakeLists -- abc -- Dependencies
|
57
|
-
|
58
|
-
##<< TargetCmakeLists -- abc -- Install
|
59
|
-
##>> TargetCmakeLists -- abc -- Install
|
60
|
-
CMAKE
|
61
|
-
|
62
|
-
assert_file_content(expected_content, abc.cmake_lists.abs_path)
|
63
|
-
end
|
1
|
+
require File.dirname(__FILE__) + "/../../../../test_helpers"
|
2
|
+
require File.dirname(__FILE__) + "/../../../../../lib/ritsu/ext/cuda"
|
3
|
+
|
4
|
+
class CudaStaticLibraryCMakeListsTest < Test::Unit::TestCase
|
5
|
+
include Ritsu::SetupProjectAndClearEverythingElse
|
6
|
+
include Ritsu::TestCaseWithFileTestData
|
7
|
+
include Ritsu::Utility
|
8
|
+
|
9
|
+
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
10
|
+
|
11
|
+
def setup
|
12
|
+
setup_project('mio')
|
13
|
+
@project.project_dir = output_dir
|
14
|
+
@project.setup_cuda
|
15
|
+
end
|
16
|
+
|
17
|
+
file_test "must be present" do
|
18
|
+
abc = Ritsu::Targets::StaticLibrary.new("abc", :project=>@project, :cuda_target=>true)
|
19
|
+
abc.add_external_library "cuda"
|
20
|
+
assert abc.respond_to?(:cmake_lists)
|
21
|
+
assert abc.cmake_lists.kind_of?(Ritsu::SrcFiles::StaticLibraryCmakeLists)
|
22
|
+
assert_equal 1,
|
23
|
+
abc.src_files.select {|x| x.kind_of?(Ritsu::SrcFiles::StaticLibraryCmakeLists)}.length
|
24
|
+
end
|
25
|
+
|
26
|
+
file_test "create" do
|
27
|
+
abc = Ritsu::Targets::StaticLibrary.new("abc", :project=>@project, :cuda_target=>true)
|
28
|
+
FileRobot.quietly do
|
29
|
+
abc.cmake_lists.create
|
30
|
+
end
|
31
|
+
assert_file_exists(abc.cmake_lists.abs_path)
|
32
|
+
|
33
|
+
expected_content = <<-CMAKE
|
34
|
+
##<< TargetCmakeLists -- abc -- Libraries
|
35
|
+
##>> TargetCmakeLists -- abc -- Libraries
|
36
|
+
|
37
|
+
##<< TargetCmakeLists -- abc -- CudaIncludeDirectories
|
38
|
+
##>> TargetCmakeLists -- abc -- CudaIncludeDirectories
|
39
|
+
|
40
|
+
##<< TargetCmakeLists -- abc -- Custom Commands
|
41
|
+
##>> TargetCmakeLists -- abc -- Custom Commands
|
42
|
+
|
43
|
+
##<< TargetCmakeLists -- abc -- Source Files
|
44
|
+
SET(ABC_SRC_FILES
|
45
|
+
)
|
46
|
+
##>> TargetCmakeLists -- abc -- Source Files
|
47
|
+
|
48
|
+
##<< TargetCmakeLists -- abc -- CudaCompile
|
49
|
+
##>> TargetCmakeLists -- abc -- CudaCompile
|
50
|
+
|
51
|
+
##<< StaticLibraryCmakeLists -- abc -- Static Library
|
52
|
+
ADD_LIBRARY(abc STATIC ${ABC_SRC_FILES})
|
53
|
+
##>> StaticLibraryCmakeLists -- abc -- Static Library
|
54
|
+
|
55
|
+
##<< TargetCmakeLists -- abc -- Dependencies
|
56
|
+
##>> TargetCmakeLists -- abc -- Dependencies
|
57
|
+
|
58
|
+
##<< TargetCmakeLists -- abc -- Install
|
59
|
+
##>> TargetCmakeLists -- abc -- Install
|
60
|
+
CMAKE
|
61
|
+
|
62
|
+
assert_file_content(expected_content, abc.cmake_lists.abs_path)
|
63
|
+
end
|
64
64
|
end
|
@@ -1,42 +1,42 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../test_helpers"
|
2
|
-
|
3
|
-
class ExternalLibraryTest < Test::Unit::TestCase
|
4
|
-
include Ritsu
|
5
|
-
|
6
|
-
def setup
|
7
|
-
ExternalLibrary.instances.clear
|
8
|
-
end
|
9
|
-
|
10
|
-
must "initialize correctly" do
|
11
|
-
qt = ExternalLibrary.new('qt')
|
12
|
-
assert_equal 'qt', qt.name
|
13
|
-
assert_equal '', qt.cmake_name
|
14
|
-
assert_equal '', qt.cmake_depend_script
|
15
|
-
assert_equal '', qt.cmake_find_script
|
16
|
-
assert_equal 1, ExternalLibrary.instances.size
|
17
|
-
end
|
18
|
-
|
19
|
-
must "be able to use cmake_name, cmake_depend_script, and cmake_find_script methods in instance_eval" do
|
20
|
-
qt = ExternalLibrary.new('qt')
|
21
|
-
qt.instance_eval do
|
22
|
-
cmake_name 'Qt'
|
23
|
-
cmake_depend_script 'abc'
|
24
|
-
cmake_find_script 'def'
|
25
|
-
end
|
26
|
-
assert_equal 'Qt', qt.cmake_name
|
27
|
-
assert_equal 'abc', qt.cmake_depend_script
|
28
|
-
assert_equal 'def', qt.cmake_find_script
|
29
|
-
end
|
30
|
-
|
31
|
-
must "raise exception if create external library with duplicated names" do
|
32
|
-
ExternalLibrary.new('qt')
|
33
|
-
assert_raises(ArgumentError) do
|
34
|
-
ExternalLibrary.new('qt')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
must "find_by_name correctly" do
|
39
|
-
qt = ExternalLibrary.new('qt')
|
40
|
-
assert_equal qt, ExternalLibrary.find_by_name('qt')
|
41
|
-
end
|
1
|
+
require File.dirname(__FILE__) + "/../test_helpers"
|
2
|
+
|
3
|
+
class ExternalLibraryTest < Test::Unit::TestCase
|
4
|
+
include Ritsu
|
5
|
+
|
6
|
+
def setup
|
7
|
+
ExternalLibrary.instances.clear
|
8
|
+
end
|
9
|
+
|
10
|
+
must "initialize correctly" do
|
11
|
+
qt = ExternalLibrary.new('qt')
|
12
|
+
assert_equal 'qt', qt.name
|
13
|
+
assert_equal '', qt.cmake_name
|
14
|
+
assert_equal '', qt.cmake_depend_script
|
15
|
+
assert_equal '', qt.cmake_find_script
|
16
|
+
assert_equal 1, ExternalLibrary.instances.size
|
17
|
+
end
|
18
|
+
|
19
|
+
must "be able to use cmake_name, cmake_depend_script, and cmake_find_script methods in instance_eval" do
|
20
|
+
qt = ExternalLibrary.new('qt')
|
21
|
+
qt.instance_eval do
|
22
|
+
cmake_name 'Qt'
|
23
|
+
cmake_depend_script 'abc'
|
24
|
+
cmake_find_script 'def'
|
25
|
+
end
|
26
|
+
assert_equal 'Qt', qt.cmake_name
|
27
|
+
assert_equal 'abc', qt.cmake_depend_script
|
28
|
+
assert_equal 'def', qt.cmake_find_script
|
29
|
+
end
|
30
|
+
|
31
|
+
must "raise exception if create external library with duplicated names" do
|
32
|
+
ExternalLibrary.new('qt')
|
33
|
+
assert_raises(ArgumentError) do
|
34
|
+
ExternalLibrary.new('qt')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
must "find_by_name correctly" do
|
39
|
+
qt = ExternalLibrary.new('qt')
|
40
|
+
assert_equal qt, ExternalLibrary.find_by_name('qt')
|
41
|
+
end
|
42
42
|
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../test_helpers"
|
2
|
-
|
3
|
-
class DefaultGeneratorTest < Test::Unit::TestCase
|
4
|
-
include Ritsu::TestCaseWithFileTestData
|
5
|
-
include Ritsu::Utility
|
6
|
-
|
7
|
-
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
8
|
-
|
9
|
-
file_test "generate" do
|
10
|
-
FileRobot.quietly do
|
11
|
-
Ritsu::ProjectGenerators::DefaultGenerator.new.generate('mio', output_dir)
|
12
|
-
end
|
13
|
-
|
14
|
-
assert_output_file_exists("mio")
|
15
|
-
assert_output_file_exists("mio/build")
|
16
|
-
assert_output_file_exists("mio/src")
|
17
|
-
assert_output_file_exists("mio/meta")
|
18
|
-
assert_output_file_exists("mio/Thorfile")
|
19
|
-
assert_output_file_exists("mio/meta/project.rb")
|
20
|
-
|
21
|
-
expected_project_rb_content = <<-RUBY
|
22
|
-
require 'rubygems'
|
23
|
-
require 'ritsu'
|
24
|
-
|
25
|
-
Ritsu::Project.create('mio') do |p|
|
26
|
-
|
27
|
-
##################
|
28
|
-
# YOUR CODE HERE #
|
29
|
-
##################
|
30
|
-
|
31
|
-
end
|
32
|
-
RUBY
|
33
|
-
assert_output_file_content(expected_project_rb_content, "mio/meta/project.rb")
|
34
|
-
end
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helpers"
|
2
|
+
|
3
|
+
class DefaultGeneratorTest < Test::Unit::TestCase
|
4
|
+
include Ritsu::TestCaseWithFileTestData
|
5
|
+
include Ritsu::Utility
|
6
|
+
|
7
|
+
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
8
|
+
|
9
|
+
file_test "generate" do
|
10
|
+
FileRobot.quietly do
|
11
|
+
Ritsu::ProjectGenerators::DefaultGenerator.new.generate('mio', output_dir)
|
12
|
+
end
|
13
|
+
|
14
|
+
assert_output_file_exists("mio")
|
15
|
+
assert_output_file_exists("mio/build")
|
16
|
+
assert_output_file_exists("mio/src")
|
17
|
+
assert_output_file_exists("mio/meta")
|
18
|
+
assert_output_file_exists("mio/Thorfile")
|
19
|
+
assert_output_file_exists("mio/meta/project.rb")
|
20
|
+
|
21
|
+
expected_project_rb_content = <<-RUBY
|
22
|
+
require 'rubygems'
|
23
|
+
require 'ritsu'
|
24
|
+
|
25
|
+
Ritsu::Project.create('mio') do |p|
|
26
|
+
|
27
|
+
##################
|
28
|
+
# YOUR CODE HERE #
|
29
|
+
##################
|
30
|
+
|
31
|
+
end
|
32
|
+
RUBY
|
33
|
+
assert_output_file_content(expected_project_rb_content, "mio/meta/project.rb")
|
34
|
+
end
|
35
35
|
end
|
data/test/ritsu/project_test.rb
CHANGED
@@ -1,128 +1,128 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../test_helpers"
|
2
|
-
|
3
|
-
class ProjectTest < Test::Unit::TestCase
|
4
|
-
include Ritsu::TestCaseWithFileTestData
|
5
|
-
include Ritsu::Utility
|
6
|
-
|
7
|
-
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
8
|
-
|
9
|
-
def setup
|
10
|
-
Ritsu::Target.instances.clear
|
11
|
-
Ritsu::SrcFile.instances.clear
|
12
|
-
Ritsu::ExternalLibrary.instances.clear
|
13
|
-
end
|
14
|
-
|
15
|
-
must "create correctly" do
|
16
|
-
hello = Ritsu::Project.create('hello')
|
17
|
-
assert_equal 'hello', hello.name
|
18
|
-
assert_equal Set.new, hello.targets
|
19
|
-
assert_equal Set.new, hello.external_libraries
|
20
|
-
end
|
21
|
-
|
22
|
-
['53k', 'abc def', '???'].each do |project_name|
|
23
|
-
must "raise exception if project name is #{project_name} (i.e., not a C name)" do
|
24
|
-
assert_raises(ArgumentError) do
|
25
|
-
Ritsu::Project.create(project_name)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
['mio', 'MikuMikuDance', '_Something'].each do |project_name|
|
31
|
-
must "not raise exception if project name is #{project_name} (i.e., a valid C name)" do
|
32
|
-
assert_nothing_raised do
|
33
|
-
Ritsu::Project.create(project_name)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
must "be able to add external libraries" do
|
39
|
-
hello = Ritsu::Project.create('hello') do |p|
|
40
|
-
p.add_external_library 'qt_core' do |e|
|
41
|
-
e.cmake_name '${QT_LIBRARIES}'
|
42
|
-
e.cmake_find_script <<-CMAKE
|
43
|
-
FIND_PACKAGE(Qt4 REQUIRED)
|
44
|
-
CMAKE
|
45
|
-
e.cmake_depend_script <<-CMAKE
|
46
|
-
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
|
47
|
-
SET(QT_DONT_USE_QTGUI TRUE)
|
48
|
-
CMAKE
|
49
|
-
end
|
50
|
-
p.add_external_library 'qt_core_gui' do |e|
|
51
|
-
e.cmake_name '${QT_LIBRARIES}'
|
52
|
-
e.cmake_find_script <<-CMAKE
|
53
|
-
FIND_PACKAGE(Qt4 REQUIRED)
|
54
|
-
CMAKE
|
55
|
-
e.cmake_depend_script <<-CMAKE
|
56
|
-
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
|
57
|
-
CMAKE
|
58
|
-
end
|
59
|
-
p.add_external_library 'qt_core_gui_opengl' do |e|
|
60
|
-
e.cmake_name '${QT_LIBRARIES}'
|
61
|
-
e.cmake_find_script <<-CMAKE
|
62
|
-
FIND_PACKAGE(Qt4 REQUIRED)
|
63
|
-
CMAKE
|
64
|
-
e.cmake_depend_script <<-CMAKE
|
65
|
-
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
|
66
|
-
SET(QT_USE_OPENGL TRUE)
|
67
|
-
CMAKE
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
assert_equal 3, hello.external_libraries.length
|
72
|
-
assert hello.external_libraries.any? { |x| x.name == 'qt_core' }
|
73
|
-
assert hello.external_libraries.any? { |x| x.name == 'qt_core_gui' }
|
74
|
-
assert hello.external_libraries.any? { |x| x.name == 'qt_core_gui_opengl' }
|
75
|
-
end
|
76
|
-
|
77
|
-
must "be able to add targets" do
|
78
|
-
hello = Ritsu::Project.create('hello') do |p|
|
79
|
-
p.add_executable 'abc'
|
80
|
-
p.add_shared_library 'def'
|
81
|
-
p.add_static_library 'ghi'
|
82
|
-
end
|
83
|
-
|
84
|
-
assert_equal 3, hello.targets.length
|
85
|
-
assert hello.targets.any? { |x| x.name == 'abc' }
|
86
|
-
assert hello.targets.any? { |x| x.name == 'def' }
|
87
|
-
assert hello.targets.any? { |x| x.name == 'ghi' }
|
88
|
-
end
|
89
|
-
|
90
|
-
file_test "create config header file" do
|
91
|
-
hello = Ritsu::Project.create('hello')
|
92
|
-
hello.project_dir = output_dir
|
93
|
-
assert hello.respond_to?(:config_header_file)
|
94
|
-
assert hello.src_files.any? {|x| x.src_path != "config.h"}
|
95
|
-
|
96
|
-
FileRobot.quietly do
|
97
|
-
hello.update
|
98
|
-
end
|
99
|
-
|
100
|
-
assert_output_file_exists("src/config.h")
|
101
|
-
assert_output_file_content("\n", "src/config.h")
|
102
|
-
end
|
103
|
-
|
104
|
-
file_test "create config header template file" do
|
105
|
-
hello = Ritsu::Project.create('hello')
|
106
|
-
hello.project_dir = output_dir
|
107
|
-
assert hello.respond_to?(:config_header_template_file)
|
108
|
-
assert hello.src_files.any? {|x| x.src_path != "config.h.in"}
|
109
|
-
|
110
|
-
FileRobot.quietly do
|
111
|
-
hello.update
|
112
|
-
end
|
113
|
-
|
114
|
-
assert_output_file_exists("src/config.h.in")
|
115
|
-
|
116
|
-
expected_content = <<-TEXT
|
117
|
-
#ifndef __PROJECT_CONFIG_H__
|
118
|
-
#define __PROJECT_CONFIG_H__
|
119
|
-
|
120
|
-
#cmakedefine __WIN_PLATFORM__
|
121
|
-
#cmakedefine __MAC_PLATFORM__
|
122
|
-
#cmakedefine __UNIX_PLATFORM__
|
123
|
-
|
124
|
-
#endif
|
125
|
-
TEXT
|
126
|
-
assert_output_file_content("\n", "src/config.h")
|
127
|
-
end
|
1
|
+
require File.dirname(__FILE__) + "/../test_helpers"
|
2
|
+
|
3
|
+
class ProjectTest < Test::Unit::TestCase
|
4
|
+
include Ritsu::TestCaseWithFileTestData
|
5
|
+
include Ritsu::Utility
|
6
|
+
|
7
|
+
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
8
|
+
|
9
|
+
def setup
|
10
|
+
Ritsu::Target.instances.clear
|
11
|
+
Ritsu::SrcFile.instances.clear
|
12
|
+
Ritsu::ExternalLibrary.instances.clear
|
13
|
+
end
|
14
|
+
|
15
|
+
must "create correctly" do
|
16
|
+
hello = Ritsu::Project.create('hello')
|
17
|
+
assert_equal 'hello', hello.name
|
18
|
+
assert_equal Set.new, hello.targets
|
19
|
+
assert_equal Set.new, hello.external_libraries
|
20
|
+
end
|
21
|
+
|
22
|
+
['53k', 'abc def', '???'].each do |project_name|
|
23
|
+
must "raise exception if project name is #{project_name} (i.e., not a C name)" do
|
24
|
+
assert_raises(ArgumentError) do
|
25
|
+
Ritsu::Project.create(project_name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
['mio', 'MikuMikuDance', '_Something'].each do |project_name|
|
31
|
+
must "not raise exception if project name is #{project_name} (i.e., a valid C name)" do
|
32
|
+
assert_nothing_raised do
|
33
|
+
Ritsu::Project.create(project_name)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
must "be able to add external libraries" do
|
39
|
+
hello = Ritsu::Project.create('hello') do |p|
|
40
|
+
p.add_external_library 'qt_core' do |e|
|
41
|
+
e.cmake_name '${QT_LIBRARIES}'
|
42
|
+
e.cmake_find_script <<-CMAKE
|
43
|
+
FIND_PACKAGE(Qt4 REQUIRED)
|
44
|
+
CMAKE
|
45
|
+
e.cmake_depend_script <<-CMAKE
|
46
|
+
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
|
47
|
+
SET(QT_DONT_USE_QTGUI TRUE)
|
48
|
+
CMAKE
|
49
|
+
end
|
50
|
+
p.add_external_library 'qt_core_gui' do |e|
|
51
|
+
e.cmake_name '${QT_LIBRARIES}'
|
52
|
+
e.cmake_find_script <<-CMAKE
|
53
|
+
FIND_PACKAGE(Qt4 REQUIRED)
|
54
|
+
CMAKE
|
55
|
+
e.cmake_depend_script <<-CMAKE
|
56
|
+
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
|
57
|
+
CMAKE
|
58
|
+
end
|
59
|
+
p.add_external_library 'qt_core_gui_opengl' do |e|
|
60
|
+
e.cmake_name '${QT_LIBRARIES}'
|
61
|
+
e.cmake_find_script <<-CMAKE
|
62
|
+
FIND_PACKAGE(Qt4 REQUIRED)
|
63
|
+
CMAKE
|
64
|
+
e.cmake_depend_script <<-CMAKE
|
65
|
+
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
|
66
|
+
SET(QT_USE_OPENGL TRUE)
|
67
|
+
CMAKE
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
assert_equal 3, hello.external_libraries.length
|
72
|
+
assert hello.external_libraries.any? { |x| x.name == 'qt_core' }
|
73
|
+
assert hello.external_libraries.any? { |x| x.name == 'qt_core_gui' }
|
74
|
+
assert hello.external_libraries.any? { |x| x.name == 'qt_core_gui_opengl' }
|
75
|
+
end
|
76
|
+
|
77
|
+
must "be able to add targets" do
|
78
|
+
hello = Ritsu::Project.create('hello') do |p|
|
79
|
+
p.add_executable 'abc'
|
80
|
+
p.add_shared_library 'def'
|
81
|
+
p.add_static_library 'ghi'
|
82
|
+
end
|
83
|
+
|
84
|
+
assert_equal 3, hello.targets.length
|
85
|
+
assert hello.targets.any? { |x| x.name == 'abc' }
|
86
|
+
assert hello.targets.any? { |x| x.name == 'def' }
|
87
|
+
assert hello.targets.any? { |x| x.name == 'ghi' }
|
88
|
+
end
|
89
|
+
|
90
|
+
file_test "create config header file" do
|
91
|
+
hello = Ritsu::Project.create('hello')
|
92
|
+
hello.project_dir = output_dir
|
93
|
+
assert hello.respond_to?(:config_header_file)
|
94
|
+
assert hello.src_files.any? {|x| x.src_path != "config.h"}
|
95
|
+
|
96
|
+
FileRobot.quietly do
|
97
|
+
hello.update
|
98
|
+
end
|
99
|
+
|
100
|
+
assert_output_file_exists("src/config.h")
|
101
|
+
assert_output_file_content("\n", "src/config.h")
|
102
|
+
end
|
103
|
+
|
104
|
+
file_test "create config header template file" do
|
105
|
+
hello = Ritsu::Project.create('hello')
|
106
|
+
hello.project_dir = output_dir
|
107
|
+
assert hello.respond_to?(:config_header_template_file)
|
108
|
+
assert hello.src_files.any? {|x| x.src_path != "config.h.in"}
|
109
|
+
|
110
|
+
FileRobot.quietly do
|
111
|
+
hello.update
|
112
|
+
end
|
113
|
+
|
114
|
+
assert_output_file_exists("src/config.h.in")
|
115
|
+
|
116
|
+
expected_content = <<-TEXT
|
117
|
+
#ifndef __PROJECT_CONFIG_H__
|
118
|
+
#define __PROJECT_CONFIG_H__
|
119
|
+
|
120
|
+
#cmakedefine __WIN_PLATFORM__
|
121
|
+
#cmakedefine __MAC_PLATFORM__
|
122
|
+
#cmakedefine __UNIX_PLATFORM__
|
123
|
+
|
124
|
+
#endif
|
125
|
+
TEXT
|
126
|
+
assert_output_file_content("\n", "src/config.h")
|
127
|
+
end
|
128
128
|
end
|