Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y clang-tidy cmake ninja-build libsqlite3-dev pkg-config
- name: Generate compile_commands.json
run: |
cmake -S . -B build -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_TESTING=OFF
run: scripts/configure.sh --tests OFF --compile-commands
- name: Run clang-tidy
run: |
find src -type f \( -name '*.cpp' -o -name '*.hpp' \) \
Expand All @@ -119,11 +118,10 @@ jobs:
sudo apt-get install -y cmake ninja-build g++ libsqlite3-dev libgtest-dev
- name: Configure
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DBUILD_TESTING=ON \
-DAPPSTREAM_BUILD_TESTS=ON \
-DENABLE_SANITIZER=${{ matrix.sanitizer }}
scripts/configure.sh \
--build-type ${{ matrix.build-type }} \
--tests ON \
--sanitizer ${{ matrix.sanitizer }}
- name: Build
run: cmake --build build --parallel
- name: Test
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ catalog.db-wal
catalog.db-shm
catalog.db.staging*

# Flutter custom-device staging. Recreated by the device's `install` step
# (see ~/.config/flutter/custom_devices.json), which copies config.toml and
# the engine bundle in and symlinks data/flutter_assets at build/. It is
# generated output, and the engine .so and icudtl.dat alone were 51 MB of
# tracked binaries.
.desktop-homescreen/
.*-homescreen/

# IDE
.idea/
.vscode/
Expand Down
7 changes: 0 additions & 7 deletions example/flathub_catalog/.desktop-homescreen/config.toml

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
8 changes: 7 additions & 1 deletion hook/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ void main(List<String> args) async {
'-B',
buildDir,
'-DCMAKE_BUILD_TYPE=Release',
'-DBUILD_TESTING=OFF',
// APPSTREAM_BUILD_TESTS, not BUILD_TESTING: the latter is not a
// variable this project defines, so CMake ignored it and warned
// "Manually-specified variables were not used by the project" on
// every Flutter build. The canonical flag list lives in
// scripts/configure.sh; this hook cannot call it, because build
// hooks run in a hermetic environment without a shell contract.
'-DAPPSTREAM_BUILD_TESTS=OFF',
'-DAPPSTREAM_HOOK_BUILD=ON',
if (hasNinja) ...['-G', 'Ninja'],
]);
Expand Down
129 changes: 129 additions & 0 deletions scripts/configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2026 Joel Winarske <joel.winarske@gmail.com>
#
# Single source of truth for configuring the CMake build. scripts/test.sh and
# .github/workflows/ci.yml both call this instead of spelling out -D flags.
#
# The flag names are the reason this exists. The test suite gate was renamed
# to APPSTREAM_BUILD_TESTS in 0.2.2, but copies of the old -DBUILD_TESTING
# lived on in the test script and in two CI jobs, where CMake ignored them
# silently ("Manually-specified variables were not used by the project").
# The C++ suite was therefore never configured by scripts/test.sh, and ctest
# ran whatever stale binary was left in the build directory. One definition
# is harder to leave behind than four.
#
# Usage:
# scripts/configure.sh [options]
#
# --build-dir DIR CMake binary directory (default: build)
# --build-type TYPE CMAKE_BUILD_TYPE (default: Release)
# --tests ON|OFF build the C++ test suite (default: OFF)
# --sanitizer NAME none|asan|msan|ubsan (default: none)
# --coverage ON|OFF gcov/lcov instrumentation (default: OFF)
# --benchmarks ON|OFF build benchmark targets (default: OFF)
# --compile-commands emit compile_commands.json (for clang-tidy)
#
# Anything after `--` is passed through to cmake verbatim.

set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")/.."

BUILD_DIR=build
BUILD_TYPE=Release
TESTS=OFF
SANITIZER=none
COVERAGE=OFF
BENCHMARKS=OFF
COMPILE_COMMANDS=OFF
EXTRA=()

while [[ $# -gt 0 ]]; do
case "$1" in
--build-dir)
BUILD_DIR="$2"
shift 2
;;
--build-type)
BUILD_TYPE="$2"
shift 2
;;
--tests)
TESTS="$2"
shift 2
;;
--sanitizer)
SANITIZER="$2"
shift 2
;;
--coverage)
COVERAGE="$2"
shift 2
;;
--benchmarks)
BENCHMARKS="$2"
shift 2
;;
--compile-commands)
COMPILE_COMMANDS=ON
shift
;;
--)
shift
EXTRA=("$@")
break
;;
-h | --help)
echo "usage: scripts/configure.sh [--build-dir DIR] [--build-type TYPE]"
echo " [--tests ON|OFF] [--sanitizer none|asan|msan|ubsan]"
echo " [--coverage ON|OFF] [--benchmarks ON|OFF]"
echo " [--compile-commands] [-- <extra cmake args>]"
exit 0
;;
*)
echo "unknown option: $1" >&2
exit 2
;;
esac
done

# Reject unknown values rather than passing them to CMake, which would take
# an unrecognized sanitizer as a literal and configure a build that silently
# does not do what was asked.
case "$TESTS" in ON | OFF) ;; *)
echo "error: --tests must be ON or OFF, got '$TESTS'" >&2
exit 2
;;
esac
case "$COVERAGE" in ON | OFF) ;; *)
echo "error: --coverage must be ON or OFF, got '$COVERAGE'" >&2
exit 2
;;
esac
case "$BENCHMARKS" in ON | OFF) ;; *)
echo "error: --benchmarks must be ON or OFF, got '$BENCHMARKS'" >&2
exit 2
;;
esac
case "$SANITIZER" in none | asan | msan | ubsan) ;; *)
echo "error: --sanitizer must be none|asan|msan|ubsan, got '$SANITIZER'" >&2
exit 2
;;
esac

GEN_ARGS=()
if command -v ninja >/dev/null 2>&1; then
GEN_ARGS+=(-G Ninja)
fi

set -x
cmake -S . -B "$BUILD_DIR" \
"${GEN_ARGS[@]}" \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DCMAKE_EXPORT_COMPILE_COMMANDS="$COMPILE_COMMANDS" \
-DAPPSTREAM_BUILD_TESTS="$TESTS" \
-DENABLE_SANITIZER="$SANITIZER" \
-DENABLE_COVERAGE="$COVERAGE" \
-DENABLE_BENCHMARKS="$BENCHMARKS" \
${EXTRA+"${EXTRA[@]}"}
19 changes: 8 additions & 11 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ BENCHMARKS="${BENCHMARKS:-OFF}"

if [[ -z "${SKIP_CXX:-}" ]]; then
echo "=== Configuring CMake ($BUILD_TYPE) ==="
GEN_ARGS=()
if command -v ninja >/dev/null 2>&1; then
GEN_ARGS+=(-G Ninja)
fi
cmake -S . -B "$BUILD_DIR" \
"${GEN_ARGS[@]}" \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DAPPSTREAM_BUILD_TESTS=ON \
-DENABLE_SANITIZER="$SANITIZER" \
-DENABLE_COVERAGE="$COVERAGE" \
-DENABLE_BENCHMARKS="$BENCHMARKS"
# Flags live in scripts/configure.sh so this script and CI cannot drift.
./scripts/configure.sh \
--build-dir "$BUILD_DIR" \
--build-type "$BUILD_TYPE" \
--tests ON \
--sanitizer "$SANITIZER" \
--coverage "$COVERAGE" \
--benchmarks "$BENCHMARKS"

echo "=== Building C++ targets ==="
cmake --build "$BUILD_DIR" --parallel
Expand Down
Loading