-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
193 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Check meson.build Format | ||
|
||
on: [push, pull_request] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
format-meson: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Meson | ||
run: pip install git+https://github.com/mesonbuild/meson | ||
|
||
- name: Format Checks | ||
run: python ./tools/run_meson_fmt.py --check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
option( | ||
'strict', | ||
description: 'Enable extra checks', | ||
type: 'boolean', | ||
value: true | ||
) | ||
|
||
# extensions | ||
option( | ||
'all-extensions', | ||
description: 'Enable or disable all known extensions by default', | ||
type: 'feature', | ||
value: 'auto' | ||
) | ||
option( | ||
'fts34', | ||
description: 'Enable FTS3 and FTS4', | ||
type: 'feature', | ||
value: 'auto' | ||
) | ||
option( | ||
'fts5', | ||
description: 'Enable FTS5', | ||
type: 'feature', | ||
value: 'auto' | ||
) | ||
option( | ||
'geopoly', | ||
description: 'Enable Geopoly extension', | ||
type: 'feature', | ||
value: 'auto' | ||
) | ||
option( | ||
'rbu', | ||
description: 'Enable Resumable Bulk Update extension', | ||
type: 'feature', | ||
value: 'auto' | ||
) | ||
option( | ||
'rtree', | ||
description: 'Enable R*Tree index extension', | ||
type: 'feature', | ||
value: 'auto' | ||
) | ||
option( | ||
'session', | ||
description: 'Enable session extension', | ||
type: 'feature', | ||
value: 'auto' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
""" | ||
format or check all meson.build file in projects | ||
arguments: | ||
--check: do check without formatting | ||
--dirty: do not format/check all files, only process files changed (only valid in git repo) | ||
""" | ||
|
||
import sys | ||
import shlex | ||
import pathlib | ||
import subprocess | ||
from shutil import which | ||
from itertools import chain | ||
|
||
is_check = "--check" in sys.argv | ||
only_dirty = "--dirty" in sys.argv | ||
|
||
meson = which("meson") | ||
if not meson: | ||
print("failed to find meson") | ||
sys.exit(1) | ||
|
||
base_command = [meson, "fmt", "--editor-config"] | ||
if is_check: | ||
base_command.append("--check-only") | ||
else: | ||
base_command.append("--inplace") | ||
|
||
project_root = pathlib.Path(__file__).parent.parent | ||
|
||
|
||
def get_file_list_from_git(cmd): | ||
out = subprocess.check_output( | ||
cmd, | ||
cwd=str(project_root), | ||
) | ||
return [ | ||
project_root.joinpath(file) | ||
for file in out.decode().splitlines() | ||
if file.endswith("meson.build") | ||
] | ||
|
||
|
||
if only_dirty: | ||
all_meson_files = get_file_list_from_git(shlex.split("git diff --name-only HEAD")) | ||
else: | ||
all_meson_files = sorted( | ||
chain( | ||
[project_root.joinpath("meson.build")], | ||
project_root.glob("subprojects/packagefiles/**/meson.build"), | ||
) | ||
) | ||
|
||
for i, meson_file in enumerate(all_meson_files): | ||
readable_filename = meson_file.relative_to(project_root).as_posix() | ||
print("processing {}/{}: {}".format(i + 1, len(all_meson_files), readable_filename)) | ||
try: | ||
subprocess.check_call(base_command + [str(meson_file)], cwd=str(project_root)) | ||
except subprocess.CalledProcessError as e: | ||
if is_check: | ||
print("{} is not formatted".format(readable_filename)) | ||
sys.exit(e.returncode) | ||
else: | ||
print("failed to format {}".format(readable_filename)) |