| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """NaCl SDK tool SCons.""" | 6 """NaCl SDK tool SCons.""" |
| 7 | 7 |
| 8 import __builtin__ | 8 import __builtin__ |
| 9 import re | 9 import re |
| 10 import os | 10 import os |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if env.Bit('host_linux'): | 167 if env.Bit('host_linux'): |
| 168 arch = '%s-linux' % arch | 168 arch = '%s-linux' % arch |
| 169 elif env.Bit('host_mac'): | 169 elif env.Bit('host_mac'): |
| 170 arch = '%s-mac' % arch | 170 arch = '%s-mac' % arch |
| 171 arch_flag = ' -arch %s' % arch | 171 arch_flag = ' -arch %s' % arch |
| 172 if env.Bit('pnacl_generate_pexe'): | 172 if env.Bit('pnacl_generate_pexe'): |
| 173 ld_arch_flag = '' | 173 ld_arch_flag = '' |
| 174 else: | 174 else: |
| 175 ld_arch_flag = arch_flag | 175 ld_arch_flag = arch_flag |
| 176 | 176 |
| 177 if env.Bit('nacl_glibc'): | |
| 178 subroot = root + '/glibc' | |
| 179 else: | |
| 180 subroot = root | |
| 181 | |
| 182 translator_root = os.path.join(os.path.dirname(root), 'pnacl_translator') | 177 translator_root = os.path.join(os.path.dirname(root), 'pnacl_translator') |
| 183 | 178 |
| 184 binprefix = os.path.join(subroot, 'bin', 'pnacl-') | 179 binprefix = os.path.join(root, 'bin', 'pnacl-') |
| 185 binext = '' | 180 binext = '' |
| 186 if env.Bit('host_windows'): | 181 if env.Bit('host_windows'): |
| 187 binext = '.bat' | 182 binext = '.bat' |
| 188 | 183 |
| 189 if env.Bit('nacl_glibc'): | |
| 190 # TODO(pdox): This bias is needed because runnable-ld is | |
| 191 # expected to be in the same directory as the SDK. | |
| 192 # This assumption should be removed. | |
| 193 pnacl_lib = os.path.join(root, 'lib-%s' % arch) | |
| 194 pnacl_extra_lib = os.path.join(subroot, 'lib') | |
| 195 else: | |
| 196 pnacl_lib = os.path.join(subroot, 'lib') | |
| 197 pnacl_extra_lib = '' | |
| 198 | |
| 199 #TODO(robertm): remove NACL_SDK_INCLUDE ASAP | |
| 200 if env.Bit('nacl_glibc'): | |
| 201 pnacl_include = os.path.join(root, 'glibc', 'usr', 'include') | |
| 202 else: | |
| 203 pnacl_include = os.path.join(root, 'usr', 'include') | |
| 204 | |
| 205 pnacl_ar = binprefix + 'ar' + binext | 184 pnacl_ar = binprefix + 'ar' + binext |
| 206 pnacl_as = binprefix + 'as' + binext | 185 pnacl_as = binprefix + 'as' + binext |
| 207 pnacl_nm = binprefix + 'nm' + binext | 186 pnacl_nm = binprefix + 'nm' + binext |
| 208 pnacl_ranlib = binprefix + 'ranlib' + binext | 187 pnacl_ranlib = binprefix + 'ranlib' + binext |
| 209 # Use the standalone sandboxed translator in sbtc mode | 188 # Use the standalone sandboxed translator in sbtc mode |
| 210 if env.Bit('use_sandboxed_translator'): | 189 if env.Bit('use_sandboxed_translator'): |
| 211 pnacl_translate = os.path.join(translator_root, 'bin', | 190 pnacl_translate = os.path.join(translator_root, 'bin', |
| 212 'pnacl-translate' + binext) | 191 'pnacl-translate' + binext) |
| 213 else: | 192 else: |
| 214 pnacl_translate = binprefix + 'translate' + binext | 193 pnacl_translate = binprefix + 'translate' + binext |
| (...skipping 25 matching lines...) Expand all Loading... |
| 240 pnacl_translate_flags += ' -fPIC' | 219 pnacl_translate_flags += ' -fPIC' |
| 241 | 220 |
| 242 if env.Bit('use_sandboxed_translator'): | 221 if env.Bit('use_sandboxed_translator'): |
| 243 sb_flags = ' --pnacl-sb' | 222 sb_flags = ' --pnacl-sb' |
| 244 pnacl_ld_flags += sb_flags | 223 pnacl_ld_flags += sb_flags |
| 245 pnacl_translate_flags += sb_flags | 224 pnacl_translate_flags += sb_flags |
| 246 | 225 |
| 247 if env.Bit('x86_64_zero_based_sandbox'): | 226 if env.Bit('x86_64_zero_based_sandbox'): |
| 248 pnacl_translate_flags += ' -sfi-zero-based-sandbox' | 227 pnacl_translate_flags += ' -sfi-zero-based-sandbox' |
| 249 | 228 |
| 250 if pnacl_extra_lib: | |
| 251 env.Prepend(LIBPATH=pnacl_extra_lib) | |
| 252 | |
| 253 env.Replace(# Replace header and lib paths. | 229 env.Replace(# Replace header and lib paths. |
| 254 NACL_SDK_INCLUDE=pnacl_include, | 230 NACL_SDK_INCLUDE=os.path.join(root, 'usr', 'include'), |
| 255 NACL_SDK_LIB=pnacl_lib, | 231 NACL_SDK_LIB=os.path.join(root, 'lib'), |
| 256 # Remove arch-specific flags (if any) | 232 # Remove arch-specific flags (if any) |
| 257 BASE_LINKFLAGS='', | 233 BASE_LINKFLAGS='', |
| 258 BASE_CFLAGS='', | 234 BASE_CFLAGS='', |
| 259 BASE_CXXFLAGS='', | 235 BASE_CXXFLAGS='', |
| 260 BASE_ASFLAGS='', | 236 BASE_ASFLAGS='', |
| 261 BASE_ASPPFLAGS='', | 237 BASE_ASPPFLAGS='', |
| 262 # Replace the normal unix tools with the PNaCl ones. | 238 # Replace the normal unix tools with the PNaCl ones. |
| 263 CC=pnacl_cc + pnacl_cc_flags, | 239 CC=pnacl_cc + pnacl_cc_flags, |
| 264 CXX=pnacl_cxx + pnacl_cxx_flags, | 240 CXX=pnacl_cxx + pnacl_cxx_flags, |
| 265 ASPP=pnacl_cc + pnacl_cc_flags, | 241 ASPP=pnacl_cc + pnacl_cc_flags, |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 if 'toolchain_feature_version' in SCons.Script.ARGUMENTS: | 677 if 'toolchain_feature_version' in SCons.Script.ARGUMENTS: |
| 702 version = int(SCons.Script.ARGUMENTS['toolchain_feature_version']) | 678 version = int(SCons.Script.ARGUMENTS['toolchain_feature_version']) |
| 703 else: | 679 else: |
| 704 version_file = os.path.join(root, 'FEATURE_VERSION') | 680 version_file = os.path.join(root, 'FEATURE_VERSION') |
| 705 if os.path.exists(version_file): | 681 if os.path.exists(version_file): |
| 706 with open(version_file, 'r') as fh: | 682 with open(version_file, 'r') as fh: |
| 707 version = int(fh.read()) | 683 version = int(fh.read()) |
| 708 else: | 684 else: |
| 709 version = 0 | 685 version = 0 |
| 710 env.Replace(TOOLCHAIN_FEATURE_VERSION=version) | 686 env.Replace(TOOLCHAIN_FEATURE_VERSION=version) |
| OLD | NEW |