gplugin/gplugin

Update the gjs loader for the meson build system
feature/gjs-cc
2017-06-05, Gary Kramlich
5b1c8afa206b
Parents bbc137ff81ce
Children 934b41f609c8
Update the gjs loader for the meson build system
--- a/gjs/CMakeLists.txt Mon Jun 05 22:33:20 2017 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-option(
- BUILD_GJS
- "Whether or not to build the GJS JavaScript plugin loader"
- "On"
-)
-
-if(BUILD_GJS)
- remove_definitions(
- -Wextra
- -std=c99
- )
-
- set(GPLUGIN_GJS_SOURCES
- gplugin-gjs-core.cc
- gplugin-gjs-loader.cc
- gplugin-gjs-plugin.cc
- )
-
- set(GPLUGIN_GJS_HEADERS
- gplugin-gjs-loader.h
- gplugin-gjs-plugin.h
- )
-
- pkg_check_modules(GJS REQUIRED gjs-1.0>=1.32.0)
-
- include_directories(${GJS_INCLUDE_DIRS})
- link_directories(${GJS_LIBRARY_DIRS})
-
- add_library(gplugin-gjs MODULE
- ${GPLUGIN_GJS_SOURCES}
- ${GPLUGIN_GJS_HEADERS}
- )
- target_compile_features(gplugin-gjs PRIVATE cxx_deleted_functions)
- set_target_properties(gplugin-gjs PROPERTIES PREFIX "")
-
- target_link_libraries(gplugin-gjs
- ${GJS_LIBRARIES}
- gplugin
- )
-
- install(TARGETS gplugin-gjs DESTINATION lib/gplugin)
-endif(BUILD_GJS)
-
-if(TESTING_ENABLED)
- add_subdirectory(tests)
-endif(TESTING_ENABLED)
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/meson.build Mon Jun 05 23:09:04 2017 -0500
@@ -0,0 +1,55 @@
+if get_option('gjs')
+ if not get_option('gobject-introspection')
+ error('gnome-javascript plugin requires GObject Introspection.')
+ endif
+
+ GPLUGIN_GJS_SOURCES = [
+ 'gplugin-gjs-core.cc',
+ 'gplugin-gjs-loader.cc',
+ 'gplugin-gjs-plugin.cc',
+ ]
+
+ GPLUGIN_GJS_HEADERS = [
+ 'gplugin-gjs-loader.h',
+ 'gplugin-gjs-plugin.h',
+ ]
+
+ GJS = dependency('gjs-1.0', version: '>=1.32.0')
+ MOZJS = dependency('mozjs-24', version: '>=24.0.0')
+
+ # tell meson we need cpp since we have gjs
+ add_languages('cpp')
+
+ gjs_args = [
+ '-DPREFIX="@0@"'.format(get_option('prefix')),
+ '-DLIBDIR="@0@"'.format(get_option('libdir')),
+ '-DGPLUGIN_WEBSITE="http://bitbucket.org/gplugin/main"',
+ ]
+
+ # check if we're using gcc
+ if meson.get_compiler('cpp').get_id() == 'gcc' or host_machine.platform() == 'darwin'
+ gjs_args += [
+ '-DGPLUGIN_UNUSED=__attribute__((unused))',
+ '-ggdb',
+ ]
+ else
+ gjs_args += [
+ '-DGPLUGIN_UNUSED=',
+ ]
+ endif
+
+ # now add the library
+ shared_library('gplugin-gjs',
+ GPLUGIN_GJS_SOURCES,
+ GPLUGIN_GJS_HEADERS,
+ name_prefix : '',
+ dependencies : [GIO, GJS, MOZJS, gplugin_dep],
+ install : true,
+ install_dir : join_paths(get_option('libdir'), 'gplugin'),
+ cpp_args: gjs_args,
+ )
+endif # lua
+
+if get_option('testing')
+ subdir('tests')
+endif
--- a/gjs/tests/CMakeLists.txt Mon Jun 05 22:33:20 2017 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-if(BUILD_GJS)
-
-macro(add_gjs_gtest target)
- add_executable(${target} ${target}.c)
- target_link_libraries(${target}
- ${GLIB_LIBRARIES} ${GJS_LIBRARIES} gplugin
- )
- add_dependencies(${target} gplugin-gjs)
-
- get_target_property(_output_name ${target} RUNTIME_OUTPUT_NAME)
- if(NOT ${_output_name})
- get_target_property(_output_name ${target} LOCATION)
- endif(NOT ${_output_name})
-
- list(APPEND GJS_TESTS ${_output_name})
-endmacro(add_gjs_gtest)
-
-add_definitions(
- -DGJS_LOADER_DIR="${CMAKE_BINARY_DIR}/gjs"
- -DGJS_PLUGIN_DIR="${CMAKE_CURRENT_SOURCE_DIR}/plugins"
-)
-
-add_gjs_gtest(test-gjs-loader)
-target_link_libraries(test-gjs-loader gplugin-loader-tests)
-
-set(GTESTER_GJS_TESTS "${GJS_TESTS}")
-set(GTESTER_GJS_LOG "test-gplugin-gjs.xml")
-set(GTESTER_GJS_JUNIT "test-gplugin-gjs-junit.xml")
-
-add_custom_command(
- COMMAND ${GTESTER} -k --verbose -o ${GTESTER_GJS_LOG} ${GJS_TESTS}
- OUTPUT ${GTESTER_GJS_LOG}
- DEPENDS gplugin gplugin-gjs
- ${GJS_TESTS} ${CMAKE_CURRENT_SOURCE_DIR}/plugins
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-)
-
-add_custom_command(
- COMMAND ${XSLTPROC} -o ${GTESTER_GJS_JUNIT} --nonet
- ${CMAKE_SOURCE_DIR}/xsl/gtester-junit.xsl
- ${GTESTER_GJS_LOG}
- OUTPUT ${GTESTER_GJS_JUNIT}
- DEPENDS ${GTESTER_GJS_LOG}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-)
-
-add_custom_target(gjs-tests ALL
- DEPENDS ${GTESTER_GJS_LOG} ${GTESTER_GJS_JUNIT} ${GJS_TESTS}
-)
-
-endif(BUILD_GJS)
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/meson.build Mon Jun 05 23:09:04 2017 -0500
@@ -0,0 +1,13 @@
+if get_option('gjs')
+
+e = executable('test-gjs-loader', 'test-gjs-loader.c',
+ include_directories : include_directories('.'),
+ c_args : [
+ '-DGJS_LOADER_DIR="@0@/gjs"'.format(meson.build_root()),
+ '-DGJS_PLUGIN_DIR="@0@/plugins"'.format(meson.current_source_dir()),
+ ],
+ link_with : gplugin_loader_tests,
+ dependencies : [GLIB, GOBJECT, GJS, gplugin_dep])
+test('GNOME JavaScript loader', e)
+
+endif # gjs
--- a/gjs/tests/test-gjs-loader.c Mon Jun 05 22:33:20 2017 -0500
+++ b/gjs/tests/test-gjs-loader.c Mon Jun 05 23:09:04 2017 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2014 Gary Kramlich <grim@reaperworld.com>
+ * Copyright (C) 2011-2017 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
--- a/meson.build Mon Jun 05 22:33:20 2017 -0500
+++ b/meson.build Mon Jun 05 23:09:04 2017 -0500
@@ -37,6 +37,7 @@
GLIB = dependency('glib-2.0', version : '>=2.34.0')
GOBJECT = dependency('gobject-2.0')
+GIO = dependency('gio-2.0')
# we separate gmodule out so our test aren't linked to it
GMODULE = dependency('gmodule-2.0')
--- a/meson_options.txt Mon Jun 05 22:33:20 2017 -0500
+++ b/meson_options.txt Mon Jun 05 23:09:04 2017 -0500
@@ -26,6 +26,12 @@
)
option(
+ 'gjs',
+ type : 'boolean', value : true,
+ description : 'Whether or not to build the GNOME JavaScript plugin loader'
+)
+
+option(
'gtk3',
type : 'boolean', value : true,
description : 'Whether or not to build the gtk3 library'