chore: use meson #79

Merged
kiyui merged 6 commits from dafne/meson into main 1 year ago
  1. 5
      .gitignore
  2. 14
      CONTRIBUTING.md
  3. 15
      build-aux/postinstall.py
  4. 11
      data/meson.build
  5. 0
      data/org.gnome.shell.extensions.nightlightslider.gschema.xml
  6. 30
      meson.build
  7. 10
      night-light-slider.timur@linux.com/metadata.json
  8. 42
      package.json
  9. 0
      src/convenience.js
  10. 0
      src/extension.js
  11. 32
      src/meson.build
  12. 10
      src/metadata.json.in
  13. 2
      src/org.gnome.shell.extensions.nightlightslider.data.gresource.xml
  14. 4
      src/prefs.js
  15. 0
      src/prefs.ui
  16. 1246
      yarn.lock

5
.gitignore

@ -1,4 +1 @@
node_modules/
night-light-slider.timur@linux.com.zip
*.compiled
*.gresource
builddir/

14
CONTRIBUTING.md

@ -9,14 +9,14 @@
## Code
- Run `yarn install` to set up the Git hooks to perform automated linting
- Otherwise, lint your code manually with [eslint](https://eslint.org/)
- Lint your code with [eslint](https://eslint.org/)
- You agree that your code will be distributed under the [GPL-2.0-or-later](LICENSE)
## Building
- If you do not already have the extension installed locally, you can symlink it with `yarn build:link`
- Run `yarn build:resources` to compile the resources
- Run `yarn build:schema` to compile the resources
- Run `yarn build` to produce a distribution archive
- View the script in `package.json` for building without `yarn`
The extension uses the [meson](https://mesonbuild.com/) build system.
- You can set up a development environment by running `meson setup --prefix=$HOME/.local builddir`
- You can compile and install a build by running `meson install -C builddir`
- Changes to the `meson.build` will require reconfiguring it with `meson --reconfigure builddir`
- You can create a packed extension by running `meson compile extension.zip -C builddir`

15
build-aux/postinstall.py

@ -0,0 +1,15 @@
#!/usr/bin/env python3
import os
import subprocess
prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
datadir = os.path.join(prefix, 'share')
# Packaging tools define DESTDIR and this isn't needed for them
if 'DESTDIR' not in os.environ:
print('Compiling GSettings schemas...')
schemas_dir = os.path.join(datadir, 'glib-2.0', 'schemas')
if not os.path.exists(schemas_dir):
os.makedirs(schemas_dir)
subprocess.call(['glib-compile-schemas', schemas_dir])

11
data/meson.build

@ -0,0 +1,11 @@
gse_schema = files([
gse_prefix + '.gschema.xml',
])
install_data(gse_schema, install_dir: schemadir)
# Test if schema compiles
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

0
night-light-slider.timur@linux.com/schemas/org.gnome.shell.extensions.nightlightslider.gschema.xml → data/org.gnome.shell.extensions.nightlightslider.gschema.xml

30
meson.build

@ -0,0 +1,30 @@
project('night-light-slider.timur@linux.com',
version: '17',
license: 'GPL2+',
meson_version: '>= 0.50.0')
# Extension information
gse_uuid = meson.project_name()
gse_prefix = 'org.gnome.shell.extensions.nightlightslider'
# Installation directories
prefixdir = get_option('prefix')
datadir = get_option('datadir')
schemadir = datadir/'glib-2.0'/'schemas'
extensiondir = datadir/'gnome-shell'/'extensions'/gse_uuid
subdir('src')
subdir('data')
# Create release zip for distribution
custom_target('extension.zip',
command: [
'gnome-extensions', 'pack', prefixdir/extensiondir,
'--extra-source', 'convenience.js',
'--extra-source', gse_prefix + 'data.gresource',
'--schema', prefixdir/schemadir/gse_prefix + '.gschema.xml',
],
output: gse_uuid + '.shell-extension.zip')
# Post-install scripts
meson.add_install_script('build-aux'/'postinstall.py')

10
night-light-slider.timur@linux.com/metadata.json

@ -1,10 +0,0 @@
{
"name": "Night Light Slider",
"description": "Change night light temperature",
"settings-schema": "org.gnome.shell.extensions.nightlightslider",
"data-gresource": "org.gnome.shell.extensions.nightlightslider.data.gresource",
"uuid": "night-light-slider.timur@linux.com",
"version": 17,
"url": "https://codeberg.org/kiyui/gnome-shell-night-light-slider-extension",
"shell-version": ["3.36", "3.38"]
}

42
package.json

@ -1,42 +0,0 @@
{
"name": "gnome-shell-night-light-slider-extension",
"description": "Change night light temperature",
"scripts": {
"build:resources": "glib-compile-resources --sourcedir night-light-slider.timur@linux.com/ night-light-slider.timur@linux.com/org.gnome.shell.extensions.nightlightslider.data.gresource.xml",
"build:schema": "glib-compile-schemas night-light-slider.timur@linux.com/schemas/",
"build:link": "ln -s $(pwd)/night-light-slider.timur@linux.com/ ~/.local/share/gnome-shell/extensions/",
"build:zip": "cd night-light-slider.timur@linux.com/ && zip -r ../night-light-slider.timur@linux.com.zip ./*",
"build": "npm run build:resources && npm run build:schema && npm run build:zip"
},
"repository": {
"type": "git",
"url": "git+https://codeberg.org/kiyui/gnome-shell-night-light-slider-extension.git"
},
"keywords": [
"gnome",
"gjs",
"night",
"light",
"extension"
],
"author": "Dafne Kiyui",
"license": "GPL-2.0",
"bugs": {
"url": "https://codeberg.org/kiyui/gnome-shell-night-light-slider-extension/issues"
},
"homepage": "https://codeberg.org/kiyui/gnome-shell-night-light-slider-extension#readme",
"devDependencies": {
"eslint": "^7.8.1",
"husky": ">=4",
"lint-staged": ">=10"
},
"dependencies": {},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": "eslint --fix"
}
}

0
night-light-slider.timur@linux.com/convenience.js → src/convenience.js

0
night-light-slider.timur@linux.com/extension.js → src/extension.js

32
src/meson.build

@ -0,0 +1,32 @@
gnome = import('gnome')
# Compile GResource objects
gresource_data = gnome.compile_resources(
gse_prefix + '.data',
gse_prefix + '.data.gresource.xml',
gresource_bundle: true,
install: true,
install_dir: extensiondir
)
# Collect sources
gse_sources = files([
'convenience.js',
'extension.js',
'prefs.js',
])
# Create metadata file
gse_conf = configuration_data()
gse_conf.set('uuid', gse_uuid)
gse_conf.set('version', meson.project_version())
gse_conf.set('settings_schema', gse_prefix)
gse_conf.set('gresource_data', gse_prefix + '.data.gresource')
metadata_json = configure_file(
input: 'metadata.json.in',
output: 'metadata.json',
configuration: gse_conf,
)
gse_sources += metadata_json
install_data(gse_sources, install_dir: extensiondir)

10
src/metadata.json.in

@ -0,0 +1,10 @@
{
"uuid": "@uuid@",
"version": @version@,
"settings-schema": "@settings_schema@",
"gresource-data": "@gresource_data@",
"name": "Night Light Slider",
"description": "A GNOME extension to manage the built-in night light temperature",
"shell-version": ["3.36", "3.38"],
"url": "https://codeberg.org/kiyui/gnome-shell-night-light-slider-extension"
}

2
night-light-slider.timur@linux.com/org.gnome.shell.extensions.nightlightslider.data.gresource.xml → src/org.gnome.shell.extensions.nightlightslider.data.gresource.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/shell/extensions/nightlightslider">
<file>ui/prefs.ui</file>
<file>prefs.ui</file>
</gresource>
</gresources>

4
night-light-slider.timur@linux.com/prefs.js → src/prefs.js

@ -26,7 +26,7 @@ const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
// Register resources
const resource = Me.metadata['data-gresource'];
const resource = Me.metadata['gresource-data'];
const resourceFile = Me.dir.get_child(resource);
Gio.resources_register(Gio.Resource.load(resourceFile.get_path()));
@ -35,7 +35,7 @@ const COLOR_SCHEMA = 'org.gnome.settings-daemon.plugins.color';
var NightLightExtensionPrefs = GObject.registerClass({
GTypeName: 'NightLightExtensionPrefs',
Template: 'resource:///org/gnome/shell/extensions/nightlightslider/ui/prefs.ui',
Template: 'resource:///org/gnome/shell/extensions/nightlightslider/prefs.ui',
InternalChildren: [
/* Night Light status infobar */
'infobar_status', 'btn_enable_night_light',

0
night-light-slider.timur@linux.com/ui/prefs.ui → src/prefs.ui

1246
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save