summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2020-05-03 19:14:43 (GMT)
committerGitHub <noreply@github.com>2020-05-03 19:14:43 (GMT)
commit0a2c949de1be0c21ad5b997221702315dd3b17b5 (patch)
tree049b8a3e50011d602b50f0e98f1fb73593459109
parentc3fb7d78509dc5eca1748d79ea97b6c7ce59869e (diff)
parentb890f5fcdfc79795533cae7b7cd1bf05cb82c527 (diff)
downloadSCons-0a2c949de1be0c21ad5b997221702315dd3b17b5.zip
SCons-0a2c949de1be0c21ad5b997221702315dd3b17b5.tar.gz
SCons-0a2c949de1be0c21ad5b997221702315dd3b17b5.tar.bz2
Merge pull request #3634 from mwichmann/win-uuid
Use uuid lib for Visual Studio guids
-rwxr-xr-xsrc/CHANGES.txt2
-rw-r--r--src/engine/SCons/CacheDir.py1
-rw-r--r--src/engine/SCons/Tool/msvs.py41
-rw-r--r--src/engine/SCons/Tool/packaging/msi.py8
-rw-r--r--src/engine/SCons/Util.py2
-rw-r--r--test/MSVS/vs-7.0-variant_dir.py2
-rw-r--r--test/MSVS/vs-7.1-variant_dir.py2
-rw-r--r--test/MSVS/vs-variant_dir.py2
-rw-r--r--testing/framework/TestSConsMSVS.py2
9 files changed, 39 insertions, 23 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 12315a4..dfaddd6 100755
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -123,6 +123,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- MSVC updates: pass on VSCMD_DEBUG and VSCMD_SKIP_SENDTELEMETRY to msvc
tool setup if set in environment. Add powershell to default env
(used to call telemetry script).
+ - MSVS - use the uuid module to generate GUIDs rather than hand rolled
+ method using md5 directly.
- Docbook builder provides a fallback if lxml fails to generate
a document with tostring().
- Fix description of ARCOMSTR constr. var. (issue 3636)
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py
index 117f6b0..9982555 100644
--- a/src/engine/SCons/CacheDir.py
+++ b/src/engine/SCons/CacheDir.py
@@ -27,7 +27,6 @@ __doc__ = """
CacheDir support
"""
-import hashlib
import json
import os
import stat
diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py
index e5c9bd0..1fda9e1 100644
--- a/src/engine/SCons/Tool/msvs.py
+++ b/src/engine/SCons/Tool/msvs.py
@@ -34,7 +34,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import SCons.compat
import base64
-import hashlib
+import uuid
import ntpath
import os
import pickle
@@ -77,6 +77,21 @@ def processIncludes(includes, env, target, source):
return [env.Dir(i).abspath for i in
SCons.PathList.PathList(includes).subst_path(env, target, source)]
+# Work-in-progress
+# individual elements each get a globally unique identifier.
+# however, there also are some "well known" guids that either
+# represent something, or are used as a namespace to base
+# generating guids that should be "in" the namespace
+#NAMESPACE_PROJECT = uuid.UUID("{D9BD5916-F055-4D77-8C69-9448E02BF433}")
+#NAMESPACE_SLN_GROUP = uuid.UUID("{2D0C29E0-512F-47BE-9AC4-F4CAE74AE16E}")
+#NAMESPACE_INTERNAL = uuid.UUID("{BAA4019E-6D67-4EF1-B3CB-AE6CD82E4060}")
+
+# Kinds of projects, as used in solution files
+#PROJECT_KIND_C = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
+#PROJECT_KIND_PCL = "{786C830F-07A1-408B-BD7F-6EE04809D6DB}"
+#NAMESPACE_PRJ_FOLDER = "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}"
+#NAMESPACE_SLN_FOLDER = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}"
+#NAMESPACE_TEST = "{3AC096D0-A1C2-E12C-1390-A8335801FDAB}"
def processFlags(flags, env):
"""
@@ -91,21 +106,23 @@ def processFlags(flags, env):
external_makefile_guid = '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}'
+def _generateGUID(slnfile, name, namespace=external_makefile_guid):
+ """Generates a GUID for the sln file to use.
+
+ The uuid5 function is used to combine an existing namespace uuid -
+ the one VS uses for C projects (external_makedile_guid) -
+ and a combination of the solution file name (slnfile) and the
+ project name (name). We just need uniqueness/repeatability.
+
+ Returns (str) "displayable" GUID, already wrapped in braces
+ """
-def _generateGUID(slnfile, name):
- """This generates a dummy GUID for the sln file to use. It is
- based on the MD5 signatures of the sln filename plus the name of
- the project. It basically just needs to be unique, and not
- change with each invocation."""
- m = hashlib.md5()
# Normalize the slnfile path to a Windows path (\ separators) so
# the generated file has a consistent GUID even if we generate
# it on a non-Windows platform.
- m.update(bytearray(ntpath.normpath(str(slnfile)) + str(name),'utf-8'))
- solution = m.hexdigest().upper()
- # convert most of the signature to GUID form (discard the rest)
- solution = "{" + solution[:8] + "-" + solution[8:12] + "-" + solution[12:16] + "-" + solution[16:20] + "-" + solution[20:32] + "}"
- return solution
+ slnfile = ntpath.normpath(str(slnfile))
+ solution = uuid.uuid5(uuid.UUID(namespace), "%s-%s" %(slnfile, name))
+ return '{' + str(solution).upper() + '}'
version_re = re.compile(r'(\d+\.\d+)(.*)')
diff --git a/src/engine/SCons/Tool/packaging/msi.py b/src/engine/SCons/Tool/packaging/msi.py
index 9f28b72..defb5c6 100644
--- a/src/engine/SCons/Tool/packaging/msi.py
+++ b/src/engine/SCons/Tool/packaging/msi.py
@@ -161,7 +161,7 @@ def generate_guids(root):
To handle this requirement, the uuid is generated with an md5 hashing the
whole subtree of a xml node.
"""
- from hashlib import md5
+ import uuid
# specify which tags need a guid and in which attribute this should be stored.
needs_id = { 'Product' : 'Id',
@@ -175,10 +175,8 @@ def generate_guids(root):
node_list = root.getElementsByTagName(key)
attribute = value
for node in node_list:
- hash = md5(node.toxml()).hexdigest()
- hash_str = '%s-%s-%s-%s-%s' % ( hash[:8], hash[8:12], hash[12:16], hash[16:20], hash[20:] )
- node.attributes[attribute] = hash_str
-
+ hash = uuid.uuid5(uuid.NAMESPACE_URL, node.toxml())
+ node.attributes[attribute] = str(hash)
def string_wxsfile(target, source, env):
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 588d02f..07cdad9 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -1538,7 +1538,6 @@ def silent_intern(x):
return x
-
# From Dinu C. Gherman,
# Python Cookbook, second edition, recipe 6.17, p. 277.
# Also:
@@ -1569,6 +1568,7 @@ class Null(object):
def __delattr__(self, name):
return self
+
class NullSeq(Null):
def __len__(self):
return 0
diff --git a/test/MSVS/vs-7.0-variant_dir.py b/test/MSVS/vs-7.0-variant_dir.py
index 5699663..41c3cdc 100644
--- a/test/MSVS/vs-7.0-variant_dir.py
+++ b/test/MSVS/vs-7.0-variant_dir.py
@@ -56,7 +56,7 @@ test.write(['src', 'SConscript'], SConscript_contents%{'HOST_ARCH': host_arch})
test.run(arguments=".")
-project_guid = "{25F6CE89-8E22-2910-8B6E-FFE6DC1E2792}"
+project_guid = "{CB4637F1-2205-50B7-B115-DCFA0DA68FB1}"
vcproj = test.read(['src', 'Test.vcproj'], 'r')
expect = test.msvs_substitute(expected_vcprojfile, '7.0', None, 'SConstruct',
project_guid=project_guid)
diff --git a/test/MSVS/vs-7.1-variant_dir.py b/test/MSVS/vs-7.1-variant_dir.py
index 3a25651..64467de 100644
--- a/test/MSVS/vs-7.1-variant_dir.py
+++ b/test/MSVS/vs-7.1-variant_dir.py
@@ -56,7 +56,7 @@ test.write(['src', 'SConscript'], SConscript_contents%{'HOST_ARCH': host_arch})
test.run(arguments=".")
-project_guid = "{25F6CE89-8E22-2910-8B6E-FFE6DC1E2792}"
+project_guid = "{CB4637F1-2205-50B7-B115-DCFA0DA68FB1}"
vcproj = test.read(['src', 'Test.vcproj'], 'r')
expect = test.msvs_substitute(expected_vcprojfile, '7.0', None, 'SConstruct',
project_guid=project_guid)
diff --git a/test/MSVS/vs-variant_dir.py b/test/MSVS/vs-variant_dir.py
index 15b46e8..7d4b9cb 100644
--- a/test/MSVS/vs-variant_dir.py
+++ b/test/MSVS/vs-variant_dir.py
@@ -58,7 +58,7 @@ SConscript('src/SConscript', variant_dir='build')
test.run(arguments=".")
- project_guid = "{25F6CE89-8E22-2910-8B6E-FFE6DC1E2792}"
+ project_guid = "{CB4637F1-2205-50B7-B115-DCFA0DA68FB1}"
vcproj = test.read(['src', project_file], 'r')
expect = test.msvs_substitute(expected_vcprojfile, vc_version, None, 'SConstruct',
project_guid=project_guid)
diff --git a/testing/framework/TestSConsMSVS.py b/testing/framework/TestSConsMSVS.py
index 4b05ddd..4de3aaf 100644
--- a/testing/framework/TestSConsMSVS.py
+++ b/testing/framework/TestSConsMSVS.py
@@ -699,7 +699,7 @@ print("self._msvs_versions =%%s"%%str(SCons.Tool.MSCommon.query_versions()))
python = sys.executable
if project_guid is None:
- project_guid = "{E5466E26-0003-F18B-8F8A-BCD76C86388D}"
+ project_guid = "{B0CC4EE9-0174-51CD-A06A-41D0713E928A}"
if 'SCONS_LIB_DIR' in os.environ:
exec_script_main = "from os.path import join; import sys; sys.path = [ r'%s' ] + sys.path; import SCons.Script; SCons.Script.main()" % os.environ['SCONS_LIB_DIR']