From e536f16bbced882531834fa8dae103b961c67348 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Tue, 13 Apr 2004 03:46:05 +0000 Subject: [PATCH] More robust searching for the ICL license file. (Gary Oberbrunner) git-svn-id: http://scons.tigris.org/svn/scons/trunk@953 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 3 +++ src/engine/SCons/Tool/icl.py | 29 ++++++++++++++++++++++++++++- test/import.py | 14 +++++++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index d7922ce8..bf2c7607 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -85,6 +85,9 @@ RELEASE 0.96 - XXX are otherwise silently (and confusingly) turned into construction variable overrides. + - Try to find the ICL license file path name in the external environment + and the registry before resorting to the hard-coded path name. + From Simon Perkins: - Fix a bug introduced in building shared libraries under MinGW. diff --git a/src/engine/SCons/Tool/icl.py b/src/engine/SCons/Tool/icl.py index ec1e0633..d59647ce 100644 --- a/src/engine/SCons/Tool/icl.py +++ b/src/engine/SCons/Tool/icl.py @@ -38,6 +38,7 @@ import string import SCons.Tool.msvc import SCons.Util +import SCons.Warnings # Find Intel compiler: # Could enumerate subkeys here to be more flexible. @@ -99,7 +100,33 @@ def generate(env): env['CXX'] = 'icl' env['LINK'] = 'xilink' - env['ENV']['INTEL_LICENSE_FILE'] = r'C:\Program Files\Common Files\Intel\Licenses' + # Look for license file dir. + envlicdir = os.environ.get("INTEL_LICENSE_FILE", '') + K = ('SOFTWARE\Intel\Licenses') + try: + k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K) + reglicdir = SCons.Util.RegQueryValueEx(k, "w_cpp")[0] + except (AttributeError, SCons.Util.RegError): + reglicdir = "" + defaultlicdir = r'C:\Program Files\Common Files\Intel\Licenses' + + licdir = None + for ld in [envlicdir, reglicdir]: + if ld and os.path.exists(ld): + licdir = ld + break + if not licdir: + licdir = defaultlicdir + if not os.path.exists(licdir): + class ICLLicenseDirWarning(SCons.Warnings.Warning): + pass + SCons.Warnings.enableWarningClass(ICLLicenseDirWarning) + SCons.Warnings.warn(ICLLicenseDirWarning, + "Intel license dir was not found." + " Tried using the INTEL_LICENSE_FILE environment variable (%s), the registry (%s) and the default path (%s)." + " Using the default path as a last resort." + % (envlicdir, reglicdir, defaultlicdir)) + env['ENV']['INTEL_LICENSE_FILE'] = licdir def exists(env): try: diff --git a/test/import.py b/test/import.py index 6d154ae8..48ae5466 100644 --- a/test/import.py +++ b/test/import.py @@ -115,6 +115,13 @@ tools = [ 'zip', ] +error_output = { + 'icl' : """ +scons: warning: Intel license dir was not found. Tried using the INTEL_LICENSE_FILE environment variable (), the registry () and the default path (C:\Program Files\Common Files\Intel\Licenses). Using the default path as a last resort. +File "SConstruct", line 1, in ? +""" +} + # An SConstruct for importing Tool names that have illegal characters # for Python variable names. indirect_import = """\ @@ -136,6 +143,11 @@ for tool in tools: test.write('SConstruct', indirect_import % (tool, tool, tool)) else: test.write('SConstruct', direct_import % (tool, tool, tool)) - test.run() + test.run(stderr=None) + stderr = test.stderr() + if stderr != '' and stderr != error_output.get(tool, ''): + print "Failed importing '%s', stderr:" % tool + print stderr + test.fail_test(1) test.pass_test() -- 2.26.2