Build system: add single threaded mode

BodgeMaster-unfinished
BodgeMaster 2022-07-06 10:50:55 +02:00
parent 51200e7d75
commit 3f6e74ed4e
3 changed files with 14 additions and 3 deletions

View File

@ -55,8 +55,10 @@ This will download the following dependenceis:
To build the project, just use the `build` alias or invoke the `build.sh` To build the project, just use the `build` alias or invoke the `build.sh`
script from the project's base directory. script from the project's base directory.
`build` and `build.sh` accept the environment variables `CXX` and `CXXFLAGS`. `build` and `build.sh` accept the environment variables `CXX`, `CXXFLAGS`, and `SINGLE`.
`CXXFLAGS` must at least specify the C++ version.
- `CXXFLAGS` must at least specify the C++ version.
- Set `SINGLE` to `yes` to run the build script in single-threaded mode.
To clean out the build or dependency directories, use `clean` and To clean out the build or dependency directories, use `clean` and
`clean_dependencies` or their corresponding scripts respectively. `clean_dependencies` or their corresponding scripts respectively.

View File

@ -15,6 +15,13 @@
# version 3 along with this program. # version 3 along with this program.
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html # If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
if [ "$(tr '[:upper:]' '[:lower:]' <<< $SINGLE)" = "yes" ]; then
echo "Running build script in single-threaded mode."
WAIT_ANYWAY="wait"
else
WAIT_ANYWAY=""
fi
if [ -z "$CXX" ]; then if [ -z "$CXX" ]; then
CXX="c++" CXX="c++"
fi fi
@ -45,6 +52,7 @@ for lib in $(find ./src/lib -name "*.cpp"); do
COMPILE_COMMAND="$CXX_WITH_FLAGS -fPIC -shared -o $(sed -e 's/^.\/src/.\/bin/;s/cpp$/so/' <<< $lib) $lib" COMPILE_COMMAND="$CXX_WITH_FLAGS -fPIC -shared -o $(sed -e 's/^.\/src/.\/bin/;s/cpp$/so/' <<< $lib) $lib"
echo $COMPILE_COMMAND echo $COMPILE_COMMAND
$COMPILE_COMMAND & $COMPILE_COMMAND &
$WAIT_ANYWAY
done done
wait wait
@ -69,6 +77,7 @@ COMPILE_COMMANDS=(
for command in ${!COMPILE_COMMANDS[@]}; do for command in ${!COMPILE_COMMANDS[@]}; do
echo "${COMPILE_COMMANDS[command]}" echo "${COMPILE_COMMANDS[command]}"
${COMPILE_COMMANDS[command]} & ${COMPILE_COMMANDS[command]} &
$WAIT_ANYWAY
done done
wait wait

View File

@ -29,7 +29,7 @@ function run_tests {
function build { function build {
pushd "$PROJECT_BASE_DIR" >/dev/null 2>&1 pushd "$PROJECT_BASE_DIR" >/dev/null 2>&1
CXX="$CXX" CXXFLAGS="$CXXFLAGS" scripts/build.sh SINGLE="$SINGLE" CXX="$CXX" CXXFLAGS="$CXXFLAGS" scripts/build.sh
popd >/dev/null 2>&1 popd >/dev/null 2>&1
} }