Commit 35460fc9 authored by José Fonseca's avatar José Fonseca

scons: Teach scons about user-land windows.

Actually, more like get rid of all our hacks when compiling for
user-land windows.

Only MSVC is supported atm though.
parent b4c7a48d
......@@ -65,7 +65,7 @@ platform = env['platform']
# derived options
x86 = machine == 'x86'
gcc = platform in ('linux', 'freebsd', 'darwin')
msvc = platform in ('win32', 'winddk')
msvc = platform in ('windows', 'winddk')
Export([
'debug',
......@@ -84,8 +84,6 @@ Export([
# TODO: put the compiler specific settings in separate files
# TODO: auto-detect as much as possible
common.generate(env)
if platform == 'winddk':
env.Tool('winddk', ['.'])
......@@ -96,37 +94,7 @@ if platform == 'winddk':
env['CRT_INC_PATH'],
])
# Optimization flags
if gcc:
if debug:
env.Append(CFLAGS = '-O0 -g3')
env.Append(CXXFLAGS = '-O0 -g3')
else:
env.Append(CFLAGS = '-O3 -g3')
env.Append(CXXFLAGS = '-O3 -g3')
env.Append(CFLAGS = '-Wall -Wmissing-prototypes -Wno-long-long -ffast-math -pedantic')
env.Append(CXXFLAGS = '-Wall -pedantic')
# Be nice to Eclipse
env.Append(CFLAGS = '-fmessage-length=0')
env.Append(CXXFLAGS = '-fmessage-length=0')
if msvc:
cflags = [
#'/Wp64', # enable 64 bit porting warnings
]
env.Append(CFLAGS = cflags)
env.Append(CXXFLAGS = cflags)
# Put debugging information in a separate .pdb file for each object file as
# descrived in the scons manpage
env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb'
# Defines
if debug:
env.Append(CPPDEFINES = ['DEBUG'])
else:
env.Append(CPPDEFINES = ['NDEBUG'])
common.generate(env)
# Includes
......@@ -188,7 +156,6 @@ if llvm:
# See also http://www.scons.org/wiki/UsingPkgConfig
env.ParseConfig('llvm-config --cflags --ldflags --libs')
env.Append(CPPDEFINES = ['MESA_LLVM'])
env.Append(CXXFLAGS = ['-Wno-long-long'])
# Force C++ linkage
env['LINK'] = env['CXX']
......
......@@ -34,7 +34,7 @@ default_machine = _machine_map.get(default_machine, 'generic')
if default_platform in ('linux', 'freebsd', 'darwin'):
default_dri = 'yes'
elif default_platform in ('winddk',):
elif default_platform in ('winddk', 'windows'):
default_dri = 'no'
else:
default_dri = 'no'
......@@ -51,7 +51,7 @@ def AddOptions(opts):
opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
allowed_values=('generic', 'x86', 'x86_64')))
opts.Add(EnumOption('platform', 'target platform', default_platform,
allowed_values=('linux', 'cell', 'winddk')))
allowed_values=('linux', 'cell', 'windows', 'winddk')))
opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))
......@@ -133,8 +133,161 @@ def generate(env):
# FIXME: this is already too late
#if env.get('quiet', False):
# quietCommandLines(env)
createConvenienceLibBuilder(env)
# shortcuts
debug = env['debug']
machine = env['machine']
platform = env['platform']
x86 = env['machine'] == 'x86'
gcc = env['platform'] in ('linux', 'freebsd', 'darwin')
msvc = env['platform'] in ('windows', 'winddk')
# C preprocessor options
cppdefines = []
if debug:
cppdefines += ['DEBUG']
else:
cppdefines += ['NDEBUG']
if platform == 'windows':
cppdefines += [
'WIN32',
'_WINDOWS',
'_UNICODE',
'UNICODE',
# http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
'WIN32_LEAN_AND_MEAN',
'VC_EXTRALEAN',
]
if debug:
cppdefines += ['_DEBUG']
if platform == 'winddk':
# Mimic WINDDK's builtin flags. See also:
# - WINDDK's bin/makefile.new i386mk.inc for more info.
# - buildchk_wxp_x86.log files, generated by the WINDDK's build
# - http://alter.org.ua/docs/nt_kernel/vc8_proj/
cppdefines += [
('_X86_', '1'),
('i386', '1'),
'STD_CALL',
('CONDITION_HANDLING', '1'),
('NT_INST', '0'),
('WIN32', '100'),
('_NT1X_', '100'),
('WINNT', '1'),
('_WIN32_WINNT', '0x0501'), # minimum required OS version
('WINVER', '0x0501'),
('_WIN32_IE', '0x0603'),
('WIN32_LEAN_AND_MEAN', '1'),
('DEVL', '1'),
('__BUILDMACHINE__', 'WinDDK'),
('FPO', '0'),
]
if debug:
cppdefines += [('DBG', 1)]
if platform == 'windows':
cppdefines += ['PIPE_SUBSYSTEM_USER']
if platform == 'winddk':
cppdefines += ['PIPE_SUBSYSTEM_KERNEL']
env.Append(CPPDEFINES = cppdefines)
# C compiler options
cflags = []
if gcc:
if debug:
cflags += ['-O0', '-g3']
else:
cflags += ['-O3', '-g3']
cflags += [
'-Wall',
'-Wmissing-prototypes',
'-Wno-long-long',
'-ffast-math',
'-pedantic',
'-fmessage-length=0', # be nice to Eclipse
]
if msvc:
# See also:
# - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
# - cl /?
if debug:
cflags += [
'/Od', # disable optimizations
'/Oi', # enable intrinsic functions
'/Oy-', # disable frame pointer omission
]
else:
cflags += [
'/Ox', # maximum optimizations
'/Oi', # enable intrinsic functions
'/Os', # favor code space
]
if platform == 'windows':
cflags += [
# TODO
#'/Wp64', # enable 64 bit porting warnings
]
if platform == 'winddk':
cflags += [
'/Zl', # omit default library name in .OBJ
'/Zp8', # 8bytes struct member alignment
'/Gy', # separate functions for linker
'/Gm-', # disable minimal rebuild
'/W3', # warning level
'/WX', # treat warnings as errors
'/Gz', # __stdcall Calling convention
'/GX-', # disable C++ EH
'/GR-', # disable C++ RTTI
'/GF', # enable read-only string pooling
'/GS', # enable security checks
'/G6', # optimize for PPro, P-II, P-III
'/Ze', # enable extensions
#'/Gi-', # ???
'/QIfdiv-', # disable Pentium FDIV fix
#'/hotpatch', # ???
#'/Z7', #enable old-style debug info
]
# Put debugging information in a separate .pdb file for each object file as
# descrived in the scons manpage
env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb'
env.Append(CFLAGS = cflags)
env.Append(CXXFLAGS = cflags)
# Linker options
if platform == 'winddk':
# See also:
# - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
env.Append(LINKFLAGS = [
'/merge:_PAGE=PAGE',
'/merge:_TEXT=.text',
'/section:INIT,d',
'/opt:ref',
'/opt:icf',
'/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
'/incremental:no',
'/fullbuild',
'/release',
'/nodefaultlib',
'/wx',
'/debug',
'/debugtype:cv',
'/version:5.1',
'/osversion:5.1',
'/functionpadmin:5',
'/safeseh',
'/pdbcompress',
'/stack:0x40000,0x1000',
'/driver',
'/align:0x80',
'/subsystem:native,5.01',
'/base:0x10000',
'/entry:DrvEnableDriver',
])
createConvenienceLibBuilder(env)
# for debugging
#print env.Dump()
......@@ -89,105 +89,6 @@ def get_winddk_paths(env, version=None):
exe_path = string.join(exe_paths, os.pathsep )
return (include_path, lib_path, exe_path)
def set_winddk_flags(env):
"""Mimic WINDDK's builtin flags.
See also:
- WINDDK's bin/makefile.new i386mk.inc for more info.
- buildchk_wxp_x86.log files, generated by the WINDDK's build
- http://alter.org.ua/docs/nt_kernel/vc8_proj/
"""
cppdefines = [
('_X86_', '1'),
('i386', '1'),
'STD_CALL',
('CONDITION_HANDLING', '1'),
('NT_INST', '0'),
('WIN32', '100'),
('_NT1X_', '100'),
('WINNT', '1'),
('_WIN32_WINNT', '0x0501'), # minimum required OS version
('WINVER', '0x0501'),
('_WIN32_IE', '0x0603'),
('WIN32_LEAN_AND_MEAN', '1'),
('DEVL', '1'),
('__BUILDMACHINE__', 'WinDDK'),
('FPO', '0'),
]
if env.get('DEBUG', False):
cppdefines += [
('DBG', 1),
]
env.Append(CPPDEFINES = cppdefines)
# See also:
# - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
# - cl /?
cflags = [
'/Zl', # omit default library name in .OBJ
'/Zp8', # 8bytes struct member alignment
'/Gy', # separate functions for linker
'/Gm-', # disable minimal rebuild
'/W3', # warning level
'/WX', # treat warnings as errors
'/Gz', # __stdcall Calling convention
'/GX-', # disable C++ EH
'/GR-', # disable C++ RTTI
'/GF', # enable read-only string pooling
'/GS', # enable security checks
'/G6', # optimize for PPro, P-II, P-III
'/Ze', # enable extensions
#'/Gi-', # ???
'/QIfdiv-', # disable Pentium FDIV fix
#'/hotpatch', # ???
#'/Z7', #enable old-style debug info
]
if env.get('debug', False):
cflags += [
'/Od', # disable optimizations
'/Oi', # enable intrinsic functions
'/Oy-', # disable frame pointer omission
]
else:
cflags += [
'/Ox', # maximum optimizations
'/Oi', # enable intrinsic functions
'/Os', # favor code space
]
env.Append(CFLAGS = cflags)
env.Append(CXXFLAGS = cflags)
# See also:
# - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
env.Append(LINKFLAGS = [
'/merge:_PAGE=PAGE',
'/merge:_TEXT=.text',
'/section:INIT,d',
'/opt:ref',
'/opt:icf',
'/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
'/incremental:no',
'/fullbuild',
'/release',
'/nodefaultlib',
'/wx',
'/debug',
'/debugtype:cv',
'/version:5.1',
'/osversion:5.1',
'/functionpadmin:5',
'/safeseh',
'/pdbcompress',
'/stack:0x40000,0x1000',
'/driver',
'/align:0x80',
'/subsystem:native,5.01',
'/base:0x10000',
'/entry:DrvEnableDriver',
])
def validate_vars(env):
"""Validate the PCH and PCHSTOP construction variables."""
if env.has_key('PCH') and env['PCH']:
......@@ -314,8 +215,6 @@ def generate(env):
SCons.Tool.mslink.generate(env)
set_winddk_flags(env)
if not env.has_key('ENV'):
env['ENV'] = {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment