summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2010-04-26 21:58:45 -0700
committerDaniel Burrows <dburrows@debian.org>2010-04-26 21:58:45 -0700
commit4e35a1ca5ae06e28a0f17cfa3d6deb746ca2a77a (patch)
treed1060dadcaea506c1a675f0ba26b6c9d4f428522
parent2ea16c284ade4141c73b818cc00960400d5860da (diff)
downloadaptitude-4e35a1ca5ae06e28a0f17cfa3d6deb746ca2a77a.tar.gz
Add SCons custom tools for msgfmt, msgmerge, and xgettext.
-rw-r--r--site_scons/site_tools/msgfmt.py40
-rw-r--r--site_scons/site_tools/msgmerge.py32
-rw-r--r--site_scons/site_tools/xgettext.py44
3 files changed, 116 insertions, 0 deletions
diff --git a/site_scons/site_tools/msgfmt.py b/site_scons/site_tools/msgfmt.py
new file mode 100644
index 00000000..13f647cb
--- /dev/null
+++ b/site_scons/site_tools/msgfmt.py
@@ -0,0 +1,40 @@
+# Copyright (C) 2010 Daniel Burrows
+#
+# 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 2 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; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+from SCons.Script import Builder
+import msgmerge
+
+def exists():
+ return True
+
+def generate(env):
+ env.Append(BUILDERS = { 'Msgfmt' : MsgfmtBuilder })
+
+# TODO: could add rules for building .mo (is that for non-GNU
+# systems?) Maybe even build either one, depending on which ones are
+# available?
+
+# Note that we can't automatically build the .po from the .pot since
+# we can't compute the .pot name from the .po name.
+MsgfmtBuilder = Builder(
+ action = [[
+ '$MSGFMT', '-c', '--statistics',
+ '-o', '$TARGET',
+ '$SOURCE'
+ ]],
+ suffix = '.gmo',
+ source_suffix = '.po')
diff --git a/site_scons/site_tools/msgmerge.py b/site_scons/site_tools/msgmerge.py
new file mode 100644
index 00000000..d03a16a7
--- /dev/null
+++ b/site_scons/site_tools/msgmerge.py
@@ -0,0 +1,32 @@
+# Copyright (C) 2010 Daniel Burrows
+#
+# 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 2 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; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+from SCons.Script import Builder
+
+def exists():
+ return True
+
+def generate(env):
+ env.Append(BUILDERS = { 'Msgmerge' : MsgmergeBuilder })
+
+MsgmergeBuilder = Builder(
+ action = [[
+ '$MSGMERGE', '--previous', '--update',
+ '$TARGET', '$SOURCE',
+ ]],
+ suffix = '.po',
+ )
diff --git a/site_scons/site_tools/xgettext.py b/site_scons/site_tools/xgettext.py
new file mode 100644
index 00000000..ecf01d46
--- /dev/null
+++ b/site_scons/site_tools/xgettext.py
@@ -0,0 +1,44 @@
+# Copyright (C) 2010 Daniel Burrows
+#
+# 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 2 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; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+from SCons.Script import AddOption, Builder, GetOption
+
+def exists():
+ return True
+
+def generate(env):
+ env.Append(BUILDERS = { 'Xgettext' : XgettextBuilder })
+
+# A more general solution would pass a lot of this stuff as parameters
+# or environment variables. In aptitude, a lot of these arguments are
+# always the same, so I can get away with hardcoding them (but
+# eventually they should be lifted out to be more hygenic). Also, the
+# environment variables here are fairly specific to aptitude's build
+# ($PACKAGE and $XGETTEXT).
+XgettextBuilder = Builder(action = [['$XGETTEXT',
+ '--default-domain=$PACKAGE',
+ '--add-comments=TRANSLATORS:',
+ '--keyword=_',
+ '--keyword=N_',
+ '--keyword=P_',
+ '--keyword=W_',
+ '--add-comments=ForTranslators:',
+ '--copyright-holder=Daniel Burrows <dburrows@debian.org>',
+ '--msgid-bugs-address=aptitude@packages.debian.org',
+ '-o', '$TARGET',
+ '$SOURCES']],
+ suffix = '.pot')