 Chromium Code Reviews
 Chromium Code Reviews Issue 9816003:
  GYP build for ARM untrusted runtime.  (Closed) 
  Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
    
  
    Issue 9816003:
  GYP build for ARM untrusted runtime.  (Closed) 
  Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/| Index: build/build_nexe.py | 
| =================================================================== | 
| --- build/build_nexe.py (revision 8056) | 
| +++ build/build_nexe.py (working copy) | 
| @@ -81,9 +81,18 @@ | 
| self.mainarch = 'x86' | 
| self.subarch = arch.split('-')[1] | 
| tool_subdir = 'x86_64-nacl' | 
| + self.pnacl = 0 | 
| 
Mark Seaborn
2012/03/22 17:13:21
Use False, not 0, in Python.  Since this is a bool
 
Nikolay
2012/03/23 11:35:20
Done.
 | 
| + elif arch == 'arm': | 
| + self.arch = arch | 
| + self.mainarch = 'arm' | 
| + self.subarch = '' | 
| + self.pnacl = 1 | 
| 
Mark Seaborn
2012/03/22 17:13:21
Use True, not 1
 
Nikolay
2012/03/23 11:35:20
Done.
 | 
| else: | 
| ErrOut('Toolchain architecture %s not supported.' % arch) | 
| + if arch == 'arm' and toolname == 'glibc': | 
| + ErrOut('arm/glibc not yet supported.' % toolname) | 
| 
Mark Seaborn
2012/03/22 17:13:21
The % substitution will fail.  Drop "% toolname".
 
Nikolay
2012/03/23 11:35:20
Thanks (blind copy-paste is evil).
On 2012/03/22 1
 | 
| + | 
| if toolname == 'newlib': | 
| toolchain = '%s_%s_newlib' % (self.osname, self.mainarch) | 
| self.toolname = 'newlib' | 
| @@ -100,10 +109,22 @@ | 
| self.outdir = options.objdir | 
| # Set the toolchain directories | 
| - self.toolchain = self.GenNaClPath(os.path.join('toolchain', toolchain)) | 
| - self.toolbin = os.path.join(self.toolchain, tool_subdir, 'bin') | 
| - self.toollib = os.path.join(self.toolchain, tool_subdir, 'lib'+self.subarch) | 
| - self.toolinc = os.path.join(self.toolchain, tool_subdir, 'include') | 
| + if self.pnacl: | 
| + pnacldir = 'pnacl_' + self.osname + '_x86_64' | 
| 
Mark Seaborn
2012/03/22 17:13:21
Prefer using format strings, i.e. 'pnacl_%s_x86_64
 
Nikolay
2012/03/23 11:35:20
Done.
 | 
| + self.toolchain = self.GenNaClPath(os.path.join('toolchain', | 
| + pnacldir, | 
| + self.toolname)) | 
| + self.toolbin = os.path.join(self.toolchain, 'bin') | 
| + self.toollib = os.path.join(self.toolchain, 'lib') | 
| + self.toolinc = os.path.join(self.toolchain, 'sysroot', 'include') | 
| + else: | 
| + self.toolchain = self.GenNaClPath(os.path.join('toolchain', | 
| + toolchain)) | 
| + self.toolbin = os.path.join(self.toolchain, tool_subdir, 'bin') | 
| + self.toollib = os.path.join(self.toolchain, | 
| + tool_subdir, | 
| + 'lib'+self.subarch) | 
| 
Mark Seaborn
2012/03/22 17:13:21
Spaces around '+'
 
Nikolay
2012/03/23 11:35:20
Done.
 | 
| + self.toolinc = os.path.join(self.toolchain, tool_subdir, 'include') | 
| self.inc_paths = ArgToList(options.incdirs) | 
| self.lib_paths = ArgToList(options.libdirs) | 
| @@ -130,6 +151,34 @@ | 
| """Helper which prepends executable with the toolchain bin directory.""" | 
| return os.path.join(self.toolbin, name) | 
| + def GetCCompiler(self): | 
| + """Helper which returns C compiler path.""" | 
| + if self.pnacl: | 
| + return self.GetBinName("pnacl-clang") | 
| 
Mark Seaborn
2012/03/22 17:13:21
Use ' rather than "
 
Nikolay
2012/03/23 11:35:20
Done.
 | 
| + else: | 
| + return self.GetBinName("gcc") | 
| + | 
| + def GetCXXCompiler(self): | 
| + """Helper which returns C++ compiler path.""" | 
| + if self.pnacl: | 
| + return self.GetBinName("pnacl-clang++") | 
| + else: | 
| + return self.GetBinName("g++") | 
| + | 
| + def GetAr(self): | 
| + """Helper which returns ar path.""" | 
| + if self.pnacl: | 
| + return self.GetBinName("pnacl-ar") | 
| + else: | 
| + return self.GetBinName("ar") | 
| + | 
| + def GetStrip(self): | 
| + """Helper which returns strip path.""" | 
| + if self.pnacl: | 
| + return self.GetBinName("pnacl-strip") | 
| + else: | 
| + return self.GetBinName("strip") | 
| + | 
| def BuildAssembleOptions(self, options): | 
| options = ArgToList(options) | 
| self.assemble_options = options + ['-I' + name for name in self.inc_paths] | 
| @@ -188,10 +237,13 @@ | 
| filename, ext = os.path.splitext(src) | 
| if ext == '.c' or ext == '.S': | 
| - bin_name = self.GetBinName('gcc') | 
| + bin_name = self.GetCCompiler() | 
| extra = ['-std=gnu99'] | 
| + if self.pnacl and ext == '.S': | 
| + extra.append('-arch') | 
| + extra.append(self.arch) | 
| elif ext == '.cc': | 
| - bin_name = self.GetBinName('g++') | 
| + bin_name = self.GetCXXCompiler() | 
| extra = [] | 
| else: | 
| if self.verbose and ext != '.h': | 
| @@ -218,7 +270,7 @@ | 
| out = self.name | 
| if self.verbose: | 
| print '\nLink %s' % out | 
| - bin_name = self.GetBinName('g++') | 
| + bin_name = self.GetCXXCompiler() | 
| MakeDir(os.path.dirname(out)) | 
| self.CleanOutput(out) | 
| @@ -244,13 +296,13 @@ | 
| if '-r' in self.link_options: | 
| - bin_name = self.GetBinName('g++') | 
| + bin_name = self.GetCXXCompiler() | 
| cmd_line = [bin_name, '-o', out, '-Wl,--as-needed'] | 
| if not self.empty: | 
| cmd_line += srcs | 
| cmd_line += self.link_options | 
| else: | 
| - bin_name = self.GetBinName('ar') | 
| + bin_name = self.GetAr() | 
| cmd_line = [bin_name, '-rc', out] | 
| if not self.empty: | 
| cmd_line += srcs | 
| @@ -273,7 +325,7 @@ | 
| tmp = out + '.tmp' | 
| self.CleanOutput(tmp) | 
| os.rename(out, tmp) | 
| - bin_name = self.GetBinName('strip') | 
| + bin_name = self.GetStrip() | 
| cmd_line = [bin_name, '--strip-debug', tmp, '-o', out] | 
| err = self.Run(cmd_line, out) | 
| if sys.platform.startswith('win') and err == 5: | 
| @@ -350,4 +402,3 @@ | 
| if __name__ == '__main__': | 
| sys.exit(Main(sys.argv)) | 
| - |