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
data/test/ritsu/src_file_test.rb
CHANGED
@@ -1,70 +1,70 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../test_helpers"
|
2
|
-
|
3
|
-
class SrcFileTest < Test::Unit::TestCase
|
4
|
-
include Ritsu::SetupProjectAndClearEverythingElse
|
5
|
-
|
6
|
-
def self.test_valid_src_path(src_path)
|
7
|
-
must "#{src_path} is a valid source path" do
|
8
|
-
assert Ritsu::SrcFile.is_valid_src_path?(src_path),
|
9
|
-
"#{src_path} must be a valid source path"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
test_valid_src_path "abc.txt"
|
14
|
-
test_valid_src_path "SomeProject/Something_else.cpp"
|
15
|
-
test_valid_src_path "mio/koakuma/shadow_gl_renderer.cpp"
|
16
|
-
test_valid_src_path ".abc"
|
17
|
-
test_valid_src_path "abc-hello.c"
|
18
|
-
|
19
|
-
def self.test_invalid_src_path(src_path)
|
20
|
-
must "#{src_path} is not a valid source path" do
|
21
|
-
assert !Ritsu::SrcFile.is_valid_src_path?(src_path),
|
22
|
-
"#{src_path} must not be a valid source path"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
test_invalid_src_path "abc def"
|
27
|
-
test_invalid_src_path "/home/one_users/.tmp"
|
28
|
-
test_invalid_src_path ""
|
29
|
-
|
30
|
-
must "throw exception if a source file with invalid source path is given" do
|
31
|
-
assert_raises ArgumentError do
|
32
|
-
Ritsu::SrcFile.new("abc def", @project)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
must "throw exception if two source files have duplicated names" do
|
37
|
-
assert_raises ArgumentError do
|
38
|
-
Ritsu::SrcFile.new("abc/abc.txt", @project)
|
39
|
-
Ritsu::SrcFile.new("abc/abc.txt", @project)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
must "now throw exception if source path is a valid source path" do
|
44
|
-
assert_nothing_raised do
|
45
|
-
Ritsu::SrcFile.new("abc/abc.txt", @project)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
must "be added to the owner's src_files array" do
|
50
|
-
abc = Ritsu::SrcFile.new("abc/abc.txt", @project)
|
51
|
-
assert @project.src_files.include?(abc)
|
52
|
-
end
|
53
|
-
|
54
|
-
must "return its project correctly when owner is the project" do
|
55
|
-
abc = Ritsu::SrcFile.new("abc/abc.txt", @project)
|
56
|
-
assert_equal @project, abc.project
|
57
|
-
end
|
58
|
-
|
59
|
-
must "return its project correct when owheter is a target" do
|
60
|
-
target = Ritsu::Targets::Executable.new("def")
|
61
|
-
abc = Ritsu::SrcFile.new('abc/abc.txt', target)
|
62
|
-
assert_equal target, abc.owner
|
63
|
-
assert_equal @project, abc.project
|
64
|
-
end
|
65
|
-
|
66
|
-
must "compute absolute path correctly" do
|
67
|
-
abc = Ritsu::SrcFile.new("abc/abc.txt", @project)
|
68
|
-
assert_equal @project.project_dir + "/src/abc/abc.txt", abc.abs_path
|
69
|
-
end
|
1
|
+
require File.dirname(__FILE__) + "/../test_helpers"
|
2
|
+
|
3
|
+
class SrcFileTest < Test::Unit::TestCase
|
4
|
+
include Ritsu::SetupProjectAndClearEverythingElse
|
5
|
+
|
6
|
+
def self.test_valid_src_path(src_path)
|
7
|
+
must "#{src_path} is a valid source path" do
|
8
|
+
assert Ritsu::SrcFile.is_valid_src_path?(src_path),
|
9
|
+
"#{src_path} must be a valid source path"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
test_valid_src_path "abc.txt"
|
14
|
+
test_valid_src_path "SomeProject/Something_else.cpp"
|
15
|
+
test_valid_src_path "mio/koakuma/shadow_gl_renderer.cpp"
|
16
|
+
test_valid_src_path ".abc"
|
17
|
+
test_valid_src_path "abc-hello.c"
|
18
|
+
|
19
|
+
def self.test_invalid_src_path(src_path)
|
20
|
+
must "#{src_path} is not a valid source path" do
|
21
|
+
assert !Ritsu::SrcFile.is_valid_src_path?(src_path),
|
22
|
+
"#{src_path} must not be a valid source path"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
test_invalid_src_path "abc def"
|
27
|
+
test_invalid_src_path "/home/one_users/.tmp"
|
28
|
+
test_invalid_src_path ""
|
29
|
+
|
30
|
+
must "throw exception if a source file with invalid source path is given" do
|
31
|
+
assert_raises ArgumentError do
|
32
|
+
Ritsu::SrcFile.new("abc def", @project)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
must "throw exception if two source files have duplicated names" do
|
37
|
+
assert_raises ArgumentError do
|
38
|
+
Ritsu::SrcFile.new("abc/abc.txt", @project)
|
39
|
+
Ritsu::SrcFile.new("abc/abc.txt", @project)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
must "now throw exception if source path is a valid source path" do
|
44
|
+
assert_nothing_raised do
|
45
|
+
Ritsu::SrcFile.new("abc/abc.txt", @project)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
must "be added to the owner's src_files array" do
|
50
|
+
abc = Ritsu::SrcFile.new("abc/abc.txt", @project)
|
51
|
+
assert @project.src_files.include?(abc)
|
52
|
+
end
|
53
|
+
|
54
|
+
must "return its project correctly when owner is the project" do
|
55
|
+
abc = Ritsu::SrcFile.new("abc/abc.txt", @project)
|
56
|
+
assert_equal @project, abc.project
|
57
|
+
end
|
58
|
+
|
59
|
+
must "return its project correct when owheter is a target" do
|
60
|
+
target = Ritsu::Targets::Executable.new("def")
|
61
|
+
abc = Ritsu::SrcFile.new('abc/abc.txt', target)
|
62
|
+
assert_equal target, abc.owner
|
63
|
+
assert_equal @project, abc.project
|
64
|
+
end
|
65
|
+
|
66
|
+
must "compute absolute path correctly" do
|
67
|
+
abc = Ritsu::SrcFile.new("abc/abc.txt", @project)
|
68
|
+
assert_equal @project.project_dir + "/src/abc/abc.txt", abc.abs_path
|
69
|
+
end
|
70
70
|
end
|
@@ -1,43 +1,43 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../test_helpers"
|
2
|
-
|
3
|
-
class CppFileTest < Test::Unit::TestCase
|
4
|
-
include Ritsu::SetupProjectAndClearEverythingElse
|
5
|
-
include Ritsu::TestCaseWithFileTestData
|
6
|
-
include Ritsu::Utility
|
7
|
-
|
8
|
-
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
9
|
-
|
10
|
-
def setup
|
11
|
-
setup_project
|
12
|
-
@project.project_dir = output_dir
|
13
|
-
@target = Ritsu::Targets::Executable.new("abc", :project=>@project)
|
14
|
-
end
|
15
|
-
|
16
|
-
file_test "create" do
|
17
|
-
@cpp_file = Ritsu::SrcFiles::CppFile.new("abc/def.cpp", @target)
|
18
|
-
FileRobot.quietly do
|
19
|
-
@cpp_file.create
|
20
|
-
end
|
21
|
-
assert_file_exists(@cpp_file.abs_path)
|
22
|
-
assert_file_content("\n", @cpp_file.abs_path)
|
23
|
-
end
|
24
|
-
|
25
|
-
file_test "update_does_nothing" do
|
26
|
-
@header_file = Ritsu::SrcFiles::CppFile.new("abc/def.cpp", @target)
|
27
|
-
FileRobot.quietly do
|
28
|
-
FileRobot.create_file(output_path("src/abc/def.cpp"), "abc")
|
29
|
-
@header_file.update
|
30
|
-
end
|
31
|
-
assert_file_content("abc", @header_file.abs_path)
|
32
|
-
end
|
33
|
-
|
34
|
-
file_test "delete" do
|
35
|
-
@header_file = Ritsu::SrcFiles::CppFile.new("abc/def.cpp", @target)
|
36
|
-
FileRobot.quietly do
|
37
|
-
@header_file.create
|
38
|
-
assert_file_exists(@header_file.abs_path)
|
39
|
-
@header_file.remove
|
40
|
-
assert_file_not_exist(@header_file.abs_path)
|
41
|
-
end
|
42
|
-
end
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helpers"
|
2
|
+
|
3
|
+
class CppFileTest < Test::Unit::TestCase
|
4
|
+
include Ritsu::SetupProjectAndClearEverythingElse
|
5
|
+
include Ritsu::TestCaseWithFileTestData
|
6
|
+
include Ritsu::Utility
|
7
|
+
|
8
|
+
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
9
|
+
|
10
|
+
def setup
|
11
|
+
setup_project
|
12
|
+
@project.project_dir = output_dir
|
13
|
+
@target = Ritsu::Targets::Executable.new("abc", :project=>@project)
|
14
|
+
end
|
15
|
+
|
16
|
+
file_test "create" do
|
17
|
+
@cpp_file = Ritsu::SrcFiles::CppFile.new("abc/def.cpp", @target)
|
18
|
+
FileRobot.quietly do
|
19
|
+
@cpp_file.create
|
20
|
+
end
|
21
|
+
assert_file_exists(@cpp_file.abs_path)
|
22
|
+
assert_file_content("\n", @cpp_file.abs_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
file_test "update_does_nothing" do
|
26
|
+
@header_file = Ritsu::SrcFiles::CppFile.new("abc/def.cpp", @target)
|
27
|
+
FileRobot.quietly do
|
28
|
+
FileRobot.create_file(output_path("src/abc/def.cpp"), "abc")
|
29
|
+
@header_file.update
|
30
|
+
end
|
31
|
+
assert_file_content("abc", @header_file.abs_path)
|
32
|
+
end
|
33
|
+
|
34
|
+
file_test "delete" do
|
35
|
+
@header_file = Ritsu::SrcFiles::CppFile.new("abc/def.cpp", @target)
|
36
|
+
FileRobot.quietly do
|
37
|
+
@header_file.create
|
38
|
+
assert_file_exists(@header_file.abs_path)
|
39
|
+
@header_file.remove
|
40
|
+
assert_file_not_exist(@header_file.abs_path)
|
41
|
+
end
|
42
|
+
end
|
43
43
|
end
|
@@ -1,93 +1,93 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../test_helpers"
|
2
|
-
|
3
|
-
class ExecutableCMakeListsTest < Test::Unit::TestCase
|
4
|
-
include Ritsu::SetupProjectAndClearEverythingElse
|
5
|
-
include Ritsu::TestCaseWithFileTestData
|
6
|
-
include Ritsu::Utility
|
7
|
-
|
8
|
-
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
9
|
-
|
10
|
-
def setup
|
11
|
-
setup_project('mio')
|
12
|
-
@project.project_dir = output_dir
|
13
|
-
end
|
14
|
-
|
15
|
-
file_test "must be present" do
|
16
|
-
abc = Ritsu::Targets::Executable.new("abc", :project=>@project)
|
17
|
-
assert abc.respond_to?(:cmake_lists)
|
18
|
-
assert abc.cmake_lists.kind_of?(Ritsu::SrcFiles::ExecutableCmakeLists)
|
19
|
-
assert_equal 1,
|
20
|
-
abc.src_files.select {|x| x.kind_of?(Ritsu::SrcFiles::ExecutableCmakeLists)}.length
|
21
|
-
end
|
22
|
-
|
23
|
-
file_test "create" do
|
24
|
-
abc = Ritsu::Targets::Executable.new("abc", :project=>@project)
|
25
|
-
FileRobot.quietly do
|
26
|
-
abc.cmake_lists.create
|
27
|
-
end
|
28
|
-
assert_file_exists(abc.cmake_lists.abs_path)
|
29
|
-
|
30
|
-
expected_content = <<-CMAKE
|
31
|
-
##<< TargetCmakeLists -- abc -- Libraries
|
32
|
-
##>> TargetCmakeLists -- abc -- Libraries
|
33
|
-
|
34
|
-
##<< TargetCmakeLists -- abc -- Custom Commands
|
35
|
-
##>> TargetCmakeLists -- abc -- Custom Commands
|
36
|
-
|
37
|
-
##<< TargetCmakeLists -- abc -- Source Files
|
38
|
-
SET(ABC_SRC_FILES
|
39
|
-
)
|
40
|
-
##>> TargetCmakeLists -- abc -- Source Files
|
41
|
-
|
42
|
-
##<< ExecutableCmakeLists -- abc -- Executable
|
43
|
-
ADD_EXECUTABLE(abc ${ABC_SRC_FILES})
|
44
|
-
##>> ExecutableCmakeLists -- abc -- Executable
|
45
|
-
|
46
|
-
##<< TargetCmakeLists -- abc -- Dependencies
|
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
|
89
|
-
CMAKE
|
90
|
-
|
91
|
-
assert_file_content(expected_content, abc.cmake_lists.abs_path)
|
92
|
-
end
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helpers"
|
2
|
+
|
3
|
+
class ExecutableCMakeListsTest < Test::Unit::TestCase
|
4
|
+
include Ritsu::SetupProjectAndClearEverythingElse
|
5
|
+
include Ritsu::TestCaseWithFileTestData
|
6
|
+
include Ritsu::Utility
|
7
|
+
|
8
|
+
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
9
|
+
|
10
|
+
def setup
|
11
|
+
setup_project('mio')
|
12
|
+
@project.project_dir = output_dir
|
13
|
+
end
|
14
|
+
|
15
|
+
file_test "must be present" do
|
16
|
+
abc = Ritsu::Targets::Executable.new("abc", :project=>@project)
|
17
|
+
assert abc.respond_to?(:cmake_lists)
|
18
|
+
assert abc.cmake_lists.kind_of?(Ritsu::SrcFiles::ExecutableCmakeLists)
|
19
|
+
assert_equal 1,
|
20
|
+
abc.src_files.select {|x| x.kind_of?(Ritsu::SrcFiles::ExecutableCmakeLists)}.length
|
21
|
+
end
|
22
|
+
|
23
|
+
file_test "create" do
|
24
|
+
abc = Ritsu::Targets::Executable.new("abc", :project=>@project)
|
25
|
+
FileRobot.quietly do
|
26
|
+
abc.cmake_lists.create
|
27
|
+
end
|
28
|
+
assert_file_exists(abc.cmake_lists.abs_path)
|
29
|
+
|
30
|
+
expected_content = <<-CMAKE
|
31
|
+
##<< TargetCmakeLists -- abc -- Libraries
|
32
|
+
##>> TargetCmakeLists -- abc -- Libraries
|
33
|
+
|
34
|
+
##<< TargetCmakeLists -- abc -- Custom Commands
|
35
|
+
##>> TargetCmakeLists -- abc -- Custom Commands
|
36
|
+
|
37
|
+
##<< TargetCmakeLists -- abc -- Source Files
|
38
|
+
SET(ABC_SRC_FILES
|
39
|
+
)
|
40
|
+
##>> TargetCmakeLists -- abc -- Source Files
|
41
|
+
|
42
|
+
##<< ExecutableCmakeLists -- abc -- Executable
|
43
|
+
ADD_EXECUTABLE(abc ${ABC_SRC_FILES})
|
44
|
+
##>> ExecutableCmakeLists -- abc -- Executable
|
45
|
+
|
46
|
+
##<< TargetCmakeLists -- abc -- Dependencies
|
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
|
89
|
+
CMAKE
|
90
|
+
|
91
|
+
assert_file_content(expected_content, abc.cmake_lists.abs_path)
|
92
|
+
end
|
93
93
|
end
|
@@ -1,58 +1,58 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../../test_helpers"
|
2
|
-
|
3
|
-
class HeaderFileTest < Test::Unit::TestCase
|
4
|
-
include Ritsu::SetupProjectAndClearEverythingElse
|
5
|
-
include Ritsu::TestCaseWithFileTestData
|
6
|
-
include Ritsu::Utility
|
7
|
-
|
8
|
-
def setup
|
9
|
-
setup_project
|
10
|
-
@project.project_dir = output_dir
|
11
|
-
@target = Ritsu::Targets::Executable.new("abc", :project=>@project)
|
12
|
-
end
|
13
|
-
|
14
|
-
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
15
|
-
|
16
|
-
must "include_guard computed correct" do
|
17
|
-
@header_file = Ritsu::SrcFiles::HeaderFile.new("abc/def.h", @target)
|
18
|
-
assert_equal "__PROJECT_ABC_DEF_H__", @header_file.include_guard
|
19
|
-
end
|
20
|
-
|
21
|
-
file_test "create" do
|
22
|
-
@header_file = Ritsu::SrcFiles::HeaderFile.new("abc/def.h", @target)
|
23
|
-
FileRobot.quietly do
|
24
|
-
@header_file.create
|
25
|
-
end
|
26
|
-
assert_file_exists(@header_file.abs_path)
|
27
|
-
expected_content = <<-HEADER_FILE
|
28
|
-
#ifndef __PROJECT_ABC_DEF_H__
|
29
|
-
#define __PROJECT_ABC_DEF_H__
|
30
|
-
|
31
|
-
////////////////////
|
32
|
-
// YOUR CODE HERE //
|
33
|
-
////////////////////
|
34
|
-
|
35
|
-
#endif
|
36
|
-
HEADER_FILE
|
37
|
-
assert_file_content(expected_content, @header_file.abs_path)
|
38
|
-
end
|
39
|
-
|
40
|
-
file_test "update_does_nothing" do
|
41
|
-
@header_file = Ritsu::SrcFiles::HeaderFile.new("abc/def.h", @target)
|
42
|
-
FileRobot.quietly do
|
43
|
-
FileRobot.create_file(output_path("src/abc/def.h"), "abc")
|
44
|
-
@header_file.update
|
45
|
-
end
|
46
|
-
assert_file_content("abc", @header_file.abs_path)
|
47
|
-
end
|
48
|
-
|
49
|
-
file_test "delete" do
|
50
|
-
@header_file = Ritsu::SrcFiles::HeaderFile.new("abc/def.h", @target)
|
51
|
-
FileRobot.quietly do
|
52
|
-
@header_file.create
|
53
|
-
assert_file_exists(@header_file.abs_path)
|
54
|
-
@header_file.remove
|
55
|
-
assert_file_not_exist(@header_file.abs_path)
|
56
|
-
end
|
57
|
-
end
|
1
|
+
require File.dirname(__FILE__) + "/../../test_helpers"
|
2
|
+
|
3
|
+
class HeaderFileTest < Test::Unit::TestCase
|
4
|
+
include Ritsu::SetupProjectAndClearEverythingElse
|
5
|
+
include Ritsu::TestCaseWithFileTestData
|
6
|
+
include Ritsu::Utility
|
7
|
+
|
8
|
+
def setup
|
9
|
+
setup_project
|
10
|
+
@project.project_dir = output_dir
|
11
|
+
@target = Ritsu::Targets::Executable.new("abc", :project=>@project)
|
12
|
+
end
|
13
|
+
|
14
|
+
def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
|
15
|
+
|
16
|
+
must "include_guard computed correct" do
|
17
|
+
@header_file = Ritsu::SrcFiles::HeaderFile.new("abc/def.h", @target)
|
18
|
+
assert_equal "__PROJECT_ABC_DEF_H__", @header_file.include_guard
|
19
|
+
end
|
20
|
+
|
21
|
+
file_test "create" do
|
22
|
+
@header_file = Ritsu::SrcFiles::HeaderFile.new("abc/def.h", @target)
|
23
|
+
FileRobot.quietly do
|
24
|
+
@header_file.create
|
25
|
+
end
|
26
|
+
assert_file_exists(@header_file.abs_path)
|
27
|
+
expected_content = <<-HEADER_FILE
|
28
|
+
#ifndef __PROJECT_ABC_DEF_H__
|
29
|
+
#define __PROJECT_ABC_DEF_H__
|
30
|
+
|
31
|
+
////////////////////
|
32
|
+
// YOUR CODE HERE //
|
33
|
+
////////////////////
|
34
|
+
|
35
|
+
#endif
|
36
|
+
HEADER_FILE
|
37
|
+
assert_file_content(expected_content, @header_file.abs_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
file_test "update_does_nothing" do
|
41
|
+
@header_file = Ritsu::SrcFiles::HeaderFile.new("abc/def.h", @target)
|
42
|
+
FileRobot.quietly do
|
43
|
+
FileRobot.create_file(output_path("src/abc/def.h"), "abc")
|
44
|
+
@header_file.update
|
45
|
+
end
|
46
|
+
assert_file_content("abc", @header_file.abs_path)
|
47
|
+
end
|
48
|
+
|
49
|
+
file_test "delete" do
|
50
|
+
@header_file = Ritsu::SrcFiles::HeaderFile.new("abc/def.h", @target)
|
51
|
+
FileRobot.quietly do
|
52
|
+
@header_file.create
|
53
|
+
assert_file_exists(@header_file.abs_path)
|
54
|
+
@header_file.remove
|
55
|
+
assert_file_not_exist(@header_file.abs_path)
|
56
|
+
end
|
57
|
+
end
|
58
58
|
end
|