1
"""SCons.Tool.Perforce.py
3
Tool-specific initialization for Perforce Source Code Management system.
5
There normally shouldn't be any need to import this module directly.
6
It will usually be imported through the generic SCons.Tool.Tool()
11
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation
13
# Permission is hereby granted, free of charge, to any person obtaining
14
# a copy of this software and associated documentation files (the
15
# "Software"), to deal in the Software without restriction, including
16
# without limitation the rights to use, copy, modify, merge, publish,
17
# distribute, sublicense, and/or sell copies of the Software, and to
18
# permit persons to whom the Software is furnished to do so, subject to
19
# the following conditions:
21
# The above copyright notice and this permission notice shall be included
22
# in all copies or substantial portions of the Software.
24
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
25
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
26
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
__revision__ = "src/engine/SCons/Tool/Perforce.py 5134 2010/08/16 23:02:40 bdeegan"
41
# This function should maybe be moved to SCons.Util?
42
from SCons.Tool.PharLapCommon import addPathIfNotExists
45
# Variables that we want to import from the base OS environment.
46
_import_env = [ 'P4PORT', 'P4CLIENT', 'P4USER', 'USER', 'USERNAME', 'P4PASSWD',
47
'P4CHARSET', 'P4LANGUAGE', 'SystemRoot' ]
49
PerforceAction = SCons.Action.Action('$P4COM', '$P4COMSTR')
52
"""Add a Builder factory function and construction variables for
53
Perforce to an Environment."""
55
def PerforceFactory(env=env):
57
import SCons.Warnings as W
58
W.warn(W.DeprecatedSourceCodeWarning, """The Perforce() factory is deprecated and there is no replacement.""")
59
return SCons.Builder.Builder(action = PerforceAction, env = env)
61
#setattr(env, 'Perforce', PerforceFactory)
62
env.Perforce = PerforceFactory
65
env['P4FLAGS'] = SCons.Util.CLVar('')
66
env['P4COM'] = '$P4 $P4FLAGS sync $TARGET'
73
# Perforce seems to use the PWD environment variable rather than
74
# calling getcwd() for itself, which is odd. If no PWD variable
75
# is present, p4 WILL call getcwd, but this seems to cause problems
76
# with good ol' Windows's tilde-mangling for long file names.
77
environ['PWD'] = env.Dir('#').get_abspath()
79
for var in _import_env:
80
v = os.environ.get(var)
84
if SCons.Util.can_read_reg:
85
# If we can read the registry, add the path to Perforce to our environment.
87
k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
88
'Software\\Perforce\\environment')
89
val, tok = SCons.Util.RegQueryValueEx(k, 'P4INSTROOT')
90
addPathIfNotExists(environ, 'PATH', val)
91
except SCons.Util.RegError:
92
# Can't detect where Perforce is, hope the user has it set in the
97
return env.Detect('p4')
101
# indent-tabs-mode:nil
103
# vim: set expandtab tabstop=4 shiftwidth=4: