From 0ca8d53215a8e2991430dbcbc13fbaf5b442318c Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sat, 14 Oct 2017 13:00:28 -0400 Subject: freedreno/ir3: use a flag instead of setting PYTHONPATH 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 Reviewed-by: Eric Engestrom Reviewed-by: Dylan Baker --- src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py | 25 +++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/gallium/drivers/freedreno/ir3') 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() -- cgit v1.2.3