summaryrefslogtreecommitdiff
path: root/skeletonmm/tools
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2019-10-26 11:17:49 +0200
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2019-10-26 11:17:49 +0200
commit2d22e63f359315c4e2fa2aa3be1f558ed4397b65 (patch)
tree7f5e9037ac978dd460ecbf146463be7b9d4b8671 /skeletonmm/tools
parenta0daa2b074923f115bfd9ae9ff1101563f6ba5d5 (diff)
downloadmm-common-2d22e63f359315c4e2fa2aa3be1f558ed4397b65.tar.gz
skeletonmm: Use Meson instead of Autotools
The files in the skeletonmm directory now show the start of a project that will use Meson. The new skeletonmm is based on experience from building pangomm with Meson. It does not include code necessary for running Meson under MSVC. See !2 and pangomm!4. Fixes #1
Diffstat (limited to 'skeletonmm/tools')
-rwxr-xr-xskeletonmm/tools/dist-cmd.py12
-rw-r--r--skeletonmm/tools/extra_defs_gen/generate_defs_skeleton.cc35
-rw-r--r--skeletonmm/tools/extra_defs_gen/meson.build26
-rwxr-xr-xskeletonmm/tools/generate_defs_and_docs.sh89
-rw-r--r--skeletonmm/tools/m4/convert.m44
-rw-r--r--skeletonmm/tools/m4/convert_skeleton.m44
6 files changed, 170 insertions, 0 deletions
diff --git a/skeletonmm/tools/dist-cmd.py b/skeletonmm/tools/dist-cmd.py
new file mode 100755
index 0000000..30da5da
--- /dev/null
+++ b/skeletonmm/tools/dist-cmd.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+# External command, intended to be called with meson.add_dist_script() in meson.build.
+# meson.add_dist_script() can't call a script that's not committed to git.
+# This script shall be committed. It can be used for calling other non-committed scripts.
+
+# dist-cmd.py <cmd> <args>...
+
+import sys
+import subprocess
+
+sys.exit(subprocess.run(sys.argv[1:]).returncode)
diff --git a/skeletonmm/tools/extra_defs_gen/generate_defs_skeleton.cc b/skeletonmm/tools/extra_defs_gen/generate_defs_skeleton.cc
new file mode 100644
index 0000000..cac1881
--- /dev/null
+++ b/skeletonmm/tools/extra_defs_gen/generate_defs_skeleton.cc
@@ -0,0 +1,35 @@
+/* Copyright (c) 2019 Joe Hacker <joe@example.com>
+ *
+ * This file is part of skeletonmm.
+ *
+ * skeletonmm is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * skeletonmm 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// We always need to generate the .defs for all types because the code
+// using deprecated API is generated unconditionally and only disabled
+// at compile time.
+#undef SKELETON_DISABLE_DEPRECATED
+
+#include <glibmm_generate_extra_defs/generate_extra_defs.h>
+#include <skeleton/skeleton.h>
+#include <iostream>
+
+int main(int, char**)
+{
+ skeleton_init();
+
+ std::cout << get_defs(SKELETON_TYPE_SOME_TYPE);
+
+ return 0;
+}
diff --git a/skeletonmm/tools/extra_defs_gen/meson.build b/skeletonmm/tools/extra_defs_gen/meson.build
new file mode 100644
index 0000000..69f3b16
--- /dev/null
+++ b/skeletonmm/tools/extra_defs_gen/meson.build
@@ -0,0 +1,26 @@
+# tools/extra_defs_gen
+
+# Input: cpp_compiler, skeletonmm_build_dep, install_libdir, skeletonmm_pcname
+# Output: m4_files, install_m4dir
+
+glibmm_generate_extra_defs_dep = cpp_compiler.find_library(
+ 'glibmm_generate_extra_defs-2.4',
+)
+
+executable('generate_defs_skeleton', 'generate_defs_skeleton.cc',
+ dependencies: [skeletonmm_build_dep, glibmm_generate_extra_defs_dep],
+ install: false,
+)
+
+# Install m4 files for reuse by other *mm projects, when building from git.
+m4_basefiles = [
+ 'convert.m4',
+ 'convert_skeleton.m4',
+]
+m4_files = []
+foreach file : m4_basefiles
+ m4_files += '..' / 'm4' / file
+endforeach
+m4_files = files(m4_files)
+install_m4dir = install_libdir / skeletonmm_pcname / 'proc' / 'm4'
+install_data(m4_files, install_dir: install_m4dir)
diff --git a/skeletonmm/tools/generate_defs_and_docs.sh b/skeletonmm/tools/generate_defs_and_docs.sh
new file mode 100755
index 0000000..025777e
--- /dev/null
+++ b/skeletonmm/tools/generate_defs_and_docs.sh
@@ -0,0 +1,89 @@
+#!/usr/bin/env bash
+
+# skeletonmm/codegen/generate_defs_and_docs.sh
+
+# Global environment variables:
+# GMMPROC_GEN_SOURCE_DIR Top directory where source files are searched for.
+# Default value: $(dirname "$0")/../..
+# i.e. 2 levels above this file.
+# GMMPROC_GEN_BUILD_DIR Top directory where built files are searched for.
+# Default value: $GMMPROC_GEN_SOURCE_DIR
+#
+# If you use jhbuild, you can set these environment variables equal to jhbuild's
+# configuration variables checkoutroot and buildroot, respectively.
+# Usually you can leave GMMPROC_GEN_SOURCE_DIR undefined.
+# If you have set buildroot=None, GMMPROC_GEN_BUILD_DIR can also be undefined.
+
+# Generated files:
+# skeletonmm/skeleton/src/skeleton_docs.xml
+# skeletonmm/skeleton/src/skeleton_enums.defs
+# skeletonmm/skeleton/src/skeleton_methods.defs
+# skeletonmm/skeleton/src/skeleton_signals.defs
+
+# Root directory of skeletonmm source files.
+root_dir="$(dirname "$0")/.."
+
+# Where to search for source files.
+if [ -z "$GMMPROC_GEN_SOURCE_DIR" ]; then
+ GMMPROC_GEN_SOURCE_DIR="$root_dir/.."
+fi
+
+# Where to search for built files.
+if [ -z "$GMMPROC_GEN_BUILD_DIR" ]; then
+ GMMPROC_GEN_BUILD_DIR="$GMMPROC_GEN_SOURCE_DIR"
+fi
+
+# Scripts in glibmm. These are source files.
+gen_docs="$GMMPROC_GEN_SOURCE_DIR/glibmm/tools/defs_gen/docextract_to_xml.py"
+gen_methods="$GMMPROC_GEN_SOURCE_DIR/glibmm/tools/defs_gen/h2def.py"
+gen_enums="$GMMPROC_GEN_SOURCE_DIR/glibmm/tools/enum.pl"
+
+# Where to find the executable that generates extra defs (signals and properties).
+extra_defs_gen_dir="$GMMPROC_GEN_BUILD_DIR/skeletonmm/tools/extra_defs_gen"
+### If skeletonmm is built with meson:
+if [ "$GMMPROC_GEN_SOURCE_DIR" == "$GMMPROC_GEN_BUILD_DIR" ]; then
+ # skeletonmm is built with meson, which requires non-source-dir builds.
+ # This is what jhbuild does, if necesary, to force non-source-dir builds.
+ extra_defs_gen_dir="$GMMPROC_GEN_BUILD_DIR/skeletonmm/build/tools/extra_defs_gen"
+fi
+### If skeletonmm is built with autotools:
+# skeletonmm is built with autotools.
+# autotools support, but don't require, non-source-dir builds.
+
+source_prefix="$GMMPROC_GEN_SOURCE_DIR/skeleton"
+build_prefix="$GMMPROC_GEN_BUILD_DIR/skeleton"
+### If skeleton is built with meson:
+if [ "$source_prefix" == "$build_prefix" ]; then
+ # skeleton is built with meson, which requires non-source-dir builds.
+ # This is what jhbuild does, if neccesary, to force non-source-dir builds.
+ build_prefix="$build_prefix/build"
+fi
+### If skeleton is built with autotools:
+# skeleton is built with autotools, which support, but don't require, non-source-dir builds.
+
+out_dir="$root_dir/skeleton/src"
+
+# Documentation
+echo === skeleton_docs.xml ===
+params="--with-properties --no-recursion"
+for dir in "$source_prefix/skeleton" "$build_prefix/skeleton"; do
+ if [ -d "$dir" ]; then
+ params="$params -s $dir"
+ fi
+done
+"$gen_docs" $params > "$out_dir/skeleton_docs.xml"
+
+shopt -s nullglob # Skip a filename pattern that matches no file
+
+# Enums
+echo === skeleton_enum.defs ===
+"$gen_enums" "$source_prefix"/skeleton/*.h "$build_prefix"/skeleton/*.h > "$out_dir/skeleton_enums.defs"
+
+# Functions and methods
+echo === skeleton_method.defs ===
+"$gen_methods" "$source_prefix"/skeleton/*.h "$build_prefix"/skeleton/*.h > "$out_dir/skeleton_methods.defs"
+
+# Properties and signals
+echo === skeleton_signal.defs ===
+"$extra_defs_gen_dir"/generate_defs_skeleton > "$out_dir/skeleton_signals.defs"
+
diff --git a/skeletonmm/tools/m4/convert.m4 b/skeletonmm/tools/m4/convert.m4
new file mode 100644
index 0000000..15e00c8
--- /dev/null
+++ b/skeletonmm/tools/m4/convert.m4
@@ -0,0 +1,4 @@
+dnl Include gmmproc type conversion definitions:
+m4_include(`convert_base.m4')
+m4_include(`convert_glib.m4')
+m4_include(`convert_skeleton.m4')
diff --git a/skeletonmm/tools/m4/convert_skeleton.m4 b/skeletonmm/tools/m4/convert_skeleton.m4
new file mode 100644
index 0000000..11b1bdc
--- /dev/null
+++ b/skeletonmm/tools/m4/convert_skeleton.m4
@@ -0,0 +1,4 @@
+dnl Copyright (c) 2019 Joe Hacker <joe@example.com>
+dnl This file is part of skeletonmm.
+
+_CONVERSION(`SkeletonSomeType*',`Glib::RefPtr<SomeType>',`Glib::wrap($3)')