summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-01-24 16:34:05 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2012-01-24 16:34:05 +0100
commitdbb2c5713e11489dfaeb318a82785017f1794dde (patch)
tree6cfc2ed4f023bf2aaa11c889b81b98ad87e4d75d /tools
parentdf490aebdfce1d52f4e5c79cd778ea088cdff71f (diff)
downloadffi-efl-dbb2c5713e11489dfaeb318a82785017f1794dde.zip
ffi-efl-dbb2c5713e11489dfaeb318a82785017f1794dde.tar.gz
tools/genruby: handle necessary requires directives for native modules
Diffstat (limited to 'tools')
-rwxr-xr-xtools/genruby.rb18
1 files 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, "