0

Reland "build: Convert build/config/nacl/rules.gni to py3"

This is a reland of 9b0ef8cae9
See patch 1-patch set 2 for a determinism fix that locally helps with
https://ci.chromium.org/ui/p/chromium/builders/ci/Deterministic%20Linux/30974/overview

Original change's description:
> build: Convert build/config/nacl/rules.gni to py3
>
> Bug: 1205627
> Change-Id: If1dc022cf0d3e670fb6deb9c3a453bbc2e171166
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2909886
> Commit-Queue: Nico Weber <thakis@chromium.org>
> Auto-Submit: Nico Weber <thakis@chromium.org>
> Reviewed-by: Sam Clegg <sbc@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#886318}

Bug: 1205627
Change-Id: I6f14a91fcbf53b1f5b7204fdabc0df5502dc9cb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2919608
Auto-Submit: Nico Weber <thakis@chromium.org>
Commit-Queue: Sam Clegg <sbc@chromium.org>
Reviewed-by: Sam Clegg <sbc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#888011}
This commit is contained in:
Nico Weber
2021-06-01 16:51:40 +00:00
committed by Chromium LUCI CQ
parent 977b474d82
commit b0d07f5bc2
6 changed files with 18 additions and 17 deletions
build/config/nacl
native_client_sdk/src/tools

@ -3,7 +3,6 @@
# found in the LICENSE file.
import("//build/config/nacl/config.gni")
import("//build/config/python.gni")
# Generate a nmf file
#
@ -20,8 +19,7 @@ template("generate_nmf") {
assert(defined(invoker.executables), "Must define executables")
assert(defined(invoker.nmf), "Must define nmf")
# TODO(crbug.com/1112471): Get this to run cleanly under Python 3.
python2_action(target_name) {
action(target_name) {
forward_variables_from(invoker,
[
"deps",

@ -132,7 +132,7 @@ def ParseElfHeader(path):
"""Wrap elf.ParseElfHeader to return raise this module's Error on failure."""
try:
return elf.ParseElfHeader(path)
except elf.Error, e:
except elf.Error as e:
raise Error(str(e))
@ -248,14 +248,14 @@ class NmfUtils(object):
self.lib_path)
except get_shared_deps.NoObjdumpError:
raise Error('No objdump executable found (see --help for more info)')
except get_shared_deps.Error, e:
except get_shared_deps.Error as e:
raise Error(str(e))
self.needed = {}
# all_files is a dictionary mapping filename to architecture. self.needed
# should be a dictionary of filename to ArchFile.
for filename, arch in all_files.iteritems():
for filename, arch in all_files.items():
name = os.path.basename(filename)
self.needed[filename] = ArchFile(name=name, path=filename, arch=arch)
@ -286,7 +286,7 @@ class NmfUtils(object):
main_dir = ''
arch_to_main_dir[arch] = main_dir
for arch_file in self.needed.itervalues():
for arch_file in self.needed.values():
prefix = ''
if DirectoryTreeContainsFile(self.nmf_root, arch_file.path):
# This file is already in the nmf_root tree, so it does not need to be
@ -317,7 +317,7 @@ class NmfUtils(object):
destination_dir: The destination directory for staging the dependencies
"""
assert self.needed is not None
for arch_file in self.needed.itervalues():
for arch_file in self.needed.values():
source = arch_file.path
destination = os.path.join(destination_dir, arch_file.url)
@ -377,7 +377,7 @@ class NmfUtils(object):
url=url))
for key, arch, url in self.extra_files]
manifest_items = needed.items() + extra_files_kv
manifest_items = list(needed.items()) + extra_files_kv
# Add dynamic loader to the program section.
for need, archinfo in manifest_items:
@ -703,7 +703,7 @@ def main(args):
if __name__ == '__main__':
try:
rtn = main(sys.argv[1:])
except Error, e:
except Error as e:
sys.stderr.write('%s: %s\n' % (os.path.basename(__file__), e))
rtn = 1
except KeyboardInterrupt:

@ -10,6 +10,8 @@ the location of Chrome. This is used, for example, to determine the correct
Toolchain to invoke.
"""
from __future__ import print_function
import argparse
import os
import re
@ -263,7 +265,7 @@ def main(args):
out = platform
if out:
print out
print(out)
return 0

@ -37,7 +37,7 @@ def ParseElfHeader(path):
raise Error("error parsing elf header: %s" % path)
e_ident, _, e_machine = header[:3]
elf_magic = '\x7fELF'
elf_magic = b'\x7fELF'
if e_ident[:4] != elf_magic:
raise Error('Not a valid NaCl executable: %s' % path)

@ -89,7 +89,7 @@ def GetNeeded(main_files, objdump, lib_path):
def _GetNeededDynamic(main_files, objdump, lib_path):
examined = set()
all_files, unexamined = GleanFromObjdump(main_files, None, objdump, lib_path)
for arch in all_files.itervalues():
for arch in all_files.values():
if unexamined:
if arch == 'arm':
unexamined.add((LOADER_ARM, arch))
@ -106,7 +106,7 @@ def _GetNeededDynamic(main_files, objdump, lib_path):
# Call GleanFromObjdump() for each architecture.
needed = set()
for arch, files in files_to_examine.iteritems():
for arch, files in files_to_examine.items():
new_files, new_needed = GleanFromObjdump(files, arch, objdump, lib_path)
all_files.update(new_files)
needed |= new_needed
@ -117,7 +117,7 @@ def _GetNeededDynamic(main_files, objdump, lib_path):
# With the runnable-ld.so scheme we have today, the proper name of
# the dynamic linker should be excluded from the list of files.
ldso = [LD_NACL_MAP[arch] for arch in set(OBJDUMP_ARCH_MAP.values())]
for filename, arch in all_files.items():
for filename, arch in list(all_files.items()):
name = os.path.basename(filename)
if name in ldso:
del all_files[filename]
@ -156,10 +156,11 @@ def GleanFromObjdump(files, arch, objdump, lib_path):
for path in _FindLibsInPath(filename, lib_path):
full_paths.add(path)
cmd = [objdump, '-p'] + list(full_paths)
cmd = [objdump, '-p'] + list(sorted(full_paths))
env = {'LANG': 'en_US.UTF-8'}
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, bufsize=-1,
universal_newlines=True,
env=env)
input_info = {}

@ -454,7 +454,7 @@ def Zip(args):
zip_info.date_time = time.localtime(st.st_mtime)[0:6]
zip_info.compress_type = zip_stream.compression
zip_info.flag_bits = 0x00
zip_info.external_attr = (st[0] & 0xFFFF) << 16L
zip_info.external_attr = (st[0] & 0xFFFF) << 16
zip_info.CRC = 0
zip_info.compress_size = 0
zip_info.file_size = 0