File indexing completed on 2024-05-12 04:44:28

0001 #!/bin/bash
0002 
0003 # SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
0004 # SPDX-License-Identifier: BSD-2-Clause OR MIT
0005 
0006 
0007 
0008 
0009 
0010 # -e exits on error,
0011 # -u errors on undefined variables,
0012 # and -o (for option) pipefail exits on command pipe failures
0013 set -euo pipefail
0014 
0015 
0016 
0017 
0018 
0019 ################# Configure #################
0020 # The “.” command will execute the given script within the context of
0021 # the current script, which is necessary in order to preserve the
0022 # environment variables that are set by the given script.
0023 . scripts/export-environment.sh
0024 
0025 
0026 
0027 
0028 
0029 ################# Add missing BOM #################
0030 # Add a byte-order-mark (\xef\xbb\xbf) to files that do not have one
0031 # but should have it. This is important for the Microsoft compiler,
0032 # because this compiler assumes a legacy one-byte Windows codepage
0033 # whenever no BOM is present. Using a BOM makes it working out-of-the-box
0034 # without relying on Microsoft-only compiler options like “/utf-8”. Details:
0035 # https://devblogs.microsoft.com/cppblog/new-options-for-managing-character-sets-in-the-microsoft-cc-compiler/#dos-donts-and-the-future
0036 for file in src/*.h src/*.cpp src/*.hpp autotests/*.cpp tests/* utils/* examples/example.cpp; do
0037     if ! grep -q $'\xef\xbb\xbf' "$file"; then
0038         sed -i '1s/^\(\xef\xbb\xbf\)\?/\xef\xbb\xbf/' "$file"
0039     fi
0040 done
0041 
0042 
0043 
0044 
0045 
0046 ################# Clang format #################
0047 # Run within a sub-shell (therefore the parenthesis),
0048 # so that after this we go back to the original working directory.
0049 mkdir --parents buildclangformat
0050 cd buildclangformat
0051 cmake -DBUILD_WITH_QT6=ON ..
0052 cmake --build . --parallel $PARALLEL_PROCESSES --target clang-format
0053 cd ..