OSDN Git Service

Windows (DDK) compilation support.
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Tue, 19 Feb 2008 09:53:16 +0000 (18:53 +0900)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Tue, 19 Feb 2008 09:53:16 +0000 (18:53 +0900)
It also works when cross compiling with Wine.

SConstruct

index 6cb0730..0420195 100644 (file)
@@ -28,6 +28,13 @@ import sys
 # to get the full list of options. See scons manpage for more info.
 #  
 
+platform_map = {
+       'linux2': 'linux',
+       'win32': 'winddk',
+}
+
+platform = platform_map.get(sys.platform, sys.platform)
+
 # TODO: auto-detect defaults
 opts = Options('config.py')
 opts.Add(BoolOption('debug', 'build debug version', False))
@@ -35,6 +42,8 @@ opts.Add(BoolOption('dri', 'build dri drivers', False))
 opts.Add(BoolOption('llvm', 'use llvm', False))
 opts.Add(EnumOption('machine', 'use machine-specific assembly code', 'x86',
                      allowed_values=('generic', 'x86', 'x86-64')))
+opts.Add(EnumOption('platform', 'target platform', platform,
+                     allowed_values=('linux', 'cell', 'winddk')))
 
 env = Environment(
        options = opts, 
@@ -44,25 +53,17 @@ Help(opts.GenerateHelpText(env))
 # for debugging
 #print env.Dump()
 
-if 0:
-       # platform will be typically 'posix' or 'win32' 
-       platform = env['PLATFORM']
-else:
-       # platform will be one of 'linux', 'freebsd', 'win32', 'darwin', etc.
-       platform = sys.platform
-       if platform == 'linux2':
-               platform = 'linux' 
-
 # replicate options values in local variables
 debug = env['debug']
 dri = env['dri']
 llvm = env['llvm']
 machine = env['machine']
+platform = env['platform']
 
 # derived options
 x86 = machine == 'x86'
-gcc = platform in ('posix', 'linux', 'freebsd', 'darwin')
-msvc = platform == 'win32'
+gcc = platform in ('linux', 'freebsd', 'darwin')
+msvc = platform in ('win32', 'winddk')
 
 Export([
        'debug', 
@@ -78,10 +79,32 @@ Export([
 #######################################################################
 # Environment setup
 #
-# TODO: put the compiler specific settings in seperate files
+# TODO: put the compiler specific settings in separate files
 # TODO: auto-detect as much as possible
 
-         
+
+if platform == 'winddk':
+       import ntpath
+       escape = env['ESCAPE']
+       env.Tool('msvc')
+       if 'BASEDIR' in os.environ:
+               WINDDK = os.environ['BASEDIR']
+       else:
+               WINDDK = "C:\\WINDDK\\3790.1830"
+       # NOTE: We need this elaborate construct to get the absolute paths and
+       # forward slashes to msvc unharmed when cross compiling from posix platforms 
+       env.Append(CPPFLAGS = [
+               escape('/I' + ntpath.join(WINDDK, 'inc\\ddk\\wxp')),
+               escape('/I' + ntpath.join(WINDDK, 'inc\\ddk\\wdm\\wxp')),
+               escape('/I' + ntpath.join(WINDDK, 'inc\\crt')),
+       ])
+       env.Append(CPPDEFINES = [
+               ('i386', '1'),
+       ])
+       if debug:
+               env.Append(CPPDEFINES = ['DBG'])
+       
+
 # Optimization flags
 if gcc:
        if debug: