Skip to content

Commit 38d4bfa

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 2ca8b69 + cfce769 commit 38d4bfa

3 files changed

Lines changed: 38 additions & 12 deletions

File tree

ext/jsonnet/callbacks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ invoke_callback(VALUE args)
2727
{
2828
long len = RARRAY_LEN(args);
2929
VALUE callback = rb_ary_entry(args, 0);
30-
return rb_funcall2(callback, id_call, len - 1, RARRAY_PTR(args) + 1);
30+
return rb_funcall2(callback, id_call, (int)(len - 1), RARRAY_PTR(args) + 1);
3131
}
3232

3333
/*

ext/jsonnet/extconf.rb

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ def using_system_libraries?
1616
recipe = MiniPortile.new('jsonnet', 'v0.18.0')
1717
recipe.files = ['https://github.com/google/jsonnet/archive/v0.18.0.tar.gz']
1818
class << recipe
19+
CORE_OBJS = %w[
20+
desugarer.o formatter.o lexer.o libjsonnet.o parser.o pass.o static_analysis.o string_utils.o vm.o
21+
].map {|name| File.join('core', name) }
22+
MD5_OBJS = %w[
23+
md5.o
24+
].map {|name| File.join('third_party', 'md5', name) }
25+
C4_CORE_OBJS = %w[
26+
base64.o
27+
char_traits.o
28+
error.o
29+
format.o
30+
language.o
31+
memory_resource.o
32+
memory_util.o
33+
time.o
34+
].map {|name| File.join('third_party', 'rapidyaml', 'rapidyaml', 'ext', 'c4core', 'src', 'c4', name) }
35+
RAPID_YAML_OBJS = %w[
36+
common.o parse.o preprocess.o tree.o
37+
].map {|name| File.join('third_party', 'rapidyaml', 'rapidyaml', 'src', 'c4', 'yml', name) }
1938

2039
def compile
2140
# We want to create a file a library we can link to. Jsonnet provides us
@@ -24,7 +43,7 @@ def compile
2443
# we compile the c into .o files and then create an archive that can
2544
# be linked to
2645
execute('compile', make_cmd)
27-
execute('archive', 'ar rcs libjsonnet.a core/desugarer.o core/formatter.o core/lexer.o core/libjsonnet.o core/parser.o core/pass.o core/static_analysis.o core/string_utils.o core/vm.o third_party/md5/md5.o')
46+
execute('archive', 'ar rcs libjsonnet.a ' + target_object_files.join(' '))
2847
end
2948

3049
def configured?
@@ -41,19 +60,22 @@ def install
4160
FileUtils.cp(File.join(work_path, 'include', 'libjsonnet.h'), include_path)
4261
FileUtils.cp(File.join(work_path, 'include', 'libjsonnet_fmt.h'), include_path)
4362
end
63+
64+
private
65+
def target_object_files
66+
if version >= 'v0.18.0'
67+
CORE_OBJS + MD5_OBJS + C4_CORE_OBJS + RAPID_YAML_OBJS
68+
else
69+
CORE_OBJS + MD5_OBJS
70+
end
71+
end
4472
end
4573

4674
recipe.cook
4775
# I tried using recipe.activate here but that caused this file to build ok
4876
# but the makefile to fail. These commands add the necessary paths to do both
4977
$LIBPATH = ["#{recipe.path}/lib"] | $LIBPATH
5078
$CPPFLAGS << " -I#{recipe.path}/include"
51-
52-
# This resolves an issue where you can get improper linkage when compiling
53-
# and get an error like "undefined symbol: _ZTVN10__cxxabiv121__vmi_class_type_infoE"
54-
# experienced on ubuntu.
55-
# See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=193950
56-
$LIBS << " -lstdc++"
5779
end
5880

5981
abort 'libjsonnet.h not found' unless have_header('libjsonnet.h')

ext/jsonnet/vm.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
#include "ruby_jsonnet.h"
99

10+
#ifndef NORETURN
11+
# define NORETURN(x) x
12+
#endif
13+
1014
/*
1115
* defines the core part of Jsonnet::VM
1216
*/
@@ -385,7 +389,7 @@ vm_fmt_snippet(VALUE self, VALUE snippet, VALUE fname)
385389
void
386390
rubyjsonnet_init_vm(VALUE mJsonnet)
387391
{
388-
cVM = rb_define_class_under(mJsonnet, "VM", rb_cData);
392+
cVM = rb_define_class_under(mJsonnet, "VM", rb_cObject);
389393
rb_define_singleton_method(cVM, "new", vm_s_new, -1);
390394
rb_define_private_method(cVM, "eval_file", vm_evaluate_file, 3);
391395
rb_define_private_method(cVM, "eval_snippet", vm_evaluate, 3);
@@ -424,7 +428,7 @@ rubyjsonnet_init_vm(VALUE mJsonnet)
424428
}
425429

426430
static void
427-
raise_error(VALUE exception_class, struct JsonnetVm *vm, char *msg, rb_encoding *enc)
431+
NORETURN(raise_error)(VALUE exception_class, struct JsonnetVm *vm, char *msg, rb_encoding *enc)
428432
{
429433
VALUE ex;
430434
const int state = rubyjsonnet_jump_tag(msg);
@@ -451,13 +455,13 @@ raise_error(VALUE exception_class, struct JsonnetVm *vm, char *msg, rb_encoding
451455
* @sa rescue_callback
452456
*/
453457
static void
454-
raise_eval_error(struct JsonnetVm *vm, char *msg, rb_encoding *enc)
458+
NORETURN(raise_eval_error)(struct JsonnetVm *vm, char *msg, rb_encoding *enc)
455459
{
456460
raise_error(eEvaluationError, vm, msg, enc);
457461
}
458462

459463
static void
460-
raise_format_error(struct JsonnetVm *vm, char *msg, rb_encoding *enc)
464+
NORETURN(raise_format_error)(struct JsonnetVm *vm, char *msg, rb_encoding *enc)
461465
{
462466
raise_error(eFormatError, vm, msg, enc);
463467
}

0 commit comments

Comments
 (0)