summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2018-04-15 16:31:36 -0300
committerThibault Saunier <tsaunier@igalia.com>2018-04-15 20:50:22 -0300
commitcb4342b8f250e3758b040cf19ce5837d77bc1bd7 (patch)
treeb6a36dc3a8b394468ddd8f19685f22a6e7030b20
parent77ee198b1b8ce1043c9d28f080b8b2185d9596e4 (diff)
debug-viewer: Port to meson
This allows us to run unit test as part of ninja test and have versionning in sync. Also the goal is to have everything inside meson. https://bugzilla.gnome.org/show_bug.cgi?id=795282
-rw-r--r--debug-viewer/GstDebugViewer/Common/Main.py6
-rw-r--r--debug-viewer/GstDebugViewer/GUI/window.py3
-rw-r--r--debug-viewer/GstDebugViewer/__init__.py7
-rw-r--r--debug-viewer/data/meson.build6
-rwxr-xr-xdebug-viewer/gst-debug-viewer6
-rw-r--r--debug-viewer/meson.build49
-rw-r--r--debug-viewer/org.freedesktop.GstDebugViewer.desktop.in (renamed from debug-viewer/gst-debug-viewer.desktop.in)0
-rw-r--r--debug-viewer/po/LINGUAS0
-rw-r--r--debug-viewer/setup.cfg19
-rwxr-xr-xdebug-viewer/setup.py334
-rw-r--r--meson.build13
-rw-r--r--meson_options.txt6
12 files changed, 83 insertions, 366 deletions
diff --git a/debug-viewer/GstDebugViewer/Common/Main.py b/debug-viewer/GstDebugViewer/Common/Main.py
index 3fd3f4f..7f4f613 100644
--- a/debug-viewer/GstDebugViewer/Common/Main.py
+++ b/debug-viewer/GstDebugViewer/Common/Main.py
@@ -270,9 +270,9 @@ class PathsProgramBase (PathsBase):
raise NotImplementedError(
"derived classes need to set program_name attribute")
- cls.data_dir = os.path.join(data_prefix, "share", cls.program_name)
- cls.icon_dir = os.path.join(data_prefix, "share", "icons")
- cls.locale_dir = os.path.join(data_prefix, "share", "locale")
+ cls.data_dir = os.path.join(data_prefix, cls.program_name)
+ cls.icon_dir = os.path.join(data_prefix, "icons")
+ cls.locale_dir = os.path.join(data_prefix, "locale")
@classmethod
def setup_uninstalled(cls, source_dir):
diff --git a/debug-viewer/GstDebugViewer/GUI/window.py b/debug-viewer/GstDebugViewer/GUI/window.py
index f5b919a..e439823 100644
--- a/debug-viewer/GstDebugViewer/GUI/window.py
+++ b/debug-viewer/GstDebugViewer/GUI/window.py
@@ -313,8 +313,7 @@ class Window (object):
self.log_filter = None
self.widget_factory = Common.GUI.WidgetFactory(Main.Paths.data_dir)
- self.widgets = self.widget_factory.make(
- "main-window.ui", "main_window")
+ self.widgets = self.widget_factory.make("main-window.ui", "main_window")
ui_filename = os.path.join(Main.Paths.data_dir, "menus.ui")
self.ui_factory = Common.GUI.UIFactory(ui_filename, self.actions)
diff --git a/debug-viewer/GstDebugViewer/__init__.py b/debug-viewer/GstDebugViewer/__init__.py
index b10cc0e..f0515a9 100644
--- a/debug-viewer/GstDebugViewer/__init__.py
+++ b/debug-viewer/GstDebugViewer/__init__.py
@@ -19,8 +19,11 @@
"""GStreamer Debug Viewer package."""
-version = "0.1"
+version = "@VERSION@"
+
+if version.startswith('@'):
+ version = 'master'
__version__ = version
-from GstDebugViewer.Main import Paths, GETTEXT_DOMAIN, main as run
+from GstDebugViewer.Main import Paths, GETTEXT_DOMAIN, main as run # noqa
diff --git a/debug-viewer/data/meson.build b/debug-viewer/data/meson.build
new file mode 100644
index 0000000..724983b
--- /dev/null
+++ b/debug-viewer/data/meson.build
@@ -0,0 +1,6 @@
+install_data('about-dialog.ui', 'main-window.ui', 'menus.ui', 'gst-debug-viewer.png',
+ install_dir: join_paths(get_option('datadir'), 'gst-debug-viewer'))
+install_data('gst-debug-viewer.png',
+ install_dir: join_paths(get_option('datadir'), 'icons/hicolor/48x48/apps'))
+install_data('gst-debug-viewer.svg',
+ install_dir: join_paths(get_option('datadir'), 'icons/hicolor/scalable/apps')) \ No newline at end of file
diff --git a/debug-viewer/gst-debug-viewer b/debug-viewer/gst-debug-viewer
index 91005e1..25bd850 100755
--- a/debug-viewer/gst-debug-viewer
+++ b/debug-viewer/gst-debug-viewer
@@ -26,7 +26,7 @@ def main ():
import os.path
def substituted (s):
- if s.startswith ("$") and s.endswith ("$"):
+ if s.startswith ("@") and s.endswith ("@"):
return None
else:
return s
@@ -34,8 +34,8 @@ def main ():
# These "$"-enclosed strings are substituted at install time by a custom
# distutils extension (see setup.py). If you don't see any dollar signs at
# all, you are looking at an installed version of this file.
- data_dir = substituted ("$DATADIR$")
- lib_dir = substituted ("$LIBDIR$")
+ data_dir = substituted ("@DATADIR@")
+ lib_dir = substituted ("@LIBDIR@")
if data_dir:
installed = True
diff --git a/debug-viewer/meson.build b/debug-viewer/meson.build
new file mode 100644
index 0000000..1b9d2c5
--- /dev/null
+++ b/debug-viewer/meson.build
@@ -0,0 +1,49 @@
+install_subdir('GstDebugViewer', install_dir: python3.sysconfig_path('purelib'),
+ exclude_files: ['__init__.py'])
+message('Installing in ' + python3.sysconfig_path('purelib'))
+
+# Desktop launcher and description file.
+desktop_file = i18n.merge_file(
+ input: 'org.freedesktop.GstDebugViewer.desktop.in',
+ output: 'org.freedesktop.GstDebugViewer.desktop',
+ type: 'desktop',
+ po_dir: 'po',
+ install: true,
+ install_dir: join_paths(get_option('datadir'), 'applications'),
+)
+
+# Appdata file.
+appdata_file = i18n.merge_file(
+ input: 'org.freedesktop.GstDebugViewer.appdata.xml.in',
+ output: 'org.freedesktop.GstDebugViewer.appdata.xml',
+ po_dir: 'po',
+ install: true,
+ install_dir: join_paths(get_option('datadir'), 'metainfo'),
+)
+
+cdata = configuration_data()
+cdata.set('LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
+cdata.set('DATADIR', join_paths(get_option('prefix'), get_option('datadir')))
+cdata.set('VERSION', meson.project_version())
+
+configure_file(input: 'gst-debug-viewer',
+ output: 'gst-debug-viewer',
+ configuration: cdata,
+ install_dir: get_option('bindir'))
+
+configure_file(input: 'GstDebugViewer/__init__.py',
+ output: '__init__.py',
+ configuration: cdata,
+ install_dir: join_paths(python3.sysconfig_path('purelib'), 'GstDebugViewer'))
+
+pkgdatadir = join_paths(get_option('datadir'), meson.project_name())
+icondir = join_paths(get_option('datadir'), 'icons/hicolor')
+
+subdir('data')
+
+
+if run_command(python3.find_python(),
+ '-c', 'import gi; gi.require_version("Gtk", "3.0")').returncode() == 0
+ test('gst-debug-viewer', python3.find_python(), args: ['-m', 'unittest'],
+ workdir: meson.current_source_dir())
+endif \ No newline at end of file
diff --git a/debug-viewer/gst-debug-viewer.desktop.in b/debug-viewer/org.freedesktop.GstDebugViewer.desktop.in
index 47ee33f..47ee33f 100644
--- a/debug-viewer/gst-debug-viewer.desktop.in
+++ b/debug-viewer/org.freedesktop.GstDebugViewer.desktop.in
diff --git a/debug-viewer/po/LINGUAS b/debug-viewer/po/LINGUAS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/debug-viewer/po/LINGUAS
diff --git a/debug-viewer/setup.cfg b/debug-viewer/setup.cfg
deleted file mode 100644
index 2466ce2..0000000
--- a/debug-viewer/setup.cfg
+++ /dev/null
@@ -1,19 +0,0 @@
-
-[build]
-
-l10n = True
-
-[build_l10n]
-
-bug-contact = mail@renestadler.de
-merge-desktop-files = [("share/applications", ("gst-debug-viewer.desktop.in",),)]
-merge-xml-files = [("share/appdata", ("org.freedesktop.GstDebugViewer.appdata.xml.in",),)]
-
-[install_scripts]
-
-substitute-files = ["gst-debug-viewer"]
-
-[tests]
-
-files = tests/test*.py
-
diff --git a/debug-viewer/setup.py b/debug-viewer/setup.py
deleted file mode 100755
index 699c6e2..0000000
--- a/debug-viewer/setup.py
+++ /dev/null
@@ -1,334 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8; mode: python; -*-
-#
-# GStreamer Debug Viewer - View and analyze GStreamer debug log files
-#
-# Copyright (C) 2007 René Stadler <mail@renestadler.de>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; either version 3 of the License, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-# more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program. If not, see <http://www.gnu.org/licenses/>.
-
-"""GStreamer Debug Viewer distutils setup script."""
-
-import sys
-import os
-import os.path
-
-import distutils.cmd
-from setuptools import setup
-from distutils.command.clean import clean
-from distutils.command.build import build
-from distutils.command.sdist import sdist
-from distutils.command.install_scripts import install_scripts
-from distutils.errors import *
-
-
-def perform_substitution(filename, values):
-
- fp = file(filename, "rt")
- data = fp.read()
- fp.close()
-
- for name, value in list(values.items()):
- data = data.replace("$%s$" % (name,), value)
-
- fp = file(filename, "wt")
- fp.write(data)
- fp.close()
-
-
-class clean_custom (clean):
-
- def remove_file(self, path):
-
- if os.path.exists(path):
- print("removing '%s'" % (path,))
- if not self.dry_run:
- os.unlink(path)
-
- def remove_directory(self, path):
-
- from distutils import dir_util
-
- if os.path.exists(path):
- dir_util.remove_tree(path, dry_run=self.dry_run)
-
- def run(self):
-
- clean.run(self)
-
- if os.path.exists("MANIFEST.in"):
- # MANIFEST is generated, get rid of it.
- self.remove_file("MANIFEST")
-
- pot_file = os.path.join("po", "gst-debug-viewer.pot")
- self.remove_file(pot_file)
-
- self.remove_directory("build")
- self.remove_directory("dist")
-
- for path, dirs, files in os.walk("."):
- for filename in files:
- if filename.endswith(".pyc") or filename.endswith(".pyo"):
- file_path = os.path.join(path, filename)
- self.remove_file(file_path)
-
-
-class build_custom (build):
-
- def build_l10n(self):
-
- return self.l10n
-
- sub_commands = build.sub_commands + [("build_l10n", build_l10n,)]
- user_options = build.user_options + \
- [("l10n", None, "enable translations",)]
- boolean_options = build.boolean_options + ["l10n"]
-
- def initialize_options(self):
-
- build.initialize_options(self)
-
- self.l10n = False
-
-
-class build_l10n (distutils.cmd.Command):
-
- # Based on code from python-distutils-extra by Sebastian Heinlein.
-
- description = "gettext framework integration"
-
- user_options = [("merge-desktop-files=", "m", ".desktop.in files to merge"),
- ("merge-xml-files=", "x", ".xml.in files to merge"),
- ("merge-schemas-files=", "s", ".schemas.in files to merge"),
- ("merge-rfc822deb-files=", "d", "RFC822 files to merge"),
- ("merge-key-files=", "k", ".key.in files to merge"),
- ("domain=", "d", "gettext domain"),
- ("bug-contact=", "c", "contact address for msgid bugs")]
-
- def initialize_options(self):
-
- self.merge_desktop_files = []
- self.merge_xml_files = []
- self.merge_key_files = []
- self.merge_schemas_files = []
- self.merge_rfc822deb_files = []
- self.domain = None
- self.bug_contact = None
-
- def finalize_options(self):
-
- for attr in ("desktop", "xml", "key", "schemas", "rfc822deb",):
- value = getattr(self, "merge_%s_files" % (attr,))
- if not value:
- value = []
- else:
- value = eval(value)
- setattr(self, "merge_%s_files" % (attr,), value)
-
- if self.domain is None:
- self.domain = self.distribution.metadata.name
-
- def run(self):
-
- from glob import glob
-
- data_files = self.distribution.data_files
-
- po_makefile = os.path.join("po", "Makefile")
- if os.path.exists(po_makefile):
- raise DistutilsFileError("file %s exists (intltool will pick up "
- "values from there)" % (po_makefile,))
-
- cwd = os.getcwd()
-
- if self.bug_contact is not None:
- os.environ["XGETTEXT_ARGS"] = "--msgid-bugs-address=%s" % (
- self.bug_contact,)
- os.chdir(os.path.join(cwd, "po"))
- # Update .pot file.
- self.spawn(["intltool-update", "-p", "-g", self.domain])
- # Merge new strings into .po files.
- self.spawn(["intltool-update", "-r", "-g", self.domain])
-
- os.chdir(cwd)
-
- for po_file in glob(os.path.join("po", "*.po")):
- lang = os.path.basename(po_file[:-3])
- if lang.startswith("."):
- # Hidden file, like auto-save data from an editor.
- continue
- mo_dir = os.path.join("build", "mo", lang, "LC_MESSAGES")
- mo_file = os.path.join(mo_dir, "%s.mo" % (self.domain,))
- self.mkpath(mo_dir)
- self.spawn(["msgfmt", po_file, "-o", mo_file])
-
- targetpath = os.path.join("share", "locale", lang, "LC_MESSAGES")
- data_files.append((targetpath, (mo_file,)))
-
- for parameter, option in ((self.merge_xml_files, "-x",),
- (self.merge_desktop_files, "-d",),
- (self.merge_schemas_files, "-s",),
- (self.merge_rfc822deb_files, "-r",),
- (self.merge_key_files, "-k",),):
- if not parameter:
- continue
- for target, files in parameter:
- build_target = os.path.join("build", target)
- for file in files:
- if file.endswith(".in"):
- file_merged = os.path.basename(file[:-3])
- else:
- file_merged = os.path.basename(file)
-
- self.mkpath(build_target)
- file_merged = os.path.join(build_target, file_merged)
- self.spawn(["intltool-merge", option, "po", file, file_merged])
- data_files.append((target, [file_merged],))
-
-
-class distcheck (sdist):
-
- # Originally based on code from telepathy-python.
-
- description = "verify self-containedness of source distribution"
-
- def run(self):
-
- from distutils import dir_util
- from distutils.spawn import spawn
-
- # This creates e.g. dist/gst-debug-viewer-0.1.tar.gz.
- sdist.run(self)
-
- base_dir = self.distribution.get_fullname()
- distcheck_dir = os.path.join(self.dist_dir, "distcheck")
- self.mkpath(distcheck_dir)
- self.mkpath(os.path.join(distcheck_dir, "again"))
-
- cwd = os.getcwd()
- os.chdir(distcheck_dir)
-
- if os.path.isdir(base_dir):
- dir_util.remove_tree(base_dir)
-
- # Unpack tarball into dist/distcheck, creating
- # e.g. dist/distcheck/gst-debug-viewer-0.1.
- for archive in self.archive_files:
- if archive.endswith(".tar.gz"):
- archive_rel = os.path.join(os.pardir, os.pardir, archive)
- spawn(["tar", "-xzf", archive_rel, base_dir])
- break
- else:
- raise ValueError("no supported archives were created")
-
- os.chdir(cwd)
- os.chdir(os.path.join(distcheck_dir, base_dir))
- spawn([sys.executable, "setup.py", "sdist", "--formats", "gztar"])
-
- # Unpack tarball into dist/distcheck/again.
- os.chdir(cwd)
- os.chdir(os.path.join(distcheck_dir, "again"))
- archive_rel = os.path.join(
- os.pardir, base_dir, "dist", "%s.tar.gz" % (base_dir,))
- spawn(["tar", "-xzf", archive_rel, base_dir])
-
- os.chdir(cwd)
- os.chdir(os.path.join(distcheck_dir, base_dir))
- spawn([sys.executable, "setup.py", "clean"])
-
- os.chdir(cwd)
- spawn(["diff", "-ru",
- os.path.join(distcheck_dir, base_dir),
- os.path.join(distcheck_dir, "again", base_dir)])
-
- if not self.keep_temp:
- dir_util.remove_tree(distcheck_dir)
-
-
-class install_scripts_custom (install_scripts):
-
- user_options = install_scripts.user_options \
- + [("substitute-files=", None,
- "files to perform substitution on")]
-
- def initialize_options(self):
-
- install_scripts.initialize_options(self)
-
- self.substitute_files = "[]"
-
- def run(self):
-
- from os.path import normpath
-
- install = self.distribution.get_command_obj("install")
- install.ensure_finalized()
-
- values = {"DATADIR": install.install_data or "",
- "PREFIX": install.home or install.prefix or "",
- "SCRIPTSDIR": self.install_dir or ""}
-
- if install.home:
- values["LIBDIR"] = os.path.normpath(install.install_lib)
-
- if install.root:
- root = normpath(install.root)
- len_root = len(root)
- for name, value in list(values.items()):
- if normpath(value).startswith(root):
- values[name] = normpath(value)[len_root:]
-
- # Perform installation as normal...
- install_scripts.run(self)
-
- if self.dry_run:
- return
-
- # ...then substitute in-place:
- for filename in eval(self.substitute_files):
- perform_substitution(os.path.join(
- self.install_dir, filename), values)
-
-
-cmdclass = {"build": build_custom,
- "clean": clean_custom,
- "install_scripts": install_scripts_custom,
-
- "build_l10n": build_l10n,
- "distcheck": distcheck}
-
-setup(cmdclass=cmdclass,
-
- packages=["GstDebugViewer",
- "GstDebugViewer.Common",
- "GstDebugViewer.GUI",
- "GstDebugViewer.Plugins",
- "GstDebugViewer.tests"],
- scripts=["gst-debug-viewer"],
- data_files=[("share/gst-debug-viewer", ["data/about-dialog.ui",
- "data/main-window.ui",
- "data/menus.ui"],),
- ("share/icons/hicolor/48x48/apps",
- ["data/gst-debug-viewer.png"],),
- ("share/icons/hicolor/scalable/apps", ["data/gst-debug-viewer.svg"],)],
-
- name="gst-debug-viewer",
- version="0.1",
- description="GStreamer Debug Viewer",
- long_description="""""",
- test_suite="GstDebugViewer.tests",
- license="GNU GPL",
- author="Rene Stadler",
- author_email="mail@renestadler.de",
- url="http://renestadler.de/projects/gst-debug-viewer")
diff --git a/meson.build b/meson.build
index a5d6d40..9ce3684 100644
--- a/meson.build
+++ b/meson.build
@@ -130,7 +130,14 @@ foreach extra_arg : warning_flags
endif
endforeach
-subdir('validate')
+i18n = import('i18n')
+python3 = import('python3')
+if get_option('disable_validate') == false
+ subdir('validate')
+endif
+
+if get_option('disable_debug_viewer') == false
+ subdir('debug-viewer')
+endif
-python3 = import('python3').find_python()
-run_command(python3, '-c', 'import shutil; shutil.copy("hooks/multi-pre-commit.hook", ".git/hooks/pre-commit")')
+run_command(python3.find_python(), '-c', 'import shutil; shutil.copy("hooks/multi-pre-commit.hook", ".git/hooks/pre-commit")') \ No newline at end of file
diff --git a/meson_options.txt b/meson_options.txt
index 5f32b03..ab80cc6 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,3 +1,9 @@
+option('disable_validate',
+ type : 'boolean', value : false,
+ description : 'Whether to disable GstValidate')
+option('disable_debug_viewer',
+ type : 'boolean', value : false,
+ description : 'Whether to disable GstDebugViewer')
option('disable_introspection',
type : 'boolean', value : false,
description : 'Whether to disable the introspection generation')