rubyuno 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .project
7
+ Makefile
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ include
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
data/CHANGES ADDED
@@ -0,0 +1,16 @@
1
+
2
+ Ruby-UNO bridge
3
+
4
+
5
+ 0.2.0
6
+ * Change directory structure.
7
+ * Changed to Rakefile to build.
8
+ * Add the component loader for Ruby.
9
+ * Add the script provider for Ruby.
10
+ * stl/hash_map is changed to ruby/st.
11
+ * Ruby 1.8.x is no longer supported.
12
+ * Primitives of UNO defined in uno.rb are moved to runo.so.
13
+
14
+
15
+ 0.1.0
16
+ * First version.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubyuno.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README ADDED
@@ -0,0 +1,46 @@
1
+
2
+ = RUNO
3
+
4
+ RUNO is a Ruby-UNO ['ju:nou] (Universal Network Object) bridge. UNO is used to
5
+ construct OpenOffice.org so that you can play with the office. RUNO
6
+ is implemented as Ruby extension library written in C++, but the bridge
7
+ is not so fast because value conversion and multiple API call consume time.
8
+ RUNO is not suite task like template creation, generating ODF (Open
9
+ Document Format) is better for the task.
10
+
11
+
12
+ = How to Compile
13
+ You need following things to compile:
14
+ * OpenOffice.org and OpenOffice.org SDK (3.x?)
15
+ * Ruby (> 1.8.7?) and its header
16
+
17
+ Package version is not well checked.
18
+
19
+ Install OpenOffice.org and SDK. And then setup the SDK with configure.pl
20
+ script equipped in the SDK. After that you can find shell script named
21
+ "setsdkenv_ENV.EXT" to set environmet variables for compilation in the
22
+ ~/openoffice.orgVERSION_sdk/HOST.DOMAIN directory. The directory and file
23
+ name is system dependent, please read SDK documentation.
24
+
25
+ For example, compilation procedure is like the following:
26
+ > . ~/openoffice.org3.2_sdk/localhost/localdomain/setsdkenv_unix.sh
27
+ > ruby extconf.rb
28
+ > make
29
+ > make site-install
30
+ compilation is successfully finished, runo.so file is created.
31
+
32
+ Current version has problem to link against ruby library on Windows
33
+ environment. I couldn't fix it, investication required.
34
+
35
+ = Environment Variables
36
+
37
+ RUNO needs a few environmet variable settings befor to run work correctly.
38
+
39
+ * LD_LIBRARY_PATH (for Linux or UNIX) or PATH (for Windows)
40
+ To find libraries of UNO (or OpenOffice.org).
41
+
42
+ * URE_BOOTSTRAP
43
+ Specifies fundamental(rc|.ini) file with vnd.sun.star.pathname protocol.
44
+ e.g. vnd.sun.star.pathname:/opt/ooo-dev3/program/fundamentalrc
45
+
46
+
@@ -0,0 +1,603 @@
1
+ #! /bin/env rake
2
+ #
3
+ # Copyright 2011 Tsutomu Uchino
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ #
18
+
19
+ require 'rbconfig'
20
+ require 'rake/packagetask'
21
+ require 'rake/clean'
22
+ require 'rubygems/package_task'
23
+ require 'rubygems'
24
+ require 'rdoc/task'
25
+
26
+ # Build packages.
27
+ # Gem file for RPC.
28
+ # RubyLoader provides that you can write an UNO component in Ruby.
29
+ # RubyScriptProvider is a servicee to execute ruby script as macros.
30
+
31
+ env_descriptions = <<EOD
32
+ OO_SDK_HOME is used to find include files and map file which are part of the SDK.
33
+ OO_SDK_URE_HOME is used to find libraries and types.rdb file.
34
+ OFFICE_BASE_PROGRAM_PATH is used to offapi.rdb file.
35
+ EOD
36
+
37
+ sdk_home = ENV['OO_SDK_HOME']
38
+ ure_home = ENV['OO_SDK_URE_HOME']
39
+ base_path = ENV['OFFICE_BASE_PROGRAM_PATH']
40
+
41
+
42
+ # Building environment
43
+ c = RbConfig::CONFIG
44
+
45
+ cc = c['CC']
46
+ link = c['LDSHAREDXX']
47
+ cxx = c['CXX']
48
+ host = c['host']
49
+
50
+ LIB_EXT = c['DLEXT']
51
+ OBJ_EXT = c['OBJEXT']
52
+
53
+ CPPU_INCLUDE = './include'
54
+ CPPUMAKER = 'cppumaker'
55
+ CPPUMAKER_FLAG = "#{CPPU_INCLUDE}/flag"
56
+
57
+ sdk_include = "#{sdk_home}/include"
58
+
59
+
60
+ rubyhdrdir = c['rubyhdrdir']
61
+ arch_rubyhdrdir = "#{rubyhdrdir}/#{c['arch']}"
62
+ ruby_backward = "#{rubyhdrdir}/ruby/backward"
63
+
64
+ dldlibs = c['DLDLIBS']
65
+
66
+ CFLAGS = c['CFLAGS']
67
+ cxxflags = CFLAGS + c['CXXFLAGS']
68
+ cxxflags.gsub!(/-O\d?/, "")
69
+
70
+
71
+ target = '3.4'
72
+ VERSION = '0.2.0'
73
+
74
+ RD2 = "rd2"
75
+ ZIP = "zip"
76
+ ZIP_ARGS = "-9"
77
+
78
+ OXT_EXT = 'oxt'
79
+ RD_EXT = 'rd'
80
+
81
+ # Local directories
82
+ SRC_DIR = "./src"
83
+ EXT_DIR = "./ext/rubyuno"
84
+ LIB_DIR = "./lib"
85
+ PKG_DIR = "./pkg"
86
+ DOC_DIR = "./doc"
87
+
88
+ # Definitions for the component loader for Ruby.
89
+ LOADER_PKG_NAME = "RubyLoader"
90
+ LOADER_PKG_DISPLAY_NAME = "Ruby Loader"
91
+ LOADER_PKG_ID = "mytools.loader.Ruby"
92
+ LOADER_PKG_DESC = "The UNO component loader written in Ruby."
93
+
94
+ LOADER_REGISTRATION = "RubyLoader.components"
95
+ LOADER_IMPLE_NAME = "mytools.loader.Ruby"
96
+ LOADER_SERVICE_NAMES = ["com.sun.star.loader.Ruby"]
97
+ LOADER_RB = "rubyloader.rb"
98
+
99
+ LOADER_PKG_DIR_NAME = "#{LOADER_PKG_NAME}-#{VERSION}"
100
+ LOADER_PKG_FULL_NAME = "#{LOADER_PKG_NAME}-#{VERSION}.#{OXT_EXT}"
101
+ LOADER_PKG_DIR = "#{PKG_DIR}/#{LOADER_PKG_NAME}-#{VERSION}"
102
+ LOADER_PKG = "#{PKG_DIR}/#{LOADER_PKG_FULL_NAME}"
103
+
104
+ # Definitions for the script provider for Ruby.
105
+ SCRIPT_PKG_NAME = "RubyScriptProvider"
106
+ SCRIPT_PKG_DISPLAY_NAME = "Ruby Script Provider"
107
+ SCRIPT_PACKAGE_ID = "mytools.script.provider.ScriptProviderForRuby"
108
+
109
+ SCRIPT_REGISTRATION = "ScriptProviderForRuby.components"
110
+ SCRIPT_DESC = "The script provider for Ruby."
111
+ SCRIPT_IMPLE_NAME = "mytools.script.provider.ScriptProviderForRuby"
112
+ SCRIPT_SERVICE_NAMES = [
113
+ "com.sun.star.script.provider.ScriptProviderForRuby",
114
+ "com.sun.star.script.provider.LanguageScriptProvider"]
115
+ SCRIPT_RB = "rubyscriptprovider.rb"
116
+
117
+ SCRIPT_PKG_DIR_NAME = "#{SCRIPT_PKG_NAME}-#{VERSION}"
118
+ SCRIPT_PKG_FULL_NAME = "#{SCRIPT_PKG_NAME}-#{VERSION}.#{OXT_EXT}"
119
+ SCRIPT_PKG_DIR = "#{PKG_DIR}/#{SCRIPT_PKG_DIR_NAME}"
120
+ SCRIPT_PKG = "#{PKG_DIR}/#{SCRIPT_PKG_FULL_NAME}"
121
+
122
+ UNO_RB = "rubyuno.rb"
123
+ CONNECTOR_RB = "rubyuno/connector.rb"
124
+ LIB_RB = "lib.rb"
125
+
126
+ # Local files
127
+
128
+ LIB_UNO_DIR = "#{LIB_DIR}/uno"
129
+
130
+ MODULE_DLL = "runo.#{LIB_EXT}"
131
+
132
+ ALL_SRCS = FileList["#{EXT_DIR}/*.cxx"]
133
+ MODULE_SRCS = FileList["#{EXT_DIR}/module.cxx"]
134
+ LOADER_SRCS = FileList["#{EXT_DIR}/loader.cxx"]
135
+ LIB_SRCS = FileList["#{EXT_DIR}/*.cxx"] - MODULE_SRCS - LOADER_SRCS
136
+
137
+ ALL_OBJS = ALL_SRCS.ext(OBJ_EXT)
138
+ MODULE_OBJS = MODULE_SRCS.ext(OBJ_EXT)
139
+ LOADER_OBJS = LOADER_SRCS.ext(OBJ_EXT)
140
+ LIB_OBJS = LIB_SRCS.ext(OBJ_EXT)
141
+
142
+ RD_DOCS = FileList["#{DOC_DIR}/*.rd"]
143
+ HTML_DOCS = RD_DOCS.ext("html")
144
+
145
+ CLEAN.include(MODULE_OBJS)
146
+ CLEAN.include(LOADER_OBJS)
147
+ CLEAN.include(LIB_OBJS)
148
+ CLEAN.include(HTML_DOCS)
149
+ CLEAN.include(PKG_DIR)
150
+ CLEAN.include(CPPU_INCLUDE)
151
+
152
+ directory LIB_DIR
153
+ directory PKG_DIR
154
+ directory LIB_UNO_DIR
155
+
156
+
157
+ if host.include? 'linux'
158
+ # how about 64bit?, Linux_x64
159
+ platform = "Linux_x86"
160
+ lib_dll = "libruno.#{LIB_EXT}"
161
+ loader_dll = "rubyloader.uno.#{LIB_EXT}"
162
+
163
+ local_link_lib = "-L#{LIB_DIR}"
164
+ lib = "-L#{c['libdir']}"
165
+
166
+ out_flag = "-o"
167
+ coutflag = c['COUTFLAG']
168
+ optflags = "-O1"
169
+ cflags = "-fPIC"
170
+ debugflags = ""#c['debugflags']
171
+
172
+ flags = "#{cflags} #{optflags} #{debugflags} #{cxxflags}"
173
+
174
+ ruby_defs = c['DEFS']
175
+ cc_defs = "-fno-strict-aliasing -DUNX -DGCC -DLINUX -DCPPU_ENV=gcc3 " +
176
+ " #{ruby_defs}"
177
+
178
+ incflags = "-I. -I#{arch_rubyhdrdir} -I#{ruby_backward} -I#{rubyhdrdir} " +
179
+ "-I#{sdk_include} -I#{CPPU_INCLUDE} "
180
+
181
+ sdk_lib = "-L#{sdk_home}/lib"
182
+ ure_lib = "-L#{ure_home}/lib"
183
+
184
+ sdk_libs = " -luno_cppuhelpergcc3 -luno_cppu -luno_salhelpergcc3 -luno_sal -lm "
185
+ ldflags = c['LDFLAGS']
186
+ lib_ldflags = ""
187
+
188
+ LIB = ""
189
+ LIBS = "#{c['LIBS']} #{dldlibs}"
190
+ LIBRUBYARG = c['LIBRUBYARG']
191
+ runo_libs = "-lruno"
192
+
193
+ uno_link_flags = "'-Wl,-rpath,$ORIGIN' -Wl,--version-script,#{sdk_home}/settings/component.uno.map"
194
+
195
+ ure_types = "#{ure_home}/share/misc/types.rdb"
196
+
197
+ elsif host.include? 'mswin'
198
+ platform = "Windows"
199
+
200
+ link = "link -nologo "
201
+ mt = "mt -nologo "
202
+
203
+ DLL_EXT = 'dll'
204
+ lib_dll = "libruno.#{DLL_EXT}"
205
+ loader_dll = "rubyloader.uno.#{DLL_EXT}"
206
+
207
+ out_flag = "/OUT:"
208
+ coutflag = "/Fo"
209
+ optflags = "/O1"
210
+ cflags = "-MD -Zi -EHsc -Zm600 -Zc:forScope,wchar_t-" #-GR
211
+ debugflags = ""#c['debugflags']
212
+ warnflags = "-wd4251 -wd4275 -wd4290 -wd4675 -wd4786 -wd4800 " +
213
+ "-Zc:forScope"
214
+
215
+ flags = "#{cflags} #{optflags} #{warnflags} #{debugflags}"
216
+
217
+ ruby_defs = c['DEFS']
218
+ cc_defs = "-DWIN32 -DWNT -D_DLL -DCPPU_V=msci -DCPPU_ENV=msci"
219
+
220
+ incflags = "-I. -I#{arch_rubyhdrdir} -I#{ruby_backward} -I#{rubyhdrdir} " +
221
+ "-I#{sdk_include} -I#{CPPU_INCLUDE} "
222
+
223
+ sdk_lib = "/LIBPATH:#{sdk_home}/lib"
224
+ ure_lib = ""
225
+
226
+ sdk_libs = " icppuhelper.lib icppu.lib isal.lib isalhelper.lib msvcprt.lib msvcrt.lib kernel32.lib" #
227
+
228
+ module_def = "#{EXT_DIR}/runo.def"
229
+ libuno_def = "#{EXT_DIR}/libruno.def"
230
+
231
+ ldflags = " /DLL /NODEFAULTLIB:library /DEBUGTYPE:cv "
232
+ module_ldflags = " #{ldflags} /MAP /DEF:#{module_def} "
233
+ lib_ldflags = " #{ldflags} /MAP /DEF:#{libuno_def} "
234
+
235
+ local_link_lib = "/LIBPATH:#{LIB_DIR}"
236
+ LIB = " /LIBPATH:#{c['libdir']} "
237
+
238
+ LIBS = "#{c['LIBS']} #{dldlibs}"
239
+ LIBRUBYARG = c['LIBRUBYARG']
240
+ runo_libs = "libruno.lib"
241
+
242
+ uno_link_flags = "/DEF:#{sdk_home}/settings/component.uno.def"
243
+
244
+ ure_types = "#{ure_home}/misc/types.rdb"
245
+
246
+ else
247
+ raise "#{host} is not yet supported to build."
248
+ end
249
+
250
+
251
+ # Default task
252
+
253
+ task :default => [:all]
254
+
255
+ task :all => [
256
+ :package,
257
+ :loader, :provider
258
+ ]
259
+
260
+
261
+ # C++ files
262
+
263
+ rule ".#{OBJ_EXT}" => '.cxx' do |t|
264
+ sh "#{cc} #{incflags} #{cc_defs} #{flags} " +
265
+ "#{coutflag}#{t.name} -c #{t.source} "
266
+ end
267
+
268
+
269
+ # Header from IDL
270
+
271
+ types = [
272
+ "com.sun.star.beans.MethodConcept",
273
+ "com.sun.star.beans.PropertyAttribute",
274
+ "com.sun.star.beans.XIntrospection",
275
+ "com.sun.star.beans.XIntrospectionAccess",
276
+ "com.sun.star.beans.XMaterialHolder",
277
+ "com.sun.star.container.XEnumerationAccess",
278
+ "com.sun.star.container.XHierarchicalNameAccess",
279
+ "com.sun.star.container.XIndexContainer",
280
+ "com.sun.star.container.XNameContainer",
281
+ "com.sun.star.lang.XMultiServiceFactory",
282
+ "com.sun.star.lang.XServiceInfo",
283
+ "com.sun.star.lang.XSingleComponentFactory",
284
+ "com.sun.star.lang.XSingleServiceFactory",
285
+ "com.sun.star.lang.XTypeProvider",
286
+ "com.sun.star.lang.XUnoTunnel",
287
+ "com.sun.star.reflection.InvocationTargetException",
288
+ "com.sun.star.reflection.ParamMode",
289
+ "com.sun.star.reflection.XConstantTypeDescription",
290
+ "com.sun.star.reflection.XConstantsTypeDescription",
291
+ "com.sun.star.reflection.XEnumTypeDescription",
292
+ "com.sun.star.reflection.XIdlReflection",
293
+ "com.sun.star.reflection.XInterfaceTypeDescription2",
294
+ "com.sun.star.reflection.XTypeDescription",
295
+ "com.sun.star.registry.XRegistryKey",
296
+ "com.sun.star.script.InvocationInfo",
297
+ "com.sun.star.script.MemberType",
298
+ "com.sun.star.script.XInvocation2",
299
+ "com.sun.star.script.XInvocationAdapterFactory2",
300
+ "com.sun.star.script.XTypeConverter",
301
+ "com.sun.star.script.provider.ScriptFrameworkErrorException",
302
+ "com.sun.star.uno.XAggregation",
303
+ "com.sun.star.uno.TypeClass",
304
+ "com.sun.star.uno.XComponentContext",
305
+ "com.sun.star.uno.XWeak",
306
+ ]
307
+
308
+ desc "generate headers"
309
+ task :header do
310
+ unless File.exists?(CPPUMAKER_FLAG)
311
+ puts "flag for cppumaker does not exist. starting cppumaker..."
312
+
313
+ office_types = "#{base_path}/offapi.rdb"
314
+ sh "#{CPPUMAKER} -Gc -BUCR -O#{CPPU_INCLUDE} -T\"#{types.join(';')}\" \"#{ure_types}\" \"#{office_types}\""
315
+ sh "echo > #{CPPUMAKER_FLAG}"
316
+ end
317
+ end
318
+
319
+
320
+ # Gem
321
+ GEM_LIB_UNO_RB = "#{LIB_DIR}/#{UNO_RB}"
322
+ GEM_LIB_RUNO_MODULE = "#{LIB_UNO_DIR}/#{MODULE_DLL}"
323
+
324
+ task :package => [:header, GEM_LIB_UNO_RB, GEM_LIB_RUNO_MODULE]
325
+
326
+ spec = Gem::Specification.new do |s|
327
+ s.platform = Gem::Platform::RUBY
328
+ s.required_ruby_version = c['RUBY_PROGRAM_VERSION']
329
+ s.summary = "Ruby-UNO native bridge."
330
+ s.name = "rubyuno"
331
+ s.version = VERSION
332
+ s.requirements << 'none'
333
+ s.author = "hanya"
334
+ s.email = "hanya.runo@gmail.com"
335
+ s.homepage = "https://github.com/hanya/RUNO"
336
+ s.files = [
337
+ GEM_LIB_UNO_RB,
338
+ GEM_LIB_RUNO_MODULE
339
+ ]
340
+ s.extra_rdoc_files = FileList["#{DOC_DIR}/*.#{RD_EXT}"]
341
+ s.description = <<EOF
342
+ RubyUNO is native bridge between Ruby and UNO.
343
+ EOF
344
+ end
345
+
346
+ Gem::PackageTask.new(spec) do |t|
347
+ end
348
+
349
+ file GEM_LIB_UNO_RB => [LIB_DIR] do |t|
350
+ uno = IO.read("#{LIB_DIR}/#{UNO_RB}")
351
+ connector = IO.read("#{LIB_DIR}/#{CONNECTOR_RB}")
352
+ uno.sub!(/#require 'uno\/runo.so'/, "require 'uno/runo.so'")
353
+ open("#{LIB_DIR}/#{UNO_RB}", "w") do |f|
354
+ f.write uno
355
+ f.write connector
356
+ f.flush
357
+ end
358
+ end
359
+
360
+ desc "runo.so for RPC connection."
361
+ file GEM_LIB_RUNO_MODULE => [LIB_UNO_DIR, *ALL_OBJS] do |t|
362
+ puts "building ./lib/uno/runo.so"
363
+ sh "#{link} #{out_flag}#{t.name} #{ALL_OBJS.join(' ')} " +
364
+ " #{LIB} #{module_ldflags} " +
365
+ " #{sdk_lib} #{ure_lib}" +
366
+ " #{sdk_libs} #{LIBRUBYARG} #{LIBS} "
367
+ if host.include? 'mswin'
368
+ sh "#{mt} -manifest #{t.name}.manifest -outputresource:#{t.name};2"
369
+ end
370
+ end
371
+
372
+
373
+ # Templates for OXT file
374
+
375
+ TEMPLATE_MANIFEST = <<EOD
376
+ <?xml version="1.0" encoding="UTF-8"?>
377
+ <manifest:manifest>
378
+ <manifest:file-entry manifest:full-path="${LOADER}" manifest:media-type="${MEDIA_TYPE}"/>
379
+ </manifest:manifest>
380
+ EOD
381
+
382
+ TEMPLATE_COMPONENTS = <<EOD
383
+ <?xml version="1.0" encoding="UTF-8"?>
384
+ <components xmlns="http://openoffice.org/2010/uno-components">
385
+ <component loader="${LOADER_NAME}" uri="${URI}">
386
+ <implementation name="${IMPLE_NAME}">
387
+ ${SERVICES}
388
+ </implementation>
389
+ </component>
390
+ </components>
391
+ EOD
392
+
393
+ TEMPLATE_DESCRIPTION = <<EOD
394
+ <?xml version="1.0" encoding="UTF-8"?>
395
+ <description xmlns="http://openoffice.org/extensions/description/2006"
396
+ xmlns:xlink="http://www.w3.org/1999/xlink"
397
+ xmlns:d="http://openoffice.org/extensions/description/2006">
398
+ <identifier value="${ID}"/>
399
+ <version value="${VERSION}"/>
400
+ <dependencies>
401
+ <OpenOffice.org-minimal-version value="${TARGET}" d:name="OpenOffice.org ${TARGET}"/>
402
+ </dependencies>
403
+ <!--
404
+ <registration>
405
+ <simple-license accept-by="admin" default-license-id="this" suppress-on-update="true">
406
+ <license-text xlink:href="LICENSE" license-id="this"/>
407
+ </simple-license>
408
+ </registration>
409
+ -->
410
+ <display-name>
411
+ <name lang="en">${DISPLAY_NAME}</name>
412
+ </display-name>
413
+ <extension-description>
414
+ <src lang="en" xlink:href="descriptions/desc.en"/>
415
+ </extension-description>
416
+ </description>
417
+ EOD
418
+
419
+ # procedures depends on templates
420
+
421
+ # Creates description.xml
422
+ def description_task(dir_path, id, target, display_name)
423
+ description_file = "#{dir_path}/description.xml"
424
+ data = String.new TEMPLATE_DESCRIPTION
425
+ data.gsub!(/\$\{ID\}/, id)
426
+ data.gsub!(/\$\{VERSION\}/, VERSION)
427
+ data.gsub!(/\$\{TARGET\}/, target)
428
+ data.gsub!(/\$\{DISPLAY_NAME\}/, display_name)
429
+ open(description_file, "w") do |f|
430
+ f.write(data)
431
+ f.flush
432
+ end
433
+ end
434
+
435
+
436
+ # Creates META-INF/manifest.xml
437
+ def manifest_task(dir_path, full_path, media_type)
438
+
439
+ manifest_file = "#{dir_path}/META-INF/manifest.xml"
440
+ manifest_dir = File.dirname(manifest_file)
441
+ mkdir_p manifest_dir unless File.exist?(manifest_dir)
442
+
443
+ data = String.new TEMPLATE_MANIFEST
444
+ data.gsub!(/\$\{LOADER\}/, full_path)
445
+ data.gsub!(/\$\{MEDIA_TYPE\}/, media_type)
446
+ open(manifest_file, "w") do |f|
447
+ f.write(data)
448
+ f.flush
449
+ end
450
+ end
451
+
452
+
453
+ def registration_task(dir_path, file_name, loader_name, uri, imple_name, services)
454
+ puts "registration"
455
+ components_f = "#{dir_path}/lib/#{file_name}"
456
+
457
+ data = String.new TEMPLATE_COMPONENTS
458
+ data.gsub!(/\$\{LOADER_NAME\}/, loader_name)
459
+ data.gsub!(/\$\{URI\}/, uri)
460
+ data.gsub!(/\$\{IMPLE_NAME\}/, imple_name)
461
+ services.map! do |name|
462
+ "<service name=\"#{name}\"/>"
463
+ end
464
+ data.gsub!(/\$\{SERVICES\}/, services.join("\n"))
465
+ open(components_f, "w") do |f|
466
+ f.write(data)
467
+ f.flush
468
+ end
469
+ end
470
+
471
+
472
+ # Creates description/desc.en
473
+ def extension_description_task(dir_path, desc)
474
+ path = "#{dir_path}/descriptions/desc.en"
475
+ desc_dir = File.dirname(path)
476
+ mkdir_p desc_dir unless File.exist?(desc_dir)
477
+ open(path, "w") do |f|
478
+ f.write(desc)
479
+ f.flush
480
+ end
481
+ end
482
+
483
+
484
+ # Pack as zip archive
485
+ def packaging_task(dir_path, pkg_name)
486
+ chdir dir_path do
487
+ sh "#{ZIP} -9 -r -o ../#{pkg_name} * **/*"
488
+ end
489
+ end
490
+
491
+
492
+ # Package of RubyLoader
493
+
494
+ task :loader => [:header, LOADER_PKG]
495
+
496
+ LOADER_PKG_DIR_LIB = "#{LOADER_PKG_DIR}/lib"
497
+ LOADER_LIB_RUNO_DLL = "#{LIB_DIR}/#{lib_dll}"
498
+ LOADER_MODULE_DLL = "#{LIB_DIR}/#{MODULE_DLL}"
499
+ LOADER_LIB_DLL = "#{LIB_DIR}/#{loader_dll}"
500
+
501
+ directory LOADER_PKG_DIR
502
+ directory LOADER_PKG_DIR_LIB
503
+
504
+
505
+ desc "create libruno library"
506
+ file LOADER_LIB_RUNO_DLL => [LIB_DIR, *LIB_OBJS] do |t|
507
+ sh "#{link} #{out_flag}#{t.name} #{LIB_OBJS.join(' ')} " +
508
+ " #{LIB} #{lib_ldflags} " +
509
+ " #{sdk_lib} #{ure_lib}" +
510
+ " #{sdk_libs} #{LIBRUBYARG} #{LIBS} "
511
+ if host.include? 'mswin'
512
+ sh "#{mt} -manifest #{t.name}.manifest -outputresource:#{t.name};2"
513
+ end
514
+ end
515
+
516
+
517
+ desc "runo.so for RubyLoader."
518
+ file LOADER_MODULE_DLL => [LIB_DIR, *MODULE_OBJS, "#{LIB_DIR}/#{lib_dll}"] do |t|
519
+ p "building runo.so"
520
+ sh "#{link} #{out_flag}#{LIB_DIR}/#{MODULE_DLL} #{MODULE_OBJS.join(' ')} " +
521
+ " #{LIB} #{local_link_lib} #{module_ldflags} " +
522
+ " #{sdk_lib} #{ure_lib}" +
523
+ " #{sdk_libs} #{LIBRUBYARG} #{LIBS} #{runo_libs}"
524
+ if host.include? 'mswin'
525
+ sh "#{mt} -manifest #{t.name}.manifest -outputresource:#{t.name};2"
526
+ end
527
+ end
528
+
529
+
530
+ desc "create loader component"
531
+ file LOADER_LIB_DLL => [LIB_DIR, *LOADER_OBJS] do |t|
532
+ p "building loader"
533
+ sh "#{link} #{out_flag}#{LIB_DIR}/#{loader_dll} #{LOADER_OBJS.join(' ')} " +
534
+ " #{LIB} #{local_link_lib} #{ldflags} #{uno_link_flags}" +
535
+ " #{sdk_lib} #{ure_lib}" +
536
+ " #{sdk_libs} #{LIBRUBYARG} #{LIBS} #{runo_libs} "
537
+ if host.include? 'mswin'
538
+ sh "#{mt} -manifest #{t.name}.manifest -outputresource:#{t.name};2"
539
+ end
540
+ end
541
+
542
+
543
+ file LOADER_PKG => [LOADER_PKG_DIR, "#{LOADER_PKG_DIR}/lib", LOADER_LIB_RUNO_DLL, LOADER_MODULE_DLL, LOADER_LIB_DLL] do |t|
544
+
545
+ dir_path = t.name.sub(/.oxt$/, "")
546
+ media_type = "application/vnd.sun.star.uno-components;platform=#{platform}"
547
+ "#{LIB_DIR}/#{loader_dll}"
548
+ full_path = "lib/#{LOADER_REGISTRATION}"
549
+
550
+ registration_task(dir_path, LOADER_REGISTRATION,
551
+ "com.sun.star.loader.SharedLibrary", loader_dll,
552
+ LOADER_IMPLE_NAME, LOADER_SERVICE_NAMES)
553
+ manifest_task(dir_path, full_path, media_type)
554
+ description_task(dir_path, LOADER_PKG_ID, target, LOADER_PKG_DISPLAY_NAME)
555
+ extension_description_task(dir_path, LOADER_PKG_DESC)
556
+
557
+ cp "#{LOADER_LIB_RUNO_DLL}", "#{LOADER_PKG_DIR_LIB}/#{lib_dll}"
558
+ cp "#{LOADER_MODULE_DLL}", "#{LOADER_PKG_DIR_LIB}/#{MODULE_DLL}"
559
+ cp "#{LOADER_LIB_DLL}", "#{LOADER_PKG_DIR_LIB}/#{loader_dll}"
560
+
561
+ cp "#{LIB_DIR}/#{LOADER_RB}", "#{LOADER_PKG_DIR_LIB}/#{LOADER_RB}"
562
+ cp "#{LIB_DIR}/#{UNO_RB}", "#{LOADER_PKG_DIR_LIB}/#{LIB_RB}"
563
+
564
+ packaging_task dir_path, File.basename(t.name)
565
+ end
566
+
567
+
568
+ # Package of RubyScriptProvider
569
+
570
+ task :provider => [SCRIPT_PKG]
571
+
572
+ SCRIPT_PKG_DIR_LIB = "#{SCRIPT_PKG_DIR}/lib"
573
+
574
+ directory SCRIPT_PKG_DIR
575
+ directory SCRIPT_PKG_DIR_LIB
576
+
577
+
578
+ file SCRIPT_PKG => [SCRIPT_PKG_DIR, SCRIPT_PKG_DIR_LIB] do |t|
579
+
580
+ dir_path = t.name.sub(/.oxt$/, "")
581
+ media_type = "application/vnd.sun.star.uno-components"
582
+
583
+ registration_task(dir_path, SCRIPT_REGISTRATION,
584
+ "com.sun.star.loader.Ruby", SCRIPT_RB,
585
+ SCRIPT_IMPLE_NAME, SCRIPT_SERVICE_NAMES)
586
+ manifest_task(dir_path, "lib/#{SCRIPT_REGISTRATION}", media_type)
587
+ description_task(dir_path, SCRIPT_PACKAGE_ID, target, SCRIPT_PKG_DISPLAY_NAME)
588
+ extension_description_task(dir_path, SCRIPT_DESC)
589
+
590
+ cp "#{LIB_DIR}/#{SCRIPT_RB}", "#{SCRIPT_PKG_DIR_LIB}/#{SCRIPT_RB}"
591
+
592
+ packaging_task dir_path, File.basename(t.name)
593
+ end
594
+
595
+ # Documents
596
+
597
+ rule '.html' => '.rd' do |t|
598
+ sh "#{RD2} #{t.source} > #{t.name}"
599
+ end
600
+
601
+ task :rd_docs => [*HTML_DOCS]
602
+
603
+