| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/python2.4 |
| 2 # Copyright 2008, Google Inc. |
| 3 # All rights reserved. |
| 4 # |
| 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are |
| 7 # met: |
| 8 # |
| 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. |
| 11 # * Redistributions in binary form must reproduce the above |
| 12 # copyright notice, this list of conditions and the following disclaimer |
| 13 # in the documentation and/or other materials provided with the |
| 14 # distribution. |
| 15 # * Neither the name of Google Inc. nor the names of its |
| 16 # contributors may be used to endorse or promote products derived from |
| 17 # this software without specific prior written permission. |
| 18 # |
| 19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 |
| 31 """Simple DirectMedia Layer tool for SCons. |
| 32 |
| 33 This tool sets up an environment to use the SDL library. |
| 34 """ |
| 35 |
| 36 import os |
| 37 import sys |
| 38 import SCons.Script |
| 39 |
| 40 |
| 41 def _HermeticSDL(env): |
| 42 """Set things up if sdl is hermetically setup somewhere.""" |
| 43 |
| 44 if sys.platform in ['win32', 'cygwin']: |
| 45 env.SetDefault( |
| 46 SDL_DIR='$SDL_HERMETIC_WINDOWS_DIR', |
| 47 SDL_CPPPATH=['$SDL_DIR/include'], |
| 48 SDL_LIBPATH=['$SDL_DIR/lib'], |
| 49 SDL_LIBS=['SDL', 'SDLmain'], |
| 50 SDL_FRAMEWORKPATH=[], |
| 51 SDL_FRAMEWORKS=[], |
| 52 ) |
| 53 elif sys.platform in ['darwin']: |
| 54 env.SetDefault( |
| 55 SDL_DIR='$SDL_HERMETIC_MAC_DIR', |
| 56 SDL_CPPPATH=[ |
| 57 '$SDL_DIR/SDL.framework/Headers', |
| 58 ], |
| 59 SDL_LIBPATH=[], |
| 60 SDL_LIBS=[], |
| 61 SDL_FRAMEWORKPATH=['$SDL_DIR'], |
| 62 SDL_FRAMEWORKS=['SDL', 'Cocoa'], |
| 63 ) |
| 64 elif sys.platform in ['linux', 'linux2', 'posix']: |
| 65 env.SetDefault( |
| 66 SDL_DIR='$SDL_HERMETIC_LINUX_DIR', |
| 67 SDL_CPPPATH='$SDL_DIR/include', |
| 68 SDL_LIBPATH='$SDL_DIR/lib', |
| 69 SDL_LIBS=['SDL', 'SDLmain'], |
| 70 SDL_FRAMEWORKPATH=[], |
| 71 SDL_FRAMEWORKS=[], |
| 72 ) |
| 73 else: |
| 74 env.SetDefault( |
| 75 SDL_VALIDATE_PATHS=[ |
| 76 ('unsupported_platform', |
| 77 ('Not supported on this platform.')), |
| 78 ], |
| 79 SDL_IS_MISSING=True, |
| 80 ) |
| 81 |
| 82 if not env.get('SDL_IS_MISSING', False): |
| 83 env.SetDefault( |
| 84 SDL_VALIDATE_PATHS=[ |
| 85 ('$SDL_DIR', |
| 86 ('You are missing a hermetic copy of SDL...')), |
| 87 ], |
| 88 ) |
| 89 |
| 90 |
| 91 def _LocalSDL(env): |
| 92 """Set things up if sdl is locally installed.""" |
| 93 |
| 94 if sys.platform in ['win32', 'cygwin']: |
| 95 env.SetDefault( |
| 96 SDL_DIR='c:/SDL-1.2.13', |
| 97 SDL_CPPPATH='$SDL_DIR/include', |
| 98 SDL_LIBPATH='$SDL_DIR/lib', |
| 99 SDL_LIBS=['SDL', 'SDLmain'], |
| 100 SDL_FRAMEWORKPATH=[], |
| 101 SDL_FRAMEWORKS=[], |
| 102 SDL_VALIDATE_PATHS=[ |
| 103 ('$SDL_DIR', |
| 104 ('You are missing SDL-1.2.13 on your system.', |
| 105 'It was supposed to be in: ${SDL_DIR}', |
| 106 'You can download it from:', |
| 107 ' http://www.libsdl.org/download-1.2.php')), |
| 108 ], |
| 109 ) |
| 110 elif sys.platform in ['darwin']: |
| 111 env.SetDefault( |
| 112 SDL_CPPPATH=['/Library/Frameworks/SDL.framework/Headers'], |
| 113 SDL_LIBPATH=[], |
| 114 SDL_LIBS=[], |
| 115 SDL_FRAMEWORKPATH=[], |
| 116 SDL_FRAMEWORKS=['SDL', 'Cocoa'], |
| 117 SDL_VALIDATE_PATHS=[ |
| 118 ('/Library/Frameworks/SDL.framework/SDL', |
| 119 ('You are missing the SDL framework on your system.', |
| 120 'You can download it from:', |
| 121 'http://www.libsdl.org/download-1.2.php')), |
| 122 ], |
| 123 ) |
| 124 elif sys.platform in ['linux', 'linux2', 'posix']: |
| 125 env.SetDefault( |
| 126 SDL_CPPPATH='/usr/include/SDL', |
| 127 SDL_LIBPATH='/usr/lib', |
| 128 SDL_LIBS=['SDL', 'SDLmain'], |
| 129 SDL_FRAMEWORKPATH=[], |
| 130 SDL_FRAMEWORKS=[], |
| 131 SDL_VALIDATE_PATHS=[ |
| 132 ('/usr/lib/libSDL.so', |
| 133 ('You are missing SDL on your system.', |
| 134 'Run sudo apt-get install libsdl1.2-dev.')), |
| 135 ], |
| 136 ) |
| 137 |
| 138 |
| 139 def generate(env): |
| 140 # NOTE: SCons requires the use of this name, which fails gpylint. |
| 141 """SCons entry point for this tool.""" |
| 142 |
| 143 # Allow the hermetic copy to be disabled on the command line. |
| 144 sdl_mode = SCons.Script.ARGUMENTS.get('sdl', 'hermetic') |
| 145 if sdl_mode == 'local': |
| 146 _LocalSDL(env) |
| 147 elif sdl_mode == 'hermetic': |
| 148 _HermeticSDL(env) |
| 149 elif sdl_mode == 'none': |
| 150 return |
| 151 else: |
| 152 assert False |
| 153 |
| 154 validate_paths = env['SDL_VALIDATE_PATHS'] |
| 155 |
| 156 if not validate_paths: |
| 157 sys.stderr.write('*' * 77 + '\n') |
| 158 sys.stderr.write('ERROR - SDL not supported on this platform.\n') |
| 159 sys.stderr.write('*' * 77 + '\n') |
| 160 sys.exit(-1) |
| 161 |
| 162 for i in validate_paths: |
| 163 if not os.path.exists(env.subst(i[0])): |
| 164 sys.stderr.write('*' * 77 + '\n') |
| 165 for j in i[1]: |
| 166 sys.stderr.write(env.subst(j) + '\n') |
| 167 sys.stderr.write('*' * 77 + '\n') |
| 168 sys.exit(-1) |
| 169 |
| 170 env.Append( |
| 171 CPPPATH=['$SDL_CPPPATH'], |
| 172 LIBPATH=['$SDL_LIBPATH'], |
| 173 LIBS=['$SDL_LIBS'], |
| 174 FRAMEWORKPATH=['$SDL_FRAMEWORKPATH'], |
| 175 FRAMEWORKS=['$SDL_FRAMEWORKS'], |
| 176 ) |
| OLD | NEW |