From 19e15f80635fd7f83d659d73845c7fd9573de41c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 25 Mar 2021 01:16:58 +0200 Subject: [PATCH 41/41] Meson: Generate 'run.sh' to support running from build directory See osdn #41856 Signed-off-by: Marko Lindqvist --- bootstrap/Makefile.am | 1 + bootstrap/generate_meson_run.sh | 22 ++++++++++++++++++++++ doc/INSTALL.meson | 10 ++++++++++ meson.build | 5 +++++ 4 files changed, 38 insertions(+) create mode 100644 bootstrap/generate_meson_run.sh diff --git a/bootstrap/Makefile.am b/bootstrap/Makefile.am index db01dd2b97..da1e43d2b7 100644 --- a/bootstrap/Makefile.am +++ b/bootstrap/Makefile.am @@ -13,6 +13,7 @@ EXTRA_DIST = freeciv.project \ fc_gitrev_gen.h.tmpl \ generate_gitrev.sh \ generate_langstat.sh \ + generate_meson_run.sh \ langstat_core.txt \ langstat_nations.txt \ langstat_ruledit.txt \ diff --git a/bootstrap/generate_meson_run.sh b/bootstrap/generate_meson_run.sh new file mode 100644 index 0000000000..f0774d17f8 --- /dev/null +++ b/bootstrap/generate_meson_run.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +DATADIR="$(cd $(dirname $0)/../data ; pwd)" + +echo "#!/bin/bash" > $1 +echo "# Generated by $(basename $0)" >> $1 +echo >> $1 +echo "if test \"\$1\" = \"--help\" || test \"\$1\" = \"-h\" ||" >> $1 +echo " test \"\$1\" = \"\" ; then" >> $1 +echo " echo \"Usage: ./run.sh [parameters] ...\"" >> $1 +echo " exit" >> $1 +echo "fi" >> $1 +echo >> $1 +echo "if test \"\$FREECIV_DATA_PATH\" = \"\" ; then" >> $1 +echo " export FREECIV_DATA_PATH=\"$DATADIR\"" >> $1 +echo "else" >> $1 +echo " export FREECIV_DATA_PATH=\"\$FREECIV_DATA_PATH:$DATADIR\"" >> $1 +echo "fi" >> $1 +echo >> $1 +echo "./\$@" >> $1 + +chmod +x $1 diff --git a/doc/INSTALL.meson b/doc/INSTALL.meson index a3b063f35c..04b54a3366 100644 --- a/doc/INSTALL.meson +++ b/doc/INSTALL.meson @@ -128,3 +128,13 @@ ruledit (boolean): nls (boolean): Build in Native Language Support. Defaults to true. + + +run.sh +------ + +One of the build results is script named 'run.sh' in the build directory - +it does not get installed to the installation directory. This script can +be used to run freeciv executables from the build directory. +Give the executable name and parameters as parameters to ./run.sh, e.g., +./run.sh freeciv-server --help diff --git a/meson.build b/meson.build index 6e9aa1241c..0da4c6f8d4 100644 --- a/meson.build +++ b/meson.build @@ -307,6 +307,11 @@ client_inc = [common_inc, include_directories('client', 'client/include', tool_inc = [server_inc, include_directories('tools/ruleutil', 'tools/shared')] +runwrap = custom_target('runwrap', output: 'run.sh', + command: ['sh', files('bootstrap/generate_meson_run.sh'), '@OUTPUT@'], + depend_files: files('bootstrap/generate_meson_run.sh'), + build_by_default: true) + verhdr = custom_target('verhdr', output: 'version_gen.h', command: ['sh', files('gen_headers/generate_version_header.sh'), '@OUTPUT@'], depend_files: files('fc_version')) -- 2.30.2