mongrel_service 0.1 → 0.4.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,35 @@
1
+ '#--
2
+ '# Copyright (c) 2006-2007 Luis Lavena, Multimedia systems
3
+ '#
4
+ '# This source code is released under the MIT License.
5
+ '# See MIT-LICENSE file for details
6
+ '#++
7
+
8
+ #include once "testly.bi"
9
+ #include once "test_helpers.bi"
10
+ #include once "file.bi"
11
+
12
+ '# Global Helpers
13
+ function content_of_file(byref filename as string) as string
14
+ dim result as string
15
+ dim handle as integer
16
+ dim buffer as string
17
+
18
+ result = ""
19
+ buffer = ""
20
+
21
+ if (fileexists(filename) = true) then
22
+ handle = freefile
23
+ open filename for input as #handle
24
+ do while not (eof(handle))
25
+ input #handle, buffer
26
+ result += buffer
27
+ buffer = ""
28
+ loop
29
+ close #handle
30
+ else
31
+ result = ""
32
+ end if
33
+
34
+ return result
35
+ end function
@@ -0,0 +1,8 @@
1
+ '#--
2
+ '# Copyright (c) 2006-2007 Luis Lavena, Multimedia systems
3
+ '#
4
+ '# This source code is released under the MIT License.
5
+ '# See MIT-LICENSE file for details
6
+ '#++
7
+
8
+ declare function content_of_file(byref as string) as string
@@ -0,0 +1,358 @@
1
+ #--
2
+ # FreeBASIC project builder
3
+ # inspired by Asset Compiler by Jeremy Voorhis
4
+ # coded by Luis Lavena
5
+ #--
6
+
7
+ # FreeBASIC Project library for compilation.
8
+ # For example:
9
+ #
10
+ # namespace :projects do
11
+ # project_task :my_fb_project do
12
+ # lib 'static'
13
+ # dylib 'dynamic library'
14
+ # executable 'exename'
15
+ #
16
+ # build_to 'bin'
17
+ #
18
+ # define 'MY_DEFINE'
19
+ #
20
+ # main 'src/main.bas'
21
+ # source 'src/other_module.bas'
22
+ # source "src/*.bas"
23
+ # end
24
+ # end
25
+ #
26
+ # This example defines the following tasks:
27
+ #
28
+ # rake projects:build # Build all projects
29
+ # rake projects:clobber # Clobber all projects
30
+ # rake projects:my_fb_project:build # Build the my_fb_project files
31
+ # rake projects:my_fb_project:clobber # Remove the my_fb_project files
32
+ # rake projects:my_fb_project:rebuild # Force a rebuild of the my_fb_project files
33
+ # rake projects:rebuild # Rebuild all projects
34
+
35
+ module FreeBASIC
36
+ # this help me reduce the attempts to remove already removed files.
37
+ # works with src_files
38
+ CLOBBER = Rake::FileList.new
39
+ ON_WINDOWS = (RUBY_PLATFORM =~ /mingw|mswin/)
40
+
41
+ class ProjectTask
42
+ attr_accessor :name
43
+ attr_accessor :output_name
44
+ attr_accessor :type
45
+ attr_accessor :build_path
46
+ attr_accessor :defines
47
+ attr_accessor :main_file
48
+ attr_accessor :sources
49
+ attr_accessor :libraries
50
+ attr_accessor :search_path
51
+ attr_accessor :libraries_path
52
+
53
+ def initialize(name, &block)
54
+ @name = name.to_s
55
+ @build_path = '.'
56
+ @defines = []
57
+ @sources = Rake::FileList.new
58
+ @libraries = []
59
+ @search_path = []
60
+ @libraries_path = []
61
+ @options = {}
62
+
63
+ instance_eval(&block) if block_given?
64
+
65
+ do_cleanup
66
+
67
+ namespace @name do
68
+ define_clobber_task
69
+ define_rebuild_task
70
+ define_build_directory_task
71
+ define_build_task
72
+ end
73
+ add_dependencies_to_main_task
74
+ end
75
+
76
+ public
77
+ # using this will set your project type to :executable
78
+ # and assign exe_name as the output_name for the project
79
+ # it dynamically will assign extension when running on windows
80
+ def executable(exe_name)
81
+ @type = :executable
82
+ @output_name = "#{exe_name}.#{(ON_WINDOWS ? "exe" : "")}"
83
+ @real_file_name = @output_name
84
+ end
85
+
86
+ # lib will set type to :lib and assign 'lib#{lib_name}.a'
87
+ # as output_name for the project
88
+ def lib(lib_name)
89
+ @type = :lib
90
+ @output_name = "#{lib_name}"
91
+ @real_file_name = "lib#{lib_name}.a"
92
+ end
93
+
94
+ # dynlib will set type to :dynlib and assign '#{dll_name}.dll|so'
95
+ # as output_name for this project
96
+ def dylib(dll_name)
97
+ @type = :dylib
98
+ @output_name = "#{dll_name}.#{(ON_WINDOWS ? "dll" : "so")}"
99
+ @real_file_name = @output_name
100
+ @complement_file = "lib#{@output_name}.a"
101
+ end
102
+
103
+ # this set where the final, compiled executable should be linked
104
+ # uses @build_path as variable
105
+ def build_to(path)
106
+ @build_path = path
107
+ end
108
+
109
+ # define allow you set compiler time options
110
+ # collect them into @defines and use later
111
+ # to call source file compilation process (it wil require cleanup)
112
+ def define(*defines)
113
+ @defines << defines
114
+ end
115
+
116
+ # main set @main_file to be the main module used during the linking
117
+ # process. also, this module requires special -m flag during his
118
+ # own compile process
119
+ # question: in case @no main_file was set, will use the first 'source'
120
+ # file defined as main? or it should raise a error?
121
+ def main(main_file)
122
+ @main_file = main_file
123
+ end
124
+
125
+ # used to collect sources files for compilation
126
+ # it will take .bas, .rc, .res as sources
127
+ # before compilation we should clean @sources!
128
+ def source(*sources)
129
+ @sources.include sources
130
+ end
131
+
132
+ # this is similar to sources, instead library linking is used
133
+ # also will require cleanup services ;-)
134
+ def library(*libraries)
135
+ @libraries << libraries
136
+ end
137
+
138
+ # use this to set the include path when looking for, ehem, includes
139
+ # (equals -i fbc compiler param)
140
+ def search_path(*search_path)
141
+ @search_path << search_path
142
+ end
143
+
144
+ # use this to tell the compiler where to look for libraries
145
+ # (equals -p fbc compiler param)
146
+ def lib_path(*libraries_path)
147
+ @libraries_path << libraries_path
148
+ end
149
+
150
+ # use this to add additional compiler parameters (like debug or errorchecking options)
151
+ #
152
+ def option(new_options = {})
153
+ @options.merge!(new_options)
154
+ end
155
+
156
+ protected
157
+ # this method will fix nested libraries and defines
158
+ # also, if main_file is missing (or wasn't set) will shift the first one
159
+ # as main
160
+ def do_cleanup
161
+ # remove duplicated definitions, flatten
162
+ @defines.flatten!
163
+ @defines.uniq! if @defines.length > 1
164
+
165
+ # set main_file
166
+ if @type == :executable
167
+ @main_file = @sources.shift unless defined?(@main_file)
168
+ end
169
+
170
+ # empty path? must be corrected
171
+ @build_path = '.' if @build_path == ''
172
+
173
+ # remove duplicates from sources
174
+ @sources.uniq! if @sources.length > 1
175
+
176
+ # now the libraries
177
+ @libraries.flatten!
178
+ @libraries.uniq! if @libraries.length > 1
179
+
180
+ # search path
181
+ @search_path.flatten!
182
+ @search_path.uniq! if @search_path.length > 1
183
+
184
+ # libraries path
185
+ @libraries_path.flatten!
186
+ @libraries_path.uniq! if @libraries_path.length > 1
187
+
188
+ # if no target was set, default to executable
189
+ unless defined?(@output_name)
190
+ executable(@name)
191
+ end
192
+ end
193
+
194
+ # return the compiled name version of the passed source file (src)
195
+ # compiled_form("test.bas") => "test.o"
196
+ def compiled_form(src)
197
+ unless src.nil?
198
+ src.ext({ ".bas" => "o", ".rc" => "obj" }[File.extname(src)])
199
+ end
200
+ end
201
+
202
+ def compiled_project_file
203
+ File.join @build_path, @real_file_name
204
+ end
205
+
206
+ def fbc_compile(source, target, main = nil)
207
+ cmdline = []
208
+ cmdline << "fbc"
209
+ cmdline << "-w pedantic" if (@options.has_key?(:pedantic) && @options[:pedantic] == true)
210
+ cmdline << "-g" if (@options.has_key?(:debug) && @options[:debug] == true)
211
+ cmdline << "-#{@options[:errorchecking].to_s}" if @options.has_key?(:errorchecking)
212
+ cmdline << "-mt" if (@options.has_key?(:mt) && @options[:mt] == true)
213
+ cmdline << "-profile" if (@options.has_key?(:profile) && @options[:profile] == true)
214
+ cmdline << "-c #{source}"
215
+ cmdline << "-o #{target}"
216
+ cmdline << "-m #{main}" unless main.nil?
217
+ cmdline << @defines.collect { |defname| "-d #{defname}" }
218
+ cmdline << @search_path.collect { |path| "-i #{path}" }
219
+ cmdline.flatten.join(' ')
220
+ end
221
+
222
+ def fbc_link(target, files, extra_files = [])
223
+ cmdline = []
224
+ cmdline << "fbc"
225
+ cmdline << "-g" if (@options.has_key?(:debug) && @options[:debug] == true)
226
+ cmdline << "-mt" if (@options.has_key?(:mt) && @options[:mt] == true)
227
+ cmdline << "-profile" if (@options.has_key?(:profile) && @options[:profile] == true)
228
+ cmdline << "-#{@type.to_s}" unless @type == :executable
229
+ cmdline << "-x #{target}"
230
+ cmdline << files << extra_files
231
+ cmdline << @defines.collect { |defname| "-d #{defname}" }
232
+ unless @type == :lib
233
+ cmdline << @libraries_path.collect { |path| "-p #{path}" }
234
+ cmdline << @libraries.collect { |libname| "-l #{libname}" }
235
+ end
236
+ cmdline.flatten.join(' ')
237
+ end
238
+
239
+ def define_clobber_task
240
+ desc "Remove all compiled files for #{@name}"
241
+ task :clobber do
242
+ # remove compiled and linked file
243
+ rm compiled_project_file rescue nil if File.exist?(compiled_project_file)
244
+ if @type == :dylib
245
+ rm File.join(@build_path, @complement_file) rescue nil if File.exist?(File.join(@build_path, @complement_file))
246
+ end
247
+
248
+ # remove main file
249
+ unless @main_file.nil? || !File.exists?(compiled_form(@main_file))
250
+ rm compiled_form(@main_file) rescue nil
251
+ end
252
+
253
+ # now the sources files
254
+ # avoid attempt to remove the file two times (this is a bug in Rake)
255
+ @sources.each do |src|
256
+ # exclude compiled source files (c obj).
257
+ unless src =~ /o$/
258
+ target = compiled_form(src)
259
+ unless CLOBBER.include?(target)
260
+ CLOBBER.include(target)
261
+ rm target rescue nil if File.exist?(target)
262
+ end
263
+ end
264
+ end
265
+ end
266
+ end
267
+
268
+ def define_rebuild_task
269
+ desc "Force a rebuild of files for #{@name}"
270
+ task :rebuild => [:clobber, :build]
271
+ end
272
+
273
+ def define_build_directory_task
274
+ directory @build_path
275
+ task :build => @build_path
276
+ end
277
+
278
+ def define_build_task
279
+ desc "Build project #{@name}"
280
+ task :build
281
+
282
+ # empty file task
283
+ file compiled_project_file
284
+
285
+ # compile main_file
286
+ # use as pre-requisite the source filename
287
+ if @type == :executable
288
+ file compiled_form(@main_file) => @main_file do |t|
289
+ # remove the path and the extension
290
+ main_module = File.basename(t.name).ext
291
+ sh fbc_compile(@main_file, t.name, main_module)
292
+ end
293
+
294
+ # add dependency
295
+ file compiled_project_file => compiled_form(@main_file)
296
+ end
297
+
298
+ # gather files that are passed "as-is" to the compiler
299
+ unprocessed_files = @sources.select { |rcfile| rcfile =~ /(res|rc|o|obj)$/ }
300
+
301
+ @sources.each do |src|
302
+ # is a unprocessed file?
303
+ unless unprocessed_files.include?(src)
304
+ target = compiled_form(src)
305
+
306
+ # is already in our list of tasks?
307
+ if not Rake::Task.task_defined?(target)
308
+ # if not, compile
309
+
310
+ file target => src do
311
+ sh fbc_compile(src, target)
312
+ end
313
+ end
314
+
315
+ # include dependency
316
+ file compiled_project_file => target
317
+ end
318
+ end
319
+
320
+ # now the linking process
321
+ file compiled_project_file do |t|
322
+ target = File.join(@build_path, @output_name)
323
+ sh fbc_link(target, t.prerequisites, unprocessed_files)
324
+ end
325
+
326
+ # add the dependency
327
+ task :build => compiled_project_file
328
+ end
329
+
330
+ # Adds dependencies in the parent namespace
331
+ def add_dependencies_to_main_task
332
+ desc 'Build all projects' unless task( :build ).comment
333
+ task :build => "#{@name}:build"
334
+
335
+ desc 'Clobber all projects' unless task( :clobber ).comment
336
+ task :clobber => "#{@name}:clobber"
337
+
338
+ desc 'Rebuild all projects' unless task( :rebuild ).comment
339
+ task :rebuild => ["#{@name}:clobber", "#{@name}:build"]
340
+ end
341
+ end
342
+ end
343
+
344
+ # helper method to define a FreeBASIC::ProjectTask in the current namespace
345
+ def project_task name, &block
346
+ FreeBASIC::ProjectTask.new name, &block
347
+ end
348
+
349
+ def include_projects_of name
350
+ desc 'Build all projects' unless task( :build ).comment
351
+ task :build => "#{name}:build"
352
+
353
+ desc 'Clobber all projects' unless task( :clobber ).comment
354
+ task :clobber => "#{name}:clobber"
355
+
356
+ desc 'Rebuild all projects' unless task( :rebuild ).comment
357
+ task :rebuild => "#{name}:rebuild"
358
+ end
metadata CHANGED
@@ -1,70 +1,123 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
3
- specification_version: 1
4
2
  name: mongrel_service
5
3
  version: !ruby/object:Gem::Version
6
- version: "0.1"
7
- date: 2006-06-16 00:00:00 -04:00
8
- summary: Mongrel Native Win32 Service Plugin for Rails
9
- require_paths:
10
- - lib
11
- email:
12
- homepage:
13
- rubyforge_project:
14
- description: This plugin offer native win32 services for rails, powered by Mongrel.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.4.beta1
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
6
  authors:
29
7
  - Luis Lavena
30
- files:
31
- - COPYING
32
- - LICENSE
33
- - README
34
- - Rakefile
35
- - bin/mongrel_service
36
- - lib/mongrel_service
37
- - lib/mongrel_service/init.rb
38
- - tools/rakehelp.rb
39
- - resources/defaults.yaml
40
- test_files: []
41
-
42
- rdoc_options: []
43
-
44
- extra_rdoc_files:
45
- - README
46
- executables:
47
- - mongrel_service
48
- extensions: []
49
-
50
- requirements: []
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
51
11
 
12
+ date: 2010-01-01 00:00:00 -03:00
13
+ default_executable:
52
14
  dependencies:
53
15
  - !ruby/object:Gem::Dependency
54
16
  name: gem_plugin
17
+ type: :runtime
55
18
  version_requirement:
56
- version_requirements: !ruby/object:Gem::Version::Requirement
19
+ version_requirements: !ruby/object:Gem::Requirement
57
20
  requirements:
58
- - - ">="
21
+ - - ~>
59
22
  - !ruby/object:Gem::Version
60
- version: 0.2.1
23
+ version: 0.2.3
61
24
  version:
62
25
  - !ruby/object:Gem::Dependency
63
26
  name: mongrel
27
+ type: :runtime
64
28
  version_requirement:
65
- version_requirements: !ruby/object:Gem::Version::Requirement
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.5
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: hoe
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
66
40
  requirements:
67
41
  - - ">="
68
42
  - !ruby/object:Gem::Version
69
- version: 0.3.12.4
43
+ version: 2.4.0
70
44
  version:
45
+ description: |-
46
+ This plugin offer native win32 services for rails.
47
+ This replace mongrel_rails_service.
48
+ email:
49
+ - luislavena@gmail.com
50
+ executables: []
51
+
52
+ extensions: []
53
+
54
+ extra_rdoc_files:
55
+ - History.txt
56
+ - LICENSE.txt
57
+ - Manifest.txt
58
+ - README.txt
59
+ - TODO.txt
60
+ files:
61
+ - History.txt
62
+ - lib/mongrel_service/init.rb
63
+ - lib/mongrel_service/service_manager.rb
64
+ - LICENSE.txt
65
+ - Manifest.txt
66
+ - Rakefile
67
+ - README.txt
68
+ - resources/defaults.yaml
69
+ - resources/mongrel_service.exe
70
+ - src/mongrel_service/_debug.bi
71
+ - src/mongrel_service/boolean.bi
72
+ - src/mongrel_service/console_process.bas
73
+ - src/mongrel_service/console_process.bi
74
+ - src/mongrel_service/mongrel_service.bas
75
+ - src/mongrel_service/mongrel_service.bi
76
+ - src/ServiceFB/_internals.bi
77
+ - src/ServiceFB/_utils_internals.bi
78
+ - src/ServiceFB/ServiceFB.bas
79
+ - src/ServiceFB/ServiceFB.bi
80
+ - src/ServiceFB/ServiceFB_Utils.bas
81
+ - src/ServiceFB/ServiceFB_Utils.bi
82
+ - tasks/gem.rake
83
+ - tasks/native_lib.rake
84
+ - tasks/native_service.rake
85
+ - tasks/tests.rake
86
+ - tests/all_tests.bas
87
+ - tests/fixtures/mock_process.bas
88
+ - tests/test_console_process.bas
89
+ - tests/test_helpers.bas
90
+ - tests/test_helpers.bi
91
+ - TODO.txt
92
+ - tools/freebasic.rb
93
+ has_rdoc: true
94
+ homepage: http://github.com/fauna/mongrel_service
95
+ licenses: []
96
+
97
+ post_install_message:
98
+ rdoc_options:
99
+ - --main
100
+ - README.txt
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: "0"
108
+ version:
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">"
112
+ - !ruby/object:Gem::Version
113
+ version: 1.3.1
114
+ version:
115
+ requirements: []
116
+
117
+ rubyforge_project: mongrel
118
+ rubygems_version: 1.3.5
119
+ signing_key:
120
+ specification_version: 3
121
+ summary: This plugin offer native win32 services for rails
122
+ test_files: []
123
+