Skip to content

Commit

Permalink
Add meson wrap files for dependencies and more meson fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dov committed Apr 23, 2024
1 parent 513a9cf commit 8f91e9d
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 3 deletions.
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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']
Expand Down
45 changes: 45 additions & 0 deletions src/file2c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
######################################################################
# Wrap an arbitrary file for inclusion in c.
#
# 2024-04-21 Sun
# Dov Grobgeld <dov.grobgeld@gmail.com>
######################################################################

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'])
30 changes: 29 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -24,7 +26,6 @@ giv_widget_sources = [
]

subdir('agg')
#subdir('plis')
subdir('glib-jsonrpc')
subdir('gtkimageviewer')

Expand Down Expand Up @@ -100,6 +101,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')
Expand Down
3 changes: 3 additions & 0 deletions subprojects/gob2.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[wrap-git]
url = http://github.com/dov/gob2
revision = cpp-new
3 changes: 3 additions & 0 deletions subprojects/libplis.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[wrap-git]
url = http://github.com/dov/libplis.git
revision = master

0 comments on commit 8f91e9d

Please sign in to comment.