From cd8724c4977ea8b9aebfebc9ea449d4ed69d1ea8 Mon Sep 17 00:00:00 2001 From: Dov Grobgeld Date: Mon, 22 Apr 2024 17:13:38 +0200 Subject: [PATCH] Add meson wrap files for dependencies and more meson fixes --- meson.build | 4 ++-- src/file2c.py | 45 ++++++++++++++++++++++++++++++++++++++++ src/meson.build | 31 +++++++++++++++++++++++++-- src/plugins/meson.build | 1 - subprojects/gob2.wrap | 3 +++ subprojects/libplis.wrap | 3 +++ 6 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 src/file2c.py create mode 100644 subprojects/gob2.wrap create mode 100644 subprojects/libplis.wrap diff --git a/meson.build b/meson.build index f96ed91..6b6d79a 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project('giv', ['c','cpp','vala'], license: 'LGPLv3+') PACKAGE_DOC_DIR = 'doc' -PACKAGE_PLUGIN_DIR = get_option('prefix') + 'lib/giv-1.0/plugins/' +PACKAGE_PLUGIN_DIR = get_option('prefix') / 'lib/giv-1.0/plugins/' add_global_arguments('-DSPDLOG_FMT_EXTERNAL', language : 'cpp') @@ -17,7 +17,7 @@ add_global_arguments(['-DPACKAGE_DOC_DIR="'+PACKAGE_DOC_DIR+'" ', gob2_proj = subproject('gob2') -libsimple_dep = dependency( +libplis_dep = dependency( 'libplis', fallback : ['libplis', 'libplis_dep'], default_options: ['default_library=static'] diff --git a/src/file2c.py b/src/file2c.py new file mode 100644 index 0000000..ba843b1 --- /dev/null +++ b/src/file2c.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +###################################################################### +# Wrap an arbitrary file for inclusion in c. +# +# 2024-04-21 Sun +# Dov Grobgeld +###################################################################### + +import argparse +import re + +def file2c(target, source): + out = open(target, "wb") + inp = open(source, "rb") + + for line in inp.readlines(): + line = line.decode('utf8').rstrip() + line = re.sub("\\\\", "\\\\", line) + line = re.sub("\\\"", "\\\"", line) + line = '"'+line+'\\n"\n' + out.write(line.encode('utf8')) + + out.close() + inp.close() + +parser = argparse.ArgumentParser(description='Process a file') +parser.add_argument('--target', + dest='target', + action='store', + type=str, + default=None, + help='target filename') +parser.add_argument('--source', + dest='source', + action='store', + default=None, + help='source filename editing') + +args = vars(parser.parse_args()) +print(f'{args["target"]=} {args["source"]=}') +if not args['target'] or not args['source']: + sys.write('Need both target asnd source arguments!') + +file2c(args['target'], + args['source']) diff --git a/src/meson.build b/src/meson.build index 7fd7b9c..54917fb 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,7 @@ gob2 = gob2_proj.get_variable('gob2_exe') +pymod = import('python') +python = pymod.find_installation() giv_widget_src = custom_target('gen-output', output : ['giv-widget.h','giv-widget-private.h','giv-widget.cc'], input : 'giv-widget.gob', @@ -24,7 +26,6 @@ giv_widget_sources = [ ] subdir('agg') -#subdir('plis') subdir('glib-jsonrpc') subdir('gtkimageviewer') @@ -35,7 +36,6 @@ gtk_dep = dependency('gtk+-3.0') fmt_dep = dependency('fmt') spdlog_dep = dependency('spdlog') gmodule_dep = dependency('gmodule-2.0') -libplis_dep = dependency('libplis') libgivwidget = shared_library( 'giv-widget', @@ -100,6 +100,33 @@ foreach basename : [ )[2] endforeach +file2c = find_program('file2c.py') + +foreach src_trg : [ + ['menu-top-xml.i','menu-top.xml'], + ['menu-popup-xml.i','menu-popup.xml'], + ['copyright.i','copyright.markup']] + + target = src_trg[0] + source = src_trg[1] + giv_src += custom_target( + target, + output : [target], + input : source, + command : [file2c, '--source', '@INPUT@', '--target', '@OUTPUT@'], + ) +endforeach + +gdk_pixbuf_csource = find_program('gdk-pixbuf-csource') + +giv_src += custom_target( + 'giv-logo.i', + output : ['giv-logo.i'], + input : ['../doc/giv-logo.png'], + capture : true, + command : [gdk_pixbuf_csource, '--name=image_giv_icon_inline', '@INPUT@'] +) + glib_dep = dependency('glib-2.0') gobject_dep = dependency('gobject-2.0') gio_dep = dependency('gio-2.0') diff --git a/src/plugins/meson.build b/src/plugins/meson.build index 352e205..c9ede24 100644 --- a/src/plugins/meson.build +++ b/src/plugins/meson.build @@ -3,7 +3,6 @@ inc = ['..'] png_dep = dependency('libpng') zip_dep = dependency('libzip') tiff_dep = dependency('libtiff-4') -libplis_dep = dependency('libplis') plugins = [['npy', 'npy.c', []], ['tiff','tiff.c', [tiff_dep]], diff --git a/subprojects/gob2.wrap b/subprojects/gob2.wrap new file mode 100644 index 0000000..5646605 --- /dev/null +++ b/subprojects/gob2.wrap @@ -0,0 +1,3 @@ +[wrap-git] +url = http://github.com/dov/gob2 +revision = cpp-new diff --git a/subprojects/libplis.wrap b/subprojects/libplis.wrap new file mode 100644 index 0000000..29ecb2c --- /dev/null +++ b/subprojects/libplis.wrap @@ -0,0 +1,3 @@ +[wrap-git] +url = http://github.com/dov/libplis.git +revision = master