[dia: 24/105] #19: Port sheets/ to meson.



commit 33ac94c802b05624ad146e12d8b718e6cc0b14a9
Author: Eduard Nicodei <eddnicodei gmail com>
Date:   Fri Dec 21 01:40:29 2018 +0000

    #19: Port sheets/ to meson.
    
      - Use intltool to compile .shape from .shape.in
      - As per the FIXME, this should be replaced with i18n.merge_file()
      - Also move the echo statement from checktrans to checktrans.py
        - This is so we can call checktrans.py directly from meson and
          avoid having the extra dependency.

 meson.build          |   1 +
 po/meson.build       |  11 +++++
 sheets/checktrans    |  12 +----
 sheets/checktrans.py |  11 ++++-
 sheets/meson.build   | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 144 insertions(+), 12 deletions(-)
---
diff --git a/meson.build b/meson.build
index 812ffdb1..3aa45e6c 100644
--- a/meson.build
+++ b/meson.build
@@ -73,5 +73,6 @@ subdir('app')
 subdir('data')
 subdir('doc')
 subdir('plug-ins')
+subdir('sheets')
 
 meson.add_install_script('meson-helpers/post-install.py', datadir)
diff --git a/po/meson.build b/po/meson.build
index dd441539..b2c92e94 100644
--- a/po/meson.build
+++ b/po/meson.build
@@ -1,3 +1,14 @@
 i18n = import('i18n')
 
+intltool_merge = find_program('intltool-merge')
+
+po_dir = meson.current_source_dir()
+
+intltool_cache = join_paths(po_dir, '.intltool-merge-cache')
+intltool_command = [
+    intltool_merge, '-x', '-u',
+    '-c', intltool_cache,
+    po_dir, '@INPUT@', '@OUTPUT@'
+]
+
 i18n.gettext(meson.project_name())
diff --git a/sheets/checktrans b/sheets/checktrans
index f5599254..e4271279 100755
--- a/sheets/checktrans
+++ b/sheets/checktrans
@@ -2,16 +2,6 @@
 
 str=sheet-translation-report
        
-cat <<__EOF__ >$str
-*** Sheet translation report: ***
-(Absence of a language code means 0% translation for that language)
-(Help for translations (and/or much more) is of course welcome !)
-__EOF__
-./checktrans.py $* >>$str || cat <<__EOF__ >>$str
-E: checktrans failed to run. Please check that python and python-xml are installed
-E: on your system. On some systems, python-xml is called PyXML. If in doubt,
-E: have a look at http://pyxml.sourceforge.net
-__EOF__
+./checktrans.py $* | tee $str
 
-cat sheet-translation-report
 exit 0
diff --git a/sheets/checktrans.py b/sheets/checktrans.py
index b70070a6..641d0e08 100755
--- a/sheets/checktrans.py
+++ b/sheets/checktrans.py
@@ -21,12 +21,21 @@
 
 
 import os,sys,string
+print("""*** Sheet translation report: ***
+(Absence of a language code means 0% translation for that language)
+(Help for translations (and/or much more) is of course welcome !)
+""")
+
 try :
        from xml.sax import saxexts
        from xml.sax import saxlib
 except ImportError :
        print "Missing dependencies: no translation report"
-       sys.exit(0)
+       print("""E: checktrans failed to run. Please check that python and python-xml are installed
+E: on your system. On some systems, python-xml is called PyXML. If in doubt,
+E: have a look at http://pyxml.sourceforge.net
+""")
+       sys.exit(1)
 
 class CounterHandler(saxlib.DocumentHandler):
 
diff --git a/sheets/meson.build b/sheets/meson.build
new file mode 100644
index 00000000..2b06382c
--- /dev/null
+++ b/sheets/meson.build
@@ -0,0 +1,121 @@
+sheetsdir = join_paths(pkgdatadir, 'sheets')
+
+sheet_icons_sources = [
+    'UML/umlclass_template.png',
+    'UML/aggregation.png',
+    'UML/receptacle.png',
+    'UML/eventsource.png',
+    'UML/eventsink.png',
+    'ER/weakentity.png',
+    'GRAFCET/etapei.png',
+    'GRAFCET/etapems.png',
+    'GRAFCET/etapeme.png',
+    'GRAFCET/etapemc.png',
+    'GRAFCET/etapesp.png',
+    'GRAFCET/vergent_and.png',
+    'Jackson/designed_domain.png',
+    'Jackson/machine_domain.png',
+    'Jackson/req_phen.png',
+    'Istar/agent.png',
+    'Istar/decomposition.png',
+    'Istar/dependency.png',
+    'Istar/goal.png',
+    'Istar/means_ends.png',
+    'Istar/neg_contrib.png',
+    'Istar/pos_contrib.png',
+    'Istar/position.png',
+    'Istar/role.png',
+    'Istar/task.png',
+    'KAOS/and-complete-ref.png',
+    'KAOS/and-ref.png',
+    'KAOS/assumption.png',
+    'KAOS/capable-of.png',
+    'KAOS/conflicts.png',
+    'KAOS/controls.png',
+    'KAOS/input.png',
+    'KAOS/monitors.png',
+    'KAOS/obstacle.png',
+    'KAOS/obstructs.png',
+    'KAOS/op-ref.png',
+    'KAOS/or-complete-ref.png',
+    'KAOS/or-ref.png',
+    'KAOS/output.png',
+    'KAOS/performs.png',
+    'KAOS/requirement.png',
+    'KAOS/responsibility.png',
+    'KAOS/softgoal.png'
+]
+
+foreach icon : sheet_icons_sources
+    rel_path = icon.split('/')
+    install_data(icon, install_dir : join_paths(sheetsdir, rel_path[0]))
+endforeach
+
+sheet_files = [
+    'UML.sheet',
+    'ER.sheet',
+    'sybase.sheet',
+    'FS.sheet',
+    'network.sheet',
+    'Flowchart.sheet',
+    'Circuit.sheet',
+    'Contact.sheet',
+    'GRAFCET.sheet',
+    'chronogram.sheet',
+    'SADT.sheet',
+    'Pneumatic.sheet',
+    'Electric.sheet',
+    'civil.sheet',
+    'jigsaw.sheet',
+    'MSE.sheet',
+    'SDL.sheet',
+    'Logic.sheet',
+    'Misc.sheet',
+    'Assorted.sheet',
+    'ciscocomputer.sheet',
+    'ciscohub.sheet',
+    'ciscomisc.sheet',
+    'cisconetwork.sheet',
+    'ciscotelephony.sheet',
+    'Cybernetics.sheet',
+    'IsometricMap.sheet',
+    'Istar.sheet',
+    'Jackson.sheet',
+    'KAOS.sheet',
+    'ChemEng.sheet',
+    'AADL.sheet',
+    'Gane_and_Sarson.sheet',
+    'BPMN.sheet',
+    'Lights.sheet',
+    'Database.sheet',
+    'Sozi.sheet',
+    'Shape_Design.sheet',
+]
+
+# FIXME: use gettext:
+# https://github.com/mesonbuild/meson/issues/1565
+# https://github.com/systemd/systemd/commit/c81217920effddc93fb780cf8f9eb699d6fe1319
+# https://wiki.gnome.org/MigratingFromIntltoolToGettext
+# https://www.gnu.org/software/gettext/manual/html_node/Preparing-ITS-Rules.html
+# https://www.w3.org/TR/its20/ (2013) standard!
+foreach sheet : sheet_files
+    custom_target(
+        sheet,
+        input : sheet + '.in',
+        output : sheet,
+        command : intltool_command,
+        install : true,
+        install_dir : sheetsdir
+    )
+endforeach
+
+checktrans_py = find_program('checktrans.py')
+
+custom_target(
+    'sheet-translation-report',
+    build_by_default :  false,  # Currently broken anyway.
+    input : sheet_files,
+    output : 'sheet-translation-report',
+    command : [checktrans_py, '@INPUT@'],
+    capture : true
+)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]