perf(const): const changed to a singelton
const needds to be accessed all throughout so it has been changed to a singleton to allow for more efficient usage BREAKING CHANGE: Any previous loads to const will break, also constant->Constant and constants->Constants
This commit is contained in:
10
src/resources/const/format.sh
Executable file
10
src/resources/const/format.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <input_file> <output_file>"
|
||||
exit 1
|
||||
fi
|
||||
input_file="$1"
|
||||
output_file="$2"
|
||||
printf 'const char embeddedConstants[] = R"(' > "$output_file"
|
||||
cat "$input_file" >> "$output_file"
|
||||
printf ')";\n' >> "$output_file"
|
||||
20
src/resources/const/meson.build
Normal file
20
src/resources/const/meson.build
Normal file
@@ -0,0 +1,20 @@
|
||||
data_file = files('const.dat')
|
||||
command_file = files('format.sh')
|
||||
output_file = meson.current_build_dir() + '/embedded_constants.h'
|
||||
message('Data file absolute path: ' + data_file[0].full_path())
|
||||
message('Meson source directory: ' + meson.current_source_dir())
|
||||
message('Meson build directory: ' + meson.current_build_dir())
|
||||
|
||||
embedded_constants_h = custom_target('embed_constants',
|
||||
input: data_file,
|
||||
output: 'embedded_constants.h',
|
||||
command: ['sh', '-c', command_file[0].full_path()+' @INPUT@ ' + output_file, '@INPUT@', '@OUTPUT@']
|
||||
)
|
||||
|
||||
# Ensure the generated header is included
|
||||
const_header = include_directories('.')
|
||||
|
||||
const_dep = declare_dependency(
|
||||
include_directories: const_header,
|
||||
sources: embedded_constants_h
|
||||
)
|
||||
1
src/resources/meson.build
Normal file
1
src/resources/meson.build
Normal file
@@ -0,0 +1 @@
|
||||
subdir('const')
|
||||
Reference in New Issue
Block a user