mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-01-16 22:08:28 +01:00
Make to-array.py list itself as a dependency of its outputs
This causes these dependencies to be rebuilt if the script chanages, which is heaps better than having to remember to clean the build directory every time.
This commit is contained in:
parent
295aad1800
commit
281dbfa283
@ -22,7 +22,8 @@ fs = import('fs')
|
||||
to_array = generator(
|
||||
python3_prog,
|
||||
output: [ '@PLAINNAME@.cpp', '@PLAINNAME@.h' ],
|
||||
arguments: [ join_paths(meson.current_source_dir(), 'resources/to-array.py'), '@OUTPUT0@', '@OUTPUT1@', '@INPUT@', '@EXTRA_ARGS@' ]
|
||||
depfile: '@PLAINNAME@.dep',
|
||||
arguments: [ join_paths(meson.current_source_dir(), 'resources/to-array.py'), '@OUTPUT0@', '@OUTPUT1@', '@DEPFILE@', '@INPUT@', '@EXTRA_ARGS@' ]
|
||||
)
|
||||
|
||||
render_icons_with_inkscape = get_option('render_icons_with_inkscape')
|
||||
|
@ -1,13 +1,17 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
(
|
||||
script,
|
||||
output_cpp_path,
|
||||
output_h_path,
|
||||
output_dep_path,
|
||||
input_path,
|
||||
symbol_name,
|
||||
) = sys.argv
|
||||
|
||||
script_path = os.path.realpath(__file__)
|
||||
|
||||
with open(input_path, 'rb') as input_f:
|
||||
data = input_f.read()
|
||||
data_size = len(data)
|
||||
@ -26,3 +30,16 @@ with open(output_h_path, 'w') as output_h_f:
|
||||
extern const unsigned char {symbol_name}[];
|
||||
extern const unsigned int {symbol_name}_size;
|
||||
''')
|
||||
|
||||
def dep_escape(s):
|
||||
t = ''
|
||||
for c in s:
|
||||
if c in [ ' ', '\n', '\\', ':', '$' ]:
|
||||
t += '$'
|
||||
t += c
|
||||
return t
|
||||
|
||||
with open(output_dep_path, 'w') as output_dep_f:
|
||||
output_dep_f.write(f'''
|
||||
{dep_escape(output_cpp_path)} {dep_escape(output_h_path)}: {dep_escape(input_path)} {dep_escape(script_path)}
|
||||
''')
|
||||
|
Loading…
x
Reference in New Issue
Block a user