From e6fa4ebf282448e08e50d33a812f663aa1228657 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Wed, 10 Aug 2022 20:09:41 +0200 Subject: [PATCH] f4pga/wrappers/sh: convert genfasm.f4pga.sh into a Python function Signed-off-by: Unai Martinez-Corral --- f4pga/setup.py | 1 - f4pga/wrappers/sh/__init__.py | 8 +++ .../sh/{genfasm.f4pga.sh => genfasm.py} | 50 ++++++++++--------- .../sh/quicklogic/write_fasm.f4pga.sh | 2 +- f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh | 2 +- 5 files changed, 37 insertions(+), 26 deletions(-) rename f4pga/wrappers/sh/{genfasm.f4pga.sh => genfasm.py} (70%) mode change 100755 => 100644 diff --git a/f4pga/setup.py b/f4pga/setup.py index 286c0cf..50a65cf 100644 --- a/f4pga/setup.py +++ b/f4pga/setup.py @@ -92,7 +92,6 @@ setuptools_setup( 'platforms/*.json' ], 'f4pga.wrappers.sh': [ - '*.f4pga.sh', 'xc7/*.f4pga.sh', 'quicklogic/*.f4pga.sh' ] diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index 9009741..19c0171 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -91,6 +91,14 @@ def write_bitstream(): run_sh(ROOT / SH_SUBDIR / "write_bitstream.f4pga.sh") +def genfasm(extra_args): + check_call(f""" +'{which('genfasm')}' ${{ARCH_DEF}} \ + ${{EBLIF}} --device ${{DEVICE_NAME}} ${{VPR_OPTIONS}} --read_rr_graph ${{RR_GRAPH}} \ + {' '.join(extra_args)} +""", env=f4pga_environ, shell=True, executable='/bin/bash') + + def write_fasm(): print("[F4PGA] Running (deprecated) write fasm") run_sh(ROOT / SH_SUBDIR / "write_fasm.f4pga.sh") diff --git a/f4pga/wrappers/sh/genfasm.f4pga.sh b/f4pga/wrappers/sh/genfasm.py old mode 100755 new mode 100644 similarity index 70% rename from f4pga/wrappers/sh/genfasm.f4pga.sh rename to f4pga/wrappers/sh/genfasm.py index 9767c89..70cab3f --- a/f4pga/wrappers/sh/genfasm.f4pga.sh +++ b/f4pga/wrappers/sh/genfasm.py @@ -1,23 +1,27 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -"`which genfasm`" ${ARCH_DEF} \ - ${EBLIF} --device ${DEVICE_NAME} ${VPR_OPTIONS} --read_rr_graph ${RR_GRAPH} \ - $@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright (C) 2020-2022 F4PGA Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# +# Python entrypoints to the shell wrappers moved from arch-defs + +from sys import argv as sys_argv + +from f4pga.wrappers.sh import genfasm + +if __name__ == '__main__': + genfasm(sys_argv[1:]) diff --git a/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh index 95e1d19..dd16153 100755 --- a/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh +++ b/f4pga/wrappers/sh/quicklogic/write_fasm.f4pga.sh @@ -31,7 +31,7 @@ EBLIF="$EBLIF" \ DEVICE_NAME="$DEVICE_NAME" \ VPR_OPTIONS="$VPR_OPTIONS" \ RR_GRAPH="$RR_GRAPH" \ - $(dirname "$0")/../genfasm.f4pga.sh + python3 -m f4pga.wrappers.sh.genfasm echo "FASM extra: $FASM_EXTRA" if [ -f $FASM_EXTRA ]; then diff --git a/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh b/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh index 868e5f8..dc68e0c 100755 --- a/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh +++ b/f4pga/wrappers/sh/xc7/write_fasm.f4pga.sh @@ -31,7 +31,7 @@ EBLIF="$EBLIF" \ DEVICE_NAME="$DEVICE_NAME" \ VPR_OPTIONS="$VPR_OPTIONS" \ RR_GRAPH="$RR_GRAPH" \ - $(dirname "$0")/../genfasm.f4pga.sh + python3 -m f4pga.wrappers.sh.genfasm echo "FASM extra: $FASM_EXTRA" if [ -f $FASM_EXTRA ]; then