ritsu 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.4
@@ -0,0 +1,28 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../project")
2
+
3
+ module Ritsu
4
+ class Project
5
+ def setup_qt
6
+ ### Qt ###
7
+ add_external_library("qt") do |e|
8
+ e.cmake_find_script "FIND_PACKAGE(Qt4 REQUIRED)"
9
+ e.cmake_depend_script "INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})"
10
+ e.cmake_name "${QT_QTCORE_LIBRARY}"
11
+ end
12
+
13
+ ### Qt GUI ###
14
+ add_external_library("qtgui") do |e|
15
+ e.cmake_find_script ""
16
+ e.cmake_depend_script "INCLUDE_DIRECTORIES(${QT_QTGUI_INCLUDE_DIR})"
17
+ e.cmake_name "${QT_QTGUI_LIBRARY}"
18
+ end
19
+
20
+ ### Qt OpenGL ###
21
+ add_external_library("qtopengl") do |e|
22
+ e.cmake_find_script ""
23
+ e.cmake_depend_script "INCLUDE_DIRECTORIES(${QT_QTOPENGL_INCLUDE_DIR})"
24
+ e.cmake_name "${QT_QTOPENGL_LIBRARY}"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,107 @@
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 QtUiTemplate < Ritsu::Template
9
+ attr_reader :target
10
+
11
+ def initialize(target)
12
+ super("TargetCmakeLists -- #{target.name} -- QtUi")
13
+ @target = target
14
+ end
15
+
16
+ def ui_header_files_var_name
17
+ "#{target.name.upcase}_UI_HEADER_FILES"
18
+ end
19
+
20
+ def update_block(block, options = {})
21
+ block.clear_contents
22
+
23
+ ui_files = target.src_files.select { |x| x.respond_to?(:ui_file?) && x.ui_file? }
24
+ if ui_files.length == 0
25
+ return
26
+ end
27
+ ui_files.sort! {|x,y| x.src_path <=> y.src_path}
28
+
29
+ block.add_line "QT4_WRAP_UI(#{ui_header_files_var_name}"
30
+ block.indent
31
+ ui_files.each do |ui_file|
32
+ block.add_line("${CMAKE_SOURCE_DIR}/#{ui_file.src_path}")
33
+ end
34
+ block.outdent
35
+ block.add_line ")"
36
+ block.add_new_line
37
+ block.add_line "SET(#{target.name.upcase}_SRC_FILES ${#{target.name.upcase}_SRC_FILES} ${#{ui_header_files_var_name}})"
38
+ end
39
+ end
40
+
41
+ class QtMocTemplate < Ritsu::Template
42
+ attr_reader :target
43
+
44
+ def initialize(target)
45
+ super("TargetCmakeLists -- #{target.name} -- QtMoc")
46
+ @target = target
47
+ end
48
+
49
+ def moc_src_files_var_name
50
+ "#{target.name.upcase}_MOC_SRC_FILES"
51
+ end
52
+
53
+ def update_block(block, options = {})
54
+ block.clear_contents
55
+
56
+ header_files = target.src_files.select { |x| x.respond_to?(:header_file?) && x.header_file? }
57
+ if header_files.length == 0
58
+ return
59
+ end
60
+ header_files.sort! {|x,y| x.src_path <=> y.src_path}
61
+
62
+ block.add_line "QT4_WRAP_CPP(#{moc_src_files_var_name}"
63
+ block.indent
64
+ header_files.each do |header_file|
65
+ block.add_line("${CMAKE_SOURCE_DIR}/#{header_file.src_path}")
66
+ end
67
+ block.outdent
68
+ block.add_line ")"
69
+ block.add_new_line
70
+ block.add_line "SET(#{target.name.upcase}_SRC_FILES ${#{target.name.upcase}_SRC_FILES} ${#{moc_src_files_var_name}})"
71
+ end
72
+ end
73
+
74
+ class Template
75
+ attr_reader :qt_ui_template
76
+ attr_reader :qt_moc_template
77
+
78
+ alias_method :initialize_before_qt, :initialize
79
+
80
+ def initialize(target, id = nil)
81
+ initialize_before_qt(target, id)
82
+
83
+ @qt_ui_template = QtUiTemplate.new(target)
84
+ @qt_moc_template = QtMocTemplate.new(target)
85
+
86
+ position = child_template_with_id_position(source_files_template.id) + 1
87
+ contents.insert(position, @qt_moc_template)
88
+ contents.insert(position, "")
89
+ contents.insert(position, @qt_ui_template)
90
+ contents.insert(position, "")
91
+ end
92
+
93
+ alias_method :position_to_insert_before_qt, :position_to_insert
94
+
95
+ def position_to_insert(block, new_block)
96
+ if new_block.id == qt_moc_template.id
97
+ block.child_block_with_id_position(qt_ui_template.id) + 1
98
+ elsif new_block.id == qt_ui_template.id
99
+ block.child_block_with_id_position(source_files_template.id) + 1
100
+ else
101
+ position_to_insert_before_cuda(block, new_block)
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ 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 UiFile < 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 ui_file?
20
+ true
21
+ end
22
+ end
23
+
24
+ module AddUiFile
25
+ def add_ui_file(path, options={})
26
+ src_path = compute_src_path(path, options)
27
+ UiFile.new(src_path, self)
28
+ end
29
+
30
+ def add_ui_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::AddUiFile
42
+ end
43
+
44
+ class Project
45
+ include Ritsu::SrcFiles::AddUiFile
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/qt/project")
2
+ require File.expand_path(File.dirname(__FILE__) + "/qt/src_files/target_cmake_lists")
3
+ require File.expand_path(File.dirname(__FILE__) + "/qt/src_files/ui_file")
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: 13
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 3
10
- version: 0.5.3
9
+ - 4
10
+ version: 0.5.4
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-09-14 00:00:00 +07:00
18
+ date: 2010-12-03 00:00:00 +07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -130,6 +130,10 @@ files:
130
130
  - lib/ritsu/ext/glsl.rb
131
131
  - lib/ritsu/ext/glsl/src_files/frag_file.rb
132
132
  - lib/ritsu/ext/glsl/src_files/vert_file.rb
133
+ - lib/ritsu/ext/qt.rb
134
+ - lib/ritsu/ext/qt/project.rb
135
+ - lib/ritsu/ext/qt/src_files/target_cmake_lists.rb
136
+ - lib/ritsu/ext/qt/src_files/ui_file.rb
133
137
  - lib/ritsu/ext/test_case.rb
134
138
  - lib/ritsu/external_library.rb
135
139
  - lib/ritsu/project.rb