Skip to content

Commit

Permalink
[WIP] Meson build system
Browse files Browse the repository at this point in the history
  • Loading branch information
amezin committed Dec 31, 2023
1 parent be899b7 commit e31e695
Show file tree
Hide file tree
Showing 56 changed files with 834 additions and 75 deletions.
4 changes: 2 additions & 2 deletions .github/problem-matchers/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"owner": "generic",
"pattern": [
{
"regexp": "^([^\\s:]+):(\\d+)(?::(\\d+))?:?\\s+(?:((?i)warning|error):?)?\\s*(.+)$",
"regexp": "^(?:\\.\\./)?([^\\s:]+):(\\d+)(?::(\\d+))?:?\\s+(?:((?i)warning|error):?)?\\s*(.+)$",
"file": 1,
"line": 2,
"column": 3,
Expand All @@ -17,7 +17,7 @@
"owner": "generic-nolocation",
"pattern": [
{
"regexp": "^(?:([^\\s:]+):?\\s+)?((?i)warning|error):?\\s*(.+)$",
"regexp": "^(?:\\.\\./)?(?:([^\\s:]+):?\\s+)?((?i)warning|error):?\\s*(.+)$",
"file": 1,
"severity": 2,
"message": 3
Expand Down
2 changes: 1 addition & 1 deletion .github/problem-matchers/gettext-stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"severity": "warning",
"pattern": [
{
"regexp": "msgfmt .* --statistics .* (po/.*\\.po)",
"regexp": "(?:^|\\s)(?:\\.\\./)?(locale/.*\\.po)$",
"file": 1
},
{
Expand Down
35 changes: 26 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ jobs:

- name: Install JS dependencies
id: npm
run: npm ci
run: npm install
if: ${{ always() && steps.checkout.conclusion == 'success' }}

- name: Lint JS code
run: make "ESLINT_OPTS=--format .github/eslint-formatter.js" lint
run: npm run-script lint -- --format .github/eslint-formatter.js
if: ${{ always() && steps.npm.conclusion == 'success' }}

- name: Pre-create pip cache directory
Expand All @@ -75,15 +75,28 @@ jobs:
run: echo "::add-matcher::.github/problem-matchers/generic.json"
if: ${{ always() && steps.checkout.conclusion == 'success' }}

- id: meson-setup
name: Prepare build directory
run: meson setup build
if: ${{ always() && steps.checkout.conclusion == 'success' }}

- name: Compile GSettings schemas
run: make schemas 2>&1 | tee schemas.log
run: ninja -j1 schemas 2>&1 | tee schemas.log
working-directory: build
shell: bash
if: ${{ always() && steps.checkout.conclusion == 'success' }}
if: ${{ always() && steps.meson-setup.conclusion == 'success' }}

- name: Validate Gtk .ui files
run: xvfb-run make gtk-builder-validate 2>&1 | tee gtk-builder.log
run: xvfb-run ninja -j1 validate-ui 2>&1 | tee gtk-builder.log
working-directory: build
shell: bash
if: ${{ always() && steps.checkout.conclusion == 'success' }}
if: ${{ always() && steps.meson-setup.conclusion == 'success' }}

- name: Validate .desktop file
run: ninja -j1 desktop-file-validate 2>&1 | tee desktop-file-validate.log
working-directory: build
shell: bash
if: ${{ always() && steps.meson-setup.conclusion == 'success' }}

- name: Ensure Python requirements .txt files are in sync with .in files
run: |
Expand All @@ -102,7 +115,7 @@ jobs:
if: ${{ always() && steps.checkout.conclusion == 'success' }}

- name: Upload reports to Testspace
run: testspace --verbose eslint.xml "*.log{lint}"
run: testspace --verbose eslint.xml "build/*.log{lint}"
if: ${{ always() && steps.setup_testspace.outcome == 'success' }}

pack:
Expand All @@ -119,13 +132,17 @@ jobs:
- name: Enable generic error matcher
run: echo "::add-matcher::.github/problem-matchers/generic.json"

- name: Prepare build directory
run: meson setup build

- name: Build extension package
run: xvfb-run make ONLY_RELEASE_LOCALES=true pack
run: xvfb-run ninja -j1 pack
working-directory: build

- name: Upload extension package as artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: pack
path: "*.shell-extension.zip"
path: "build/*.shell-extension.zip"
if-no-files-found: error
22 changes: 12 additions & 10 deletions .github/workflows/check-po.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:

env:
FORCE_COLOR: 1
PIP_DISABLE_PIP_VERSION_CHECK: 1

jobs:
configure:
Expand All @@ -23,7 +22,7 @@ jobs:
echo -n linguas= >>$GITHUB_OUTPUT
grep -Ev '^\s*#.*' LINGUAS | jq -Rcn '[inputs | scan("\\S+")]' >>$GITHUB_OUTPUT
shell: bash
working-directory: po
working-directory: locale

check:
needs: configure
Expand All @@ -39,27 +38,30 @@ jobs:

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- run: git config --global --replace-all safe.directory "$GITHUB_WORKSPACE"

- name: Enable generic problem matcher
run: echo "::add-matcher::.github/problem-matchers/generic.json"

- name: Enable gettext stats problem matcher
run: echo "::add-matcher::.github/problem-matchers/gettext-stats.json"

- name: Enable generic problem matcher
run: echo "::add-matcher::.github/problem-matchers/generic.json"
- id: meson-setup
name: Prepare build directory
run: meson setup build

- name: Compile translation
run: make msgfmt/${{ matrix.lang }} 2>&1 | tee $GITHUB_STEP_SUMMARY
run: ninja -j1 -v msgfmt-${{ matrix.lang }} 2>&1 | tee $GITHUB_STEP_SUMMARY
shell: bash
working-directory: build

- name: Disable gettext stats problem matcher
run: echo "::remove-matcher owner=gettext-stats::"

- name: Ensure .po file is in sync with .pot
run: |
touch po/*.pot # Make sure .pot won't be re-generated
make msgcmp/${{ matrix.lang }} 2>&1
run: ninja -j1 msgcmp-${{ matrix.lang }}
shell: bash
if: ${{ always() && steps.checkout.conclusion == 'success' }}
working-directory: build
if: ${{ always() && steps.meson-setup.conclusion == 'success' }}
17 changes: 13 additions & 4 deletions .github/workflows/pot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- master
paths-ignore:
- docs/**
- po/*.po
- locale/*.po
- README.md
- Vagrantfile
- vagrant-provision/**
Expand Down Expand Up @@ -40,11 +40,20 @@ jobs:
- name: Enable generic error matcher
run: echo "::add-matcher::.github/problem-matchers/generic.json"

- name: Update .pot files
run: po/update-pot.sh
- name: Prepare build directory
run: meson setup build
if: ${{ always() && steps.checkout.conclusion == 'success' }}

- name: Update .pot file
run: ninja -j1 pot
working-directory: build

- name: Merge changes into .po files
run: ninja -j1 msgmerge
working-directory: build

- name: Stage changes
run: git add po/*.po po/*.pot
run: git add locale/*.po locale/*.pot

- name: Check if there are any changes
id: diff
Expand Down
13 changes: 1 addition & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
*~
/node_modules/

# Makefile output
/*.shell-extension.zip
/ddterm/pref/ui/
/ddterm/com.github.amezin.ddterm.desktop
/ddterm/com.github.amezin.ddterm.desktop.in
/ddterm/com.github.amezin.ddterm.service
/metadata.json
/schemas/gschemas.compiled
/locale/
/tmp/
/revision.txt
/node_modules/

# do-in-docker.sh/do-in-podman.sh
/.container-home/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ then
PATH="$bindir${PATH:+:${PATH}}"
fi

exec gjs -m "${bindir%/*}/ddterm/app/main.js" "$@"
exec "@GJS@" -m "${bindir%/*}/ddterm/app/main.js" "$@"
16 changes: 16 additions & 0 deletions bin/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pack += configure_file(
input: 'com.github.amezin.ddterm.in',
output: '@BASENAME@',
configuration: gjs_config,
install: true,
install_dir: extension_dir / 'bin',
install_mode: 'rwxr-xr-x'
)

launcher_installed = extension_dir / 'bin' / 'com.github.amezin.ddterm'

install_symlink(
'com.github.amezin.ddterm',
pointing_to: launcher_installed,
install_dir: bindir,
)
9 changes: 3 additions & 6 deletions bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ set -ex

command -V jq

CURRENT_VERSION=$(jq .version metadata.json.in)
CURRENT_VERSION=$(meson rewrite kwargs info project / 2>&1 | jq -r '.kwargs."project#/".version')
NEXT_VERSION=$(( ${CURRENT_VERSION} + 1 ))

git tag v${CURRENT_VERSION}

jq ".version=${NEXT_VERSION}" metadata.json.in > metadata.json.next
mv -f metadata.json.next metadata.json.in

meson rewrite kwargs set project / version "${NEXT_VERSION}"
sed -i "/^pkgver=/c\pkgver=${NEXT_VERSION}" PKGBUILD

git tag "v${CURRENT_VERSION}"
git commit -m "[ci skip] Post-release version bump" metadata.json.in PKGBUILD
13 changes: 13 additions & 0 deletions ddterm/app/icons/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
icon_files = files(
'quotation-symbolic.svg',
'regex-symbolic.svg',
'uppercase-symbolic.svg',
)

foreach icon_file : icon_files
pack += fs.copyfile(
icon_file,
install: true,
install_dir: extension_dir / 'ddterm' / 'app' / 'icons',
)
endforeach
43 changes: 43 additions & 0 deletions ddterm/app/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
app_js_files = files(

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / build / pack

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / build / lint

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (cs)

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (de)

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (el)

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (es)

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (fr)

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (id)

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (it)

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (nb_NO)

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (pl)

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (pt)

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (ru)

File dependencies-notification.js does not exist.

Check failure on line 1 in ddterm/app/meson.build

View workflow job for this annotation

GitHub Actions / po / check (zh_CN)

File dependencies-notification.js does not exist.
'accellabel.js',
'application.js',
'appwindow.js',
'dependencies-notification.js',
'dependencies.js',
'gtktheme.js',
'heapdump.js',
'init.js',
'main.js',
'meta.js',
'notebook.js',
'pcre2.js',
'prefsdialog.js',
'search.js',
'settings.js',
'tablabel.js',
'tcgetpgrp.js',
'terminal.js',
'terminalpage.js',
'terminalsettings.js',
'urldetect.js',
'urldetect_patterns.js',
'waitstatus.js'
)

potfiles += app_js_files
potfiles += files('menus.ui')

foreach app_file : app_js_files + files('dependencies.json', 'menus.ui', 'style.css')
pack += fs.copyfile(
app_file,
install: true,
install_dir: extension_dir / 'ddterm' / 'app',
)
endforeach

subdir('icons')

ui_validate_targets += run_target(
'validate-app-ui',
command: [gtk3_builder_tool, 'validate', files('menus.ui')],
)
59 changes: 59 additions & 0 deletions ddterm/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
ddterm_files = files(
'com.github.amezin.ddterm.Extension.xml',
'com.github.amezin.ddterm.HeapDump.xml',
'com.github.amezin.ddterm.service.in',
)

foreach ddterm_file : ddterm_files
pack += fs.copyfile(
ddterm_file,
install: true,
install_dir: extension_dir / 'ddterm',
)
endforeach

desktop_entry_untranslated = files('com.github.amezin.ddterm.desktop.in.in')
potfiles += desktop_entry_untranslated

pack += i18n.merge_file(
input: desktop_entry_untranslated,
output: '@BASENAME@',
po_dir: '../locale',
type: 'desktop',
)

launcher_config = configuration_data()
launcher_config.set('LAUNCHER', launcher_installed)

desktop_entry_final = i18n.merge_file(
input: configure_file(
input: desktop_entry_untranslated,
output: '@BASENAME@_configured',
configuration: launcher_config,
),
output: '@BASENAME@',
po_dir: '../locale',
type: 'desktop',
install: true,
install_dir: applications_dir,
)

configure_file(
input: 'com.github.amezin.ddterm.service.in',
output: '@BASENAME@',
configuration: launcher_config,
install: true,
install_dir: dbus_service_dir,
)

subdir('app')
subdir('pref')
subdir('shell')
subdir('util')

desktop_file_validate_tool = find_program('desktop-file-validate', native: true)

check_targets += run_target(
'desktop-file-validate',
command: [desktop_file_validate_tool, desktop_entry_final],
)
Loading

0 comments on commit e31e695

Please sign in to comment.