summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons
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 /src/engine/SCons
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
Diffstat (limited to 'src/engine/SCons')
-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
4 files changed, 33 insertions, 19 deletions
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