don't use stupid variables and sed jank

This commit is contained in:
speedie 2023-05-09 12:03:53 +02:00
parent a87a360063
commit d19a9104bf
4 changed files with 38 additions and 70 deletions

View file

@ -4,6 +4,7 @@ opt="${opt:-${OPT:--O2}}"
warn="${warn:-true}" warn="${warn:-true}"
reconfigure="${reconfigure:-true}" reconfigure="${reconfigure:-true}"
version="${version:-1.1}" version="${version:-1.1}"
xresources="${xresources:-true}"
check_dist() { check_dist() {
[ -f "/etc/pacman.conf" ] && [ "$warn" != "false" ] && printf "hint: detected Pacman. if you want you can run 'makepkg' with proper arguments to install it using pacman.\n" && pacman=true [ -f "/etc/pacman.conf" ] && [ "$warn" != "false" ] && printf "hint: detected Pacman. if you want you can run 'makepkg' with proper arguments to install it using pacman.\n" && pacman=true
@ -52,62 +53,30 @@ build() {
[ "$reconfigure" != "false" ] && rm -rf build/ [ "$reconfigure" != "false" ] && rm -rf build/
if [ "$libconfig" != "true" ]; then
libconfig_text="libconfig = false"
else
libconfig_text="libconfig = true"
fi
if [ "$pango" != "true" ] || [ "$pangoxft" != "true" ]; then
pango_text="pango = false"
pangoxft_text="pangoxft = false"
else
pango_text="pango = true"
pangoxft_text="pangoxft = true"
fi
if [ "$openssl" != "true" ] || [ "$imlib2" != "true" ]; then
imlib2_text="imlib2 = false"
openssl_text="openssl = false"
else
imlib2_text="imlib2 = true"
openssl_text="openssl = true"
fi
if [ "$xinerama" != "true" ]; then
xinerama_text="xinerama = false"
else
xinerama_text="xinerama = true"
fi
if [ "$fribidi" != "true" ]; then
fribidi_text="fribidi = false"
else
fribidi_text="fribidi = true"
fi
if [ "$xresources" != "true" ]; then
xresources_text="xresources = false"
else
xresources_text="xresources = true"
fi
sed -i "s/libconfig = true/$libconfig_text/" meson.build
sed -i "s/pango = true/$pango_text/" meson.build
sed -i "s/pangoxft = true/$pangoxft_text/" meson.build
sed -i "s/imlib2 = true/$imlib2_text/" meson.build
sed -i "s/openssl = true/$openssl_text/" meson.build
sed -i "s/xinerama = true/$xinerama_text/" meson.build
sed -i "s/fribidi = true/$fribidi_text/" meson.build
sed -i "s/xresources = true/$xresources_text/" meson.build
sed -i "s/opt = '-O2'/opt = '$opt'/g" meson.build
mkdir -p build/ mkdir -p build/
if [ "$reconfigure" = "true" ]; then if [ "$reconfigure" = "true" ]; then
meson setup --reconfigure build meson setup --reconfigure \
-Dxresources="$xresources" \
-Dfribidi="$fribidi" \
-Dxinerama="$xinerama" \
-Dimlib2="$imlib2" \
-Dopenssl="$openssl" \
-Dpango="$pango" \
-Dpangoxft="$pangoxft" \
-Dlibconfig="$libconfig" \
build
else else
meson setup build meson setup \
-Dxresources="$xresources" \
-Dfribidi="$fribidi" \
-Dxinerama="$xinerama" \
-Dimlib2="$imlib2" \
-Dopenssl="$openssl" \
-Dpango="$pango" \
-Dpangoxft="$pangoxft" \
-Dlibconfig="$libconfig" \
build
fi fi
ninja -C build ninja -C build

View file

@ -5,16 +5,6 @@ project(
default_options : ['warning_level=3'] default_options : ['warning_level=3']
) )
imlib2 = true
openssl = true
xresources = true
fribidi = true
libconfig = true
pango = true
pangoxft = true
xinerama = true
opt = '-O2'
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
project_source_files = [ project_source_files = [
@ -45,26 +35,26 @@ build_args = [
'-Wno-deprecated-declarations', '-Wno-deprecated-declarations',
'-Wno-unused-parameter', '-Wno-unused-parameter',
'-Wno-sign-compare', '-Wno-sign-compare',
opt, get_option('opt'),
] ]
if imlib2 and openssl if get_option('imlib2') and get_option('openssl')
project_dependencies += [ dependency('imlib2') ] project_dependencies += [ dependency('imlib2') ]
project_dependencies += [ dependency('openssl') ] project_dependencies += [ dependency('openssl') ]
build_args += [ '-DIMAGE' ] build_args += [ '-DIMAGE' ]
endif endif
if fribidi if get_option('fribidi')
project_dependencies += [ dependency('fribidi') ] project_dependencies += [ dependency('fribidi') ]
build_args += [ '-DRTL' ] build_args += [ '-DRTL' ]
endif endif
if xinerama if get_option('xinerama')
project_dependencies += [ dependency('xinerama') ] project_dependencies += [ dependency('xinerama') ]
build_args += [ '-DXINERAMA' ] build_args += [ '-DXINERAMA' ]
endif endif
if pango and pangoxft if get_option('pango') and get_option('pangoxft')
project_dependencies += [ dependency('pango') ] project_dependencies += [ dependency('pango') ]
project_dependencies += [ dependency('pangoxft') ] project_dependencies += [ dependency('pangoxft') ]
build_args += [ '-DPANGO' ] build_args += [ '-DPANGO' ]
@ -72,12 +62,12 @@ else
project_dependencies += [ dependency('fontconfig') ] project_dependencies += [ dependency('fontconfig') ]
endif endif
if libconfig if get_option('libconfig')
project_dependencies += [ dependency('libconfig') ] project_dependencies += [ dependency('libconfig') ]
build_args += [ '-DCONFIG' ] build_args += [ '-DCONFIG' ]
endif endif
if xresources if get_option('xresources')
build_args += [ '-DXRESOURCES' ] build_args += [ '-DXRESOURCES' ]
endif endif

9
meson.options Normal file
View file

@ -0,0 +1,9 @@
option('imlib2', type : 'boolean', value : true, description : 'Enable image support')
option('openssl', type : 'boolean', value : true, description : 'Enable OpenSSL, used for image support')
option('xresources', type : 'boolean', value : true, description : 'Enable .Xresources/xrdb support')
option('fribidi', type : 'boolean', value : true, description : 'Enable Right-to-left language support')
option('libconfig', type : 'boolean', value : true, description : 'Enable configuration file support')
option('pango', type : 'boolean', value : true, description : 'Enable Pango markup support')
option('pangoxft', type : 'boolean', value : true, description : 'Enable Pango for libXft')
option('xinerama', type : 'boolean', value : true, description : 'Enable multi-monitor support using libXinerama')
option('opt', type : 'string', value : '-O2', description : 'Optimization level')

View file

@ -3,7 +3,7 @@ version="$(grep "version : '" meson.build | awk '{ print $3 }' | sed "s/'\"//g;
rm -f spmenu spmenu-${version}.tar.gz spmenu-${version}.PKGBUILD *.o *zst* rm -f spmenu spmenu-${version}.tar.gz spmenu-${version}.PKGBUILD *.o *zst*
mkdir -p spmenu-${version} mkdir -p spmenu-${version}
cp -rf LICENSE meson.build *.h *.c scripts/ docs/ libs/ PKGBUILD build.sh spmenu-${version} cp -rf LICENSE meson.build meson.options *.h *.c scripts/ docs/ libs/ themes/ PKGBUILD build.sh spmenu-${version}
[ -f buildconf ] && cp buildconf spmenu-${version} || : [ -f buildconf ] && cp buildconf spmenu-${version} || :
[ -f Makefile ] && cp Makefile spmenu-${version} || : [ -f Makefile ] && cp Makefile spmenu-${version} || :
[ -f host.mk ] && cp host.mk spmenu-${version} || : [ -f host.mk ] && cp host.mk spmenu-${version} || :