diff options
author | Jose Fonseca <jose.r.fonseca@gmail.com> | 2021-03-19 20:08:54 +0000 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-03-20 10:38:55 +0000 |
commit | 6e6cd7d93cc54fc8c279377c2d552761f4457174 (patch) | |
tree | 9a4aeaca6cb9effd78d5ce36807fe7feaba27ee2 /scons | |
parent | 85c1770044830fe2fcfb93c84df342706b7a8f38 (diff) | |
download | mesa-6e6cd7d93cc54fc8c279377c2d552761f4457174.tar.gz mesa-6e6cd7d93cc54fc8c279377c2d552761f4457174.tar.bz2 mesa-6e6cd7d93cc54fc8c279377c2d552761f4457174.zip |
scons: Remove.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9720>
Diffstat (limited to 'scons')
-rw-r--r-- | scons/crossmingw.py | 178 | ||||
-rw-r--r-- | scons/custom.py | 331 | ||||
-rw-r--r-- | scons/fixes.py | 27 | ||||
-rwxr-xr-x | scons/gallium.py | 741 | ||||
-rw-r--r-- | scons/llvm.py | 350 | ||||
-rw-r--r-- | scons/source_list.py | 130 | ||||
-rw-r--r-- | scons/x11.py | 51 |
7 files changed, 0 insertions, 1808 deletions
diff --git a/scons/crossmingw.py b/scons/crossmingw.py deleted file mode 100644 index b2efccea7e8..00000000000 --- a/scons/crossmingw.py +++ /dev/null @@ -1,178 +0,0 @@ -"""SCons.Tool.gcc - -Tool-specific initialization for MinGW (http://www.mingw.org/) - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. - -See also http://www.scons.org/wiki/CrossCompilingMingw -""" - -# -# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -import os -import os.path -import string - -import SCons.Action -import SCons.Builder -import SCons.Tool -import SCons.Util - -# These are the mingw toolchain prefixes we search for: -# (We only search for the mingw-w64 toolchain, and not the mingw.org one.) -prefixes32 = SCons.Util.Split(""" - i686-w64-mingw32- -""") -prefixes64 = SCons.Util.Split(""" - x86_64-w64-mingw32- -""") - -def find(env): - if env['machine'] == 'x86_64': - prefixes = prefixes64 - else: - prefixes = prefixes32 - for prefix in prefixes: - # First search in the SCons path and then the OS path: - if env.WhereIs(prefix + 'gcc') or SCons.Util.WhereIs(prefix + 'gcc'): - return prefix - - return '' - -def shlib_generator(target, source, env, for_signature): - cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS']) - - dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX') - if dll: cmd.extend(['-o', dll]) - - cmd.extend(['$SOURCES', '$_LIBDIRFLAGS', '$_LIBFLAGS']) - - implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX') - if implib: cmd.append('-Wl,--out-implib,'+implib.get_string(for_signature)) - - def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX') - if def_target: cmd.append('-Wl,--output-def,'+def_target.get_string(for_signature)) - - return [cmd] - -def shlib_emitter(target, source, env): - dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX') - no_import_lib = env.get('no_import_lib', 0) - - if not dll: - raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")) - - if not no_import_lib and \ - not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'): - - # Append an import library to the list of targets. - target.append(env.ReplaceIxes(dll, - 'SHLIBPREFIX', 'SHLIBSUFFIX', - 'LIBPREFIX', 'LIBSUFFIX')) - - # Append a def file target if there isn't already a def file target - # or a def file source. There is no option to disable def file - # target emitting, because I can't figure out why someone would ever - # want to turn it off. - def_source = env.FindIxes(source, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX') - def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX') - if not def_source and not def_target: - target.append(env.ReplaceIxes(dll, - 'SHLIBPREFIX', 'SHLIBSUFFIX', - 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')) - - return (target, source) - - -shlib_action = SCons.Action.Action(shlib_generator, '$SHLINKCOMSTR', generator=1) - -res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR') - -res_builder = SCons.Builder.Builder(action=res_action, suffix='.o', - source_scanner=SCons.Tool.SourceFileScanner) -SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan) - - - -def generate(env): - mingw_prefix = find(env) - - if mingw_prefix: - dir = os.path.dirname(env.WhereIs(mingw_prefix + 'gcc') or SCons.Util.WhereIs(mingw_prefix + 'gcc')) - - # The mingw bin directory must be added to the path: - path = env['ENV'].get('PATH', []) - if not path: - path = [] - if SCons.Util.is_String(path): - path = str.split(path, os.pathsep) - - env['ENV']['PATH'] = str.join(os.pathsep, [dir] + path) - - # Most of mingw is the same as gcc and friends... - gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas'] - for tool in gnu_tools: - SCons.Tool.Tool(tool)(env) - - #... but a few things differ: - env['CC'] = mingw_prefix + 'gcc' - env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS') - env['CXX'] = mingw_prefix + 'g++' - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') - env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared') - env['SHLINKCOM'] = shlib_action - env.Append(SHLIBEMITTER = [shlib_emitter]) - env['LINK'] = mingw_prefix + 'g++' - env['AR'] = mingw_prefix + 'ar' - env['RANLIB'] = mingw_prefix + 'ranlib' - env['LINK'] = mingw_prefix + 'g++' - env['AS'] = mingw_prefix + 'as' - env['WIN32DEFPREFIX'] = '' - env['WIN32DEFSUFFIX'] = '.def' - env['SHOBJSUFFIX'] = '.o' - env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 - - env['RC'] = mingw_prefix + 'windres' - env['RCFLAGS'] = SCons.Util.CLVar('') - env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS ${INCPREFIX}${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET' - env['BUILDERS']['RES'] = res_builder - - # Some setting from the platform also have to be overridden: - env['OBJPREFIX'] = '' - env['OBJSUFFIX'] = '.o' - env['SHOBJPREFIX'] = '$OBJPREFIX' - env['SHOBJSUFFIX'] = '$OBJSUFFIX' - env['PROGPREFIX'] = '' - env['PROGSUFFIX'] = '.exe' - env['LIBPREFIX'] = 'lib' - env['LIBSUFFIX'] = '.a' - env['SHLIBPREFIX'] = '' - env['SHLIBSUFFIX'] = '.dll' - env['LIBPREFIXES'] = [ 'lib', '' ] - env['LIBSUFFIXES'] = [ '.a', '.lib' ] - -def exists(env): - return find(env) diff --git a/scons/custom.py b/scons/custom.py deleted file mode 100644 index 2fad8f5b6d4..00000000000 --- a/scons/custom.py +++ /dev/null @@ -1,331 +0,0 @@ -"""custom - -Custom builders and methods. - -""" - -# -# Copyright 2008 VMware, Inc. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - - -import os.path -import sys -import subprocess -import modulefinder - -import SCons.Action -import SCons.Builder -import SCons.Scanner - -import fixes - -import source_list - -# the get_implicit_deps() method changed between 2.4 and 2.5: now it expects -# a callable that takes a scanner as argument and returns a path, rather than -# a path directly. We want to support both, so we need to detect the SCons version, -# for which no API is provided by SCons 8-P - -# Scons version string has consistently been in this format: -# MajorVersion.MinorVersion.Patch[.alpha/beta.yyyymmdd] -# so this formula should cover all versions regardless of type -# stable, alpha or beta. -# For simplicity alpha and beta flags are removed. -scons_version = tuple(map(int, SCons.__version__.split('.')[:3])) - -def quietCommandLines(env): - # Quiet command lines - # See also http://www.scons.org/wiki/HidingCommandLinesInOutput - env['ASCOMSTR'] = " Assembling $SOURCE ..." - env['ASPPCOMSTR'] = " Assembling $SOURCE ..." - env['CCCOMSTR'] = " Compiling $SOURCE ..." - env['SHCCCOMSTR'] = " Compiling $SOURCE ..." - env['CXXCOMSTR'] = " Compiling $SOURCE ..." - env['SHCXXCOMSTR'] = " Compiling $SOURCE ..." - env['ARCOMSTR'] = " Archiving $TARGET ..." - env['RANLIBCOMSTR'] = " Indexing $TARGET ..." - env['LINKCOMSTR'] = " Linking $TARGET ..." - env['SHLINKCOMSTR'] = " Linking $TARGET ..." - env['LDMODULECOMSTR'] = " Linking $TARGET ..." - env['SWIGCOMSTR'] = " Generating $TARGET ..." - env['LEXCOMSTR'] = " Generating $TARGET ..." - env['YACCCOMSTR'] = " Generating $TARGET ..." - env['CODEGENCOMSTR'] = " Generating $TARGET ..." - env['INSTALLSTR'] = " Installing $TARGET ..." - - -def createConvenienceLibBuilder(env): - """This is a utility function that creates the ConvenienceLibrary - Builder in an Environment if it is not there already. - - If it is already there, we return the existing one. - - Based on the stock StaticLibrary and SharedLibrary builders. - """ - - try: - convenience_lib = env['BUILDERS']['ConvenienceLibrary'] - except KeyError: - action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ] - if env.Detect('ranlib'): - ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR") - action_list.append(ranlib_action) - - convenience_lib = SCons.Builder.Builder(action = action_list, - emitter = '$LIBEMITTER', - prefix = '$LIBPREFIX', - suffix = '$LIBSUFFIX', - src_suffix = '$SHOBJSUFFIX', - src_builder = 'SharedObject') - env['BUILDERS']['ConvenienceLibrary'] = convenience_lib - - return convenience_lib - - -def python_scan(node, env, path): - # http://www.scons.org/doc/0.98.5/HTML/scons-user/c2781.html#AEN2789 - # https://docs.python.org/2/library/modulefinder.html - contents = node.get_contents() - - # Tell ModuleFinder to search dependencies in the script dir, and the glapi - # dirs - source_dir = node.get_dir().abspath - GLAPI = env.Dir('#src/mapi/glapi/gen').abspath - path = [source_dir, GLAPI] + sys.path - - finder = modulefinder.ModuleFinder(path=path) - finder.run_script(node.abspath) - results = [] - for name, mod in finder.modules.items(): - if mod.__file__ is None: - continue - assert os.path.exists(mod.__file__) - results.append(env.File(mod.__file__)) - return results - -python_scanner = SCons.Scanner.Scanner(function = python_scan, skeys = ['.py']) - - -def code_generate(env, script, target, source, command): - """Method to simplify code generation via python scripts. - - http://www.scons.org/wiki/UsingCodeGenerators - http://www.scons.org/doc/0.98.5/HTML/scons-user/c2768.html - """ - - # We're generating code using Python scripts, so we have to be - # careful with our scons elements. This entry represents - # the generator file *in the source directory*. - script_src = env.File(script).srcnode() - - # This command creates generated code *in the build directory*. - command = command.replace('$SCRIPT', script_src.path) - action = SCons.Action.Action(command, "$CODEGENCOMSTR") - code = env.Command(target, source, action) - - # Explicitly mark that the generated code depends on the generator, - # and on implicitly imported python modules - path = (script_src.get_dir(),) if scons_version < (2, 5, 0) else lambda x: script_src - deps = [script_src] - deps += script_src.get_implicit_deps(env, python_scanner, path) - env.Depends(code, deps) - - # Running the Python script causes .pyc files to be generated in the - # source directory. When we clean up, they should go too. So add side - # effects for .pyc files - for dep in deps: - pyc = env.File(str(dep) + 'c') - env.SideEffect(pyc, code) - - return code - - -def createCodeGenerateMethod(env): - env.Append(SCANNERS = python_scanner) - env.AddMethod(code_generate, 'CodeGenerate') - - -def _pkg_check_modules(env, name, modules): - '''Simple wrapper for pkg-config.''' - - env['HAVE_' + name] = False - - # For backwards compatability - env[name.lower()] = False - - if env['platform'] == 'windows': - return - - if not env.Detect('pkg-config'): - return - - if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0: - return - - # Strip version expressions from modules - modules = [module.split(' ', 1)[0] for module in modules] - - # Other flags may affect the compilation of unrelated targets, so store - # them with a prefix, (e.g., XXX_CFLAGS, XXX_LIBS, etc) - try: - flags = env.ParseFlags('!pkg-config --cflags --libs ' + ' '.join(modules)) - except OSError: - return - prefix = name + '_' - for flag_name, flag_value in flags.items(): - assert '_' not in flag_name - env[prefix + flag_name] = flag_value - - env['HAVE_' + name] = True - -def pkg_check_modules(env, name, modules): - - sys.stdout.write('Checking for %s (%s)...' % (name, ' '.join(modules))) - _pkg_check_modules(env, name, modules) - result = env['HAVE_' + name] - sys.stdout.write(' %s\n' % ['no', 'yes'][int(bool(result))]) - - # XXX: For backwards compatability - env[name.lower()] = result - - -def pkg_use_modules(env, names): - '''Search for all environment flags that match NAME_FOO and append them to - the FOO environment variable.''' - - names = env.Flatten(names) - - for name in names: - prefix = name + '_' - - if not 'HAVE_' + name in env: - raise Exception('Attempt to use unknown module %s' % name) - - if not env['HAVE_' + name]: - raise Exception('Attempt to use unavailable module %s' % name) - - flags = {} - for flag_name, flag_value in env.Dictionary().items(): - if flag_name.startswith(prefix): - flag_name = flag_name[len(prefix):] - if '_' not in flag_name: - flags[flag_name] = flag_value - if flags: - env.MergeFlags(flags) - - -def createPkgConfigMethods(env): - env.AddMethod(pkg_check_modules, 'PkgCheckModules') - env.AddMethod(pkg_use_modules, 'PkgUseModules') - - -def parse_source_list(env, filename, names=None): - # parse the source list file - parser = source_list.SourceListParser() - src = env.File(filename).srcnode() - - cur_srcdir = env.Dir('.').srcnode().abspath - top_srcdir = env.Dir('#').abspath - top_builddir = os.path.join(top_srcdir, env['build_dir']) - - # Normalize everything to / slashes - cur_srcdir = cur_srcdir.replace('\\', '/') - top_srcdir = top_srcdir.replace('\\', '/') - top_builddir = top_builddir.replace('\\', '/') - - # Populate the symbol table of the Makefile parser. - parser.add_symbol('top_srcdir', top_srcdir) - parser.add_symbol('top_builddir', top_builddir) - - sym_table = parser.parse(src.abspath) - - if names: - if sys.version_info[0] >= 3: - if isinstance(names, str): - names = [names] - else: - if isinstance(names, basestring): - names = [names] - - symbols = names - else: - symbols = list(sym_table.keys()) - - # convert the symbol table to source lists - src_lists = {} - for sym in symbols: - val = sym_table[sym] - srcs = [] - for f in val.split(): - if f: - # Process source paths - if f.startswith(top_builddir + '/src'): - # Automake puts build output on a `src` subdirectory, but - # SCons does not, so strip it here. - f = top_builddir + f[len(top_builddir + '/src'):] - if f.startswith(cur_srcdir + '/'): - # Prefer relative source paths, as absolute files tend to - # cause duplicate actions. - f = f[len(cur_srcdir + '/'):] - # do not include any headers - if f.endswith(tuple(['.h','.hpp','.inl'])): - continue - srcs.append(f) - - src_lists[sym] = srcs - - # if names are given, concatenate the lists - if names: - srcs = [] - for name in names: - srcs.extend(src_lists[name]) - - return srcs - else: - return src_lists - -def createParseSourceListMethod(env): - env.AddMethod(parse_source_list, 'ParseSourceList') - - -def generate(env): - """Common environment generation code""" - - verbose = env.get('verbose', False) or not env.get('quiet', True) - if not verbose: - quietCommandLines(env) - - # Custom builders and methods - createConvenienceLibBuilder(env) - createCodeGenerateMethod(env) - createPkgConfigMethods(env) - createParseSourceListMethod(env) - - # for debugging - #print env.Dump() - - -def exists(env): - return 1 diff --git a/scons/fixes.py b/scons/fixes.py deleted file mode 100644 index 714cccf61d2..00000000000 --- a/scons/fixes.py +++ /dev/null @@ -1,27 +0,0 @@ -import sys - -# Monkey patch os.spawnve on windows to become thread safe -if sys.platform == 'win32': - import os - import threading - from os import spawnve as old_spawnve - - spawn_lock = threading.Lock() - - def new_spawnve(mode, file, args, env): - spawn_lock.acquire() - try: - if mode == os.P_WAIT: - ret = old_spawnve(os.P_NOWAIT, file, args, env) - else: - ret = old_spawnve(mode, file, args, env) - finally: - spawn_lock.release() - if mode == os.P_WAIT: - pid, status = os.waitpid(ret, 0) - ret = status >> 8 - return ret - - os.spawnve = new_spawnve - - diff --git a/scons/gallium.py b/scons/gallium.py deleted file mode 100755 index 63accb143a5..00000000000 --- a/scons/gallium.py +++ /dev/null @@ -1,741 +0,0 @@ -"""gallium - -Frontend-tool for Gallium3D architecture. - -""" - -# -# Copyright 2008 VMware, Inc. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -from __future__ import print_function - -import distutils.version -import os -import os.path -import re -import subprocess -import platform as host_platform -import sys -import tempfile - -import SCons.Action -import SCons.Builder -import SCons.Scanner - - -def symlink(target, source, env): - target = str(target[0]) - source = str(source[0]) - if os.path.islink(target) or os.path.exists(target): - os.remove(target) - os.symlink(os.path.basename(source), target) - -def install(env, source, subdir): - target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'], subdir) - return env.Install(target_dir, source) - -def install_program(env, source): - return install(env, source, 'bin') - -def install_shared_library(env, sources, version = ()): - targets = [] - install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir']) - version = tuple(map(str, version)) - if env['SHLIBSUFFIX'] == '.dll': - dlls = env.FindIxes(sources, 'SHLIBPREFIX', 'SHLIBSUFFIX') - targets += install(env, dlls, 'bin') - libs = env.FindIxes(sources, 'LIBPREFIX', 'LIBSUFFIX') - targets += install(env, libs, 'lib') - else: - for source in sources: - target_dir = os.path.join(install_dir, 'lib') - target_name = '.'.join((str(source),) + version) - last = env.InstallAs(os.path.join(target_dir, target_name), source) - targets += last - while len(version): - version = version[:-1] - target_name = '.'.join((str(source),) + version) - action = SCons.Action.Action(symlink, " Symlinking $TARGET ...") - last = env.Command(os.path.join(target_dir, target_name), last, action) - targets += last - return targets - - -def msvc2013_compat(env): - if env['gcc']: - env.Append(CCFLAGS = [ - '-Werror=pointer-arith', - ]) - - -def unit_test(env, test_name, program_target, args=None): - env.InstallProgram(program_target) - - cmd = [program_target[0].abspath] - if args is not None: - cmd += args - cmd = ' '.join(cmd) - - # http://www.scons.org/wiki/UnitTests - action = SCons.Action.Action(cmd, " Running $SOURCE ...") - alias = env.Alias(test_name, program_target, action) - env.AlwaysBuild(alias) - env.Depends('check', alias) - - -def num_jobs(): - try: - return int(os.environ['NUMBER_OF_PROCESSORS']) - except (ValueError, KeyError): - pass - - try: - return os.sysconf('SC_NPROCESSORS_ONLN') - except (ValueError, OSError, AttributeError): - pass - - try: - return int(os.popen2("sysctl -n hw.ncpu")[1].read()) - except ValueError: - pass - - return 1 - - -def check_cc(env, cc, expr, cpp_opt = '-E'): - # Invoke C-preprocessor to determine whether the specified expression is - # true or not. - - sys.stdout.write('Checking for %s ... ' % cc) - - source = tempfile.NamedTemporaryFile(suffix='.c', delete=False) - source.write(('#if !(%s)\n#error\n#endif\n' % expr).encode()) - source.close() - - # sys.stderr.write('%r %s %s\n' % (env['CC'], cpp_opt, source.name)); - - pipe = SCons.Action._subproc(env, env.Split(env['CC']) + [cpp_opt, source.name], - stdin = 'devnull', - stderr = 'devnull', - stdout = 'devnull') - result = pipe.wait() == 0 - - os.unlink(source.name) - - sys.stdout.write(' %s\n' % ['no', 'yes'][int(bool(result))]) - return result - -def check_header(env, header): - '''Check if the header exist''' - - conf = SCons.Script.Configure(env) - have_header = False - - if conf.CheckHeader(header): - have_header = True - - env = conf.Finish() - return have_header - -def check_functions(env, functions): - '''Check if all of the functions exist''' - - conf = SCons.Script.Configure(env) - have_functions = True - - for function in functions: - if not conf.CheckFunc(function): - have_functions = False - - env = conf.Finish() - return have_functions - -def check_prog(env, prog): - """Check whether this program exists.""" - - sys.stdout.write('Checking for %s ... ' % prog) - - result = env.Detect(prog) - - sys.stdout.write(' %s\n' % ['no', 'yes'][int(bool(result))]) - return result - - -def generate(env): - """Common environment generation code""" - - # Tell tools which machine to compile for - env['TARGET_ARCH'] = env['machine'] - env['MSVS_ARCH'] = env['machine'] - - # Toolchain - platform = env['platform'] - env.Tool(env['toolchain']) - - # Allow override compiler and specify additional flags from environment - if 'CC' in os.environ: - env['CC'] = os.environ['CC'] - if 'CFLAGS' in os.environ: - env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) - if 'CXX' in os.environ: - env['CXX'] = os.environ['CXX'] - if 'CXXFLAGS' in os.environ: - env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) - if 'LDFLAGS' in os.environ: - env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) - - # Detect gcc/clang not by executable name, but through pre-defined macros - # as autoconf does, to avoid drawing wrong conclusions when using tools - # that overrice CC/CXX like scan-build. - env['gcc_compat'] = 0 - env['clang'] = 0 - env['msvc'] = 0 - if host_platform.system() == 'Windows': - env['msvc'] = check_cc(env, 'MSVC', 'defined(_MSC_VER)', '/E') - if not env['msvc']: - env['gcc_compat'] = check_cc(env, 'GCC', 'defined(__GNUC__)') - env['clang'] = check_cc(env, 'Clang', '__clang__') - env['gcc'] = env['gcc_compat'] and not env['clang'] - env['suncc'] = env['platform'] == 'sunos' and os.path.basename(env['CC']) == 'cc' - env['icc'] = 'icc' == os.path.basename(env['CC']) - - # shortcuts - machine = env['machine'] - platform = env['platform'] - x86 = env['machine'] == 'x86' - ppc = env['machine'] == 'ppc' - gcc_compat = env['gcc_compat'] - msvc = env['msvc'] - suncc = env['suncc'] - icc = env['icc'] - - # Determine whether we are cross compiling; in particular, whether we need - # to compile code generators with a different compiler as the target code. - hosthost_platform = host_platform.system().lower() - if hosthost_platform.startswith('cygwin'): - hosthost_platform = 'cygwin' - # Avoid spurious crosscompilation in MSYS2 environment. - if hosthost_platform.startswith('mingw'): - hosthost_platform = 'windows' - host_machine = os.environ.get('PROCESSOR_ARCHITEW6432', os.environ.get('PROCESSOR_ARCHITECTURE', host_platform.machine())) - host_machine = { - 'x86': 'x86', - 'i386': 'x86', - 'i486': 'x86', - 'i586': 'x86', - 'i686': 'x86', - 'ppc' : 'ppc', - 'AMD64': 'x86_64', - 'x86_64': 'x86_64', - }.get(host_machine, 'generic') - env['crosscompile'] = platform != hosthost_platform - if machine == 'x86_64' and host_machine != 'x86_64': - env['crosscompile'] = True - env['hostonly'] = False - - # Backwards compatability with the debug= profile= options - if env['build'] == 'debug': - if not env['debug']: - print('scons: warning: debug option is deprecated and will be removed eventually; use instead') - print('') - print(' scons build=release') - print('') - env['build'] = 'release' - if env['profile']: - print('scons: warning: profile option is deprecated and will be removed eventually; use instead') - print('') - print(' scons build=profile') - print('') - env['build'] = 'profile' - if False: - # Enforce SConscripts to use the new build variable - env.popitem('debug') - env.popitem('profile') - else: - # Backwards portability with older sconscripts - if env['build'] in ('debug', 'checked'): - env['debug'] = True - env['profile'] = False - if env['build'] == 'profile': - env['debug'] = False - env['profile'] = True - if env['build'] == 'release': - env['debug'] = False - env['profile'] = False - - # Put build output in a separate dir, which depends on the current - # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample - build_topdir = 'build' - build_subdir = env['platform'] - if env['embedded']: - build_subdir = 'embedded-' + build_subdir - if env['machine'] != 'generic': - build_subdir += '-' + env['machine'] - if env['build'] != 'release': - build_subdir += '-' + env['build'] - build_dir = os.path.join(build_topdir, build_subdir) - # Place the .sconsign file in the build dir too, to avoid issues with - # different scons versions building the same source file - env['build_dir'] = build_dir - env.SConsignFile(os.path.join(build_dir, '.sconsign')) - if 'SCONS_CACHE_DIR' in os.environ: - print('scons: Using build cache in %s.' % (os.environ['SCONS_CACHE_DIR'],)) - env.CacheDir(os.environ['SCONS_CACHE_DIR']) - env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf') - env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log') - - # Parallel build - if env.GetOption('num_jobs') <= 1: - env.SetOption('num_jobs', num_jobs()) - - # Speed up dependency checking. See - # - https://github.com/SCons/scons/wiki/GoFastButton - # - https://bugs.freedesktop.org/show_bug.cgi?id=109443 - - # Scons version string has consistently been in this format: - # MajorVersion.MinorVersion.Patch[.alpha/beta.yyyymmdd] - # so this formula should cover all versions regardless of type - # stable, alpha or beta. - # For simplicity alpha and beta flags are removed. - - scons_version = distutils.version.StrictVersion('.'.join(SCons.__version__.split('.')[:3])) - if scons_version < distutils.version.StrictVersion('3.0.2') or \ - scons_version > distutils.version.StrictVersion('3.0.4'): - env.Decider('MD5-timestamp') - env.SetOption('max_drift', 60) - - # C preprocessor options - cppdefines = [] - cppdefines += [ - '__STDC_CONSTANT_MACROS', - '__STDC_FORMAT_MACROS', - '__STDC_LIMIT_MACROS', - 'HAVE_SCONS', - ] - if env['build'] in ('debug', 'checked'): - cppdefines += ['DEBUG'] - else: - cppdefines += ['NDEBUG'] - if env['build'] == 'profile': - cppdefines += ['PROFILE'] - - if check_functions(env, ['timespec_get']): - cppdefines += ['HAVE_TIMESPEC_GET'] - - if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'): - cppdefines += [ - '_POSIX_SOURCE', - ('_POSIX_C_SOURCE', '199309L'), - '_SVID_SOURCE', - '_BSD_SOURCE', - '_GNU_SOURCE', - '_DEFAULT_SOURCE', - ] - if env['platform'] == 'darwin': - cppdefines += [ - '_DARWIN_C_SOURCE', - 'GLX_USE_APPLEGL', - 'GLX_DIRECT_RENDERING', - 'BUILDING_MESA', - ] - else: - cppdefines += [ - 'GLX_DIRECT_RENDERING', - 'GLX_INDIRECT_RENDERING', - ] - - if check_header(env, 'xlocale.h'): - cppdefines += ['HAVE_XLOCALE_H'] - - if check_header(env, 'endian.h'): - cppdefines += ['HAVE_ENDIAN_H'] - - if check_functions(env, ['strtod_l', 'strtof_l']): - cppdefines += ['HAVE_STRTOD_L'] - - if check_functions(env, ['random_r']): - cppdefines += ['HAVE_RANDOM_R'] - - if check_header(env, 'sys/shm.h'): - cppdefines += ['HAVE_SYS_SHM_H'] - - if check_functions(env, ['strtok_r']): - cppdefines += ['HAVE_STRTOK_R'] - - #FIXME: we should really be checking for the major()/minor() - # functions/macros in these headers, but check_functions()'s - # SConf.CheckFunc() doesn't seem to support macros. - if check_header(env, 'sys/mkdev.h'): - cppdefines += ['MAJOR_IN_MKDEV'] - if check_header(env, 'sys/sysmacros.h'): - cppdefines += ['MAJOR_IN_SYSMACROS'] - - if platform == 'windows': - cppdefines += [ - 'WIN32', - '_WINDOWS', - #'_UNICODE', - #'UNICODE', - # http://msdn.microsoft.com/en-us/library/aa383745.aspx - ('_WIN32_WINNT', '0x0A00'), - ('WINVER', '0x0A00'), - ] - if gcc_compat: - cppdefines += [('__MSVCRT_VERSION__', '0x0700')] - cppdefines += ['_USE_MATH_DEFINES'] - if msvc: - cppdefines += [ - 'VC_EXTRALEAN', - '_USE_MATH_DEFINES', - '_CRT_SECURE_NO_WARNINGS', - '_CRT_SECURE_NO_DEPRECATE', - '_SCL_SECURE_NO_WARNINGS', - '_SCL_SECURE_NO_DEPRECATE', - '_ALLOW_KEYWORD_MACROS', - '_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions - ] - if env['build'] in ('debug', 'checked'): - cppdefines += ['_DEBUG'] - if env['embedded']: - cppdefines += ['EMBEDDED_DEVICE'] - env.Append(CPPDEFINES = cppdefines) - - # C compiler options - cflags = [] # C - cxxflags = [] # C++ - ccflags = [] # C & C++ - if gcc_compat: - if env['build'] == 'debug': - ccflags += ['-O0'] - else: - ccflags += ['-O3'] - if env['gcc']: - # gcc's builtin memcmp is slower than glibc's - # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052 - ccflags += ['-fno-builtin-memcmp'] - # Work around aliasing bugs - developers should comment this out - ccflags += ['-fno-strict-aliasing'] - ccflags += ['-g'] - if env['build'] in ('checked', 'profile') or env['asan']: - # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling? - ccflags += [ - '-fno-omit-frame-pointer', - ] - if env['gcc']: - ccflags += ['-fno-optimize-sibling-calls'] - if env['machine'] == 'x86': - ccflags += [ - '-m32', - #'-march=pentium4', - ] - if platform != 'haiku': - # NOTE: We need to ensure stack is realigned given that we - # produce shared objects, and have no control over the stack - # alignment policy of the application. Therefore we need - # -mstackrealign ore -mincoming-stack-boundary=2. - # - # XXX: We could have SSE without -mstackrealign if we always used - # __attribute__((force_align_arg_pointer)), but that's not - # always the case. - ccflags += [ - '-mstackrealign', # ensure stack is aligned - '-msse', '-msse2', # enable SIMD intrinsics - '-mfpmath=sse', # generate SSE floating-point arithmetic - ] - if platform in ['windows', 'darwin']: - # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216 - ccflags += ['-fno-common'] - if platform in ['haiku']: - # Make optimizations compatible with Pentium or higher on Haiku - ccflags += [ - '-mstackrealign', # ensure stack is aligned - '-march=i586', # Haiku target is Pentium - '-mtune=i686' # use i686 where we can - ] - if env['machine'] == 'x86_64': - ccflags += ['-m64'] - if platform == 'darwin': - ccflags += ['-fno-common'] - if env['platform'] not in ('cygwin', 'haiku', 'windows'): - ccflags += ['-fvisibility=hidden'] - # See also: - # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html - ccflags += [ - '-Wall', - '-Wno-long-long', - '-fmessage-length=0', # be nice to Eclipse - ] - cflags += [ - '-Werror=implicit-function-declaration', - '-Werror=missing-prototypes', - '-Werror=return-type', - '-Werror=incompatible-pointer-types', - ] - if platform == 'darwin' and host_platform.mac_ver()[0] >= '10.15': - cflags += ['-std=gnu11'] - else: - cflags += ['-std=gnu99'] - cxxflags += ['-std=c++14'] - if icc: - cflags += [ - '-std=gnu99', - ] - if msvc: - # See also: - # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx - # - cl /? - if env['build'] == 'debug': - ccflags += [ - '/Od', # disable optimizations - '/Oi', # enable intrinsic functions - ] - else: - ccflags += [ - '/O2', # optimize for speed - ] - if env['build'] == 'release': - if not env['clang']: - ccflags += [ - '/GL', # enable whole program optimization - ] - else: - ccflags += [ - '/Oy-', # disable frame pointer omission - ] - ccflags += [ - '/W3', # warning level - '/wd4018', # signed/unsigned mismatch - '/wd4056', # overflow in floating-point constant arithmetic - '/wd4244', # conversion from 'type1' to 'type2', possible loss of data - '/wd4267', # 'var' : conversion from 'size_t' to 'type', possible loss of data - '/wd4305', # truncation from 'type1' to 'type2' - '/wd4351', # new behavior: elements of array 'array' will be default initialized - '/wd4756', # overflow in constant arithmetic - '/wd4800', # forcing value to bool 'true' or 'false' (performance warning) - '/wd4996', # disable deprecated POSIX name warnings - ] - if env['clang']: - ccflags += [ - '-Wno-microsoft-enum-value', # enumerator value is not representable in underlying type 'int' - ] - if env['machine'] == 'x86': - ccflags += [ - '/arch:SSE2', # use the SSE2 instructions (default since MSVC 2012) - ] - if platform == 'windows': - ccflags += [ - # TODO - ] - # Automatic pdb generation - # See http://scons.tigris.org/issues/show_bug.cgi?id=1656 - env.EnsureSConsVersion(0, 98, 0) - env['PDB'] = '${TARGET.base}.pdb' - env.Append(CCFLAGS = ccflags) - env.Append(CFLAGS = cflags) - env.Append(CXXFLAGS = cxxflags) - - if env['platform'] == 'windows' and msvc: - # Choose the appropriate MSVC CRT - # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - if env['build'] in ('debug', 'checked'): - env.Append(CCFLAGS = ['/MTd']) - env.Append(SHCCFLAGS = ['/LDd']) - else: - env.Append(CCFLAGS = ['/MT']) - env.Append(SHCCFLAGS = ['/LD']) - - # Static code analysis - if env['analyze']: - if env['msvc']: - # http://msdn.microsoft.com/en-us/library/ms173498.aspx - env.Append(CCFLAGS = [ - '/analyze', - #'/analyze:log', '${TARGET.base}.xml', - '/wd28251', # Inconsistent annotation for function - ]) - if env['clang']: - # scan-build will produce more comprehensive output - env.Append(CCFLAGS = ['--analyze']) - - # https://github.com/google/sanitizers/wiki/AddressSanitizer - if env['asan']: - if gcc_compat: - env.Append(CCFLAGS = [ - '-fsanitize=address', - ]) - env.Append(LINKFLAGS = [ - '-fsanitize=address', - ]) - - # Assembler options - if gcc_compat: - if env['machine'] == 'x86': - env.Append(ASFLAGS = ['-m32']) - if env['machine'] == 'x86_64': - env.Append(ASFLAGS = ['-m64']) - - # Linker options - linkflags = [] - shlinkflags = [] - if gcc_compat: - if env['machine'] == 'x86': - linkflags += ['-m32'] - if env['machine'] == 'x86_64': - linkflags += ['-m64'] - if env['platform'] not in ('darwin'): - shlinkflags += [ - '-Wl,-Bsymbolic', - ] - # Handle circular dependencies in the libraries - if env['platform'] in ('darwin'): - pass - else: - env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group' - if env['platform'] == 'windows': - linkflags += [ - '-Wl,--nxcompat', # DEP - '-Wl,--dynamicbase', # ASLR - ] - # Avoid depending on gcc runtime DLLs - linkflags += ['-static-libgcc'] - if 'w64' in env['CC'].split('-'): - linkflags += ['-static-libstdc++'] - # Handle the @xx symbol munging of DLL exports - shlinkflags += ['-Wl,--enable-stdcall-fixup'] - #shlinkflags += ['-Wl,--kill-at'] - if msvc: - if env['build'] == 'release' and not env['clang']: - # enable Link-time Code Generation - linkflags += ['/LTCG'] - env.Append(ARFLAGS = ['/LTCG']) - if platform == 'windows' and msvc: - # See also: - # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx - linkflags += [ - '/fixed:no', - '/incremental:no', - '/dynamicbase', # ASLR - '/nxcompat', # DEP - ] - env.Append(LINKFLAGS = linkflags) - env.Append(SHLINKFLAGS = shlinkflags) - - # We have C++ in several libraries, so always link with the C++ compiler - if gcc_compat: - env['LINK'] = env['CXX'] - - # Default libs - libs = [] - if env['platform'] in ('darwin', 'freebsd', 'linux', 'posix', 'sunos'): - libs += ['m', 'pthread', 'dl'] - if env['platform'] in ('linux',): - libs += ['rt'] - if env['platform'] in ('haiku'): - libs += ['root', 'be', 'network', 'translation'] - env.Append(LIBS = libs) - - # OpenMP - if env['openmp']: - if env['msvc']: - env.Append(CCFLAGS = ['/openmp']) - # When building openmp release VS2008 link.exe crashes with LNK1103 error. - # Workaround: overwrite PDB flags with empty value as it isn't required anyways - if env['build'] == 'release': - env['PDB'] = '' - if env['gcc']: - env.Append(CCFLAGS = ['-fopenmp']) - env.Append(LIBS = ['gomp']) - - # Load tools - env.Tool('lex') - if env['msvc']: - env.Append(LEXFLAGS = [ - # Force flex to use const keyword in prototypes, as relies on - # __cplusplus or __STDC__ macro to determine whether it's safe to - # use const keyword, but MSVC never defines __STDC__ unless we - # disable all MSVC extensions. - '-DYY_USE_CONST=', - ]) - # Flex relies on __STDC_VERSION__>=199901L to decide when to include - # C99 inttypes.h. We always have inttypes.h available with MSVC - # (either the one bundled with MSVC 2013, or the one we bundle - # ourselves), but we can't just define __STDC_VERSION__ without - # breaking stuff, as MSVC doesn't fully support C99. There's also no - # way to premptively include stdint. - env.Append(CCFLAGS = ['-FIinttypes.h']) - if host_platform.system() == 'Windows': - # Prefer winflexbison binaries, as not only they are easier to install - # (no additional dependencies), but also better Windows support. - if check_prog(env, 'win_flex'): - env["LEX"] = 'win_flex' - env.Append(LEXFLAGS = [ - # windows compatibility (uses <io.h> instead of <unistd.h> and - # _isatty, _fileno functions) - '--wincompat' - ]) - - env.Tool('yacc') - if host_platform.system() == 'Windows': - if check_prog(env, 'win_bison'): - env["YACC"] = 'win_bison' - - if env['llvm']: - env.Tool('llvm') - - # Custom builders and methods - env.Tool('custom') - env.AddMethod(install_program, 'InstallProgram') - env.AddMethod(install_shared_library, 'InstallSharedLibrary') - env.AddMethod(msvc2013_compat, 'MSVC2013Compat') - env.AddMethod(unit_test, 'UnitTest') - - env.PkgCheckModules('X11', ['x11', 'xext', 'xfixes', 'glproto >= 1.4.13', 'dri2proto >= 2.8']) - env.PkgCheckModules('XCB', ['x11-xcb', 'xcb-glx >= 1.8.1', 'xcb-dri2 >= 1.8']) - env.PkgCheckModules('XF86VIDMODE', ['xxf86vm']) - env.PkgCheckModules('DRM', ['libdrm >= 2.4.75']) - - if not os.path.exists("src/util/format_srgb.c"): - print("Checking for Python Mako module (>= 0.8.0)... ", end='') - try: - import mako - except ImportError: - print("no") - exit(1) - if distutils.version.StrictVersion(mako.__version__) < distutils.version.StrictVersion('0.8.0'): - print("no") - exit(1) - print("yes") - - if env['x11']: - env.Append(CPPPATH = env['X11_CPPPATH']) - - env['dri'] = env['x11'] and env['drm'] - - # for debugging - #print env.Dump() - - -def exists(env): - return 1 diff --git a/scons/llvm.py b/scons/llvm.py deleted file mode 100644 index a8d2860a3be..00000000000 --- a/scons/llvm.py +++ /dev/null @@ -1,350 +0,0 @@ -"""llvm - -Tool-specific initialization for LLVM - -""" - -# -# Copyright (c) 2009 VMware, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -import os -import os.path -import re -import platform as host_platform -import sys -import distutils.version - -import SCons.Errors -import SCons.Util - - -required_llvm_version = '3.9' - - -def generate(env): - env['llvm'] = False - - try: - llvm_dir = os.environ['LLVM'] - except KeyError: - # Do nothing -- use the system headers/libs - llvm_dir = None - else: - if not os.path.isdir(llvm_dir): - raise SCons.Errors.InternalError("Specified LLVM directory not found") - - if env['debug']: - llvm_subdir = 'Debug' - else: - llvm_subdir = 'Release' - - llvm_bin_dir = os.path.join(llvm_dir, llvm_subdir, 'bin') - if not os.path.isdir(llvm_bin_dir): - llvm_bin_dir = os.path.join(llvm_dir, 'bin') - if not os.path.isdir(llvm_bin_dir): - raise SCons.Errors.InternalError("LLVM binary directory not found") - - env.PrependENVPath('PATH', llvm_bin_dir) - - if env['platform'] == 'windows': - # XXX: There is no llvm-config on Windows, so assume a standard layout - if llvm_dir is None: - print('scons: LLVM environment variable must be specified when building for windows') - return - - # Try to determine the LLVM version from llvm/Config/config.h - llvm_config = os.path.join(llvm_dir, 'include/llvm/Config/llvm-config.h') - if not os.path.exists(llvm_config): - print('scons: could not find %s' % llvm_config) - return - llvm_version_major_re = re.compile(r'^#define LLVM_VERSION_MAJOR ([0-9]+)') - llvm_version_minor_re = re.compile(r'^#define LLVM_VERSION_MINOR ([0-9]+)') - llvm_version = None - llvm_version_major = None - llvm_version_minor = None - for line in open(llvm_config, 'rt'): - mo = llvm_version_major_re.match(line) - if mo: - llvm_version_major = mo.group(1) - mo = llvm_version_minor_re.match(line) - if mo: - llvm_version_minor = mo.group(1) - if llvm_version_major is not None and llvm_version_minor is not None: - llvm_version = distutils.version.LooseVersion('%s.%s' % (llvm_version_major, llvm_version_minor)) - - if llvm_version is None: - print('scons: could not determine the LLVM version from %s' % llvm_config) - return - if llvm_version < distutils.version.LooseVersion(required_llvm_version): - print('scons: LLVM version %s found, but %s is required' % (llvm_version, required_llvm_version)) - return - - env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')]) - env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')]) - - # LLVM 5.0 and newer requires MinGW w/ pthreads due to use of std::thread and friends. - if llvm_version >= distutils.version.LooseVersion('5.0') and env['crosscompile']: - assert env['gcc'] - env.AppendUnique(CXXFLAGS = ['-posix']) - - # LIBS should match the output of `llvm-config --libs engine mcjit bitwriter x86asmprinter irreader` for LLVM<=7.0 - # and `llvm-config --libs engine coroutines` for LLVM>=8.0 - # LLVMAggressiveInstCombine library part of engine component since LLVM 6 is only needed by Mesa3D for LLVM>=8. - # While not directly needed by Mesa3D, this library is needed by LLVMipo which is part of coroutines component. - if llvm_version >= distutils.version.LooseVersion('11.0'): - env.Prepend(LIBS = [ - 'LLVMX86Disassembler', 'LLVMX86AsmParser', - 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', - 'LLVMDebugInfoCodeView', 'LLVMCodeGen', - 'LLVMScalarOpts', 'LLVMInstCombine', - 'LLVMTransformUtils', - 'LLVMBitWriter', 'LLVMX86Desc', - 'LLVMMCDisassembler', 'LLVMX86Info', - 'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', - 'LLVMAnalysis', 'LLVMProfileData', - 'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', - 'LLVMBitReader', 'LLVMMC', 'LLVMCore', - 'LLVMSupport', - 'LLVMIRReader', 'LLVMAsmParser', - 'LLVMDemangle', 'LLVMGlobalISel', 'LLVMDebugInfoMSF', - 'LLVMBinaryFormat', - 'LLVMRemarks', 'LLVMBitstreamReader', 'LLVMDebugInfoDWARF', - 'LLVMAggressiveInstCombine','LLVMLinker', 'LLVMVectorize', - 'LLVMInstrumentation', 'LLVMipo', 'LLVMCoroutines', - 'LLVMCFGuard', 'LLVMTextAPI', - 'LLVMFrontendOpenMP', - ]) - elif llvm_version >= distutils.version.LooseVersion('10.0'): - env.Prepend(LIBS = [ - 'LLVMX86Disassembler', 'LLVMX86AsmParser', - 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', - 'LLVMDebugInfoCodeView', 'LLVMCodeGen', - 'LLVMScalarOpts', 'LLVMInstCombine', - 'LLVMTransformUtils', - 'LLVMBitWriter', 'LLVMX86Desc', - 'LLVMMCDisassembler', 'LLVMX86Info', - 'LLVMX86Utils', - 'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', - 'LLVMAnalysis', 'LLVMProfileData', - 'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', - 'LLVMBitReader', 'LLVMMC', 'LLVMCore', - 'LLVMSupport', - 'LLVMIRReader', 'LLVMAsmParser', - 'LLVMDemangle', 'LLVMGlobalISel', 'LLVMDebugInfoMSF', - 'LLVMBinaryFormat', - 'LLVMRemarks', 'LLVMBitstreamReader', 'LLVMDebugInfoDWARF', - 'LLVMAggressiveInstCombine','LLVMLinker', 'LLVMVectorize', - 'LLVMInstrumentation', 'LLVMipo', 'LLVMCoroutines', - 'LLVMCFGuard', 'LLVMTextAPI', - ]) - elif llvm_version >= distutils.version.LooseVersion('9.0'): - env.Prepend(LIBS = [ - 'LLVMX86Disassembler', 'LLVMX86AsmParser', - 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', - 'LLVMDebugInfoCodeView', 'LLVMCodeGen', - 'LLVMScalarOpts', 'LLVMInstCombine', - 'LLVMTransformUtils', - 'LLVMBitWriter', 'LLVMX86Desc', - 'LLVMMCDisassembler', 'LLVMX86Info', - 'LLVMX86Utils', - 'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', - 'LLVMAnalysis', 'LLVMProfileData', - 'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', - 'LLVMBitReader', 'LLVMMC', 'LLVMCore', - 'LLVMSupport', - 'LLVMIRReader', 'LLVMAsmParser', - 'LLVMDemangle', 'LLVMGlobalISel', 'LLVMDebugInfoMSF', - 'LLVMBinaryFormat', - 'LLVMRemarks', 'LLVMBitstreamReader', 'LLVMDebugInfoDWARF', - # Add these libraries to enable ompute shaders support. - 'LLVMAggressiveInstCombine','LLVMLinker', 'LLVMVectorize', - 'LLVMInstrumentation', 'LLVMipo', 'LLVMCoroutines', - ]) - elif llvm_version >= distutils.version.LooseVersion('8.0'): - env.Prepend(LIBS = [ - 'LLVMX86Disassembler', 'LLVMX86AsmParser', - 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', - 'LLVMDebugInfoCodeView', 'LLVMCodeGen', - 'LLVMScalarOpts', 'LLVMInstCombine', - 'LLVMTransformUtils', - 'LLVMBitWriter', 'LLVMX86Desc', - 'LLVMMCDisassembler', 'LLVMX86Info', - 'LLVMX86AsmPrinter', 'LLVMX86Utils', - 'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', - 'LLVMAnalysis', 'LLVMProfileData', - 'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', - 'LLVMBitReader', 'LLVMMC', 'LLVMCore', - 'LLVMSupport', - 'LLVMIRReader', 'LLVMAsmParser', - 'LLVMDemangle', 'LLVMGlobalISel', 'LLVMDebugInfoMSF', - 'LLVMBinaryFormat', - # Add these libraries to enable ompute shaders support. - 'LLVMAggressiveInstCombine', 'LLVMLinker', 'LLVMVectorize', - 'LLVMInstrumentation', 'LLVMipo', 'LLVMCoroutines', - ]) - elif llvm_version >= distutils.version.LooseVersion('5.0'): - env.Prepend(LIBS = [ - 'LLVMX86Disassembler', 'LLVMX86AsmParser', - 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', - 'LLVMDebugInfoCodeView', 'LLVMCodeGen', - 'LLVMScalarOpts', 'LLVMInstCombine', - 'LLVMTransformUtils', - 'LLVMBitWriter', 'LLVMX86Desc', - 'LLVMMCDisassembler', 'LLVMX86Info', - 'LLVMX86AsmPrinter', 'LLVMX86Utils', - 'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', - 'LLVMAnalysis', 'LLVMProfileData', - 'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', - 'LLVMBitReader', 'LLVMMC', 'LLVMCore', - 'LLVMSupport', - 'LLVMIRReader', 'LLVMAsmParser', - 'LLVMDemangle', 'LLVMGlobalISel', 'LLVMDebugInfoMSF', - 'LLVMBinaryFormat', - ]) - elif llvm_version >= distutils.version.LooseVersion('4.0'): - env.Prepend(LIBS = [ - 'LLVMX86Disassembler', 'LLVMX86AsmParser', - 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', - 'LLVMDebugInfoCodeView', 'LLVMCodeGen', - 'LLVMScalarOpts', 'LLVMInstCombine', - 'LLVMTransformUtils', - 'LLVMBitWriter', 'LLVMX86Desc', - 'LLVMMCDisassembler', 'LLVMX86Info', - 'LLVMX86AsmPrinter', 'LLVMX86Utils', - 'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', - 'LLVMAnalysis', 'LLVMProfileData', - 'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', - 'LLVMBitReader', 'LLVMMC', 'LLVMCore', - 'LLVMSupport', - 'LLVMIRReader', 'LLVMAsmParser', - 'LLVMDemangle', 'LLVMGlobalISel', 'LLVMDebugInfoMSF', - ]) - else: - env.Prepend(LIBS = [ - 'LLVMX86Disassembler', 'LLVMX86AsmParser', - 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', - 'LLVMDebugInfoCodeView', 'LLVMCodeGen', - 'LLVMScalarOpts', 'LLVMInstCombine', - 'LLVMInstrumentation', 'LLVMTransformUtils', - 'LLVMBitWriter', 'LLVMX86Desc', - 'LLVMMCDisassembler', 'LLVMX86Info', - 'LLVMX86AsmPrinter', 'LLVMX86Utils', - 'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', - 'LLVMAnalysis', 'LLVMProfileData', - 'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', - 'LLVMBitReader', 'LLVMMC', 'LLVMCore', - 'LLVMSupport', - 'LLVMIRReader', 'LLVMASMParser' - ]) - env.Append(LIBS = [ - 'imagehlp', - 'psapi', - 'shell32', - 'advapi32', - 'ole32', - 'uuid', - ]) - - # Mingw-w64 zlib is required when building with LLVM support in MSYS2 environment - if host_platform.system().lower().startswith('mingw'): - env.Append(LIBS = [ - 'z', - ]) - - if env['msvc']: - # Some of the LLVM C headers use the inline keyword without - # defining it. - env.Append(CPPDEFINES = [('inline', '__inline')]) - # Match some of the warning options from llvm/cmake/modules/HandleLLVMOptions.cmake - env.AppendUnique(CXXFLAGS = [ - '/wd4355', # 'this' : used in base member initializer list - '/wd4624', # 'derived class' : destructor could not be generated because a base class destructor is inaccessible - ]) - if env['build'] in ('debug', 'checked'): - # LLVM libraries are static, build with /MT, and they - # automatically link agains LIBCMT. When we're doing a - # debug build we'll be linking against LIBCMTD, so disable - # that. - env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT']) - else: - llvm_config = os.environ.get('LLVM_CONFIG', 'llvm-config') - if not env.Detect(llvm_config): - print('scons: %s script not found' % llvm_config) - return - - llvm_version = env.backtick('%s --version' % llvm_config).rstrip() - llvm_version = distutils.version.LooseVersion(llvm_version) - - if llvm_version < distutils.version.LooseVersion(required_llvm_version): - print('scons: LLVM version %s found, but %s is required' % (llvm_version, required_llvm_version)) - return - - try: - # Treat --cppflags specially to prevent NDEBUG from disabling - # assertion failures in debug builds. - cppflags = env.ParseFlags('!%s --cppflags' % llvm_config) - try: - cppflags['CPPDEFINES'].remove('NDEBUG') - except ValueError: - pass - env.MergeFlags(cppflags) - - # Match llvm --fno-rtti flag - cxxflags = env.backtick('%s --cxxflags' % llvm_config).split() - if '-fno-rtti' in cxxflags: - env.Append(CXXFLAGS = ['-fno-rtti']) - - if llvm_version < distutils.version.LooseVersion('9.0'): - components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler', 'irreader'] - else: - components = ['engine', 'mcjit', 'bitwriter', 'mcdisassembler', 'irreader'] - - if llvm_version >= distutils.version.LooseVersion('8.0'): - components.append('coroutines') - - if llvm_version >= distutils.version.LooseVersion('12.0'): - components.append('native') - - env.ParseConfig('%s --libs ' % llvm_config + ' '.join(components)) - env.ParseConfig('%s --ldflags' % llvm_config) - env.ParseConfig('%s --system-libs' % llvm_config) - env.Append(CXXFLAGS = ['-std=c++14']) - except OSError: - print('scons: llvm-config version %s failed' % llvm_version) - return - - assert llvm_version is not None - env['llvm'] = True - - print('scons: Found LLVM version %s' % llvm_version) - env['LLVM_VERSION'] = llvm_version - - # Define LLVM_AVAILABLE macro to guard code blocks, and MESA_LLVM_VERSION_STRING - env.Prepend(CPPDEFINES = [('LLVM_AVAILABLE', 1)]) - env.Prepend(CPPDEFINES = [('DRAW_LLVM_AVAILABLE', 1)]) - env.Prepend(CPPDEFINES = [('MESA_LLVM_VERSION_STRING=\\"%s\\"' % llvm_version)]) - -def exists(env): - return True - -# vim:set ts=4 sw=4 et: diff --git a/scons/source_list.py b/scons/source_list.py deleted file mode 100644 index e16d1f9b6d2..00000000000 --- a/scons/source_list.py +++ /dev/null @@ -1,130 +0,0 @@ -"""Source List Parser - -The syntax of a source list file is a very small subset of GNU Make. These -features are supported - - operators: =, +=, := - line continuation - non-nested variable expansion - comment - -The goal is to allow Makefile's and SConscript's to share source listing. -""" - -class SourceListParser(object): - def __init__(self): - self.symbol_table = {} - self._reset() - - def _reset(self, filename=None): - self.filename = filename - - self.line_no = 1 - self.line_cont = '' - - def _error(self, msg): - raise RuntimeError('%s:%d: %s' % (self.filename, self.line_no, msg)) - - def _next_dereference(self, val, cur): - """Locate the next $(...) in value.""" - deref_pos = val.find('$', cur) - if deref_pos < 0: - return (-1, -1) - elif val[deref_pos + 1] != '(': - self._error('non-variable dereference') - - deref_end = val.find(')', deref_pos + 2) - if deref_end < 0: - self._error('unterminated variable dereference') - - return (deref_pos, deref_end + 1) - - def _expand_value(self, val): - """Perform variable expansion.""" - expanded = '' - cur = 0 - while True: - deref_pos, deref_end = self._next_dereference(val, cur) - if deref_pos < 0: - expanded += val[cur:] - break - - sym = val[(deref_pos + 2):(deref_end - 1)] - expanded += val[cur:deref_pos] + self.symbol_table[sym] - cur = deref_end - - return expanded - - def _parse_definition(self, line): - """Parse a variable definition line.""" - op_pos = line.find('=') - op_end = op_pos + 1 - if op_pos < 0: - self._error('not a variable definition') - - if op_pos > 0: - if line[op_pos - 1] in [':', '+', '?']: - op_pos -= 1 - else: - self._error('only =, :=, and += are supported') - - # set op, sym, and val - op = line[op_pos:op_end] - sym = line[:op_pos].strip() - val = self._expand_value(line[op_end:].lstrip()) - - if op in ('=', ':='): - self.symbol_table[sym] = val - elif op == '+=': - self.symbol_table[sym] += ' ' + val - elif op == '?=': - if sym not in self.symbol_table: - self.symbol_table[sym] = val - - def _parse_line(self, line): - """Parse a source list line.""" - # more lines to come - if line and line[-1] == '\\': - # spaces around "\\\n" are replaced by a single space - if self.line_cont: - self.line_cont += line[:-1].strip() + ' ' - else: - self.line_cont = line[:-1].rstrip() + ' ' - return 0 - - # combine with previous lines - if self.line_cont: - line = self.line_cont + line.lstrip() - self.line_cont = '' - - if line: - begins_with_tab = (line[0] == '\t') - - line = line.lstrip() - if line[0] != '#': - if begins_with_tab: - self._error('recipe line not supported') - else: - self._parse_definition(line) - - return 1 - - def parse(self, filename): - """Parse a source list file.""" - if self.filename != filename: - fp = open(filename) - lines = fp.read().splitlines() - fp.close() - - try: - self._reset(filename) - for line in lines: - self.line_no += self._parse_line(line) - except: - self._reset() - raise - - return self.symbol_table - - def add_symbol(self, name, value): - self.symbol_table[name] = value diff --git a/scons/x11.py b/scons/x11.py deleted file mode 100644 index d25897aad7f..00000000000 --- a/scons/x11.py +++ /dev/null @@ -1,51 +0,0 @@ -"""x11 - -Tool-specific initialization for X11 - -""" - -# -# Copyright (c) 2010 VMware, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - - -def generate(env): - env.Append(CPPPATH = ['/usr/X11R6/include']) - env.Append(LIBPATH = ['/usr/X11R6/lib']) - - env.Append(LIBS = [ - 'X11', - 'Xext', - 'Xxf86vm', - 'Xfixes', - ]) - - -def exists(env): - # TODO: actually detect the presence of the headers - if env['platform'] in ('linux', 'freebsd', 'darwin'): - return True - else: - return False - - -# vim:set ts=4 sw=4 et: |