scons: Remove.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9720>
This commit is contained in:
Jose Fonseca 2021-03-19 20:08:54 +00:00 committed by Marge Bot
parent 85c1770044
commit 6e6cd7d93c
48 changed files with 4 additions and 3760 deletions

View File

@ -13,17 +13,12 @@ matrix:
include:
- env:
- BUILD=meson
- env:
- BUILD=scons
before_install:
- HOMEBREW_NO_AUTO_UPDATE=1 brew install expat gettext
- if test "x$BUILD" = xmeson; then
HOMEBREW_NO_AUTO_UPDATE=1 brew install ninja;
fi
- if test "x$BUILD" = xscons; then
HOMEBREW_NO_AUTO_UPDATE=1 brew install scons;
fi
# Set PATH for homebrew pip3 installs
- PYTHON_VERSION=$(python3 -V | awk '{print $2}' | cut -d. -f1-2)
@ -47,9 +42,6 @@ install:
pip3 install --user meson;
pip3 install --user mako;
fi
- if test "x$BUILD" = xscons; then
pip2 install --user mako;
fi
script:
- if test "x$BUILD" = xmeson; then
@ -58,7 +50,3 @@ script:
ninja -C _build test || travis_terminate 1;
ninja -C _build install || travis_terminate 1;
fi
- if test "x$BUILD" = xscons; then
scons force_scons=1 || travis_terminate 1;
scons force_scons=1 check || travis_terminate 1;
fi

View File

@ -67,11 +67,6 @@ GALLIUM TARGETS
R: Emil Velikov <emil.l.velikov@gmail.com>
F: src/gallium/targets/
SCONS BUILD
F: scons/
F: */SConscript*
F: */Makefile.sources
ANDROID BUILD
R: Emil Velikov <emil.l.velikov@gmail.com>
R: Rob Herring <robh@kernel.org>

View File

@ -1,187 +0,0 @@
#######################################################################
# Top-level SConstruct
#
# For example, invoke scons as
#
# scons build=debug llvm=yes machine=x86
#
# to set configuration variables. Or you can write those options to a file
# named config.py:
#
# # config.py
# build='debug'
# llvm=True
# machine='x86'
#
# Invoke
#
# scons -h
#
# to get the full list of options. See scons manpage for more info.
#
from __future__ import print_function
import os
import os.path
import sys
import SCons.Util
import common
#######################################################################
# Minimal scons version
EnsureSConsVersion(2, 4)
EnsurePythonVersion(2, 7)
#######################################################################
# Configuration options
opts = Variables('config.py')
common.AddOptions(opts)
env = Environment(
options = opts,
tools = ['gallium'],
toolpath = ['#scons'],
ENV = os.environ,
)
# XXX: This creates a many problems as it saves...
#opts.Save('config.py', env)
# Backwards compatability with old target configuration variable
try:
targets = ARGUMENTS['targets']
except KeyError:
pass
else:
targets = targets.split(',')
print('scons: warning: targets option is deprecated; pass the targets on their own such as')
print()
print(' scons %s' % ' '.join(targets))
print()
COMMAND_LINE_TARGETS.append(targets)
Help(opts.GenerateHelpText(env))
#######################################################################
# Print a deprecation warning for using scons on non-windows
if common.host_platform != 'windows' and env['platform'] != 'windows':
if env['force_scons']:
print("WARNING: Scons is deprecated for non-windows platforms (including cygwin) "
"please use meson instead.", file=sys.stderr)
else:
print("ERROR: Scons is deprecated for non-windows platforms (including cygwin) "
"please use meson instead. If you really need to use scons you "
"can add `force_scons=1` to the scons command line.", file=sys.stderr)
sys.exit(1)
else:
print("WARNING: Scons support is in the process of being deprecated on "
"on windows platforms (including mingw). If you haven't already "
"please try using meson for windows builds. Be sure to report any "
"issues you run into", file=sys.stderr)
#######################################################################
# Environment setup
with open("VERSION") as f:
mesa_version = f.read().strip()
env.Append(CPPDEFINES = [
('PACKAGE_VERSION', '\\"%s\\"' % mesa_version),
('PACKAGE_BUGREPORT', '\\"https://gitlab.freedesktop.org/mesa/mesa/-/issues\\"'),
])
# Includes
env.Prepend(CPPPATH = [
'#/include',
])
env.Append(CPPPATH = [
'#/src/gallium/include',
'#/src/gallium/auxiliary',
'#/src/gallium/drivers',
'#/src/gallium/winsys',
])
# for debugging
#print env.Dump()
# Add a check target for running tests
check = env.Alias('check')
env.AlwaysBuild(check)
#######################################################################
# Invoke host SConscripts
#
# For things that are meant to be run on the native host build machine, instead
# of the target machine.
#
# Create host environent
if env['crosscompile'] and not env['embedded']:
host_env = Environment(
options = opts,
# no tool used
tools = [],
toolpath = ['#scons'],
ENV = os.environ,
)
# Override options
host_env['platform'] = common.host_platform
host_env['machine'] = common.host_machine
host_env['toolchain'] = 'default'
host_env['llvm'] = False
host_env.Tool('gallium')
host_env['hostonly'] = True
assert host_env['crosscompile'] == False
target_env = env
env = host_env
Export('env')
SConscript(
'src/SConscript',
variant_dir = host_env['build_dir'],
duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
)
env = target_env
Export('env')
#######################################################################
# Invoke SConscripts
# TODO: Build several variants at the same time?
# http://www.scons.org/wiki/SimultaneousVariantBuilds
SConscript(
'src/SConscript',
variant_dir = env['build_dir'],
duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
)
########################################################################
# List all aliases
try:
from SCons.Node.Alias import default_ans
except ImportError:
pass
else:
aliases = sorted(default_ans.keys())
env.Help('\n')
env.Help('Recognized targets:\n')
for alias in aliases:
env.Help(' %s\n' % alias)

124
common.py
View File

@ -1,124 +0,0 @@
#######################################################################
# Common SCons code
import os
import os.path
import re
import subprocess
import sys
import platform as _platform
import SCons.Script.SConscript
#######################################################################
# Defaults
host_platform = _platform.system().lower()
if host_platform.startswith('cygwin'):
host_platform = 'cygwin'
# MSYS2 default platform selection.
if host_platform.startswith('mingw'):
host_platform = 'windows'
# Search sys.argv[] for a "platform=foo" argument since we don't have
# an 'env' variable at this point.
if 'platform' in SCons.Script.ARGUMENTS:
target_platform = SCons.Script.ARGUMENTS['platform']
else:
target_platform = host_platform
_machine_map = {
'x86': 'x86',
'i386': 'x86',
'i486': 'x86',
'i586': 'x86',
'i686': 'x86',
'BePC': 'x86',
'Intel': 'x86',
'ppc': 'ppc',
'BeBox': 'ppc',
'BeMac': 'ppc',
'AMD64': 'x86_64',
'x86_64': 'x86_64',
'sparc': 'sparc',
'sun4u': 'sparc',
}
# find host_machine value
if 'PROCESSOR_ARCHITECTURE' in os.environ:
host_machine = os.environ['PROCESSOR_ARCHITECTURE']
else:
host_machine = _platform.machine()
host_machine = _machine_map.get(host_machine, 'generic')
# MSYS2 default machine selection.
if _platform.system().lower().startswith('mingw') and 'MSYSTEM' in os.environ:
if os.environ['MSYSTEM'] == 'MINGW32':
host_machine = 'x86'
if os.environ['MSYSTEM'] == 'MINGW64':
host_machine = 'x86_64'
default_machine = host_machine
default_toolchain = 'default'
# MSYS2 default toolchain selection.
if _platform.system().lower().startswith('mingw'):
default_toolchain = 'mingw'
if target_platform == 'windows' and host_platform != 'windows':
default_machine = 'x86'
default_toolchain = 'crossmingw'
# find default_llvm value
if 'LLVM' in os.environ or 'LLVM_CONFIG' in os.environ:
default_llvm = 'yes'
else:
default_llvm = 'no'
try:
if target_platform != 'windows' and \
subprocess.call(['llvm-config', '--version'],
stdout=subprocess.PIPE) == 0:
default_llvm = 'yes'
except:
pass
#######################################################################
# Common options
def AddOptions(opts):
try:
from SCons.Variables.BoolVariable import BoolVariable as BoolOption
except ImportError:
from SCons.Options.BoolOption import BoolOption
try:
from SCons.Variables.EnumVariable import EnumVariable as EnumOption
except ImportError:
from SCons.Options.EnumOption import EnumOption
opts.Add(EnumOption('build', 'build type', 'debug',
allowed_values=('debug', 'checked', 'profile',
'release')))
opts.Add(BoolOption('verbose', 'verbose output', 'no'))
opts.Add(EnumOption('machine', 'use machine-specific assembly code',
default_machine,
allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
opts.Add(EnumOption('platform', 'target platform', host_platform,
allowed_values=('cygwin', 'darwin', 'freebsd', 'haiku',
'linux', 'sunos', 'windows')))
opts.Add(BoolOption('embedded', 'embedded build', 'no'))
opts.Add(BoolOption('analyze',
'enable static code analysis where available', 'no'))
opts.Add(BoolOption('asan', 'enable Address Sanitizer', 'no'))
opts.Add('toolchain', 'compiler toolchain', default_toolchain)
opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
opts.Add(BoolOption('force_scons', 'Force enable scons on deprecated platforms', 'false'))
opts.Add(BoolOption('openmp', 'EXPERIMENTAL: compile with openmp (swrast)',
'no'))
opts.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes'))
opts.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no'))
opts.Add(BoolOption('quiet', 'DEPRECATED: profile build', 'yes'))
opts.Add(BoolOption('swr', 'Build OpenSWR', 'no'))
if host_platform == 'windows':
opts.Add('MSVC_VERSION', 'Microsoft Visual C/C++ version')
opts.Add('MSVC_USE_SCRIPT', 'Microsoft Visual C/C++ vcvarsall script', True)

View File

@ -1,64 +0,0 @@
File: docs/README.WIN32
Last updated: 21 June 2013
Quick Start
----- -----
Windows drivers are build with SCons. Makefiles or Visual Studio projects are
no longer shipped or supported.
Run
scons libgl-gdi
to build gallium based GDI driver.
This will work both with MSVS or Mingw.
Windows Drivers
------- -------
At this time, only the gallium GDI driver is known to work.
Source code also exists in the tree for other drivers in
src/mesa/drivers/windows, but the status of this code is unknown.
Recipe
------
Building on windows requires several open-source packages. These are
steps that work as of this writing.
- install python 2.7
- install scons (latest)
- install mingw, flex, and bison
- install pywin32 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs
get pywin32-218.4.win-amd64-py2.7.exe
- install git
- download mesa from git
see https://www.mesa3d.org/repository.html
- run scons
General
-------
After building, you can copy the above DLL files to a place in your
PATH such as $SystemRoot/SYSTEM32. If you don't like putting things
in a system directory, place them in the same directory as the
executable(s). Be careful about accidentially overwriting files of
the same name in the SYSTEM32 directory.
The DLL files are built so that the external entry points use the
stdcall calling convention.
Static LIB files are not built. The LIB files that are built with are
the linker import files associated with the DLL files.
The si-glu sources are used to build the GLU libs. This was done
mainly to get the better tessellator code.
If you have a Windows-related build problem or question, please post
to the mesa-dev or mesa-users list.

View File

@ -14,7 +14,7 @@ modified and thus is unreliable).
The CI runs a number of tests, from trivial build-testing to complex GPU rendering:
- Build testing for a number of build systems, configurations and platforms
- Sanity checks (``meson test`` & ``scons check``)
- Sanity checks (``meson test``)
- Some drivers (softpipe, llvmpipe, freedreno and panfrost) are also tested
using `VK-GL-CTS <https://github.com/KhronosGroup/VK-GL-CTS>`__
- Replay of application traces

View File

@ -8,7 +8,7 @@ with debugging. If ``MESA_DEBUG`` is defined, a message will be printed
to stdout whenever an error occurs.
More extensive error checking is done in DEBUG builds
(``--buildtype debug`` for Meson, ``build=debug`` for SCons).
(``--buildtype debug`` for Meson).
In your debugger you can set a breakpoint in ``_mesa_error()`` to trap
Mesa errors.

View File

@ -68,18 +68,10 @@ Requirements
You can build only the x86 target by passing
``-DLLVM_TARGETS_TO_BUILD=X86`` to cmake.
- scons (optional)
Building
--------
To build everything on Linux invoke scons as:
.. code-block:: console
scons build=debug libgl-xlib
Alternatively, you can build it with meson with:
To build everything on Linux invoke meson as:
.. code-block:: console
@ -88,12 +80,6 @@ Alternatively, you can build it with meson with:
meson -D glx=gallium-xlib -D gallium-drivers=swrast
ninja
but the rest of these instructions assume that scons is used. For
Windows the procedure is similar except the target:
.. code-block:: console
scons platform=windows build=debug libgl-gdi
Using
-----
@ -116,9 +102,6 @@ or
To use it set the ``LD_LIBRARY_PATH`` environment variable accordingly.
For performance evaluation pass ``build=release`` to scons, and use the
corresponding lib directory without the ``-debug`` suffix.
Windows
~~~~~~~
@ -156,15 +139,6 @@ on systems without any OpenGL drivers):
Profiling
---------
To profile llvmpipe you should build as
::
scons build=profile <same-as-before>
This will ensure that frame pointers are used both in C and JIT
functions, and that no tail call optimizations are done by gcc.
Linux perf integration
~~~~~~~~~~~~~~~~~~~~~~

View File

@ -219,7 +219,6 @@ Most of the testing should already be done during the
:ref:`cherry-pick <pickntest>` So we do a quick 'touch test'
- meson dist
- scons (from release tarball)
- the produced binaries work
Here is one solution:

View File

@ -980,7 +980,7 @@ elif host_machine.system() == 'windows'
pre_args += [
'-D_WINDOWS', '-D_WIN32_WINNT=0x0A00', '-DWINVER=0x0A00',
'-DPIPE_SUBSYSTEM_WINDOWS_USER',
'-D_USE_MATH_DEFINES', # XXX: scons doesn't use this for mingw
'-D_USE_MATH_DEFINES', # XXX: scons didn't use this for mingw
]
if cc.get_id() == 'msvc'
pre_args += [

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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:

View File

@ -1,50 +0,0 @@
import filecmp
import os
import subprocess
from sys import executable as python_cmd
Import('*')
if env['platform'] == 'windows':
SConscript('getopt/SConscript')
SConscript('util/SConscript')
SConscript('compiler/SConscript')
if env['hostonly']:
# We are just compiling the things necessary on the host for cross
# compilation
Return()
def write_git_sha1_h_file(filename):
"""Mesa looks for a git_sha1.h file at compile time in order to display
the current git hash id in the GL_VERSION string. This function tries
to retrieve the git hashid and write the header file. An empty file
will be created if anything goes wrong."""
args = [ python_cmd, Dir('#').abspath + '/bin/git_sha1_gen.py', '--output', filename ]
try:
subprocess.call(args)
except:
print("Warning: exception in write_git_sha1_h_file()")
return
# Create the git_sha1.h header file
write_git_sha1_h_file("git_sha1.h")
# and update CPPPATH so the git_sha1.h header can be found
env.Append(CPPPATH = ["#" + env['build_dir']])
if env['platform'] != 'windows':
SConscript('loader/SConscript')
SConscript('mapi/glapi/gen/SConscript')
SConscript('mapi/glapi/SConscript')
SConscript('mesa/SConscript')
SConscript('gallium/SConscript')

View File

@ -1,30 +0,0 @@
Import('*')
env = env.Clone()
env.MSVC2013Compat()
env.Prepend(CPPPATH = [
'#include',
'#src',
'#src/mapi',
'#src/mesa',
'#src/gallium/include',
'#src/gallium/auxiliary',
])
# Make generated headers reachable from the include path.
env.Prepend(CPPPATH = [Dir('.').abspath, Dir('glsl').abspath])
env.Prepend(CPPPATH = [Dir('.').abspath, Dir('nir').abspath])
sources = env.ParseSourceList('Makefile.sources', 'LIBCOMPILER_FILES')
compiler = env.ConvenienceLibrary(
target = 'compiler',
source = sources
)
Export('compiler')
SConscript('SConscript.glsl')
SConscript('SConscript.nir')
SConscript('SConscript.spirv')

View File

@ -1,159 +0,0 @@
import common
Import('*')
from sys import executable as python_cmd
env = env.Clone()
env.MSVC2013Compat()
env.Prepend(CPPPATH = [
'#include',
'#src',
'#src/mapi',
'#src/mesa',
'#src/gallium/include',
'#src/gallium/auxiliary',
'#src/compiler/glsl',
'#src/compiler/glsl/glcpp',
'#src/compiler/nir',
])
env.Prepend(LIBS = [mesautil])
# Make glcpp-parse.h and glsl_parser.h reachable from the include path.
env.Prepend(CPPPATH = [Dir('.').abspath, Dir('glsl').abspath])
# Make NIR headers reachable from the include path.
env.Prepend(CPPPATH = [Dir('.').abspath, Dir('nir').abspath])
glcpp_env = env.Clone()
glcpp_env.Append(YACCFLAGS = [
'-d',
'-p', 'glcpp_parser_'
])
glsl_env = env.Clone()
glsl_env.Append(YACCFLAGS = [
'--defines=%s' % File('glsl/glsl_parser.h').abspath,
'-p', '_mesa_glsl_',
])
# without this line scons will expect "glsl_parser.hpp" instead of
# "glsl_parser.h", causing glsl_parser.cpp to be regenerated every time
glsl_env['YACCHXXFILESUFFIX'] = '.h'
glcpp_lexer = glcpp_env.CFile('glsl/glcpp/glcpp-lex.c', 'glsl/glcpp/glcpp-lex.l')
glcpp_parser = glcpp_env.CFile('glsl/glcpp/glcpp-parse.c', 'glsl/glcpp/glcpp-parse.y')
glsl_lexer = glsl_env.CXXFile('glsl/glsl_lexer.cpp', 'glsl/glsl_lexer.ll')
glsl_parser = glsl_env.CXXFile('glsl/glsl_parser.cpp', 'glsl/glsl_parser.yy')
# common generated sources
glsl_sources = [
glcpp_lexer,
glcpp_parser[0],
glsl_lexer,
glsl_parser[0],
]
# parse Makefile.sources
source_lists = env.ParseSourceList('Makefile.sources')
# add non-generated sources
for l in ('LIBGLCPP_FILES', 'LIBGLSL_FILES'):
glsl_sources += source_lists[l]
glsl_sources += env.StaticObject("glsl/glcpp/pp_standalone_scaffolding.c")
if env['msvc']:
env.Prepend(CPPPATH = ['#/src/getopt'])
env.PrependUnique(LIBS = [getopt])
# Copy these files to avoid generation object files into src/mesa/program
env.Prepend(CPPPATH = ['#src/mesa/main'])
env.Command('glsl/extensions_table.c', '#src/mesa/main/extensions_table.c', Copy('$TARGET', '$SOURCE'))
# Copy these files to avoid generation object files into src/mesa/program
env.Prepend(CPPPATH = ['#src/mesa/program'])
env.Command('glsl/symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE'))
env.Command('glsl/dummy_errors.c', '#src/mesa/program/dummy_errors.c', Copy('$TARGET', '$SOURCE'))
compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
mesa_objs = env.StaticObject([
'glsl/extensions_table.c',
'glsl/symbol_table.c',
'glsl/dummy_errors.c',
])
compiler_objs += mesa_objs
# GLSL generated sources
env.CodeGenerate(
target = 'glsl/float64_glsl.h',
script = '../util/xxd.py',
source = ['glsl/float64.glsl'],
command = python_cmd + ' $SCRIPT $SOURCE $TARGET -n float64_source',
)
env.CodeGenerate(
target = 'glsl/ir_expression_operation.h',
script = 'glsl/ir_expression_operation.py',
source = [],
command = python_cmd + ' $SCRIPT enum > $TARGET'
)
env.CodeGenerate(
target = 'glsl/ir_expression_operation_constant.h',
script = 'glsl/ir_expression_operation.py',
source = [],
command = python_cmd + ' $SCRIPT constant > $TARGET'
)
env.CodeGenerate(
target = 'glsl/ir_expression_operation_strings.h',
script = 'glsl/ir_expression_operation.py',
source = [],
command = python_cmd + ' $SCRIPT strings > $TARGET'
)
glsl = env.ConvenienceLibrary(
target = 'glsl',
source = glsl_sources,
)
# SCons builtin dependency scanner doesn't detect that glsl_lexer.ll depends on
# glsl_parser.h
env.Depends(glsl, glsl_parser)
Export('glsl')
#
# XXX: It's important to not add any generated source files after this point,
# or it will break MinGW cross-compilation.
#
# Skip building these programs as they will cause SCons error "Two environments
# with different actions were specified for the same target"
if env['crosscompile'] or env['embedded']:
Return()
env = env.Clone()
if env['platform'] == 'windows':
env.PrependUnique(LIBS = [
'user32',
])
env.Prepend(LIBS = [compiler, glsl])
compiler_objs += env.StaticObject("glsl/main.cpp")
glsl_compiler = env.Program(
target = 'glsl_compiler',
source = compiler_objs,
)
env.Alias('glsl_compiler', glsl_compiler)
glcpp = env.Program(
target = 'glsl/glcpp/glcpp',
source = ['glsl/glcpp/glcpp.c'] + mesa_objs,
)
env.Alias('glcpp', glcpp)

View File

@ -1,97 +0,0 @@
import common
Import('*')
from sys import executable as python_cmd
env = env.Clone()
env.MSVC2013Compat()
env.Prepend(CPPPATH = [
'#include',
'#src',
'#src/mapi',
'#src/mesa',
'#src/gallium/include',
'#src/gallium/auxiliary',
'#src/compiler/nir',
])
# Make generated headers reachable from the include path.
env.Prepend(CPPPATH = [Dir('.').abspath, Dir('glsl').abspath])
env.Prepend(CPPPATH = [Dir('.').abspath, Dir('nir').abspath])
# nir generated sources
nir_builder_opcodes_h = env.CodeGenerate(
target = 'nir/nir_builder_opcodes.h',
script = 'nir/nir_builder_opcodes_h.py',
source = [],
command = python_cmd + ' $SCRIPT > $TARGET'
)
env.CodeGenerate(
target = 'nir/nir_constant_expressions.c',
script = 'nir/nir_constant_expressions.py',
source = [],
command = python_cmd + ' $SCRIPT > $TARGET'
)
env.CodeGenerate(
target = 'nir/nir_opcodes.h',
script = 'nir/nir_opcodes_h.py',
source = [],
command = python_cmd + ' $SCRIPT > $TARGET'
)
env.CodeGenerate(
target = 'nir/nir_opcodes.c',
script = 'nir/nir_opcodes_c.py',
source = [],
command = python_cmd + ' $SCRIPT > $TARGET'
)
env.CodeGenerate(
target = 'nir/nir_opt_algebraic.c',
script = 'nir/nir_opt_algebraic.py',
source = [],
command = python_cmd + ' $SCRIPT > $TARGET'
)
bldroot = Dir('.').abspath
env.CodeGenerate(
target = 'nir/nir_intrinsics.h',
script = 'nir/nir_intrinsics_h.py',
source = [],
command = python_cmd + ' $SCRIPT --outdir ' + bldroot + '/nir'
)
env.CodeGenerate(
target = 'nir/nir_intrinsics.c',
script = 'nir/nir_intrinsics_c.py',
source = [],
command = python_cmd + ' $SCRIPT --outdir ' + bldroot + '/nir'
)
env.CodeGenerate(
target = 'nir/nir_intrinsics_indices.h',
script = 'nir/nir_intrinsics_indices_h.py',
source = [],
command = python_cmd + ' $SCRIPT --outdir ' + bldroot + '/nir'
)
# parse Makefile.sources
source_lists = env.ParseSourceList('Makefile.sources')
nir_sources = source_lists['NIR_FILES']
nir_sources += source_lists['NIR_GENERATED_FILES']
nir = env.ConvenienceLibrary(
target = 'nir',
source = nir_sources,
)
env.Alias('nir', nir)
Export('nir')

View File

@ -1,61 +0,0 @@
import common
Import('*')
from sys import executable as python_cmd
env = env.Clone()
env.MSVC2013Compat()
env.Prepend(CPPPATH = [
'#include',
'#src',
'#src/mapi',
'#src/mesa',
'#src/gallium/include',
'#src/gallium/auxiliary',
'#src/compiler/nir',
'#src/compiler/spirv',
])
# Make generated headers reachable from the include path.
env.Prepend(CPPPATH = [Dir('.').abspath, Dir('nir').abspath])
env.Prepend(CPPPATH = [Dir('.').abspath, Dir('spirv').abspath])
# spirv generated sources
env.CodeGenerate(
target = 'spirv/spirv_info.c',
script = 'spirv/spirv_info_c.py',
source = ['spirv/spirv.core.grammar.json'],
command = python_cmd + ' $SCRIPT $SOURCE $TARGET'
)
env.CodeGenerate(
target = 'spirv/vtn_gather_types.c',
script = 'spirv/vtn_gather_types_c.py',
source = ['spirv/spirv.core.grammar.json'],
command = python_cmd + ' $SCRIPT $SOURCE $TARGET'
)
env.CodeGenerate(
target = 'spirv/vtn_generator_ids.h',
script = 'spirv/vtn_generator_ids_h.py',
source = ['spirv/spir-v.xml'],
command = python_cmd + ' $SCRIPT $SOURCE $TARGET'
)
# parse Makefile.sources
source_lists = env.ParseSourceList('Makefile.sources')
spirv_sources = source_lists['SPIRV_FILES']
spirv_sources += source_lists['SPIRV_GENERATED_FILES']
spirv = env.ConvenienceLibrary(
target = 'spirv',
source = spirv_sources,
)
env.Alias('spirv', spirv)
Export('spirv')

View File

@ -1,56 +0,0 @@
Import('env')
#
# Auxiliary modules
#
SConscript('auxiliary/SConscript')
SConscript('auxiliary/pipe-loader/SConscript')
#
# Drivers
#
# These are common and work across all platforms
SConscript([
'drivers/llvmpipe/SConscript',
'drivers/softpipe/SConscript',
'drivers/svga/SConscript',
])
#
# Winsys
#
SConscript([
'winsys/sw/null/SConscript',
'winsys/sw/wrapper/SConscript',
])
if env['x11']:
SConscript([
'winsys/sw/xlib/SConscript',
])
if env['platform'] == 'windows':
SConscript([
'winsys/sw/gdi/SConscript',
])
#
# Frontends and targets
#
if not env['embedded']:
if env['x11']:
SConscript([
'frontends/glx/xlib/SConscript',
'targets/libgl-xlib/SConscript',
])
if env['platform'] == 'windows':
SConscript([
'frontends/wgl/SConscript',
'targets/libgl-gdi/SConscript',
])

View File

@ -1,64 +0,0 @@
Import('*')
from sys import executable as python_cmd
env.Append(CPPPATH = [
'#src',
'indices',
'util',
'#src/compiler/nir',
'../../compiler/nir',
])
env = env.Clone()
env.MSVC2013Compat()
env.CodeGenerate(
target = 'indices/u_indices_gen.c',
script = 'indices/u_indices_gen.py',
source = [],
command = python_cmd + ' $SCRIPT > $TARGET'
)
env.CodeGenerate(
target = 'indices/u_unfilled_gen.c',
script = 'indices/u_unfilled_gen.py',
source = [],
command = python_cmd + ' $SCRIPT > $TARGET'
)
env.CodeGenerate(
target = 'util/u_tracepoints.c',
script = 'util/u_tracepoints.py',
source = [],
command = python_cmd + ' $SCRIPT -p ' + Dir('#').abspath + '/src/gallium/auxiliary/util -C $TARGET'
)
env.CodeGenerate(
target = 'util/u_tracepoints.h',
script = 'util/u_tracepoints.py',
source = [],
command = python_cmd + ' $SCRIPT -p ' + Dir('#').abspath + '/src/gallium/auxiliary/util -H $TARGET'
)
source = env.ParseSourceList('Makefile.sources', [
'C_SOURCES',
'NIR_SOURCES',
'VL_STUB_SOURCES',
'GENERATED_SOURCES'
])
if env['llvm']:
source += env.ParseSourceList('Makefile.sources', [
'GALLIVM_SOURCES',
])
gallium = env.ConvenienceLibrary(
target = 'gallium',
source = source,
)
env.Alias('gallium', gallium)
Export('gallium')

View File

@ -1,32 +0,0 @@
Import('*')
env = env.Clone()
env.MSVC2013Compat()
env.Append(CPPPATH = [
'#/src/loader',
'#/src/gallium/winsys',
])
env.Append(CPPDEFINES = [
('HAVE_PIPE_LOADER_DRI', '1'),
('GALLIUM_STATIC_TARGETS', '1'),
])
source = env.ParseSourceList('Makefile.sources', 'COMMON_SOURCES')
if env['HAVE_DRM']:
source += env.ParseSourceList('Makefile.sources', 'DRM_SOURCES')
env.PkgUseModules('DRM')
env.Append(LIBS = [libloader])
pipe_loader = env.ConvenienceLibrary(
target = 'pipe_loader',
source = source,
)
env.Alias('pipe_loader', pipe_loader)
Export('pipe_loader')

View File

@ -1,46 +0,0 @@
from sys import executable as python_cmd
import distutils.version
Import('*')
if not env['llvm']:
print('warning: LLVM disabled: not building llvmpipe')
Return()
env = env.Clone()
env.MSVC2013Compat()
llvmpipe = env.ConvenienceLibrary(
target = 'llvmpipe',
source = env.ParseSourceList('Makefile.sources', 'C_SOURCES')
)
env.Alias('llvmpipe', llvmpipe)
env.Append(CPPPATH = [
'../../../compiler/nir',
])
if not env['embedded']:
env = env.Clone()
env.Prepend(LIBS = [llvmpipe, gallium, mesautil])
tests = [
'arit',
'format',
'blend',
'conv',
'printf',
]
for test in tests:
testname = 'lp_test_' + test
target = env.Program(
target = testname,
source = [testname + '.c', 'lp_test_main.c'],
)
env.UnitTest(testname, target)
Export('llvmpipe')

View File

@ -1,18 +0,0 @@
Import('*')
env = env.Clone()
env.Prepend(CPPPATH = [
'../../../compiler/nir',
])
env.MSVC2013Compat()
softpipe = env.ConvenienceLibrary(
target = 'softpipe',
source = env.ParseSourceList('Makefile.sources', 'C_SOURCES')
)
env.Alias('softpipe', softpipe)
Export('softpipe')

View File

@ -1,27 +0,0 @@
Import('*')
env = env.Clone()
env.MSVC2013Compat()
if env['suncc']:
print('warning: not building svga')
Return()
env.Prepend(CPPPATH = [
'include',
])
env.Append(CPPDEFINES = [
])
sources = env.ParseSourceList('Makefile.sources', 'C_SOURCES')
svga = env.ConvenienceLibrary(
target = 'svga',
source = sources,
)
env.Alias('svga', svga)
Export('svga')

View File

@ -1,29 +0,0 @@
#######################################################################
# SConscript for dri state_tracker
Import('*')
env = env.Clone()
env.PkgUseModules(['DRM'])
env.Append(CPPPATH = [
'#/src',
'#/src/mapi',
'#/src/mesa',
'#/src/mesa/drivers/dri/common',
])
sources = env.ParseSourceList('Makefile.sources', 'common_SOURCES')
# XXX: if HAVE_DRISW
sources.append(env.ParseSourceList('Makefile.sources', 'drisw_SOURCES'))
# XXX: if HAVE_DRI2
sources.append(env.ParseSourceList('Makefile.sources', 'dri2_SOURCES'))
st_dri = env.ConvenienceLibrary(
target = 'st_dri',
source = sources
)
Export('st_dri')

View File

@ -1,18 +0,0 @@
#######################################################################
# SConscript for xlib state_tracker
Import('*')
env = env.Clone()
env.Append(CPPPATH = [
'#/src',
'#/src/mapi',
'#/src/mesa',
])
st_xlib = env.ConvenienceLibrary(
target = 'st_xlib',
source = env.ParseSourceList('Makefile.sources', 'C_SOURCES')
)
Export('st_xlib')

View File

@ -1,24 +0,0 @@
#######################################################################
# SConscript for Haiku state_tracker
Import('*')
env = env.Clone()
env.Append(CPPPATH = [
'#/src',
'#/src/mapi',
'#/src/mesa',
'#/include/HaikuGL',
])
sources = [
'hgl.c',
'bitmap_wrapper.cpp',
]
st_haiku = env.ConvenienceLibrary(
target = 'st_haiku',
source = sources
)
Export('st_haiku')

View File

@ -1,24 +0,0 @@
import os
Import('*')
env = env.Clone()
env.Append(CPPPATH = [
'#src/mapi',
'#src/mesa',
'.',
])
if env['platform'] == 'windows':
env.AppendUnique(CPPDEFINES = [
'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
'WIN32_LEAN_AND_MEAN', # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx
'_GLAPI_NO_EXPORTS', # prevent _glapi_* from being declared __declspec(dllimport)
])
st_osmesa = env.ConvenienceLibrary(
target ='st_osmesa',
source = env.ParseSourceList('Makefile.sources', 'C_SOURCES'),
)
Export('st_osmesa')

View File

@ -1,24 +0,0 @@
import os
Import('*')
env = env.Clone()
env.Append(CPPPATH = [
'#src/mapi',
'#src/mesa',
'.',
])
env.AppendUnique(CPPDEFINES = [
'_GDI32_', # prevent wgl* being declared __declspec(dllimport)
'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
'WIN32_LEAN_AND_MEAN', # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx
'_GLAPI_NO_EXPORTS', # prevent _glapi_* from being declared __declspec(dllimport)
])
wgl = env.ConvenienceLibrary(
target ='wgl',
source = env.ParseSourceList('Makefile.sources', 'C_SOURCES'),
)
Export('wgl')

View File

@ -1,59 +0,0 @@
Import('*')
env = drienv.Clone()
if env['suncc']:
print('warning: not building dri-vmwgfx')
Return()
env.Append(CPPPATH = [
'#/src/loader',
'#/src/mapi',
'#/src/mesa',
'#/src/mesa/drivers/dri/common',
'#/src/gallium/frontends/dri',
])
if env['llvm']:
env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
env.Prepend(LIBS = [llvmpipe])
env.PkgUseModules('DRM')
env.Append(CPPDEFINES = [
'GALLIUM_VMWGFX',
'GALLIUM_SOFTPIPE',
])
env.Prepend(LIBS = [
st_dri,
svgadrm,
svga,
ws_dri,
softpipe,
pipe_loader,
libloader,
mesautil,
compiler,
mesa,
glsl,
nir,
spirv,
gallium,
megadrivers_stub,
dri_common,
])
module = env.LoadableModule(
target = 'gallium_dri.so',
source = 'target.c',
SHLIBPREFIX = '',
)
# vmwgfx_dri.so
env.Command('vmwgfx_dri.so', 'gallium_dri.so', "ln -f ${SOURCE} ${TARGET}")
# swrast_dri.so
env.Command('swrast_dri.so', 'gallium_dri.so', "ln -f ${SOURCE} ${TARGET}")
env.Alias('dri-vmwgfx', module)
env.Alias('dri-swrast', module)

View File

@ -1,47 +0,0 @@
Import('*')
env.Prepend(LIBS = [
ws_haiku,
st_haiku,
mesautil,
compiler,
mesa,
glsl,
nir,
spirv,
gallium
])
if True:
env.Append(CPPDEFINES = [
'GALLIUM_SOFTPIPE',
])
env.Prepend(LIBS = [softpipe])
env.Prepend(LIBS = [libgl])
env.Append(CPPPATH = [
'#/src/mapi',
'#/src/mesa',
'#/src/mesa/main',
'#/include/HaikuGL',
'#/src/gallium/winsys',
'#/src/gallium/frontends/hgl',
'/boot/system/develop/headers/private',
])
if env['llvm']:
env.Append(CPPDEFINES = ['GALLIUM_LLVMPIPE'])
env.Prepend(LIBS = [llvmpipe])
softpipe_sources = [
'GalliumContext.cpp',
'SoftwareRenderer.cpp'
]
# libswpipe gets turned into "Softpipe" by the haiku package system
module = env.LoadableModule(
target ='swpipe',
source = softpipe_sources,
)

View File

@ -1,55 +0,0 @@
#######################################################################
# SConscript for gdi winsys
Import('*')
env = env.Clone()
env.Append(CPPPATH = [
'#src',
'#src/gallium/frontends/wgl',
'#src/gallium/winsys/sw',
])
env.Append(LIBS = [
'gdi32',
'user32',
'kernel32',
'ws2_32',
'advapi32',
])
env.Prepend(LIBS = [
mesautil,
nir,
spirv
])
sources = ['libgl_gdi.c']
drivers = []
if True:
env.Append(CPPDEFINES = ['GALLIUM_SOFTPIPE'])
drivers += [softpipe]
if env['llvm']:
env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
drivers += [llvmpipe]
if env['gcc'] and env['machine'] != 'x86_64':
# DEF parser in certain versions of MinGW is busted, as does not behave as
# MSVC. mingw-w64 works fine.
sources += ['#src/gallium/frontends/wgl/opengl32.mingw.def']
else:
sources += ['#src/gallium/frontends/wgl/opengl32.def']
env['no_import_lib'] = 1
opengl32 = env.SharedLibrary(
target ='opengl32',
source = sources,
LIBS = wgl + ws_gdi + glapi + compiler + mesa + drivers + gallium + glsl + nir + env['LIBS'],
)
env.Alias('opengl32', opengl32)
env.Alias('libgl-gdi', opengl32)

View File

@ -1,72 +0,0 @@
#######################################################################
# SConscript for xlib winsys
Import('*')
env = env.Clone()
env.Append(CPPPATH = [
'#/src/mapi',
'#/src/mesa',
'#/src/mesa/main',
'#src/gallium/frontends/glx/xlib',
Dir('../../../mapi'), # src/mapi build path for python-generated GL API files/headers
Dir('../../../mapi/glapi/gen'), # src/mapi build path for python-generated GL API files/headers
])
env.Append(CPPDEFINES = ['USE_XSHM'])
env.Prepend(LIBS = env['X11_LIBS'])
env.Prepend(LIBPATH = env['X11_LIBPATH'])
env.Prepend(LIBS = [
st_xlib,
ws_xlib,
glapi,
mesautil,
compiler,
mesa,
glsl,
nir,
spirv,
gallium,
])
sources = [
'xlib.c',
]
if True:
env.Append(CPPDEFINES = ['GALLIUM_SOFTPIPE'])
env.Prepend(LIBS = [softpipe])
if env['llvm']:
env.Append(CPPDEFINES = ['GALLIUM_LLVMPIPE'])
env.Prepend(LIBS = [llvmpipe])
if env['platform'] != 'darwin':
# Disallow undefined symbols, except with Address Sanitizer, since libasan
# is not linked on shared libs, as it should be LD_PRELOAD'ed instead
if not env['asan']:
env.Append(SHLINKFLAGS = [
'-Wl,-z,defs',
])
env.Append(SHLINKFLAGS = [
# Restrict exported symbols
'-Wl,--version-script=%s' % File("libgl-xlib.sym").srcnode().path,
])
# libGL.so.1.5
libgl_1_5 = env.SharedLibrary(
target ='GL',
source = sources,
SHLIBSUFFIX = env['SHLIBSUFFIX'] + '.1.5',
)
# libGL.so.1
libgl = env.subst('${SHLIBPREFIX}GL${SHLIBSUFFIX}')
libgl_1 = libgl + '.1'
env.Command(libgl_1, libgl_1_5, "ln -sf ${SOURCE.file} ${TARGET}")
env.Command(libgl, libgl_1, "ln -sf ${SOURCE.file} ${TARGET}")
env.Alias('libgl-xlib', libgl)

View File

@ -1,24 +0,0 @@
#######################################################################
# SConscript for xlib winsys
Import('*')
if env['platform'] == 'windows':
env = env.Clone()
env.Append(CPPPATH = [
'#/src/gallium/include',
'#/src/gallium/auxiliary',
'#/src/gallium/drivers',
])
ws_gdi = env.ConvenienceLibrary(
target = 'ws_gdi',
source = [
'gdi_sw_winsys.c',
]
)
env.Alias('ws_gdi', ws_gdi)
Export('ws_gdi')

View File

@ -1,24 +0,0 @@
#######################################################################
# SConscript for haiku winsys
Import('*')
if env['platform'] in ('haiku'):
env = env.Clone()
env.Append(CPPPATH = [
'#/src/gallium/include',
'#/src/gallium/auxiliary',
'#/src/gallium/drivers',
'#/src/gallium/frontend/hgl',
])
ws_haiku = env.ConvenienceLibrary(
target = 'ws_haiku',
source = [
'hgl_sw_winsys.c',
]
)
Export('ws_haiku')

View File

@ -1,19 +0,0 @@
#######################################################################
# SConscript for xlib winsys
Import('*')
env = env.Clone()
env.Append(CPPPATH = [
'#/src/gallium/include',
'#/src/gallium/auxiliary',
])
ws_null = env.ConvenienceLibrary(
target = 'ws_null',
source = env.ParseSourceList('Makefile.sources', 'C_SOURCES'),
)
env.Alias('ws_null', ws_null)
Export('ws_null')

View File

@ -1,18 +0,0 @@
#######################################################################
# SConscript for xlib winsys
Import('*')
env = env.Clone()
env.Append(CPPPATH = [
'#/src/gallium/include',
'#/src/gallium/auxiliary',
])
ws_wrapper = env.ConvenienceLibrary(
target = 'ws_wrapper',
source = env.ParseSourceList('Makefile.sources', 'C_SOURCES'),
)
Export('ws_wrapper')

View File

@ -1,21 +0,0 @@
#######################################################################
# SConscript for xlib winsys
Import('*')
if env['platform'] in ('cygwin', 'darwin', 'freebsd', 'linux', 'sunos'):
env = env.Clone()
env.Append(CPPPATH = [
'#/src/gallium/include',
'#/src/gallium/auxiliary',
])
ws_xlib = env.ConvenienceLibrary(
target = 'ws_xlib',
source = env.ParseSourceList('Makefile.sources', 'C_SOURCES'),
)
env.Alias('ws_xlib', ws_xlib)
Export('ws_xlib')

View File

@ -1,15 +0,0 @@
Import('*')
if not env['msvc']:
Return()
env = env.Clone()
env.Prepend(CPPPATH = ['.'])
getopt = env.ConvenienceLibrary(
target = 'getopt',
source = ['getopt_long.c'],
)
Export('getopt')

View File

@ -1,26 +0,0 @@
Import('*')
env = env.Clone()
env.MSVC2013Compat()
env.Prepend(CPPPATH = [
'#include'
])
if env['drm']:
env.PkgUseModules('DRM')
env.Append(CPPDEFINES = ['HAVE_LIBDRM'])
env.Append(CPPDEFINES = ['DEFAULT_DRIVER_DIR=\\"/usr/local/lib/dri\\"'])
# parse Makefile.sources
sources = env.ParseSourceList('Makefile.sources', 'LOADER_C_FILES')
libloader = env.ConvenienceLibrary(
target = 'libloader',
source = sources,
)
env.Alias('libloader', libloader)
Export('libloader')

View File

@ -1,102 +0,0 @@
#######################################################################
# SConscript for glapi
from sys import executable as python_cmd
Import('*')
env = env.Clone()
env.MSVC2013Compat()
env.Append(CPPDEFINES = [
'MAPI_MODE_UTIL',
])
if env['platform'] == 'windows':
env.Append(CPPDEFINES = [
'_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
'KHRONOS_DLL_EXPORTS', # declare gl* as __declspec(dllexport) in Khronos headers
'_GLAPI_NO_EXPORTS', # prevent _glapi_* from being declared __declspec(dllimport)
])
env.Append(CPPPATH = [
'#/src',
'#/src/mapi',
'#/src/mesa',
Dir('.'), # src/mapi/glapi build path
Dir('gen'), # src/mapi/glapi/gen build path
])
glapi_sources = [
'glapi_dispatch.c',
'glapi_entrypoint.c',
'glapi_getproc.c',
'glapi_nop.c',
'glapi.c',
]
mapi_sources = [
'u_current.c',
'u_execmem.c',
]
for s in mapi_sources:
o = env.SharedObject(s[:-2], '../' + s)
glapi_sources.append(o)
#
# Assembly sources
#
if env['platform'] not in ('cygwin', 'darwin', 'windows'):
GLAPI = '#src/mapi/glapi/'
sources = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml')
if env['machine'] == 'x86':
env.Append(CPPDEFINES = [
'USE_X86_ASM',
])
glapi_sources += [
'glapi_x86.S',
]
env.CodeGenerate(
target = 'glapi_x86.S',
script = GLAPI + 'gen/gl_x86_asm.py',
source = sources,
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)
elif env['machine'] == 'x86_64':
env.Append(CPPDEFINES = [
'USE_X86_64_ASM',
])
glapi_sources += [
'glapi_x86-64.S'
]
env.CodeGenerate(
target = 'glapi_x86-64.S',
script = GLAPI + 'gen/gl_x86-64_asm.py',
source = sources,
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)
elif env['machine'] == 'sparc':
env.Append(CPPDEFINES = [
'USE_SPARC_ASM',
])
glapi_sources += [
'glapi_sparc.S'
]
env.CodeGenerate(
target = 'glapi_sparc.S',
script = GLAPI + 'gen/gl_SPARC_asm.py',
source = sources,
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)
else:
pass
glapi = env.ConvenienceLibrary(
target = 'glapi',
source = glapi_sources,
)
Export('glapi')

View File

@ -1,63 +0,0 @@
Import('*')
from sys import executable as python_cmd
# Be conservative and depend on all XML files here. Missing dependencies means
# broken builds, whereas extraneous dependencies merely means regenerate the
# .[ch] files -- scons should not recompile them though.
sources = ['gl_and_es_API.xml'] + env.Glob('*.xml')
# Generate the GL API headers that are used by various parts of the
# Mesa and GLX tree. Other .c and .h files are generated elsewhere
# if they're only used in one place.
env.CodeGenerate(
target = '../../../mesa/main/dispatch.h',
script = 'gl_table.py',
source = sources,
command = python_cmd + ' $SCRIPT -m remap_table -f $SOURCE > $TARGET',
)
env.CodeGenerate(
target = '../../../mapi/glapi/glapitable.h',
script = 'gl_table.py',
source = sources,
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)
env.CodeGenerate(
target = '../../../mapi/glapi/gen/glapitemp.h',
script = 'gl_apitemp.py',
source = sources,
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)
env.CodeGenerate(
target = '../../../mapi/glapi/glprocs.h',
script = 'gl_procs.py',
source = sources,
command = python_cmd + ' $SCRIPT -c -f $SOURCE > $TARGET'
)
env.CodeGenerate(
target = '../../../mesa/main/remap_helper.h',
script = 'remap_helper.py',
source = sources,
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)
env.CodeGenerate(
target = '../../../mesa/main/enums.c',
script = 'gl_enums.py',
source = '../registry/gl.xml',
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)
env.CodeGenerate(
target = '../../../mesa/main/api_exec.c',
script = 'gl_genexec.py',
source = sources,
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)

View File

@ -1,127 +0,0 @@
#######################################################################
# SConscript for Mesa
Import('*')
from sys import executable as python_cmd
env = env.Clone()
env.MSVC2013Compat()
env.Append(CPPPATH = [
'../compiler/nir', # for generated nir_opcodes.h, etc
'../compiler/glsl', # for generated headers
'#/src',
Dir('../mapi'), # src/mapi build path
'#/src/mapi',
Dir('.'), # src/mesa build path
'#/src/mesa',
Dir('main'), # src/mesa/main/ build path
'#/src/mesa/main',
'#/src/gallium/include',
'#/src/gallium/auxiliary',
])
if env['platform'] == 'windows':
env.Append(CPPDEFINES = [
'_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
'_GLAPI_NO_EXPORTS', # prevent _glapi_* from being declared __declspec(dllimport)
])
# parse Makefile.sources
source_lists = env.ParseSourceList('Makefile.sources')
env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_'])
env.CFile('program/lex.yy.c', 'program/program_lexer.l')
env.CFile('program/program_parse.tab.c', 'program/program_parse.y')
mesa_sources = (
source_lists['MESA_FILES'] +
source_lists['PROGRAM_FILES'] +
source_lists['PROGRAM_NIR_FILES'] +
source_lists['STATETRACKER_FILES']
)
GLAPI = '#src/mapi/glapi/'
get_hash_header = env.CodeGenerate(
target = 'main/get_hash.h',
script = 'main/get_hash_generator.py',
source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET'
)
format_info = env.CodeGenerate(
target = 'main/format_info.h',
script = 'main/format_info.py',
source = 'main/formats.csv',
command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
)
format_pack = env.CodeGenerate(
target = 'main/format_pack.c',
script = 'main/format_pack.py',
source = 'main/formats.csv',
command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
)
format_fallback = env.CodeGenerate(
target = 'main/format_fallback.c',
script = 'main/format_fallback.py',
source = 'main/formats.csv',
command = python_cmd + ' $SCRIPT ' + ' $SOURCE ' + ' $TARGET'
)
#
# Assembly sources
#
if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
if env['machine'] == 'x86':
env.Append(CPPDEFINES = [
'USE_X86_ASM',
'USE_MMX_ASM',
'USE_3DNOW_ASM',
'USE_SSE_ASM',
])
mesa_sources += source_lists['X86_FILES']
elif env['machine'] == 'x86_64':
env.Append(CPPDEFINES = [
'USE_X86_64_ASM',
])
mesa_sources += source_lists['X86_64_FILES']
elif env['machine'] == 'sparc':
mesa_sources += source_lists['SPARC_FILES']
else:
pass
# The marshal_generated.c file is generated from the GL/ES API.xml file
for i in range(8):
env.CodeGenerate(
target = 'main/marshal_generated{0}.c'.format(i),
script = GLAPI + 'gen/gl_marshal.py',
source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
command = python_cmd + ' $SCRIPT -f $SOURCE -i {0} -n 8 > $TARGET'.format(i)
)
# The marshal_generated.h file is generated from the GL/ES API.xml file
env.CodeGenerate(
target = 'main/marshal_generated.h',
script = GLAPI + 'gen/gl_marshal_h.py',
source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)
#
# Libraries
#
mesa = env.ConvenienceLibrary(
target = 'mesa',
source = mesa_sources,
)
env.Alias('mesa', mesa)
Export('mesa')

View File

@ -1,98 +0,0 @@
import common
Import('*')
from sys import executable as python_cmd
env = env.Clone()
env.MSVC2013Compat()
env.Prepend(CPPPATH = [
'#include',
'#src',
'#src/mapi',
'#src/mesa',
'#src/gallium/include',
'#src/gallium/auxiliary',
'#src/util',
'#src/util/format',
env.Dir('..'), # Build path corresponding to src
env.Dir('format'), # Build path corresponding to src/util/format
])
env.CodeGenerate(
target = 'format_srgb.c',
script = 'format_srgb.py',
source = [],
command = python_cmd + ' $SCRIPT > $TARGET'
)
env.CodeGenerate(
target = 'format/u_format_pack.h',
script = 'format/u_format_table.py',
source = ['format/u_format.csv'],
command = python_cmd + ' $SCRIPT $SOURCE --header > $TARGET'
)
env.Depends('format/u_format_pack.h', [
'format/u_format_parse.py',
'format/u_format_pack.py',
])
env.CodeGenerate(
target = 'format/u_format_table.c',
script = 'format/u_format_table.py',
source = ['format/u_format.csv'],
command = python_cmd + ' $SCRIPT $SOURCE > $TARGET'
)
env.Depends('format/u_format_table.c', [
'format/u_format_parse.py',
'format/u_format_pack.py',
])
# parse Makefile.sources
source_lists = env.ParseSourceList('Makefile.sources')
mesautil_sources = (
source_lists['MESA_UTIL_FILES'] +
source_lists['MESA_UTIL_GENERATED_FILES']
)
mesautilenv = env.Clone()
if env['dri']:
mesautil_sources += source_lists['XMLCONFIG_FILES']
mesautilenv.AppendUnique(LIBS = [
'expat',
])
mesautil = mesautilenv.ConvenienceLibrary(
target = 'mesautil',
source = mesautil_sources,
)
env.Alias('mesautil', mesautil)
Export('mesautil')
u_atomic_test = env.Program(
target = 'u_atomic_test',
source = ['u_atomic_test.c'],
)
env.UnitTest("u_atomic_test", u_atomic_test)
roundeven_test = env.Program(
target = 'roundeven_test',
source = ['roundeven_test.c'],
)
env.UnitTest("roundeven_test", roundeven_test)
env.Prepend(LIBS = [mesautil])
mesa_sha1_test = env.Program(
target = 'mesa-sha1_test',
source = ['mesa-sha1_test.c'],
)
env.UnitTest("mesa-sha1_test", mesa_sha1_test)