1

When I need to turn a list of input files to a list of output files in a makefile I'd do something like this:

input := file_a.ts file_b.ts file_c.ts
output := $(input:.ts=.js)

How would I do this in meson? I tried using the '@BASENAME@' syntax first:

js = custom_target(
  'compile-ts',
  input: ts,
  command: [ tsc, '-p', tsconfig, '--outDir', '.' ],
  output: '@BASENAME@.js'
)

But no luck:

ERROR: custom_target: output cannot contain "@PLAINNAME@" or "@BASENAME@" when there is more than one input

I then tried the replace() function:

  ...
  output: sources.replace('.ts', '.js')

Alas, more errors:

ERROR: Unknown method "replace" in object <[ArrayHolder] holds [list]: ['main.ts', 'window.ts']> of type ArrayHolder.

Surprisingly, I can't find any documentation for such a basic use case.

Edit:
found a workaround using loops:

javascript = []
foreach ts: typescript
  javascript += ts.replace('.ts', '.js')
endforeach

But this feels rather dirty... still looking for a better way.

ea7ababe
  • 373
  • 5
  • 13

0 Answers0