Skip to content

Commit

Permalink
Merge pull request #68 from YosysHQ/remember-installed-version
Browse files Browse the repository at this point in the history
Add --version option based on git describe
  • Loading branch information
jix authored Jul 8, 2024
2 parents 702af89 + fe5390b commit cc43fd4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.gittag export-subst
1 change: 1 addition & 0 deletions .gittag
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$Format:%(describe)$
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ ifeq ($(OS), Windows_NT)
PYTHON = $(shell cygpath -w -m $(PREFIX)/bin/python3)
endif

ifeq ($(file < .gittag),$$Format:%(describe)$$)
YOSYS_RELEASE_VERSION := EQY $(shell git describe --dirty)
else
YOSYS_RELEASE_VERSION := EQY $(file < .gittag)
endif

build: src/eqy_combine.so src/eqy_partition.so src/eqy_recode.so

DEBUG_CXXFLAGS :=
Expand Down Expand Up @@ -41,10 +47,12 @@ install: src/eqy_combine.so src/eqy_partition.so src/eqy_recode.so
cp src/eqy_recode.so $(DESTDIR)$(PREFIX)/share/yosys/plugins/
ifeq ($(OS), Windows_NT)
sed -e 's|##yosys-sys-path##|sys.path += [os.path.dirname(__file__) + p for p in ["/share/python3", "/../share/yosys/python3"]]|;' \
-e "s|##yosys-release-version##|release_version = '$(YOSYS_RELEASE_VERSION)'|;" \
-e "s|#!/usr/bin/env python3|#!$(PYTHON)|" < src/eqy.py > $(DESTDIR)$(PREFIX)/bin/eqy-script.py
gcc -DGUI=0 -O -s -o $(DESTDIR)$(PREFIX)/bin/eqy.exe extern/launcher.c
else
sed 's|##yosys-sys-path##|sys.path += [os.path.dirname(__file__) + p for p in ["/share/python3", "/../share/yosys/python3"]]|;' < src/eqy.py > $(DESTDIR)$(PREFIX)/bin/eqy
sed -e 's|##yosys-sys-path##|sys.path += [os.path.dirname(__file__) + p for p in ["/share/python3", "/../share/yosys/python3"]]|;' \
-e "s|##yosys-release-version##|release_version = '$(YOSYS_RELEASE_VERSION)'|;" < src/eqy.py > $(DESTDIR)$(PREFIX)/bin/eqy
chmod +x $(DESTDIR)$(PREFIX)/bin/eqy
endif

Expand Down
7 changes: 6 additions & 1 deletion src/eqy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

from eqy_job import EqyJob, EqyTask

release_version = 'unknown EQY version'
##yosys-release-version##

def exit_with_error(error, retcode=1):
print("ERROR:", error, file=sys.stderr)
exit(retcode)
Expand Down Expand Up @@ -102,6 +105,8 @@ def parse_args(ctx):
action=DictAction, dest="exe_paths",
help="configure which executable to use for the respective tool")

parser.add_argument('--version', action='version', version=release_version)

ctx.args = parser.parse_args()

exe_paths = {
Expand Down Expand Up @@ -1183,7 +1188,7 @@ def main():
build_recode(ctx.args, ctx, ctx.job)
else:
shutil.copyfile(f"{ctx.args.workdir}/gate.il", f"{ctx.args.workdir}/gate_recoded.il")

build_combined(ctx.args, ctx, ctx.job)

ctx.gold_ids = read_ids(ctx.args.workdir + "/gold.ids")
Expand Down

0 comments on commit cc43fd4

Please sign in to comment.