colorschemes: simplify build and allow parallel compilation

This commit is contained in:
Boris Faure 2021-11-25 00:16:14 +01:00
parent f73a806868
commit caba4bf828
Signed by untrusted user who does not match committer: borisfaure
GPG Key ID: 35C0410516166BE8
4 changed files with 53 additions and 60 deletions

View File

@ -104,8 +104,6 @@ proportion is configurable, like this for a 80/20 proportion:
Now that we are happy with the content of `FooBar.ini`, we can call Now that we are happy with the content of `FooBar.ini`, we can call
the script `add_color_scheme.sh` stored in `data/color_schemes/` as seen the script `add_color_scheme.sh` stored in `data/color_schemes/` as seen
below: below:
`add_color_scheme.sh eet ~/.config/terminology/colorschemes.eet FooBar.ini` `add_color_scheme.sh eet ~/.config/terminology/colorschemes/FooBar.eet FooBar.ini`
Now you should be able to select your color scheme in Terminology! Now you should be able to select your color scheme in Terminology!

View File

@ -6,6 +6,8 @@ COMPRESS=1
EET=$1 EET=$1
shift shift
EET_FILE=$1
shift
INI=$1 INI=$1
shift shift
@ -14,17 +16,18 @@ GET_NAME=$(dirname "$0")/get_name.py
NAME=$($GET_NAME "$INI") NAME=$($GET_NAME "$INI")
# ensure output directory exists
mkdir -p "$(dirname "$EET_FILE")"
# generate desc on a temporary file # generate desc on a temporary file
TMP_DESC=$(mktemp "$NAME-DESC-XXXXXX") TMP_DESC=$(mktemp "$NAME-DESC-XXXXXX")
TMP_EET=$(mktemp "$NAME-EET-XXXXXX")
# trap to avoid creating orphan files # trap to avoid creating orphan files
trap 'rm -f "$TMP_DESC"' INT TERM HUP EXIT trap 'rm -f "$TMP_DESC" "$TMP_EET"' INT TERM HUP EXIT
NAME=$($GET_NAME "$INI") NAME=$($GET_NAME "$INI")
mkdir -p "data/colorschemes"
EET_FILE="data/colorschemes/$NAME.eet"
[ ! -w "$EET_FILE" ] && touch "$EET_FILE" [ ! -w "$EET_FILE" ] && touch "$EET_FILE"
echo "Generating $EET_FILE" echo "Generating $EET_FILE"

View File

@ -1,14 +0,0 @@
#!/bin/bash
set -e
set -u
EET=$1
shift
ADD_COLOR_SCHEME=$(dirname "$0")/add_color_scheme.sh
for INI in "$@"
do
echo "Building $INI"
# use the name, without extension as key in eet
$ADD_COLOR_SCHEME "$EET" "$INI"
done

View File

@ -1,46 +1,52 @@
colorschemes_desc = [ colorschemes = [
'Belafonte Day.ini', 'Belafonte Day',
'Belafonte Night.ini', 'Belafonte Night',
'Black.ini', 'Black',
'Cobalt2.ini', 'Cobalt2',
'Dracula.ini', 'Dracula',
'Fahrenheit.ini', 'Fahrenheit',
'Material.ini', 'Material',
'Mild.ini', 'Mild',
'Mustang.ini', 'Mustang',
'Nord.ini', 'Nord',
'Ocean Dark.ini', 'Ocean Dark',
'One Dark.ini', 'One Dark',
'PaleNight.ini', 'PaleNight',
'PaperColor.ini', 'PaperColor',
'Smyck.ini', 'Smyck',
'Soft Era.ini', 'Soft Era',
'Solarized.ini', 'Solarized',
'Solarized Light.ini', 'Solarized Light',
'Tango Dark.ini', 'Tango Dark',
'Tango Light.ini', 'Tango Light',
'Tomorrow Night Burns.ini', 'Tomorrow Night Burns',
] ]
colorschemes_out = [] add_color_scheme_sh = find_program(
'add_color_scheme.sh',
native: false,
required: true,
dirs: [join_paths(meson.source_root(), 'data', 'colorschemes')])
foreach c : colorschemes_desc cs_builder = [add_color_scheme_sh,
colorschemes_out += c.replace('ini','eet') eet_bin, '@OUTPUT@', '@INPUT@']
endforeach
cs_builder = [join_paths(meson.source_root(),
'data', 'colorschemes', 'builder.sh'),
eet_bin, '@INPUT@']
cs_install_dir = join_paths(get_option('datadir'), cs_install_dir = join_paths(get_option('datadir'),
meson.project_name(), meson.project_name())
'colorschemes')
cs_install_dir = join_paths(
get_option('datadir'),
meson.project_name(),
'colorschemes')
custom_target('colorschemes', foreach c : colorschemes
install:true, custom_target(c,
install_dir: cs_install_dir, install:true,
install_mode: 'rw-r--r--', install_dir: cs_install_dir,
depend_files: ['builder.sh', 'ini2desc.py', 'get_name.py', 'add_color_scheme.sh'], install_mode: 'rw-r--r--',
command: cs_builder, depend_files : ['ini2desc.py', 'get_name.py', 'add_color_scheme.sh'],
input: colorschemes_desc, command: cs_builder,
output: colorschemes_out) input: [c + '.ini'],
output: [c + '.eet'])
endforeach