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

Dont hardcode path to config.h #465

Merged
merged 3 commits into from
Feb 11, 2025
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
7 changes: 6 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ jobs:
sudo apt update
sudo apt build-dep -y policykit-1
# polkit in Ubuntu Jammy (ATTOW) doesn't have the latest build dependencies yet
sudo apt install -y duktape-dev meson
sudo apt install -y duktape-dev python3-pip

# Ubuntu 22.04 ships only meson 1.3.4 (ATTOW), so install a newer one via pip
dpkg-query -W meson && sudo apt remove -y meson
sudo pip3 install 'meson>=1.4.0'
sudo meson --version

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
6 changes: 3 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(
'c_std=c99',
'cpp_std=c++17',
],
meson_version: '>= 0.63.0',
meson_version: '>= 1.4.0',
)

pk_version = meson.project_version()
Expand Down Expand Up @@ -375,12 +375,12 @@ if gettext
config_data.set('ENABLE_GETTEXT', 1)
endif

configure_file(
config_h = configure_file(
output: 'config.h',
configuration: config_data,
)

compiler_common_flags += ['-include', 'config.h']
compiler_common_flags += ['-include', config_h.full_path()]
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to bump the minimum required version. You do "need" the full path if polkit can ever be built as a subproject -- the compiler is always run from the global_build_root(), that is, the same directory as the build.ninja file, and config.h is generated where current_build_dir() == project_build_root(), which is the same directory as build.ninja except in a subproject.

But regardless, the string config_h.full_path() is provided for API equivalence with other objects. You could have always reliably guaranteed the location quite simply:

config_h_full_path = meson.current_build_dir() / 'config.h'

No version bump needed.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that's actually pretty neat, thanks a lot for the explanation!


add_project_arguments(compiler_common_flags + compiler_c_flags, language: 'c')
add_project_arguments(compiler_common_flags + compiler_cpp_flags, language: 'cpp')
Expand Down