Use python_exec.py instead of passing --pythonpath
Reduces our delta from upstream.
Change-Id: I5148749d0aec006c4104d510a74919ef77a79840
diff --git a/scripts/python_exec.py b/scripts/python_exec.py
new file mode 100755
index 0000000..5b0fb55
--- /dev/null
+++ b/scripts/python_exec.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+# This script executes the second argument with PYTHONPATH set to the first argument.
+import subprocess
+import sys
+
+if __name__ == '__main__':
+ exec_string = "PYTHONPATH=" + sys.argv[1] + " python " + " ".join(sys.argv[2:])
+ child = subprocess.Popen(exec_string, shell=True, stdout=subprocess.PIPE)
+ exit(child.returncode)
\ No newline at end of file
diff --git a/src/compiler/nir/BUILD.gn b/src/compiler/nir/BUILD.gn
index 6ec36c1..dd20b9c 100644
--- a/src/compiler/nir/BUILD.gn
+++ b/src/compiler/nir/BUILD.gn
@@ -273,7 +273,7 @@
action("nir_intrinsics_h") {
output_name = "nir_intrinsics.h"
- script = "nir_intrinsics_h.py"
+ script = "$mesa_build_root/scripts/python_exec.py"
outputs = [
"$target_gen_dir/$output_name",
@@ -285,8 +285,8 @@
]
args = [
- "--pythonpath",
- "$magma_python_path",
+ rebase_path("$magma_python_path"),
+ rebase_path("nir_intrinsics_h.py"),
"--outdir",
rebase_path(target_gen_dir),
]
@@ -294,7 +294,7 @@
action("nir_intrinsics_c") {
output_name = "nir_intrinsics.c"
- script = "nir_intrinsics_c.py"
+ script = "$mesa_build_root/scripts/python_exec.py"
outputs = [
"$target_gen_dir/$output_name",
@@ -306,8 +306,8 @@
]
args = [
- "--pythonpath",
- "$magma_python_path",
+ rebase_path("$magma_python_path"),
+ rebase_path("nir_intrinsics_c.py"),
"--outdir",
rebase_path(target_gen_dir),
]
diff --git a/src/compiler/nir/nir_intrinsics_c.py b/src/compiler/nir/nir_intrinsics_c.py
index ccf0a03..98af67c 100755
--- a/src/compiler/nir/nir_intrinsics_c.py
+++ b/src/compiler/nir/nir_intrinsics_c.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+
template = """\
/* Copyright (C) 2018 Red Hat
*
@@ -50,11 +50,6 @@
};
"""
-import sys
-
-# --pythonpath must be the first argument
-sys.path.append(sys.argv[2])
-
from nir_intrinsics import INTR_OPCODES
from mako.template import Template
import argparse
@@ -62,7 +57,6 @@
def main():
parser = argparse.ArgumentParser()
- parser.add_argument('--pythonpath')
parser.add_argument('--outdir', required=True,
help='Directory to put the generated files in')
diff --git a/src/compiler/nir/nir_intrinsics_h.py b/src/compiler/nir/nir_intrinsics_h.py
index 7431128..8a4f0d5 100755
--- a/src/compiler/nir/nir_intrinsics_h.py
+++ b/src/compiler/nir/nir_intrinsics_h.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+
template = """\
/* Copyright (C) 2018 Red Hat
*
@@ -38,11 +38,6 @@
#endif /* _NIR_INTRINSICS_ */"""
-import sys
-
-# --pythonpath must be the first argument
-sys.path.append(sys.argv[2])
-
from nir_intrinsics import INTR_OPCODES
from mako.template import Template
import argparse
@@ -51,7 +46,6 @@
def main():
parser = argparse.ArgumentParser()
- parser.add_argument('--pythonpath')
parser.add_argument('--outdir', required=True,
help='Directory to put the generated files in')
diff --git a/src/intel/BUILD.gn b/src/intel/BUILD.gn
index 8ad855a..701fbfe 100644
--- a/src/intel/BUILD.gn
+++ b/src/intel/BUILD.gn
@@ -192,20 +192,22 @@
action("gen_format_layout") {
output_name = "isl_format_layout.c"
- script = "isl/gen_format_layout.py"
+ script = "$mesa_build_root/scripts/python_exec.py"
outputs = [
"$target_gen_dir/$output_name",
]
inputs = [
+ "isl/gen_format_layout.py",
"isl/isl_format_layout.csv",
]
- args = [ "--pythonpath", "$magma_python_path" ]
- args += [ "--csv" ]
- args += rebase_path(inputs, root_build_dir)
- args += [
+ args = [
+ rebase_path("$magma_python_path"),
+ rebase_path("isl/gen_format_layout.py"),
+ "--csv",
+ rebase_path("isl/isl_format_layout.csv", root_build_dir),
"--out",
rebase_path("$target_gen_dir") + "/$output_name",
]
diff --git a/src/intel/isl/gen_format_layout.py b/src/intel/isl/gen_format_layout.py
index fe90a12..1fa7c62 100755
--- a/src/intel/isl/gen_format_layout.py
+++ b/src/intel/isl/gen_format_layout.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# encoding=utf-8
# Copyright © 2016 Intel Corporation
@@ -27,10 +26,6 @@
import csv
import re
import textwrap
-import sys
-
-# --pythonpath must be the first argument
-sys.path.append(sys.argv[2])
from mako import template
@@ -236,7 +231,6 @@
def main():
"""Main function."""
parser = argparse.ArgumentParser()
- parser.add_argument('--pythonpath')
parser.add_argument('--csv', action='store', help='The CSV file to parse.')
parser.add_argument(
'--out',
diff --git a/src/intel/vulkan/BUILD.gn b/src/intel/vulkan/BUILD.gn
index e121307..158ab38 100644
--- a/src/intel/vulkan/BUILD.gn
+++ b/src/intel/vulkan/BUILD.gn
@@ -224,15 +224,16 @@
"$target_gen_dir/anv_entrypoints.c",
]
- script = "anv_entrypoints_gen.py"
+ script = "$mesa_build_root/scripts/python_exec.py"
inputs = [
+ "anv_entrypoints_gen.py",
"$mesa_build_root/src/vulkan/registry/vk.xml",
]
-
+
args = [
- "--pythonpath",
rebase_path("$magma_python_path"),
+ rebase_path("anv_entrypoints_gen.py"),
"--xml",
rebase_path("$mesa_build_root") + "/src/vulkan/registry/vk.xml",
"--outdir",
@@ -245,14 +246,18 @@
"$target_gen_dir/anv_extensions.c",
"$target_gen_dir/anv_extensions.h"
]
- script = "anv_extensions_gen.py"
+
+ script = "$mesa_build_root/scripts/python_exec.py"
+
inputs = [
+ "anv_extensions_gen.py",
"$mesa_build_root/src/vulkan/registry/vk.xml",
"anv_extensions.py",
]
+
args = [
- "--pythonpath",
rebase_path("$magma_python_path"),
+ rebase_path("anv_extensions_gen.py"),
"--out-c",
rebase_path("$target_gen_dir/anv_extensions.c"),
"--out-h",
diff --git a/src/intel/vulkan/anv_entrypoints_gen.py b/src/intel/vulkan/anv_entrypoints_gen.py
index 2471636..27b1153 100755
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# coding=utf-8
#
# Copyright © 2015, 2017 Intel Corporation
@@ -27,10 +26,6 @@
import math
import os
import xml.etree.cElementTree as et
-import sys
-
-# --pythonpath must be the first argument
-sys.path.append(sys.argv[2])
from collections import OrderedDict, namedtuple
from mako.template import Template
@@ -533,7 +528,6 @@
def main():
parser = argparse.ArgumentParser()
- parser.add_argument('--pythonpath')
parser.add_argument('--outdir', help='Where to write the files.',
required=True)
parser.add_argument('--xml',
diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py
index 4d56497..0cb6b4f 100755
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
COPYRIGHT = """\
/*
* Copyright 2017 Intel Corporation
@@ -29,10 +28,6 @@
import copy
import re
import xml.etree.cElementTree as et
-import sys
-
-# --pythonpath must be the first argument
-sys.path.append(sys.argv[2])
def _bool_to_c_expr(b):
if b is True:
diff --git a/src/intel/vulkan/anv_extensions_gen.py b/src/intel/vulkan/anv_extensions_gen.py
index 454eedf..a140c26 100755
--- a/src/intel/vulkan/anv_extensions_gen.py
+++ b/src/intel/vulkan/anv_extensions_gen.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
COPYRIGHT = """\
/*
* Copyright 2017 Intel Corporation
@@ -27,10 +26,6 @@
import argparse
import xml.etree.cElementTree as et
-import sys
-
-# --pythonpath must be the first argument
-sys.path.append(sys.argv[2])
from mako.template import Template
@@ -189,7 +184,6 @@
if __name__ == '__main__':
parser = argparse.ArgumentParser()
- parser.add_argument('--pythonpath')
parser.add_argument('--out-c', help='Output C file.')
parser.add_argument('--out-h', help='Output H file.')
parser.add_argument('--xml',
diff --git a/src/vulkan/util/BUILD.gn b/src/vulkan/util/BUILD.gn
index b61d07b..b431d79 100644
--- a/src/vulkan/util/BUILD.gn
+++ b/src/vulkan/util/BUILD.gn
@@ -48,15 +48,16 @@
"$target_gen_dir/vk_enum_to_str.c",
]
- script = "gen_enum_to_str.py"
+ script = "$mesa_build_root/scripts/python_exec.py"
inputs = [
"$mesa_build_root/src/vulkan/registry/vk.xml",
+ "gen_enum_to_str.py",
]
args = [
- "--pythonpath",
rebase_path("$magma_python_path"),
+ rebase_path("gen_enum_to_str.py"),
"--xml",
rebase_path("$mesa_build_root") + "/src/vulkan/registry/vk.xml",
"--outdir",
diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
index 6d36ef5..fb9ecd6 100755
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# encoding=utf-8
# Copyright © 2017 Intel Corporation
@@ -27,10 +26,6 @@
import os
import textwrap
import xml.etree.cElementTree as et
-import sys
-
-# --pythonpath must be the first argument
-sys.path.append(sys.argv[2])
from mako.template import Template
@@ -224,7 +219,6 @@
def main():
parser = argparse.ArgumentParser()
- parser.add_argument('--pythonpath')
parser.add_argument('--xml', required=True,
help='Vulkan API XML files',
action='append',