summaryrefslogtreecommitdiff
path: root/engine/SCons/Tool/xgettext.py
diff options
context:
space:
mode:
Diffstat (limited to 'engine/SCons/Tool/xgettext.py')
-rw-r--r--engine/SCons/Tool/xgettext.py59
1 files changed, 27 insertions, 32 deletions
diff --git a/engine/SCons/Tool/xgettext.py b/engine/SCons/Tool/xgettext.py
index 46ea768..920255a 100644
--- a/engine/SCons/Tool/xgettext.py
+++ b/engine/SCons/Tool/xgettext.py
@@ -3,7 +3,7 @@
Tool specific initialization of `xgettext` tool.
"""
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -24,7 +24,24 @@ Tool specific initialization of `xgettext` tool.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/xgettext.py 74b2c53bc42290e911b334a6b44f187da698a668 2017/11/14 13:16:53 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/xgettext.py 72ae09dc35ac2626f8ff711d8c4b30b6138e08e3 2019-08-08 14:50:06 bdeegan"
+
+import os
+import re
+import subprocess
+import sys
+
+import SCons.Action
+import SCons.Node.FS
+import SCons.Tool
+import SCons.Util
+from SCons.Builder import BuilderBase
+from SCons.Environment import _null
+from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
+from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
+from SCons.Tool.GettextCommon import _POTargetFactory
+from SCons.Tool.GettextCommon import RPaths, _detect_xgettext
+from SCons.Tool.GettextCommon import _xgettext_exists
#############################################################################
@@ -41,10 +58,6 @@ class _CmdRunner(object):
self.commandstr = commandstr
def __call__(self, target, source, env):
- import SCons.Action
- import subprocess
- import os
- import sys
kw = {
'stdin': 'devnull',
'stdout': subprocess.PIPE,
@@ -57,11 +70,10 @@ class _CmdRunner(object):
self.out, self.err = proc.communicate()
self.status = proc.wait()
if self.err:
- sys.stderr.write(unicode(self.err))
+ sys.stderr.write(SCons.Util.UnicodeType(self.err))
return self.status
def strfunction(self, target, source, env):
- import os
comstr = self.commandstr
if env.subst(comstr, target=target, source=source) == "":
comstr = self.command
@@ -74,9 +86,6 @@ class _CmdRunner(object):
#############################################################################
def _update_pot_file(target, source, env):
""" Action function for `POTUpdate` builder """
- import re
- import os
- import SCons.Action
nop = lambda target, source, env: 0
# Save scons cwd and os cwd (NOTE: they may be different. After the job, we
@@ -154,10 +163,6 @@ def _update_pot_file(target, source, env):
#############################################################################
#############################################################################
-from SCons.Builder import BuilderBase
-
-
-#############################################################################
class _POTBuilder(BuilderBase):
def _execute(self, env, target, source, *args):
if not target:
@@ -175,10 +180,6 @@ class _POTBuilder(BuilderBase):
def _scan_xgettext_from_files(target, source, env, files=None, path=None):
""" Parses `POTFILES.in`-like file and returns list of extracted file names.
"""
- import re
- import SCons.Util
- import SCons.Node.FS
-
if files is None:
return 0
if not SCons.Util.is_List(files):
@@ -230,10 +231,6 @@ def _scan_xgettext_from_files(target, source, env, files=None, path=None):
#############################################################################
def _pot_update_emitter(target, source, env):
""" Emitter function for `POTUpdate` builder """
- from SCons.Tool.GettextCommon import _POTargetFactory
- import SCons.Util
- import SCons.Node.FS
-
if 'XGETTEXTFROM' in env:
xfrom = env['XGETTEXTFROM']
else:
@@ -261,10 +258,6 @@ def _pot_update_emitter(target, source, env):
#############################################################################
#############################################################################
-from SCons.Environment import _null
-
-
-#############################################################################
def _POTUpdateBuilderWrapper(env, target=None, source=_null, **kw):
return env._POTUpdateBuilder(target, source, **kw)
@@ -274,8 +267,6 @@ def _POTUpdateBuilderWrapper(env, target=None, source=_null, **kw):
#############################################################################
def _POTUpdateBuilder(env, **kw):
""" Creates `POTUpdate` builder object """
- import SCons.Action
- from SCons.Tool.GettextCommon import _POTargetFactory
kw['action'] = SCons.Action.Action(_update_pot_file, None)
kw['suffix'] = '$POTSUFFIX'
kw['target_factory'] = _POTargetFactory(env, alias='$POTUPDATE_ALIAS').File
@@ -288,9 +279,14 @@ def _POTUpdateBuilder(env, **kw):
#############################################################################
def generate(env, **kw):
""" Generate `xgettext` tool """
- import SCons.Util
- from SCons.Tool.GettextCommon import RPaths, _detect_xgettext
+ if sys.platform == 'win32':
+ xgettext = SCons.Tool.find_program_path(env, 'xgettext', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
+ if xgettext:
+ xgettext_bin_dir = os.path.dirname(xgettext)
+ env.AppendENVPath('PATH', xgettext_bin_dir)
+ else:
+ SCons.Warnings.Warning('xgettext tool requested, but binary not found in ENV PATH')
try:
env['XGETTEXT'] = _detect_xgettext(env)
except:
@@ -347,7 +343,6 @@ def generate(env, **kw):
#############################################################################
def exists(env):
""" Check, whether the tool exists """
- from SCons.Tool.GettextCommon import _xgettext_exists
try:
return _xgettext_exists(env)
except: