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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 # 'lib32' in the x86_64-nacl tooldir. | 94 # 'lib32' in the x86_64-nacl tooldir. |
95 libdir = os.path.join(tooldir, subarch_spec.get('other_libdir', 'lib')) | 95 libdir = os.path.join(tooldir, subarch_spec.get('other_libdir', 'lib')) |
96 break | 96 break |
97 | 97 |
98 if tool_prefix is None: | 98 if tool_prefix is None: |
99 raise Exception("Cannot find a toolchain for %s in %s" % | 99 raise Exception("Cannot find a toolchain for %s in %s" % |
100 (env['TARGET_FULLARCH'], sdk_path)) | 100 (env['TARGET_FULLARCH'], sdk_path)) |
101 | 101 |
102 cc = 'clang' if env.Bit('nacl_clang') else 'gcc' | 102 cc = 'clang' if env.Bit('nacl_clang') else 'gcc' |
103 cxx = 'clang++' if env.Bit('nacl_clang') else 'g++' | 103 cxx = 'clang++' if env.Bit('nacl_clang') else 'g++' |
104 # Eventually nacl-clang will default to -no-integrated-as but for now we have | |
105 # to use the integrated as for compilation because of | |
106 # https://code.google.com/p/nativeclient/issues/detail?id=3966 | |
107 # However clang's as' support of some of the nacl syntax is incomplete, so for | |
108 # now use binutils as for our asm files. | |
109 as_flags = '-no-integrated-as' if env.Bit('nacl_clang') else [] | |
110 | 104 |
111 env.Replace(# Replace header and lib paths. | 105 env.Replace(# Replace header and lib paths. |
112 # where to put nacl extra sdk headers | 106 # where to put nacl extra sdk headers |
113 # TODO(robertm): switch to using the mechanism that | 107 # TODO(robertm): switch to using the mechanism that |
114 # passes arguments to scons | 108 # passes arguments to scons |
115 NACL_SDK_INCLUDE='%s/%s/include' % (sdk_path, tool_prefix), | 109 NACL_SDK_INCLUDE='%s/%s/include' % (sdk_path, tool_prefix), |
116 # where to find/put nacl generic extra sdk libraries | 110 # where to find/put nacl generic extra sdk libraries |
117 NACL_SDK_LIB='%s/%s' % (sdk_path, libdir), | 111 NACL_SDK_LIB='%s/%s' % (sdk_path, libdir), |
118 # Replace the normal unix tools with the NaCl ones. | 112 # Replace the normal unix tools with the NaCl ones. |
119 CC=os.path.join(bin_path, '%s-%s' % (tool_prefix, cc)), | 113 CC=os.path.join(bin_path, '%s-%s' % (tool_prefix, cc)), |
(...skipping 21 matching lines...) Expand all Loading... |
141 '-Werror', | 135 '-Werror', |
142 '-Wall', | 136 '-Wall', |
143 '-Wno-variadic-macros', | 137 '-Wno-variadic-macros', |
144 '-Wswitch-enum', | 138 '-Wswitch-enum', |
145 '-g', | 139 '-g', |
146 '-fno-stack-protector', | 140 '-fno-stack-protector', |
147 '-fdiagnostics-show-option', | 141 '-fdiagnostics-show-option', |
148 '-pedantic', | 142 '-pedantic', |
149 '-D__linux__', | 143 '-D__linux__', |
150 ], | 144 ], |
151 ASFLAGS=as_flags, | 145 ASFLAGS=[], |
152 ) | 146 ) |
153 | 147 |
154 # NaClSdk environment seems to be inherited from the host environment. | 148 # NaClSdk environment seems to be inherited from the host environment. |
155 # On Linux host, this probably makes sense. On Windows and Mac, this | 149 # On Linux host, this probably makes sense. On Windows and Mac, this |
156 # introduces nothing except problems. | 150 # introduces nothing except problems. |
157 # For now, simply override the environment settings as in | 151 # For now, simply override the environment settings as in |
158 # <scons>/engine/SCons/Platform/posix.py | 152 # <scons>/engine/SCons/Platform/posix.py |
159 env.Replace(LIBPREFIX='lib', | 153 env.Replace(LIBPREFIX='lib', |
160 LIBSUFFIX='.a', | 154 LIBSUFFIX='.a', |
161 SHLIBPREFIX='$LIBPREFIX', | 155 SHLIBPREFIX='$LIBPREFIX', |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 # translation. | 722 # translation. |
729 if not os.path.exists(version_file) or env.Bit('use_sandboxed_translator'): | 723 if not os.path.exists(version_file) or env.Bit('use_sandboxed_translator'): |
730 version_file = os.path.join(os.path.dirname(root), 'pnacl_translator', | 724 version_file = os.path.join(os.path.dirname(root), 'pnacl_translator', |
731 'FEATURE_VERSION') | 725 'FEATURE_VERSION') |
732 if os.path.exists(version_file): | 726 if os.path.exists(version_file): |
733 with open(version_file, 'r') as fh: | 727 with open(version_file, 'r') as fh: |
734 version = int(fh.read()) | 728 version = int(fh.read()) |
735 else: | 729 else: |
736 version = 0 | 730 version = 0 |
737 env.Replace(TOOLCHAIN_FEATURE_VERSION=version) | 731 env.Replace(TOOLCHAIN_FEATURE_VERSION=version) |
OLD | NEW |