[Mesa-dev] [PATCH v2 1/2] freedreno/ir3: use a flag instead of setting PYTHONPATH

Rob Clark robdclark at gmail.com
Sat Oct 14 17:10:19 UTC 2017


Similar to 848da662224326ccfbe6647bc82f4f89ca22c762, pass an arg to
ir3_nir_trig.py to add to python path, rather than using $PYTHONPATH,
to prep for meson build support.

Signed-off-by: Rob Clark <robdclark at gmail.com>
---
 src/gallium/drivers/freedreno/Makefile.am         |  2 +-
 src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py | 25 +++++++++++++++++++----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/freedreno/Makefile.am b/src/gallium/drivers/freedreno/Makefile.am
index 128c7fb5990..5cb4c74cb68 100644
--- a/src/gallium/drivers/freedreno/Makefile.am
+++ b/src/gallium/drivers/freedreno/Makefile.am
@@ -12,7 +12,7 @@ AM_CFLAGS = \
 MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
 ir3/ir3_nir_trig.c: ir3/ir3_nir_trig.py $(top_srcdir)/src/compiler/nir/nir_algebraic.py
 	$(MKDIR_GEN)
-	$(AM_V_GEN) PYTHONPATH=$(top_srcdir)/src/compiler/nir $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/ir3/ir3_nir_trig.py > $@ || ($(RM) $@; false)
+	$(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/ir3/ir3_nir_trig.py -p $(top_srcdir)/src/compiler/nir > $@ || ($(RM) $@; false)
 
 noinst_LTLIBRARIES = libfreedreno.la
 
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
index f358f4d6bc4..a0ab9d01903 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
+++ b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py
@@ -20,13 +20,30 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
-import nir_algebraic
+import argparse
+import sys
 
 trig_workarounds = [
    (('fsin', 'x'), ('fsin', ('fsub', ('fmul', 6.283185, ('ffract', ('fadd', ('fmul', 0.159155, 'x'), 0.5))), 3.141593))),
    (('fcos', 'x'), ('fcos', ('fsub', ('fmul', 6.283185, ('ffract', ('fadd', ('fmul', 0.159155, 'x'), 0.5))), 3.141593))),
 ]
 
-print '#include "ir3_nir.h"'
-print nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds",
-                                  trig_workarounds).render()
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('-p', '--import-path', required=True)
+    args = parser.parse_args()
+    sys.path.insert(0, args.import_path)
+    run()
+
+
+def run():
+    import nir_algebraic  # pylint: disable=import-error
+
+    print '#include "ir3_nir.h"'
+    print nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds",
+                                      trig_workarounds).render()
+
+
+if __name__ == '__main__':
+    main()
-- 
2.13.6



More information about the mesa-dev mailing list