Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wcesdk.py 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. """wcesdk
  2. Tool-specific initialization for Microsoft Window CE SDKs.
  3. """
  4. #
  5. # Copyright (c) 2001-2007 The SCons Foundation
  6. # Copyright (c) 2008 Tungsten Graphics, Inc.
  7. #
  8. # Permission is hereby granted, free of charge, to any person obtaining
  9. # a copy of this software and associated documentation files (the
  10. # "Software"), to deal in the Software without restriction, including
  11. # without limitation the rights to use, copy, modify, merge, publish,
  12. # distribute, sublicense, and/or sell copies of the Software, and to
  13. # permit persons to whom the Software is furnished to do so, subject to
  14. # the following conditions:
  15. #
  16. # The above copyright notice and this permission notice shall be included
  17. # in all copies or substantial portions of the Software.
  18. #
  19. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  20. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  21. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. #
  27. import os.path
  28. import re
  29. import string
  30. import SCons.Action
  31. import SCons.Builder
  32. import SCons.Errors
  33. import SCons.Platform.win32
  34. import SCons.Tool
  35. import SCons.Util
  36. import SCons.Warnings
  37. import msvc_sa
  38. import mslib_sa
  39. import mslink_sa
  40. def get_wce500_paths(env):
  41. """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
  42. of those three environment variables that should be set
  43. in order to execute the MSVC tools properly."""
  44. exe_paths = []
  45. lib_paths = []
  46. include_paths = []
  47. # mymic the batch files located in Microsoft eMbedded C++ 4.0\EVC\WCExxx\BIN
  48. os_version = os.environ.get('OSVERSION', 'WCE500')
  49. platform = os.environ.get('PLATFORM', 'STANDARDSDK_500')
  50. wce_root = os.environ.get('WCEROOT', 'C:\\Program Files\\Microsoft eMbedded C++ 4.0')
  51. sdk_root = os.environ.get('SDKROOT', 'C:\\Windows CE Tools')
  52. target_cpu = 'x86'
  53. cfg = 'none'
  54. exe_paths.append( os.path.join(wce_root, 'COMMON', 'EVC', 'bin') )
  55. exe_paths.append( os.path.join(wce_root, 'EVC', os_version, 'bin') )
  56. include_paths.append( os.path.join(sdk_root, os_version, platform, 'include', target_cpu) )
  57. include_paths.append( os.path.join(sdk_root, os_version, platform, 'MFC', 'include') )
  58. include_paths.append( os.path.join(sdk_root, os_version, platform, 'ATL', 'include') )
  59. lib_paths.append( os.path.join(sdk_root, os_version, platform, 'lib', target_cpu) )
  60. lib_paths.append( os.path.join(sdk_root, os_version, platform, 'MFC', 'lib', target_cpu) )
  61. lib_paths.append( os.path.join(sdk_root, os_version, platform, 'ATL', 'lib', target_cpu) )
  62. include_path = string.join( include_paths, os.pathsep )
  63. lib_path = string.join(lib_paths, os.pathsep )
  64. exe_path = string.join(exe_paths, os.pathsep )
  65. return (include_path, lib_path, exe_path)
  66. def get_wce600_root(env):
  67. try:
  68. return os.environ['_WINCEROOT']
  69. except KeyError:
  70. pass
  71. if SCons.Util.can_read_reg:
  72. key = r'SOFTWARE\Microsoft\Platform Builder\6.00\Directories\OS Install Dir'
  73. try:
  74. path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key)
  75. except SCons.Util.RegError:
  76. pass
  77. else:
  78. return path
  79. default_path = os.path.join(r'C:\WINCE600', version)
  80. if os.path.exists(default_path):
  81. return default_path
  82. return None
  83. def get_wce600_paths(env):
  84. """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
  85. of those three environment variables that should be set
  86. in order to execute the MSVC tools properly."""
  87. exe_paths = []
  88. lib_paths = []
  89. include_paths = []
  90. # See also C:\WINCE600\public\common\oak\misc\wince.bat
  91. wince_root = get_wce600_root(env)
  92. if wince_root is None:
  93. raise SCons.Errors.InternalError, "Windows CE 6.0 SDK not found"
  94. os_version = os.environ.get('_WINCEOSVER', '600')
  95. platform_root = os.environ.get('_PLATFORMROOT', os.path.join(wince_root, 'platform'))
  96. sdk_root = os.environ.get('_SDKROOT' ,os.path.join(wince_root, 'sdk'))
  97. platform_root = os.environ.get('_PLATFORMROOT', os.path.join(wince_root, 'platform'))
  98. sdk_root = os.environ.get('_SDKROOT' ,os.path.join(wince_root, 'sdk'))
  99. host_cpu = os.environ.get('_HOSTCPUTYPE', 'i386')
  100. target_cpu = os.environ.get('_TGTCPU', 'x86')
  101. if env['debug']:
  102. build = 'debug'
  103. else:
  104. build = 'retail'
  105. try:
  106. project_root = os.environ['_PROJECTROOT']
  107. except KeyError:
  108. # No project root defined -- use the common stuff instead
  109. project_root = os.path.join(wince_root, 'public', 'common')
  110. exe_paths.append( os.path.join(sdk_root, 'bin', host_cpu) )
  111. exe_paths.append( os.path.join(sdk_root, 'bin', host_cpu, target_cpu) )
  112. exe_paths.append( os.path.join(wince_root, 'common', 'oak', 'bin', host_cpu) )
  113. exe_paths.append( os.path.join(wince_root, 'common', 'oak', 'misc') )
  114. include_paths.append( os.path.join(project_root, 'sdk', 'inc') )
  115. include_paths.append( os.path.join(project_root, 'oak', 'inc') )
  116. include_paths.append( os.path.join(project_root, 'ddk', 'inc') )
  117. include_paths.append( os.path.join(sdk_root, 'CE', 'inc') )
  118. lib_paths.append( os.path.join(project_root, 'sdk', 'lib', target_cpu, build) )
  119. lib_paths.append( os.path.join(project_root, 'oak', 'lib', target_cpu, build) )
  120. lib_paths.append( os.path.join(project_root, 'ddk', 'lib', target_cpu, build) )
  121. include_path = string.join( include_paths, os.pathsep )
  122. lib_path = string.join(lib_paths, os.pathsep )
  123. exe_path = string.join(exe_paths, os.pathsep )
  124. return (include_path, lib_path, exe_path)
  125. def generate(env):
  126. msvc_sa.generate(env)
  127. mslib_sa.generate(env)
  128. mslink_sa.generate(env)
  129. if not env.has_key('ENV'):
  130. env['ENV'] = {}
  131. try:
  132. include_path, lib_path, exe_path = get_wce600_paths(env)
  133. env.PrependENVPath('INCLUDE', include_path)
  134. env.PrependENVPath('LIB', lib_path)
  135. env.PrependENVPath('PATH', exe_path)
  136. except (SCons.Util.RegError, SCons.Errors.InternalError):
  137. pass
  138. def exists(env):
  139. return get_wce600_root(env) is not None
  140. # vim:set ts=4 sw=4 et: