Migrate to Python 3
Python 2 will not be maintained past April 2020. Fortunately our scripts
require almost no changes to continue working under Python 3.
This patch forces the use of `python3` binary for all `action*` build
targets in GN and updates hashbang directives in our scripts.
Change-Id: Ic34ac547dfe5f85023ddcf4d1a969818f94a72fb
diff --git a/build/image/check_elf.py b/build/image/check_elf.py
index cbc6454..1dc0cec 100644
--- a/build/image/check_elf.py
+++ b/build/image/check_elf.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright 2019 The Hafnium Authors.
#
@@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#!/usr/bin/env python
"""Check ELF file for assembly-level regressions.
Objdumps the given ELF file and detects known assembly patterns, checking for
@@ -79,7 +78,7 @@
objdump_stdout = subprocess.check_output([
OBJDUMP, "-d", args.input_elf ])
- objdump_stdout = objdump_stdout.splitlines()
+ objdump_stdout = objdump_stdout.decode("utf-8").splitlines()
check_eret_speculation_barrier(objdump_stdout)
diff --git a/build/image/convert_to_binary.py b/build/image/convert_to_binary.py
index 482b70e..978d359 100644
--- a/build/image/convert_to_binary.py
+++ b/build/image/convert_to_binary.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright 2018 The Hafnium Authors.
#
@@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#!/usr/bin/env python
"""Convert a file to binary format.
Calls objcopy to convert a file into raw binary format.
diff --git a/build/image/dtc.py b/build/image/dtc.py
index 2ae8efe..c0caff8 100755
--- a/build/image/dtc.py
+++ b/build/image/dtc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright 2019 The Hafnium Authors.
#
diff --git a/build/image/generate_initrd.py b/build/image/generate_initrd.py
index aba5ec1..901bc68 100644
--- a/build/image/generate_initrd.py
+++ b/build/image/generate_initrd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright 2018 The Hafnium Authors.
#
diff --git a/build/image/generate_linux_initrd.py b/build/image/generate_linux_initrd.py
index 06f6502..c93e19a 100644
--- a/build/image/generate_linux_initrd.py
+++ b/build/image/generate_linux_initrd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright 2019 The Hafnium Authors.
#