Skip to content

Commit

Permalink
meson: run thunk_gen via make [#146]
Browse files Browse the repository at this point in the history
Who says that meson should not use make?
It seems, mixing those 2 produces good results. :)
  • Loading branch information
stsp committed Dec 29, 2024
1 parent 7dd6671 commit caf355f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
54 changes: 26 additions & 28 deletions fdpp/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ project('libfdpp', ['c', 'cpp'], default_options: ['cpp_std=c++20'],

MF = meson.current_source_dir() / 'parsers/mkfar.sh'
PD = meson.current_source_dir() / 'parsers/parse_decls.sh'
RA = meson.current_source_dir() / 'run_arg.sh'
tg = dependency('thunk_gen')
TG = tg.get_variable(pkgconfig: 'binary')
MA = tg.get_variable(pkgconfig: 'mkadscript')
TGS = tg.get_variable(pkgconfig: 'tgscript')
TGM4 = tg.get_variable(pkgconfig: 'm4script')
TFLAGS = ['-a', '2', '-p', '2']
TGMK = tg.get_variable(pkgconfig: 'makeinc')
TFLAGS = '-a 2 -p 2'
SRC = 'src'
rel_inc = 'include/fdpp'
incdir = include_directories(rel_inc)
Expand Down Expand Up @@ -61,11 +59,16 @@ ccgen = generator(find_program(MF),
capture: true)
ccfiles = ccgen.process(CFILES)

make = find_program('make')

gad = custom_target('glob_asmdefs.h',
output: 'glob_asmdefs.h',
input: 'src/glob_asm.h',
command: [MA, '@INPUT@'],
capture: true)
command: [make, '-f', TGMK,
# this doesn't work
# fs.name('@OUTPUT@'),
'glob_asmdefs.h',
'GLOB_ASM=@INPUT@'])

GEN_TMP = { '1':'thunk_calls.tmp', '2':'thunk_asms.tmp' }
GEN_H = { 'plt_asmc.h':'4', 'plt_asmp.h':'5' }
Expand Down Expand Up @@ -97,33 +100,28 @@ pap = custom_target('plt_asmp.h',
env: env,
capture: true)

tgenv = environment()
tgenv.set('TFLAGS', TFLAGS)

tc = custom_target('thunk_calls.h',
output: 'thunk_calls.h',
input: GEN['thunk_calls.tmp'],
command: [TG, TFLAGS],
feed: true,
capture: true)

ta1 = custom_target('thunk_asms1.h',
output: 'thunk_asms1.h',
input: GEN['thunk_asms.tmp'],
command: [TG, TFLAGS, '1'],
feed: true,
capture: true)

ta2 = custom_target('thunk_asms2.h',
output: 'thunk_asms2.h',
input: GEN['thunk_asms.tmp'],
command: [TG, TFLAGS, '2'],
feed: true,
capture: true)
command: [RA, 'thunk_calls.tmp', make, '-f', TGMK,
# this doesn't work
# fs.name('@OUTPUT@'),
'thunk_calls.h'],
env: tgenv,
feed: true)

ta = custom_target('thunk_asms.h',
output: 'thunk_asms.h',
input: [ta1, ta2],
command: ['sh', '-c', 'cat @INPUT0@ | ' + TGS + ' ' + TGM4 +
' | cat - @INPUT1@'],
capture: true)
input: GEN['thunk_asms.tmp'],
command: [RA, 'thunk_asms.tmp', make, '-f', TGMK,
# this doesn't work
# fs.name('@OUTPUT@'),
'thunk_asms.h'],
env: tgenv,
feed: true)

FDPP_CFILES = ['smalloc.c', 'farhlp_sta.c']
ccgen = generator(find_program('echo'),
Expand Down
7 changes: 7 additions & 0 deletions fdpp/run_arg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

cat >$1
shift
PRG=$1
shift
$PRG $*

0 comments on commit caf355f

Please sign in to comment.