Skip to content

Commit

Permalink
Merge pull request #9781 from keymanapp/chore/linux/fixbuild
Browse files Browse the repository at this point in the history
chore(linux): Fix build scripts
  • Loading branch information
ermshiperete authored Oct 18, 2023
2 parents 2e38f35 + 7980266 commit 7b06beb
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 59 deletions.
15 changes: 15 additions & 0 deletions docs/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ The `run-tests` script accepts different arguments which can be seen with

### Code Coverage Report

#### Prerequisites

Code coverage reports require some additional tools: lcov, gcovr,
libdatetime-perl, and coverage.

You can install these with:

```bash
sudo apt update
sudo apt install -y lcov libdatetime-perl gcovr
pip3 install coverage
```

#### Creating and displaying code coverage reports

All three projects (ibus-keyman, keyman-config, and keyman-system-service)
can produce code coverage reports.

Expand Down
47 changes: 16 additions & 31 deletions linux/ibus-keyman/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,46 +49,31 @@ else
MESON_COVERAGE=
fi

if builder_start_action clean; then
rm -rf "$THIS_SCRIPT_PATH/../build/"
builder_finish_action success clean
fi

if builder_start_action configure; then
cd "$THIS_SCRIPT_PATH"
# shellcheck disable=SC2086
meson setup "$MESON_PATH" --werror --buildtype $MESON_TARGET ${MESON_COVERAGE} "${builder_extra_params[@]}"
builder_finish_action success configure
fi

if builder_start_action build; then
cd "$THIS_SCRIPT_PATH/$MESON_PATH"
ninja
builder_finish_action success build
fi
configure_action() {
# shellcheck disable=SC2086,SC2154
meson setup ${MESON_COVERAGE} --werror --buildtype $MESON_TARGET "${builder_extra_params[@]}" "$MESON_PATH"
}

if builder_start_action test; then
cd "$THIS_SCRIPT_PATH/$MESON_PATH"
test_action() {
if builder_has_option --no-integration; then
# shellcheck disable=SC2086,SC2154
meson test --print-errorlogs $builder_verbose setup-src-test keymanutil-tests print-kmpdetails-test print-kmp-test bcp47-util-tests teardown-src-test
else
# shellcheck disable=SC2086
meson test --print-errorlogs $builder_verbose
fi
if builder_has_option --coverage; then
# Note: requires lcov > 1.16 to properly work (see https://github.com/mesonbuild/meson/issues/6747)
ninja coverage-html
fi
builder_finish_action success test
fi
}

if builder_start_action install; then
cd "$THIS_SCRIPT_PATH/$MESON_PATH"
ninja install
builder_finish_action success install
fi
builder_run_action clean rm -rf "$THIS_SCRIPT_PATH/../build/"
builder_run_action configure configure_action

if builder_start_action uninstall; then
cd "$THIS_SCRIPT_PATH/$MESON_PATH"
ninja uninstall
builder_finish_action success uninstall
fi
[ -d "$MESON_PATH" ] && cd "$MESON_PATH"

builder_run_action build ninja
builder_run_action test test_action
builder_run_action install ninja install
builder_run_action uninstall ninja uninstall
68 changes: 40 additions & 28 deletions linux/keyman-system-service/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,39 @@ else
fi
MESON_PATH="build/$(uname -m)/$MESON_TARGET"

clean_action() {
rm -rf "$THIS_SCRIPT_PATH/build/"
}

check_missing_coverage_configuration() {
if builder_has_option --coverage && [ -d "$MESON_PATH" ]; then
# It's possible that we got configured because we're a dependency of ibus-keyman
# in which case the `--coverage` option wasn't passed along.
cd "$MESON_PATH"
if ! ninja -t targets | grep -q coverage-html ; then
cd "$THIS_SCRIPT_PATH"
clean_action
fi
cd "$THIS_SCRIPT_PATH"
fi
}

configure_action() {
# shellcheck disable=SC2086,SC2154
meson setup ${MESON_COVERAGE} --werror --buildtype $MESON_TARGET "${builder_extra_params[@]}" "$MESON_PATH"
}

test_action() {
# shellcheck disable=SC2086,SC2154
meson test --print-errorlogs $builder_verbose
if builder_has_option --coverage; then
# Note: requires lcov > 1.16 to properly work (see https://github.com/mesonbuild/meson/issues/6747)
ninja coverage-html
fi
}

check_missing_coverage_configuration

builder_describe_outputs \
configure "${MESON_PATH}/build.ninja" \
build "${MESON_PATH}/src/keyman-system-service"
Expand All @@ -45,33 +78,12 @@ else
MESON_COVERAGE=
fi

builder_run_action clean rm -rf "$THIS_SCRIPT_PATH/build/"

# shellcheck disable=SC2086
builder_run_action configure meson setup "$MESON_PATH" --werror --buildtype $MESON_TARGET ${MESON_COVERAGE} "${builder_extra_params[@]}"

cd "$MESON_PATH" || true

if builder_start_action build; then
ninja
builder_finish_action success build
fi

if builder_start_action test; then
meson test --print-errorlogs $builder_verbose
if builder_has_option --coverage; then
# Note: requires lcov > 1.16 to properly work (see https://github.com/mesonbuild/meson/issues/6747)
ninja coverage-html
fi
builder_finish_action success test
fi
builder_run_action clean clean_action
builder_run_action configure configure_action

if builder_start_action install; then
ninja install
builder_finish_action success install
fi
[ -d "$MESON_PATH" ] && cd "$MESON_PATH"

if builder_start_action uninstall; then
ninja uninstall
builder_finish_action success uninstall
fi
builder_run_action build ninja
builder_run_action test test_action
builder_run_action install ninja install
builder_run_action uninstall ninja uninstall

0 comments on commit 7b06beb

Please sign in to comment.