diff --git a/ext/extconf.rb b/ext/extconf.rb index 59c39a6..e9d04d1 100644 --- a/ext/extconf.rb +++ b/ext/extconf.rb @@ -12,10 +12,28 @@ def using_system_libraries? require 'rubygems' require 'mini_portile2' + onig_recipe = MiniPortile.new('onigmo', '6.2.0') + onig_recipe.files << 'https://github.com/k-takata/Onigmo/releases/download/Onigmo-6.2.0/onigmo-6.2.0.tar.gz' + onig_recipe.configure_options = [ + '--disable-static', + '--disable-maintainer-mode' + ] + class << onig_recipe + def configure + execute('autoreconf', 'autoreconf -vfi') + super + end + end + onig_recipe.cook + onig_recipe.activate + $LIBPATH = ["#{onig_recipe.path}/lib"] | $LIBPATH # rubocop:disable Style/GlobalVars + $CPPFLAGS << " -I#{onig_recipe.path}/include" # rubocop:disable Style/GlobalVars + recipe = MiniPortile.new('jq', '1.6') - recipe.files = ['https://github.com/stedolan/jq/releases/download/jq-1.6/jq-1.6.tar.gz'] + recipe.files = ['https://github.com/stedolan/jq/archive/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8.tar.gz'] + recipe.patch_files << File.join(File.dirname(File.expand_path(__FILE__)), "jq-onigmo.patch") recipe.configure_options = [ - '--enable-shared', + '--disable-static', '--disable-maintainer-mode' ] class << recipe @@ -27,7 +45,7 @@ def configure end recipe.cook recipe.activate - $LIBPATH = ["#{recipe.path}/lib"] | $LIBPATH # rubocop:disable Style/GlobalVars + $LIBPATH = ["#{onig_recipe.path}/lib", "#{recipe.path}/lib"] | $LIBPATH # rubocop:disable Style/GlobalVars $CPPFLAGS << " -I#{recipe.path}/include" # rubocop:disable Style/GlobalVars end diff --git a/ext/jq-onigmo.patch b/ext/jq-onigmo.patch new file mode 100644 index 0000000..62abecd --- /dev/null +++ b/ext/jq-onigmo.patch @@ -0,0 +1,62 @@ +--- configure.ac ++++ configure.ac +@@ -270,10 +270,10 @@ AS_IF([test "x$with_oniguruma" != xno], [ + # check for ONIGURUMA library, either in /usr or where requested + CFLAGS="$CFLAGS $onig_CFLAGS" + LDFLAGS="$LDFLAGS $onig_LDFLAGS" +- AC_CHECK_HEADER("oniguruma.h", +- AC_CHECK_LIB([onig],[onig_version])) ++ AC_CHECK_HEADER("onigmo.h", ++ AC_CHECK_LIB([onigmo],[onig_version])) + # handle check results +- AS_IF([test "x$ac_cv_lib_onig_onig_version" != "xyes"], [ ++ AS_IF([test "x$ac_cv_lib_onigmo_onig_version" != "xyes"], [ + build_oniguruma=yes + AC_MSG_NOTICE([Oniguruma was not found. Will use the packaged oniguruma.]) + ]) +--- src/builtin.c ++++ src/builtin.c +@@ -29,8 +29,8 @@ void *alloca (size_t); + #include + #include + #include +-#ifdef HAVE_LIBONIG +-#include ++#ifdef HAVE_LIBONIGMO ++#include + #endif + #include + #include +@@ -801,7 +801,7 @@ static jv f_group_by_impl(jq_state *jq, jv input, jv keys) { + } + } + +-#ifdef HAVE_LIBONIG ++#ifdef HAVE_LIBONIGMO + static int f_match_name_iter(const UChar* name, const UChar *name_end, int ngroups, + int *groups, regex_t *reg, void *arg) { + jv captures = *(jv*)arg; +@@ -889,7 +889,7 @@ static jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) { + + onigret = onig_new(®, (const UChar*)jv_string_value(regex), + (const UChar*)(jv_string_value(regex) + jv_string_length_bytes(jv_copy(regex))), +- options, ONIG_ENCODING_UTF8, ONIG_SYNTAX_PERL_NG, &einfo); ++ options, ONIG_ENCODING_UTF8, ONIG_SYNTAX_PERL58_NG, &einfo); + if (onigret != ONIG_NORMAL) { + UChar ebuf[ONIG_MAX_ERROR_MESSAGE_LEN]; + onig_error_code_to_str(ebuf, onigret, &einfo); +@@ -1005,11 +1005,11 @@ static jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) { + jv_free(regex); + return result; + } +-#else /* !HAVE_LIBONIG */ ++#else /* !HAVE_LIBONIGMO */ + static jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) { +- return jv_invalid_with_msg(jv_string("jq was compiled without ONIGURUMA regex library. match/test/sub and related functions are not available.")); ++ return jv_invalid_with_msg(jv_string("jq was compiled without ONIGMO regex library. match/test/sub and related functions are not available.")); + } +-#endif /* HAVE_LIBONIG */ ++#endif /* HAVE_LIBONIGMO */ + + static jv minmax_by(jv values, jv keys, int is_min) { + if (jv_get_kind(values) != JV_KIND_ARRAY) diff --git a/ext/jq_core.c b/ext/jq_core.c index 54cba6b..386fef9 100644 --- a/ext/jq_core.c +++ b/ext/jq_core.c @@ -95,6 +95,7 @@ static void jq_process(jq_state *jq, jv value, VALUE (*proc)(), int *status, VAL if (*status == 0) { rb_protect(proc, rb_str_new2(str), status); } + jv_free(dumped); } if (jv_invalid_has_msg(jv_copy(result))) { diff --git a/lib/jq/version.rb b/lib/jq/version.rb index 6bd6bbe..7e46048 100644 --- a/lib/jq/version.rb +++ b/lib/jq/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module JQ - VERSION = '0.2.2' + VERSION = '0.2.3' end diff --git a/ruby-jq.gemspec b/ruby-jq.gemspec index c1c35e5..88961be 100644 --- a/ruby-jq.gemspec +++ b/ruby-jq.gemspec @@ -23,8 +23,8 @@ Gem::Specification.new do |spec| spec.add_dependency 'multi_json', '~> 1.15', '>= 1.10.0' spec.add_runtime_dependency 'mini_portile2', '~> 2.2', '>= 2.2.0' - spec.add_development_dependency 'rake', '~> 0' - spec.add_development_dependency 'rake-compiler', '~> 0' - spec.add_development_dependency 'rspec', '~> 0' - spec.add_development_dependency 'rubocop', '~> 0' + spec.add_development_dependency 'rake', '~> 0.9.6' + spec.add_development_dependency 'rake-compiler', '~> 0.9.9' + spec.add_development_dependency 'rspec', '~> 3.9.0' + spec.add_development_dependency 'rubocop', '~> 0.93.1' end