gplugin/gplugin

Update the ruby stuff for meson and add all the stub plugins
feature/ruby-loader
2017-06-03, Gary Kramlich
53d47c07a63d
Parents fa275888f359
Children e182652acae6
Update the ruby stuff for meson and add all the stub plugins
--- a/meson.build Sat Jun 03 02:47:28 2017 -0500
+++ b/meson.build Sat Jun 03 03:07:52 2017 -0500
@@ -110,6 +110,7 @@
subdir('lua')
subdir('perl')
subdir('python')
+subdir('ruby')
subdir('tcc')
###############################################################################
--- a/meson_options.txt Sat Jun 03 02:47:28 2017 -0500
+++ b/meson_options.txt Sat Jun 03 03:07:52 2017 -0500
@@ -56,6 +56,12 @@
)
option(
+ 'ruby',
+ type : 'boolean', value : true,
+ description : 'Whether or not to build the Ruby plugin loader.'
+)
+
+option(
'tcc',
type : 'boolean', value : false,
description : 'Whether or not to build the TCC plugin loader'
--- a/ruby/CMakeLists.txt Sat Jun 03 02:47:28 2017 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-option(
- BUILD_RUBY
- "Whether or not to build the Ruby plugin loader"
- "On"
-)
-
-if(BUILD_RUBY)
- if(NOT BUILD_GIR)
- message(FATAL_ERROR "Ruby plugin requires GObject Introspection.")
- endif(NOT BUILD_GIR)
-
- set(GPLUGIN_RUBY_SOURCES
- gplugin-ruby-core.c
- gplugin-ruby-loader.c
- gplugin-ruby-plugin.c
- )
-
- set(GPLUGIN_RUBY_HEADERS
- gplugin-ruby-loader.h
- gplugin-ruby-plugin.h
- )
-
- pkg_check_modules(RUBY REQUIRED ruby-2.1)
-
- include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${RUBY_INCLUDE_DIRS}
- )
-
- # Now add our libraries
- add_library(gplugin-ruby MODULE
- ${GPLUGIN_RUBY_SOURCES}
- ${GPLUGIN_RUBY_HEADERS}
- )
-
- add_library(gplugin-ruby-static STATIC
- ${GPLUGIN_RUBY_SOURCES}
- ${GPLUGIN_RUBY_HEADERS}
- )
-
- set_target_properties(gplugin-ruby PROPERTIES PREFIX "")
-
- target_link_libraries(gplugin-ruby
- ${RUBY_LIBRARIES}
- gplugin
- )
-
- target_link_libraries(gplugin-ruby-static
- ${RUBY_LIBRARIES}
- gplugin
- )
-
- install(TARGETS gplugin-ruby DESTINATION lib/gplugin)
-endif(BUILD_RUBY)
-
-if(TESTING_ENABLED)
- add_subdirectory(tests)
-endif(TESTING_ENABLED)
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ruby/meson.build Sat Jun 03 03:07:52 2017 -0500
@@ -0,0 +1,45 @@
+if get_option('ruby')
+ if not get_option('gobject-introspection')
+ error('Ruby plugin requires GObject Introspection.')
+ endif
+
+ GPLUGIN_RUBY_SOURCES = [
+ 'gplugin-ruby-core.c',
+ 'gplugin-ruby-loader.c',
+ 'gplugin-ruby-plugin.c',
+ ]
+
+ GPLUGIN_RUBY_HEADERS = [
+ 'gplugin-ruby-loader.h',
+ 'gplugin-ruby-plugin.h',
+ ]
+
+ _RUBYS = [['ruby-2.3', '>=2.3.0'],
+ ['ruby-2.2', '>=2.2.0'],
+ ['ruby-2.1', '>=2.1.0']]
+ RUBY_FOUND = false
+ foreach _RUBY : _RUBYS
+ if not RUBY_FOUND
+ RUBY = dependency(_RUBY[0], version : _RUBY[1], required : false)
+ RUBY_FOUND = RUBY.found()
+ endif
+ endforeach
+
+ if not RUBY_FOUND
+ error('No usable Ruby library was found')
+ endif
+
+ # now add the library
+ shared_library('gplugin-ruby',
+ GPLUGIN_RUBY_SOURCES,
+ GPLUGIN_RUBY_HEADERS,
+ name_prefix : '',
+ dependencies : [RUBY, gplugin_dep],
+ install : true,
+ install_dir : join_paths(get_option('libdir'), 'gplugin')
+ )
+endif # ruby
+
+if get_option('testing')
+ subdir('tests')
+endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ruby/tests/meson.build Sat Jun 03 03:07:52 2017 -0500
@@ -0,0 +1,12 @@
+if get_option('ruby')
+
+e = executable('test-ruby-loader', 'test-ruby-loader.c',
+ c_args : [
+ '-DRUBY_LOADER_DIR="@0@/ruby"'.format(meson.build_root()),
+ '-DRUBY_PLUGIN_DIR="@0@/plugins"'.format(meson.current_source_dir()),
+ ],
+ link_with : gplugin_loader_tests,
+ dependencies : [GLIB, GOBJECT, RUBY, gplugin_dep])
+test('ruby Loader', e)
+
+endif # ruby
--- a/ruby/tests/plugins/basic.rb Sat Jun 03 02:47:28 2017 -0500
+++ b/ruby/tests/plugins/basic.rb Sat Jun 03 03:07:52 2017 -0500
@@ -5,22 +5,14 @@
def gplugin_query()
return GPlugin::PluginInfo.new({
:id => 'ruby/ruby-basic-plugin',
- :abi_version => 0x01020304,
- :name => 'basic plugin',
})
end
def gplugin_load(plugin)
- puts 'load'
- puts plugin
-
return true
end
def gplugin_unload(plugin)
- puts 'unload'
- puts plugin
-
return true
end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ruby/tests/plugins/dependent.rb Sat Jun 03 03:07:52 2017 -0500
@@ -0,0 +1,18 @@
+require 'gir_ffi'
+
+GirFFI.setup :GPlugin
+
+def gplugin_query()
+ return GPlugin::PluginInfo.new({
+ :id => 'ruby/ruby-dependent',
+ :dependencies => ["dependency1", "dependency2"],
+ })
+end
+
+def gplugin_load(plugin)
+ return true
+end
+
+def gplugin_unload(plugin)
+ return true
+end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ruby/tests/plugins/load-exception.rb Sat Jun 03 03:07:52 2017 -0500
@@ -0,0 +1,17 @@
+require 'gir_ffi'
+
+GirFFI.setup :GPlugin
+
+def gplugin_query()
+ return GPlugin::PluginInfo.new({
+ :id => 'ruby/ruby-load-exception',
+ })
+end
+
+def gplugin_load(plugin)
+ raise 'explosion!'
+end
+
+def gplugin_unload(plugin)
+ return true
+end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ruby/tests/plugins/load-failed.rb Sat Jun 03 03:07:52 2017 -0500
@@ -0,0 +1,17 @@
+require 'gir_ffi'
+
+GirFFI.setup :GPlugin
+
+def gplugin_query()
+ return GPlugin::PluginInfo.new({
+ :id => 'ruby/ruby-load-failed',
+ })
+end
+
+def gplugin_load(plugin)
+ return false
+end
+
+def gplugin_unload(plugin)
+ return true
+end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ruby/tests/plugins/unload-failed.rb Sat Jun 03 03:07:52 2017 -0500
@@ -0,0 +1,17 @@
+require 'gir_ffi'
+
+GirFFI.setup :GPlugin
+
+def gplugin_query()
+ return GPlugin::PluginInfo.new({
+ :id => 'ruby/ruby-unload-failed',
+ })
+end
+
+def gplugin_load(plugin)
+ return true
+end
+
+def gplugin_unload(plugin)
+ return false
+end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ruby/tests/test-ruby-loader.c Sat Jun 03 03:07:52 2017 -0500
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011-2014 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <gplugin.h>
+
+#include <gplugin/gplugin-loader-tests.h>
+
+gint
+main(gint argc, gchar **argv) {
+ g_test_init(&argc, &argv, NULL);
+
+ gplugin_loader_tests_main(RUBY_LOADER_DIR, RUBY_PLUGIN_DIR, "ruby");
+
+ return g_test_run();
+}
+