@@ -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++"
5779end
5880
5981abort 'libjsonnet.h not found' unless have_header ( 'libjsonnet.h' )
0 commit comments