From aefb8552edc71cf61aaf6cffc39ea9e4a5b226e6 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 13 Sep 2023 15:13:31 +0200 Subject: [PATCH] jbig2dec: add 0.20 --- ci_config.json | 5 + releases.json | 8 ++ subprojects/jbig2dec.wrap | 9 ++ .../packagefiles/jbig2dec/include/meson.build | 9 ++ subprojects/packagefiles/jbig2dec/meson.build | 131 ++++++++++++++++++ .../packagefiles/jbig2dec/meson_options.txt | 2 + .../packagefiles/jbig2dec/src/config.h.meson | 23 +++ .../jbig2dec/src/config_types.h.meson | 23 +++ .../packagefiles/jbig2dec/src/jbig2dec.def | 13 ++ .../packagefiles/jbig2dec/src/meson.build | 99 +++++++++++++ tools/sanity_checks.py | 3 + 11 files changed, 325 insertions(+) create mode 100644 subprojects/jbig2dec.wrap create mode 100644 subprojects/packagefiles/jbig2dec/include/meson.build create mode 100644 subprojects/packagefiles/jbig2dec/meson.build create mode 100644 subprojects/packagefiles/jbig2dec/meson_options.txt create mode 100644 subprojects/packagefiles/jbig2dec/src/config.h.meson create mode 100644 subprojects/packagefiles/jbig2dec/src/config_types.h.meson create mode 100644 subprojects/packagefiles/jbig2dec/src/jbig2dec.def create mode 100644 subprojects/packagefiles/jbig2dec/src/meson.build diff --git a/ci_config.json b/ci_config.json index 637ec259e..af3c8a2b2 100644 --- a/ci_config.json +++ b/ci_config.json @@ -184,6 +184,11 @@ "htslib:tests=true" ] }, + "jbig2dec": { + "msys_packages": [ + "libpng" + ] + }, "json-glib": { "_comment": "gettext is not optional: https://gitlab.gnome.org/GNOME/json-glib/-/merge_requests/50", "debian_packages": [ diff --git a/releases.json b/releases.json index ebeb8be72..f627febd1 100644 --- a/releases.json +++ b/releases.json @@ -1075,6 +1075,14 @@ "2.11-1" ] }, + "jbig2dec": { + "versions": [ + "0.20-1" + ], + "dependency_names": [ + "jbig2dec" + ] + }, "jbigkit": { "versions": [ "2.1-2", diff --git a/subprojects/jbig2dec.wrap b/subprojects/jbig2dec.wrap new file mode 100644 index 000000000..53614ce97 --- /dev/null +++ b/subprojects/jbig2dec.wrap @@ -0,0 +1,9 @@ +[wrap-file] +directory = jbig2dec-0.20 +source_url = https://github.com/ArtifexSoftware/jbig2dec/archive/refs/tags/0.20.tar.gz +source_filename = jbig2dec-0.20.tar.gz +source_hash = a9705369a6633aba532693450ec802c562397e1b824662de809ede92f67aff21 +patch_directory = jbig2dec + +[provide] +dependency_names = jbig2dec diff --git a/subprojects/packagefiles/jbig2dec/include/meson.build b/subprojects/packagefiles/jbig2dec/include/meson.build new file mode 100644 index 000000000..f77e09032 --- /dev/null +++ b/subprojects/packagefiles/jbig2dec/include/meson.build @@ -0,0 +1,9 @@ +jbig2_h = fs.copyfile( + '../jbig2.h', + 'jbig2.h', + install: true, + install_dir: get_option('includedir'), + install_tag: 'devel', +) + +public_include = include_directories('.') diff --git a/subprojects/packagefiles/jbig2dec/meson.build b/subprojects/packagefiles/jbig2dec/meson.build new file mode 100644 index 000000000..b72f89e72 --- /dev/null +++ b/subprojects/packagefiles/jbig2dec/meson.build @@ -0,0 +1,131 @@ +project( + 'jbig2dec', + 'c', + version: '0.20', + meson_version: '>=0.64.0', +) + +cc = meson.get_compiler('c') + +fs = import('fs') + +progs_opt = get_option('progs') +tests_opt = get_option('tests') + +lib_inc = [ + 'jbig2_arith.h', + 'jbig2_arith_iaid.h', + 'jbig2_arith_int.h', + 'jbig2_generic.h', + 'jbig2_halftone.h', + 'jbig2_huffman.h', + 'jbig2_hufftab.h', + 'jbig2_image.h', + 'jbig2_image_rw.h', + 'jbig2_mmr.h', + 'jbig2_page.h', + 'jbig2_priv.h', + 'jbig2_refinement.h', + 'jbig2_segment.h', + 'jbig2_symbol_dict.h', + 'jbig2_text.h', + 'memento.h', + 'os_types.h', + 'sha1.h', +] +lib_src = [ + 'jbig2.c', + 'jbig2_arith.c', + 'jbig2_arith_iaid.c', + 'jbig2_arith_int.c', + 'jbig2_generic.c', + 'jbig2_halftone.c', + 'jbig2_huffman.c', + 'jbig2_hufftab.c', + 'jbig2_image.c', + 'jbig2_image_pbm.c', + 'jbig2_mmr.c', + 'jbig2_page.c', + 'jbig2_refinement.c', + 'jbig2_segment.c', + 'jbig2_symbol_dict.c', + 'jbig2_text.c', +] +progs_src = [ + 'jbig2dec.c', + 'sha1.c', +] +tests_src = [ +] + +m_dep = cc.find_library('m', required: false) + +png_dep = dependency('libpng', required: progs_opt.disabled() ? progs_opt : false) +if png_dep.found() + progs_src += 'jbig2_image_png.c' +endif + +add_project_arguments('-DHAVE_CONFIG_H', language: 'c') + +cdata = configuration_data() +cdata.set('HAVE_LIBPNG', png_dep.found()) +cdata.set('WORDS_BIGENDIAN', host_machine.endian() == 'big' ? 1 : false) + +foreach _header : [ + 'stdint.h', + 'string.h', +] + cdata.set( + 'HAVE_' + _header.underscorify().to_upper(), + cc.has_header(_header) ? 1 : false, + ) +endforeach + +if ( + progs_opt.allowed() + and cc.has_function('getopt_long', prefix: '#include') +) + cdata.set('HAVE_GETOPT_H', 1) +else + progs_src += [ + 'getopt.c', + 'getopt.h', + 'getopt1.c', + ] +endif + +# Optional replacement for int…_t / uint…_t types. +cdata.set('JBIG2_STDINT_H', '') +cdata.set('JBIG2_INT8_T' , '') +cdata.set('JBIG2_INT16_T' , '') +cdata.set('JBIG2_INT32_T' , '') +if cdata.get('HAVE_STDINT_H').to_string() != '1' + sizeof_types = {} + foreach _type : ['char', 'short', 'int', 'long'] + sizeof_types += {_type: cc.sizeof(_type)} + endforeach + foreach _spec : [ + ['int8' , 1, 'char' ], + ['int16', 2, 'short char int'], + ['int32', 4, 'int long short'], + ] + _name = _spec[0] + _size = _spec[1] + _typelist = _spec[2] + _type = '' + foreach _candidate : _typelist.split() + if _size == sizeof_types[_candidate] + _type = _candidate + break + endif + endforeach + if _type == '' + error('could not find a suitable replacement type for @0@_t / u@0@_t'.format(_name)) + endif + message('using @0@ for @1@_t / u@1@_t'.format(_type, _name)) + cdata.set('JBIG2_@0@_T'.format(_name.to_upper()), _type) + endforeach +endif + +subdir('include') +subdir('src') diff --git a/subprojects/packagefiles/jbig2dec/meson_options.txt b/subprojects/packagefiles/jbig2dec/meson_options.txt new file mode 100644 index 000000000..7bee73b7f --- /dev/null +++ b/subprojects/packagefiles/jbig2dec/meson_options.txt @@ -0,0 +1,2 @@ +option('progs', type: 'feature') +option('tests', type: 'feature') diff --git a/subprojects/packagefiles/jbig2dec/src/config.h.meson b/subprojects/packagefiles/jbig2dec/src/config.h.meson new file mode 100644 index 000000000..96c695fe7 --- /dev/null +++ b/subprojects/packagefiles/jbig2dec/src/config.h.meson @@ -0,0 +1,23 @@ +/* config.h. Generated from config.h.meson by meson. */ + +/* Define to 1 if you have the header + * with a compatible `getopt_long` function. */ +#mesondefine HAVE_GETOPT_H + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_LIBINTL_H + +/* Define if libpng is available (-lpng) */ +#mesondefine HAVE_LIBPNG + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#mesondefine HAVE_STRING_H + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#mesondefine WORDS_BIGENDIAN + +/* vim: set ft=c: */ diff --git a/subprojects/packagefiles/jbig2dec/src/config_types.h.meson b/subprojects/packagefiles/jbig2dec/src/config_types.h.meson new file mode 100644 index 000000000..dd38e0129 --- /dev/null +++ b/subprojects/packagefiles/jbig2dec/src/config_types.h.meson @@ -0,0 +1,23 @@ +/* + generated header with missing types for the + jbig2dec program and library. include this + after config.h, within the HAVE_CONFIG_H + ifdef +*/ + +#ifdef HAVE_STDINT_H +# include +#else +# ifdef JBIG2_REPLACE_STDINT_H +# include <@JBIG2_STDINT_H@> +# else + typedef unsigned @JBIG2_INT32_T@ uint32_t; + typedef unsigned @JBIG2_INT16_T@ uint16_t; + typedef unsigned @JBIG2_INT8_T@ uint8_t; + typedef signed @JBIG2_INT32_T@ int32_t; + typedef signed @JBIG2_INT16_T@ int16_t; + typedef signed @JBIG2_INT8_T@ int8_t; +# endif /* JBIG2_REPLACE_STDINT */ +#endif /* HAVE_STDINT_H */ + +/* vim: set ft=c: */ diff --git a/subprojects/packagefiles/jbig2dec/src/jbig2dec.def b/subprojects/packagefiles/jbig2dec/src/jbig2dec.def new file mode 100644 index 000000000..cd38fd718 --- /dev/null +++ b/subprojects/packagefiles/jbig2dec/src/jbig2dec.def @@ -0,0 +1,13 @@ +EXPORTS +; Public API. +jbig2_complete_page +jbig2_ctx_free +jbig2_ctx_new_imp +jbig2_data_in +jbig2_global_ctx_free +jbig2_make_global_ctx +jbig2_page_out +jbig2_release_page +; Private, but used by the jbig2dec executable. +jbig2_error +jbig2_image_write_pbm diff --git a/subprojects/packagefiles/jbig2dec/src/meson.build b/subprojects/packagefiles/jbig2dec/src/meson.build new file mode 100644 index 000000000..f7e8125ed --- /dev/null +++ b/subprojects/packagefiles/jbig2dec/src/meson.build @@ -0,0 +1,99 @@ +# Because of the presence of `getopt.h` alongside the standard source files, +# and the mix of private and public headers in the same directory, we copy +# only the files needed to the build directory. +foreach _listname, _needed : { + 'lib_inc' : true, + 'lib_src' : true, + 'progs_src': progs_opt.allowed(), + 'tests_src': progs_opt.allowed(), +} + if not _needed + continue + endif + _srclist = get_variable(_listname) + _dstlist = [] + foreach _file : _srclist + _filecopy = fs.copyfile('..' / _file, _file) + set_variable(_file.underscorify(), _filecopy) + _dstlist += _filecopy + endforeach + set_variable(_listname, _dstlist) +endforeach + +config_h = configure_file( + configuration: cdata, + input: 'config.h.meson', + output: 'config.h', +) + +config_types_h = configure_file( + configuration: cdata, + input: 'config_types.h.meson', + output: 'config_types.h', +) + +lib_inc += [ + config_h, + config_types_h, + jbig2_h, +] + +jbig2dec_lib = library( + 'jbig2dec', + [ + lib_inc, + lib_src, + ], + dependencies: m_dep, + install: true, + version: '0.0.0', + vs_module_defs: 'jbig2dec.def', +) + +jbig2dec_dep = declare_dependency( + include_directories: public_include, + link_with: jbig2dec_lib, + sources: jbig2_h, +) +meson.override_dependency('jbig2dec', jbig2dec_dep) + +pkg = import('pkgconfig') +pkg.generate( + jbig2dec_lib, + description: 'JBIG2 decoder library.', + filebase: 'jbig2dec', + name: 'libjbig2dec', +) + +if progs_opt.allowed() + executable( + 'jbig2dec', + [lib_inc, progs_src], + dependencies: [jbig2dec_dep, png_dep], + install: true, + ) +endif + +if tests_opt.allowed() + # Tests need access to all symbols, including on Windows. + jbig2dec_priv_lib = static_library( + 'jbig2dec_priv', + objects: jbig2dec_lib.extract_all_objects(recursive: true), + ) + foreach _name, _src : { + 'arith' : jbig2_arith_c, + 'huffman': jbig2_huffman_c, + 'sha1' : sha1_c, + } + test( + _name, + executable( + _name, + [lib_inc, _src], + c_args: '-DTEST', + include_directories: public_include, + link_with: jbig2dec_priv_lib, + ), + ) + endforeach +endif diff --git a/tools/sanity_checks.py b/tools/sanity_checks.py index 190a79b81..0a8456abe 100755 --- a/tools/sanity_checks.py +++ b/tools/sanity_checks.py @@ -41,6 +41,9 @@ 'glbinding-aux_features.h', 'glbinding-aux_export.h' ], + 'jbig2dec': [ + 'jbig2dec.def', + ], 'jbigkit': [ 'jbig.def', 'jbig85.def'