-
Notifications
You must be signed in to change notification settings - Fork 11
WIP: Add test for building meson project #141
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| from os import environ, path | ||
| from subprocess import call | ||
|
|
||
| prefix = environ.get("MESON_INSTALL_PREFIX", "/usr/local") | ||
| datadir = path.join(prefix, "share") | ||
| destdir = environ.get("DESTDIR", "") | ||
|
|
||
| # Package managers set this so we don't need to run | ||
| if not destdir: | ||
| print("Updating icon cache...") | ||
| call(["gtk-update-icon-cache", "-qtf", path.join(datadir, "icons", "hicolor")]) | ||
|
|
||
| print("Updating desktop database...") | ||
| call(["update-desktop-database", "-q", path.join(datadir, "applications")]) | ||
|
|
||
| print("Compiling GSettings schemas...") | ||
| call(["glib-compile-schemas", path.join(datadir, "glib-2.0", "schemas")]) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| desktop_file = i18n.merge_file( | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need such sophisticated thing, we can just install_data and copy the file to the right directory, handling translations and validations are imho a bit out of scope of such a test case. |
||
| input: 'some.meson.Project.desktop.in', | ||
| output: 'some.meson.Project.desktop', | ||
| type: 'desktop', | ||
| po_dir: '../po', | ||
| install: true, | ||
| install_dir: join_paths(get_option('datadir'), 'applications') | ||
| ) | ||
|
|
||
| desktop_utils = find_program('desktop-file-validate', required: false) | ||
| if desktop_utils.found() | ||
| test('Validate desktop file', desktop_utils, | ||
| args: [desktop_file] | ||
| ) | ||
| endif | ||
|
|
||
| appstream_file = i18n.merge_file( | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly here, do we even need an appdata file? |
||
| input: 'some.meson.Project.appdata.xml.in', | ||
| output: 'some.meson.Project.appdata.xml', | ||
| po_dir: '../po', | ||
| install: true, | ||
| install_dir: join_paths(get_option('datadir'), 'appdata') | ||
| ) | ||
|
|
||
| appstream_util = find_program('appstream-util', required: false) | ||
| if appstream_util.found() | ||
| test('Validate appstream file', appstream_util, | ||
| args: ['validate', appstream_file] | ||
| ) | ||
| endif | ||
|
|
||
| install_data('some.meson.Project.gschema.xml', | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The gschema should definitely be removed |
||
| install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas') | ||
| ) | ||
|
|
||
| compile_schemas = find_program('glib-compile-schemas', required: false) | ||
| if compile_schemas.found() | ||
| test('Validate schema file', compile_schemas, | ||
| args: ['--strict', '--dry-run', meson.current_source_dir()] | ||
| ) | ||
| endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <component type="desktop"> | ||
| <id>some.meson.Project.desktop</id> | ||
| <metadata_license>CC0-1.0</metadata_license> | ||
| <project_license>LicenseRef-proprietary</project_license> | ||
| <description> | ||
| <p>No description</p> | ||
| </description> | ||
| </component> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [Desktop Entry] | ||
| Name=meson | ||
| Exec=meson | ||
| Icon=some.meson.Project | ||
| Terminal=false | ||
| Type=Application | ||
| Categories=GTK; | ||
| StartupNotify=true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <schemalist gettext-domain="meson"> | ||
| <schema id="some.meson.Project" path="/some/meson/Project/"/> | ||
| </schemalist> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| project('meson', | ||
| version: '0.1.0', | ||
| meson_version: '>= 0.50.0', | ||
| default_options: [ 'warning_level=2', | ||
| ], | ||
| ) | ||
|
|
||
| i18n = import('i18n') | ||
|
|
||
|
|
||
|
|
||
| subdir('data') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would avoid using subdirs, just put all the necessary files for the test on the same directory. |
||
| subdir('src') | ||
|
|
||
| meson.add_install_script('build-aux/meson/postinstall.py') | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||
| { | ||||||
| "app-id": "some.meson.Project", | ||||||
| "runtime": "org.gnome.Platform", | ||||||
| "runtime-version": "41", | ||||||
| "sdk": "org.gnome.Sdk", | ||||||
| "command": "meson", | ||||||
| "finish-args": [ | ||||||
| "--share=network", | ||||||
| "--share=ipc", | ||||||
| "--socket=fallback-x11", | ||||||
| "--device=dri", | ||||||
| "--socket=wayland" | ||||||
| ], | ||||||
| "cleanup": [ | ||||||
| "/include", | ||||||
| "/lib/pkgconfig", | ||||||
| "/man", | ||||||
| "/share/doc", | ||||||
| "/share/gtk-doc", | ||||||
| "/share/man", | ||||||
| "/share/pkgconfig", | ||||||
| "*.la", | ||||||
| "*.a" | ||||||
| ], | ||||||
| "modules": [ | ||||||
| { | ||||||
| "name": "meson", | ||||||
| "builddir": true, | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we actually handle the builddir argument in flatpak-vscode it is mostly used by builder to whether build stuff in current directory or do so in the cache directory. |
||||||
| "buildsystem": "meson", | ||||||
| "sources": [ | ||||||
| { | ||||||
| "type": "dir", | ||||||
| "url": "." | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
| ] | ||||||
| } | ||||||
| ] | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| def main(version: str): | ||
| print(f"Hi from a meson project {version}") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) | ||
| moduledir = join_paths(pkgdatadir, 'meson') | ||
|
|
||
| python = import('python') | ||
|
|
||
| conf = configuration_data() | ||
| conf.set('PYTHON', python.find_installation('python3').path()) | ||
| conf.set('VERSION', meson.project_version()) | ||
| conf.set('pkgdatadir', pkgdatadir) | ||
|
|
||
| configure_file( | ||
| input: 'meson.in', | ||
| output: 'meson', | ||
| configuration: conf, | ||
| install: true, | ||
| install_dir: get_option('bindir') | ||
| ) | ||
|
|
||
| meson_sources = [ | ||
| '__init__.py', | ||
| 'main.py', | ||
| ] | ||
|
|
||
| install_data(meson_sources, install_dir: moduledir) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #!@PYTHON@ | ||
|
|
||
|
|
||
| import sys | ||
|
|
||
| pkgdatadir = '@pkgdatadir@' | ||
| version = '@VERSION@' | ||
|
|
||
| sys.path.insert(1, pkgdatadir) | ||
|
|
||
| if __name__ == '__main__': | ||
| from meson import main | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just do the print call here and drop the other file? |
||
| sys.exit(main.main(version)) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the new meson post install, the less files we have for tests the better.