Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(linux): Fix build scripts #9781

Merged
merged 3 commits into from
Oct 18, 2023
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
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
Comment on lines +43 to +52
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an easier solution? I don't think our build.sh system allows to pass the --coverage option to dependencies, or does it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keyman-system-service should be a child build rather than a dependency. A dependency is explicitly something that is required for the project but that you only want to build and use. A child build is a component owned by the parent build.

If a `+` is appended (after the optional shorthand form, but before the
default), then the option will be passed to child scripts. All child scripts
_must_ accept this option, or they will fail. It is acceptable for the child
script to declare the option but ignore it. However, the option will _not_ be
passed to dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's both. You can't run ibus-keyman tests without first building keyman-system-service.

Or do you mean keyman-system-service should be a child of ibus-keyman? But that doesn't make completely sense either because it's not really a component of ibus-keyman.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what you are trying to solve here. It seems like the top-level linux/build.sh is already building all the modules as child builds, and the --coverage option already has + so it should be passed through.

If things are building in the wrong order, you could try putting the keyman-system-service first in linux/build.sh.

}

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