mirror of
https://github.com/YosysHQ/yosys
synced 2025-12-19 02:33:44 +00:00
Merge pull request #5538 from YosysHQ/emil/driver-git-hash
driver: add --git-hash
This commit is contained in:
commit
1cceaa2a80
5 changed files with 22 additions and 16 deletions
2
.github/workflows/extra-builds.yml
vendored
2
.github/workflows/extra-builds.yml
vendored
|
|
@ -37,7 +37,7 @@ jobs:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- run: sudo apt-get install libfl-dev
|
- run: sudo apt-get install libfl-dev
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make vcxsrc YOSYS_VER=latest
|
run: make vcxsrc YOSYS_COMPILER="Visual Studio" VCX_DIR_NAME=yosys-win32-vcxsrc-latest
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: vcxsrc
|
name: vcxsrc
|
||||||
|
|
|
||||||
23
Makefile
23
Makefile
|
|
@ -177,8 +177,10 @@ CXXFLAGS += -DYOSYS_VER=\\"$(YOSYS_VER)\\" \
|
||||||
TARBALL_GIT_REV := $(shell cat $(YOSYS_SRC)/.gitcommit)
|
TARBALL_GIT_REV := $(shell cat $(YOSYS_SRC)/.gitcommit)
|
||||||
ifneq ($(findstring Format:,$(TARBALL_GIT_REV)),)
|
ifneq ($(findstring Format:,$(TARBALL_GIT_REV)),)
|
||||||
GIT_REV := $(shell GIT_DIR=$(YOSYS_SRC)/.git git rev-parse --short=9 HEAD || echo UNKNOWN)
|
GIT_REV := $(shell GIT_DIR=$(YOSYS_SRC)/.git git rev-parse --short=9 HEAD || echo UNKNOWN)
|
||||||
|
GIT_DIRTY := $(shell GIT_DIR=$(YOSYS_SRC)/.git git diff --exit-code --quiet 2>/dev/null; if [ $$? -ne 0 ]; then echo "-dirty"; fi)
|
||||||
else
|
else
|
||||||
GIT_REV := $(TARBALL_GIT_REV)
|
GIT_REV := $(TARBALL_GIT_REV)
|
||||||
|
GIT_DIRTY := ""
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJS = kernel/version_$(GIT_REV).o
|
OBJS = kernel/version_$(GIT_REV).o
|
||||||
|
|
@ -791,12 +793,13 @@ endif
|
||||||
$(Q) mkdir -p $(dir $@)
|
$(Q) mkdir -p $(dir $@)
|
||||||
$(P) $(CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<
|
$(P) $(CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<
|
||||||
|
|
||||||
YOSYS_VER_STR := Yosys $(YOSYS_VER) (git sha1 $(GIT_REV), $(notdir $(CXX)) $(shell \
|
YOSYS_GIT_STR := $(GIT_REV)$(GIT_DIRTY)
|
||||||
$(CXX) --version | tr ' ()' '\n' | grep '^[0-9]' | head -n1) $(filter -f% -m% -O% -DNDEBUG,$(CXXFLAGS)))
|
YOSYS_COMPILER := $(notdir $(CXX)) $(shell $(CXX) --version | tr ' ()' '\n' | grep '^[0-9]' | head -n1) $(filter -f% -m% -O% -DNDEBUG,$(CXXFLAGS))
|
||||||
|
YOSYS_VER_STR := Yosys $(YOSYS_VER) (git sha1 $(YOSYS_GIT_STR), $(YOSYS_COMPILER))
|
||||||
|
|
||||||
kernel/version_$(GIT_REV).cc: $(YOSYS_SRC)/Makefile
|
kernel/version_$(GIT_REV).cc: $(YOSYS_SRC)/Makefile
|
||||||
$(P) rm -f kernel/version_*.o kernel/version_*.d kernel/version_*.cc
|
$(P) rm -f kernel/version_*.o kernel/version_*.d kernel/version_*.cc
|
||||||
$(Q) mkdir -p kernel && echo "namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"$(YOSYS_VER_STR)\"; }" > kernel/version_$(GIT_REV).cc
|
$(Q) mkdir -p kernel && echo "namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"$(YOSYS_VER_STR)\"; const char *yosys_git_hash_str=\"$(YOSYS_GIT_STR)\"; }" > kernel/version_$(GIT_REV).cc
|
||||||
|
|
||||||
ifeq ($(ENABLE_VERIFIC),1)
|
ifeq ($(ENABLE_VERIFIC),1)
|
||||||
CXXFLAGS_NOVERIFIC = $(foreach v,$(CXXFLAGS),$(if $(findstring $(VERIFIC_DIR),$(v)),,$(v)))
|
CXXFLAGS_NOVERIFIC = $(foreach v,$(CXXFLAGS),$(if $(findstring $(VERIFIC_DIR),$(v)),,$(v)))
|
||||||
|
|
@ -1200,15 +1203,17 @@ qtcreator:
|
||||||
{ echo .; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \) -printf '%h\n' | sort -u; } > qtcreator.includes
|
{ echo .; find backends frontends kernel libs passes -type f \( -name '*.h' -o -name '*.hh' \) -printf '%h\n' | sort -u; } > qtcreator.includes
|
||||||
touch qtcreator.creator
|
touch qtcreator.creator
|
||||||
|
|
||||||
vcxsrc: $(GENFILES) $(EXTRA_TARGETS)
|
VCX_DIR_NAME := yosys-win32-vcxsrc-$(YOSYS_VER)
|
||||||
rm -rf yosys-win32-vcxsrc-$(YOSYS_VER){,.zip}
|
vcxsrc: $(GENFILES) $(EXTRA_TARGETS) kernel/version_$(GIT_REV).cc
|
||||||
|
rm -rf $(VCX_DIR_NAME){,.zip}
|
||||||
|
cp -f kernel/version_$(GIT_REV).cc kernel/version.cc
|
||||||
set -e; for f in `ls $(filter %.cc %.cpp,$(GENFILES)) $(addsuffix .cc,$(basename $(OBJS))) $(addsuffix .cpp,$(basename $(OBJS))) 2> /dev/null`; do \
|
set -e; for f in `ls $(filter %.cc %.cpp,$(GENFILES)) $(addsuffix .cc,$(basename $(OBJS))) $(addsuffix .cpp,$(basename $(OBJS))) 2> /dev/null`; do \
|
||||||
echo "Analyse: $$f" >&2; cpp -std=c++17 -MM -I. -D_YOSYS_ $$f; done | sed 's,.*:,,; s,//*,/,g; s,/[^/]*/\.\./,/,g; y, \\,\n\n,;' | grep '^[^/]' | sort -u | grep -v kernel/version_ > srcfiles.txt
|
echo "Analyse: $$f" >&2; cpp -std=c++17 -MM -I. -D_YOSYS_ $$f; done | sed 's,.*:,,; s,//*,/,g; s,/[^/]*/\.\./,/,g; y, \\,\n\n,;' | grep '^[^/]' | sort -u | grep -v kernel/version_ > srcfiles.txt
|
||||||
echo "libs/fst/fst_win_unistd.h" >> srcfiles.txt
|
echo "libs/fst/fst_win_unistd.h" >> srcfiles.txt
|
||||||
bash misc/create_vcxsrc.sh yosys-win32-vcxsrc $(YOSYS_VER) $(GIT_REV)
|
echo "kernel/version.cc" >> srcfiles.txt
|
||||||
echo "namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys (Version Information Unavailable)\"; }" > kernel/version.cc
|
bash misc/create_vcxsrc.sh $(VCX_DIR_NAME) $(YOSYS_VER)
|
||||||
zip yosys-win32-vcxsrc-$(YOSYS_VER)/genfiles.zip $(GENFILES) kernel/version.cc
|
zip $(VCX_DIR_NAME)/genfiles.zip $(GENFILES) kernel/version.cc
|
||||||
zip -r yosys-win32-vcxsrc-$(YOSYS_VER).zip yosys-win32-vcxsrc-$(YOSYS_VER)/
|
zip -r $(VCX_DIR_NAME).zip $(VCX_DIR_NAME)/
|
||||||
rm -f srcfiles.txt kernel/version.cc
|
rm -f srcfiles.txt kernel/version.cc
|
||||||
|
|
||||||
config-clean: clean
|
config-clean: clean
|
||||||
|
|
|
||||||
|
|
@ -255,6 +255,7 @@ int main(int argc, char **argv)
|
||||||
("h,help", "print this help message. If given, print help for <command>.",
|
("h,help", "print this help message. If given, print help for <command>.",
|
||||||
cxxopts::value<std::string>(), "[<command>]")
|
cxxopts::value<std::string>(), "[<command>]")
|
||||||
("V,version", "print version information and exit")
|
("V,version", "print version information and exit")
|
||||||
|
("git-hash", "print git commit hash and exit")
|
||||||
("infile", "input files", cxxopts::value<std::vector<std::string>>())
|
("infile", "input files", cxxopts::value<std::vector<std::string>>())
|
||||||
;
|
;
|
||||||
options.add_options("logging")
|
options.add_options("logging")
|
||||||
|
|
@ -332,6 +333,10 @@ int main(int argc, char **argv)
|
||||||
std::cout << yosys_version_str << std::endl;
|
std::cout << yosys_version_str << std::endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
if (result.count("git-hash")) {
|
||||||
|
std::cout << yosys_git_hash_str << std::endl;
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
if (result.count("S")) {
|
if (result.count("S")) {
|
||||||
passes_commands.push_back("synth");
|
passes_commands.push_back("synth");
|
||||||
run_shell = false;
|
run_shell = false;
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ extern std::set<std::string> yosys_input_files, yosys_output_files;
|
||||||
|
|
||||||
// from kernel/version_*.o (cc source generated from Makefile)
|
// from kernel/version_*.o (cc source generated from Makefile)
|
||||||
extern const char *yosys_version_str;
|
extern const char *yosys_version_str;
|
||||||
|
extern const char *yosys_git_hash_str;
|
||||||
const char* yosys_maybe_version();
|
const char* yosys_maybe_version();
|
||||||
|
|
||||||
// from passes/cmds/design.cc
|
// from passes/cmds/design.cc
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
vcxsrc="$1-$2"
|
vcxsrc="$1"
|
||||||
yosysver="$2"
|
yosysver="$2"
|
||||||
gitsha="$3"
|
|
||||||
|
|
||||||
rm -rf YosysVS-Tpl-v2.zip YosysVS
|
rm -rf YosysVS-Tpl-v2.zip YosysVS
|
||||||
wget https://github.com/YosysHQ/yosys/releases/download/resources/YosysVS-Tpl-v2.zip
|
wget https://github.com/YosysHQ/yosys/releases/download/resources/YosysVS-Tpl-v2.zip
|
||||||
|
|
@ -33,7 +32,6 @@ popd
|
||||||
head -n$n "$vcxsrc"/YosysVS/YosysVS.vcxproj
|
head -n$n "$vcxsrc"/YosysVS/YosysVS.vcxproj
|
||||||
egrep '\.(h|hh|hpp|inc)$' srcfiles.txt | sed 's,.*,<ClInclude Include="../yosys/&" />,'
|
egrep '\.(h|hh|hpp|inc)$' srcfiles.txt | sed 's,.*,<ClInclude Include="../yosys/&" />,'
|
||||||
egrep -v '\.(h|hh|hpp|inc)$' srcfiles.txt | sed 's,.*,<ClCompile Include="../yosys/&" />,'
|
egrep -v '\.(h|hh|hpp|inc)$' srcfiles.txt | sed 's,.*,<ClCompile Include="../yosys/&" />,'
|
||||||
echo '<ClCompile Include="../yosys/kernel/version.cc" />'
|
|
||||||
tail -n +$((n+1)) "$vcxsrc"/YosysVS/YosysVS.vcxproj
|
tail -n +$((n+1)) "$vcxsrc"/YosysVS/YosysVS.vcxproj
|
||||||
} > "$vcxsrc"/YosysVS/YosysVS.vcxproj.new
|
} > "$vcxsrc"/YosysVS/YosysVS.vcxproj.new
|
||||||
|
|
||||||
|
|
@ -48,9 +46,6 @@ mkdir -p "$vcxsrc"/yosys
|
||||||
tar -cf - -T srcfiles.txt | tar -xf - -C "$vcxsrc"/yosys
|
tar -cf - -T srcfiles.txt | tar -xf - -C "$vcxsrc"/yosys
|
||||||
cp -r share "$vcxsrc"/
|
cp -r share "$vcxsrc"/
|
||||||
|
|
||||||
echo "namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys" \
|
|
||||||
"$yosysver (git sha1 $gitsha, Visual Studio)\"; }" > "$vcxsrc"/yosys/kernel/version.cc
|
|
||||||
|
|
||||||
cat > "$vcxsrc"/readme-git.txt << EOT
|
cat > "$vcxsrc"/readme-git.txt << EOT
|
||||||
Want to use a git working copy for the yosys source code?
|
Want to use a git working copy for the yosys source code?
|
||||||
Open "Git Bash" in this directory and run:
|
Open "Git Bash" in this directory and run:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue