mirror of
https://github.com/YosysHQ/sby.git
synced 2025-04-04 13:54:07 +00:00
Add --version option based on git describe
This commit is contained in:
parent
c9e3b8224a
commit
8709c8a8ee
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/.gittag export-subst
|
10
Makefile
10
Makefile
|
@ -10,6 +10,12 @@ ifeq ($(OS), Windows_NT)
|
||||||
PYTHON = $(shell cygpath -w -m $(PREFIX)/bin/python3)
|
PYTHON = $(shell cygpath -w -m $(PREFIX)/bin/python3)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(file < .gittag),$$Format:%(describe)$$)
|
||||||
|
YOSYS_RELEASE_VERSION := SBY $(shell git describe --dirty)
|
||||||
|
else
|
||||||
|
YOSYS_RELEASE_VERSION := SBY $(file < .gittag)
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: help install ci test html clean
|
.PHONY: help install ci test html clean
|
||||||
|
|
||||||
help:
|
help:
|
||||||
|
@ -38,10 +44,12 @@ install:
|
||||||
sed -e 's|##yosys-program-prefix##|"'$(PROGRAM_PREFIX)'"|' < sbysrc/sby_core.py > $(DESTDIR)$(PREFIX)/share/yosys/python3/sby_core.py
|
sed -e 's|##yosys-program-prefix##|"'$(PROGRAM_PREFIX)'"|' < sbysrc/sby_core.py > $(DESTDIR)$(PREFIX)/share/yosys/python3/sby_core.py
|
||||||
ifeq ($(OS), Windows_NT)
|
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"]]|;' \
|
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)|" < sbysrc/sby.py > $(DESTDIR)$(PREFIX)/bin/sby-script.py
|
-e "s|#!/usr/bin/env python3|#!$(PYTHON)|" < sbysrc/sby.py > $(DESTDIR)$(PREFIX)/bin/sby-script.py
|
||||||
gcc -DGUI=0 -O -s -o $(DESTDIR)$(PREFIX)/bin/sby.exe extern/launcher.c
|
gcc -DGUI=0 -O -s -o $(DESTDIR)$(PREFIX)/bin/sby.exe extern/launcher.c
|
||||||
else
|
else
|
||||||
sed 's|##yosys-sys-path##|sys.path += [os.path.dirname(__file__) + p for p in ["/share/python3", "/../share/yosys/python3"]]|;' < sbysrc/sby.py > $(DESTDIR)$(PREFIX)/bin/sby
|
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)'|;" < sbysrc/sby.py > $(DESTDIR)$(PREFIX)/bin/sby
|
||||||
chmod +x $(DESTDIR)$(PREFIX)/bin/sby
|
chmod +x $(DESTDIR)$(PREFIX)/bin/sby
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,12 @@ from sby_jobserver import SbyJobClient, process_jobserver_environment
|
||||||
from sby_status import SbyStatusDb
|
from sby_status import SbyStatusDb
|
||||||
import time, platform, click
|
import time, platform, click
|
||||||
|
|
||||||
|
release_version = 'unknown SBY version'
|
||||||
|
##yosys-release-version##
|
||||||
|
|
||||||
process_jobserver_environment() # needs to be called early
|
process_jobserver_environment() # needs to be called early
|
||||||
|
|
||||||
parser = parser_func()
|
parser = parser_func(release_version)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ class DictAction(argparse.Action):
|
||||||
name = option_string.lstrip(parser.prefix_chars).replace("-", "_")
|
name = option_string.lstrip(parser.prefix_chars).replace("-", "_")
|
||||||
getattr(namespace, self.dest)[name] = values
|
getattr(namespace, self.dest)[name] = values
|
||||||
|
|
||||||
def parser_func():
|
def parser_func(release_version='unknown SBY version'):
|
||||||
parser = argparse.ArgumentParser(prog="sby",
|
parser = argparse.ArgumentParser(prog="sby",
|
||||||
usage="%(prog)s [options] [<jobname>.sby [tasknames] | <dirname>]")
|
usage="%(prog)s [options] [<jobname>.sby [tasknames] | <dirname>]")
|
||||||
parser.set_defaults(exe_paths=dict())
|
parser.set_defaults(exe_paths=dict())
|
||||||
|
@ -81,4 +81,6 @@ def parser_func():
|
||||||
parser.add_argument("arg_tasknames", metavar="tasknames", nargs="*",
|
parser.add_argument("arg_tasknames", metavar="tasknames", nargs="*",
|
||||||
help="tasks to run (only valid when <jobname>.sby is used)")
|
help="tasks to run (only valid when <jobname>.sby is used)")
|
||||||
|
|
||||||
|
parser.add_argument('--version', action='version', version=release_version)
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
Loading…
Reference in a new issue