From dbb2c5713e11489dfaeb318a82785017f1794dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 24 Jan 2012 16:34:05 +0100 Subject: tools/genruby: handle necessary requires directives for native modules --- tools/genruby.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/genruby.rb b/tools/genruby.rb index e2ee632..2eae0e7 100755 --- a/tools/genruby.rb +++ b/tools/genruby.rb @@ -6,14 +6,14 @@ lib_path = File.join path, '..', 'lib', 'efl', 'native' # # header, module name, fct prefix, lib libraries = [ - # HEADER MODUE NAME FCT PREFIX LIB OUTPUT + # HEADER MODUE NAME FCT PREFIX LIB OUTPUT REQUIRES [ 'eina_types.h', 'Eina', 'eina', 'eina', 'eina_types.rb' ], [ 'eina_main.h', 'Eina', 'eina', 'eina', 'eina.rb' ], [ 'eina_xattr.h', 'EinaXattr', 'eina_xattr', 'eina', 'eina_xattr.rb' ], [ 'eina_log.h', 'EinaLog', 'eina_log', 'eina', 'eina_log.rb' ], [ 'eina_list.h', 'EinaList', 'eina_list', 'eina', 'eina_list.rb' ], [ 'eina_hash.h', 'EinaHash', 'eina_hash', 'eina', 'eina_hash.rb' ], - [ 'Eet.h', 'Eet', 'eet', 'eet', 'eet.rb' ], + [ 'Eet.h', 'Eet', 'eet', 'eet', 'eet.rb', [ 'efl/native/eina_xattr' ] ], [ 'Evas.h', 'Evas', 'evas', 'evas', 'evas.rb' ], # [ 'Evas_GL.h', 'EvasGl', 'evas_gl', 'evas', 'evas/evas_gl.rb' ], [ 'Edje.h', 'Edje', 'edje', 'edje', 'edje.rb' ], @@ -30,11 +30,13 @@ libraries = [ # INDENT=' '*8 # +REQUIRES=['efl/ffi'] +# HEADER =<<-EOF #! /usr/bin/env ruby # -*- coding: UTF-8 -*- # -require 'efl/ffi' +REQUIRES # module Efl # @@ -269,12 +271,12 @@ end # Dir.mkdir lib_path unless (File.exists? lib_path) # -libraries.collect do |header,module_name,fct_prefix,lib, output| +libraries.collect do |header,module_name,fct_prefix,lib, output, requires| base = File.join path, 'api', header output = File.join lib_path, output Dir.mkdir File.dirname(output) unless File.exists? File.dirname(output) printf "%-60s", "parse #{base}-*" - r = [lib, output, module_name, fct_prefix ] + r = [lib, output, module_name, fct_prefix, requires ] print "enums, " r << gen_enums(base, INDENT) print "typedefs, " @@ -286,10 +288,12 @@ libraries.collect do |header,module_name,fct_prefix,lib, output| puts "functions." r << gen_functions(base, INDENT) r -end.each do |lib, output, module_name, fct_prefix, enums, typedefs, callbacks, variables, functions| +end.each do |lib, output, module_name, fct_prefix, requires, enums, typedefs, callbacks, variables, functions| printf "%-60s", "generate #{output}" open(output,'w:utf-8') do |f| - f << HEADER.gsub(/MNAME/,module_name).sub(/MY_FCT_PREFIX/,fct_prefix) + requires||=[] + reqs = REQUIRES.concat(requires).collect{|r| "require '#{r}'" }.join ("\n") + f << HEADER.gsub(/MNAME/,module_name).sub(/MY_FCT_PREFIX/,fct_prefix).sub(/REQUIRES/,reqs) f << "#{INDENT}#\n#{INDENT}ffi_lib '#{lib}'" f << "\n#{INDENT}#\n#{INDENT}# ENUMS" print "enums, " -- cgit v1.1-2-g2b99