Skip to content

Commit

Permalink
Setup Github release and enable systemwide installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Szelwiga authored and kamilrakoczy committed Sep 11, 2024
1 parent 2546475 commit 7221971
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 80 deletions.
20 changes: 15 additions & 5 deletions .ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ build_plugin:
- apt update && apt install -y $BUILD_DEPENDENCIES
- echo "##/ Build yosys, surelog and synlig binaries \##"
- git submodule sync && git submodule update --init --recursive third_party/{surelog,yosys}
- make plugin -j $(nproc)
- make plugin install@surelog -j $(nproc) PREFIX=out

build_asan:
<<: *build_binary
Expand All @@ -65,7 +65,7 @@ build_asan:
- apt update && apt install -y $BUILD_DEPENDENCIES
- echo "##/ Build yosys, surelog and synlig binaries \##"
- git submodule sync && git submodule update --init --recursive third_party/{surelog,yosys}
- make install -j $(nproc) ENABLE_ASAN=1 CC=clang CXX=clang++ CFG_BUILD_TYPE=asan
- make install install@surelog -j $(nproc) ENABLE_ASAN=1 CC=clang CXX=clang++ CFG_BUILD_TYPE=asan PREFIX=out

build_release:
<<: *build_binary
Expand All @@ -74,10 +74,20 @@ build_release:
- apt update && apt install -y $BUILD_DEPENDENCIES
- echo "##/ Build synlig binary \##"
- git submodule sync && git submodule update --init --recursive --checkout third_party/{surelog,yosys,sv2v}
- make install -j $(nproc)
- make install install@surelog -j $(nproc) PREFIX=out
- echo "##/ Build tools \##"
- wget -qO- https://get.haskellstack.org/ | sh -s - -f -d /usr/local/bin
- make install@sv2v install@yosys-tools -j$(nproc)
- make install@sv2v install@yosys-tools -j$(nproc) PREFIX=out

build_package:
<<: *build_binary
script:
- echo "##/ Install dependencies and build \##"
- apt update && apt install -y $BUILD_DEPENDENCIES
- echo "##/ Build yosys, surelog and synlig binaries \##"
- git submodule sync && git submodule update --init --recursive third_party/{surelog,yosys}
- make install -j $(nproc) DESTDIR=out
- (cd out && tar -zcvf release.tar.gz usr)

.job_template: &parsing_test
stage: "Run parsing and formal verification tests"
Expand Down Expand Up @@ -297,7 +307,7 @@ bsg_test_diff:
- git submodule sync
- git submodule update --depth 1 --init --recursive --checkout third_party/bsg_micro_designs
- echo "##/ Start bsg diff test \##"
- export PATH="$PWD/out/current/bin:$PATH"
- export PATH="$PWD/out/bin:$PATH"
- python3 ./tests/bsg_micro_designs/generate_bsg_tests.py
- cat tests/bsg_micro_designs/build/bsg_micro_designs_summary.md
artifacts:
Expand Down
6 changes: 3 additions & 3 deletions .github/scripts/run_group_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ for test_case in "${test_cases[@]}"; do
ASAN_OPTIONS+=":log_path=${test_out_dir}/asan"

if [ "$BUILD_TYPE" == "'plugin'" ]; then
BINARY="${REPO_DIR}/out/current/bin/yosys -Q"
BINARY="yosys -Q"
else
BINARY="${REPO_DIR}/out/current/bin/synlig -Q"
BINARY="synlig -Q"
fi
make -C $REPO_DIR/tests \
-j $(nproc) \
--no-print-directory \
SYNLIG_BIN:="$BINARY" \
BINARY:="$BINARY" \
BUILD_TYPE=$BUILD_TYPE \
ENABLE_READLINE=0 \
PRETTY=0 \
Expand Down
27 changes: 19 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,25 @@ jobs:
apt-extra-deps: 'gcc g++'
cc: 'gcc'
cxx: 'g++'
build-binaries-args: 'install'
build-binaries-args: 'install install@surelog PREFIX=out'
- name: 'Build Plugin'
artifact-name: 'binaries-plugin'
cc: 'gcc'
cxx: 'g++'
apt-extra-deps: 'gcc g++'
build-binaries-args: 'plugin'
build-binaries-args: 'plugin install@surelog PREFIX=out'
- name: 'Build Synlig (ASAN)'
artifact-name: 'binaries-asan'
cc: 'clang-15'
cxx: 'clang++-15'
apt-extra-deps: 'clang-15'
build-binaries-args: 'install ENABLE_ASAN=1 CFG_BUILD_TYPE=asan'
build-binaries-args: 'install install@surelog ENABLE_ASAN=1 CFG_BUILD_TYPE=asan PREFIX=out'
- name: 'Build Package'
artifact-name: 'binaries-package'
apt-extra-deps: 'gcc g++'
cc: 'gcc'
cxx: 'g++'
build-binaries-args: 'install DESTDIR=out'
name: ${{ matrix.name }}
runs-on: [self-hosted, Linux, X64, gcp-custom-runners]
container: debian:bookworm
Expand Down Expand Up @@ -313,14 +319,18 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: binaries-release
name: binaries-package

# See https://github.com/actions/upload-artifact/issues/38
- name: Extract
run: |
tar -xf binaries-release.tar
tar -xf binaries-package.tar
- name: Generate tarball and apply TAG
- name: Prepare tarball
run: |
(cd out && tar -zcvf release.tar.gz usr)
- name: Name tarball and apply TAG
run: |
GIT_VERSION=${GIT_VERSION:-$(git rev-parse --short "$GITHUB_SHA")}
DATE=$(git show -s --date=short --format=%cd)
Expand All @@ -329,8 +339,9 @@ jobs:
TAG="${TAG:-$(git show -s --date=short --format=%cd-%h)}"
git tag "$TAG" || true
echo "TAG=$TAG" >> $GITHUB_ENV
ls -lah out
tar -zcvf $FULL_TARBALL out
mv out/release.tar.gz $FULL_TARBALL
tar -tvf $FULL_TARBALL
- name: Get PR data
uses: 8BitJonny/[email protected]
with:
Expand Down
21 changes: 3 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,6 @@ undefine longest_variable_len
undefine variables_to_dump
endif

#--------------------------------------------------------------------------------
# Update "current" symlink, if needed.

# Skip this for targets that do not build anything.
ifneq ($(filter-out list help,${MAKECMDGOALS}),)
ifdef build_dir_current_symlink
$(shell mkdir -p ${build_dir_common_parent})
$(shell ln -fs -T ${build_dir_current_symlink_target} ${build_dir_current_symlink})
endif
ifdef out_dir_current_symlink
$(shell mkdir -p ${out_dir_common_parent})
$(shell ln -fs -T ${out_dir_current_symlink_target} ${out_dir_current_symlink})
endif
endif

#--------------------------------------------------------------------------------
# Check whether build configuration changed, and warn if so.

Expand Down Expand Up @@ -366,13 +351,13 @@ help : list
build : build@surelog build@synlig

.PHONY: install
install : install@surelog install@synlig
install : build@surelog install@synlig

.PHONY: build-plugin
build-plugin : build@surelog build@yosys build@systemverilog-plugin

.PHONY: install-plugin
install-plugin : install@surelog install@yosys install@systemverilog-plugin
install-plugin : build@surelog install@yosys install@systemverilog-plugin
#####################################################
# WARNING #
# Using synlig as yosys plugin is deprecated. It is #
Expand All @@ -396,7 +381,7 @@ tools: install@eqy install@sby install@sv2v install@yosys-tools
clean : $(foreach t,${GetTargetsList},$(if ${$(call GetTargetStructName,${t}).src_clean_command},srcclean@${t}))
@:
if [[ -e ${BUILD_DIR}buildconfig ]]; then
rm -rf ${BUILD_DIR} ${OUT_DIR}
rm -rf ${BUILD_DIR}
fi

#--------------------------------------------------------------------------------
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ You can download Synlig from the GitHub [release page](https://github.com/chipsa
To download the latest version, use the following script:

```bash
# TODO: update it after initial release
curl https://api.github.com/repos/chipsalliance/synlig/releases/latest | jq -r '.assets | .[] | select(.name | startswith("synlig")) | .browser_download_url' | xargs wget
```
Then, install it with superuser privileges:
Then, you can install it by unpacking archive with superuser privileges:

```bash
# TODO: update it after initial release
tar -C / -xf synlig-*.tar.gz
```

Synlig is now ready to be used.
Expand All @@ -37,8 +37,7 @@ Debian Trixie:
#### Build required binaries

You can build all required binaries using the provided `Makefile`.
`make install` will build Surelog, Yosys and Synlig, and place them in the `out` directory.
You need to add `out/bin` to your `PATH` variable to ensure you are using correct versions of the binaries.
`make install` will build and install Synlig in `/usr/local` directory.

<!-- name="build-binaries" -->
``` bash
Expand Down
4 changes: 3 additions & 1 deletion buildconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ CFG_BUILD_TYPE := release

# Base directory for all build outputs.
CFG_BUILD_DIR = build/${CFG_BUILD_TYPE}/
CFG_OUT_DIR = out/${CFG_BUILD_TYPE}/
PREFIX ?= /usr/local
DESTDIR ?=
CFG_OUT_DIR := $(DESTDIR)$(PREFIX)/

# Basic build tools
CC ?= cc
Expand Down
24 changes: 0 additions & 24 deletions install_plugin.sh

This file was deleted.

7 changes: 5 additions & 2 deletions src/Build.synlig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ ${ts}.output_files := \
${${ts}.src_dir}synlig

${ts}.make_args := \
PREFIX:=${${ts}.out_install_dir} \
PREFIX:=$(call ToAbsPaths,${PREFIX}) \
DESTDIR:=$(if $(DESTDIR),$(call ToAbsPaths,$(DESTDIR)),) \
CONFIG:=$(if cxx_is_clang,clang,gcc) \
CC:=${CC} \
CXX:=${CXX} \
Expand Down Expand Up @@ -48,5 +49,7 @@ define ${ts}.install_command
endef

define ${ts}.src_clean_command
${MAKE} -C $(BUILD_DIR)/synlig -f $(TOP_DIR)/src/Makefile clean
if [ -d $(BUILD_DIR)/synlig ]; then
${MAKE} -C $(BUILD_DIR)/synlig -f $(TOP_DIR)/src/Makefile clean
fi
endef
3 changes: 1 addition & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ GCC_LTO :=
CLANG_LTO := -flto=thin

# --- install directory --- #
PREFIX ?= $(REPO_DIR)/out/release
BINDIR := $(PREFIX)/bin
DATDIR := $(PREFIX)/share/yosys
DATDIR := $(PREFIX)/share/synlig

# --- vpath --- #
VPATH := $(YOSYS_SRC)
Expand Down
10 changes: 4 additions & 6 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ TEST ?= simple_tests/onenet

root_dir:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

OUT_DIR = ${root_dir}/../out/current
SURELOG_BIN = ${OUT_DIR}/bin/surelog
SYNLIG_BIN = ${OUT_DIR}/bin/synlig
OUT_DIR = ${root_dir}/../out
COVARAGE_REPORT = ${root_dir}/build/coverage

TEST_DIR := $(realpath $(root_dir)/$(TEST))
Expand All @@ -29,13 +27,13 @@ list:

uhdm/yosys/test-ast: clean-build surelog/parse
(export TEST_DIR=${TEST_DIR} TEST_FILES="${TEST_FILES}" TOP_MODULE="${TOP_MODULE}" SURELOG_FLAGS="${SURELOG_FLAGS}" && \
cd $(root_dir)/build && ${SYNLIG_BIN} -c $(YOSYS_TCL))
cd $(root_dir)/build && $(BINARY) -c $(YOSYS_TCL))

# ------------ Test helper targets ------------

surelog/parse: clean-build
(cd ${root_dir}/build && \
${SURELOG_BIN} -parse -sverilog -d coveruhdm -elabuhdm ${SURELOG_FLAGS} $(INCLUDE) $(TEST_FILES))
surelog -parse -sverilog -d coveruhdm -elabuhdm ${SURELOG_FLAGS} $(INCLUDE) $(TEST_FILES))
cp ${root_dir}/build/slpp_all/surelog.uhdm ${TOP_UHDM}

# ------------ Clean targets ------------
Expand All @@ -50,6 +48,6 @@ clean:: clean-build

surelog/parse-earlgrey: clean-build
(cd ${root_dir}/third_party/surelog/third_party/tests/Earlgrey_0_1/sim-icarus && \
${SURELOG_BIN} -f Earlgrey_0_1.sl \
surelog -f Earlgrey_0_1.sl \
)
cp ${root_dir}/third_party/surelog/third_party/tests/Earlgrey_0_1/sim-icarus/slpp_all/surelog.uhdm ${TOP_UHDM}
6 changes: 3 additions & 3 deletions tests/scripts/run_formal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ source tests/scripts/common.sh

function build_dependencies(){
[ -z "$GITHUB_ACTIONS" ] && echo "##/ Build eqy and sby \##"
make install@eqy install@sby -j $(nproc)
make install@eqy install@sby -j $(nproc) PREFIX=out
}

function run_formal_tests(){
[ -z "$GITHUB_ACTIONS" ] && echo "##/ Start testing $1 \##"
export PATH="$PWD/out/current/bin:$PATH"
export PATH="$PWD/out/bin:$PATH"
# this link is necessary because eqy doesn't
# support specifying executable file correctly
ln -f -s $(realpath $PWD/out/current/bin/synlig) $PWD/out/current/bin/yosys
ln -f -s $(realpath $PWD/out/bin/synlig) $PWD/out/bin/yosys
./run_fv_tests.mk -j $(nproc) TEST_SUITE_DIR:="$2" TEST_SUITE_NAME:="$1" test
}

Expand Down
4 changes: 2 additions & 2 deletions tests/scripts/run_large_designs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function run_opentitan(){

function run_opentitan_parse_quick(){
[ -z "$GITHUB_ACTIONS" ] && echo "##/ Start Opentitan large design test \##"
export PATH="$PWD/out/current/bin:$PATH"
export PATH="$PWD/out/bin:$PATH"
cd tests/opentitan/opentitan_parsing_test
make gen-opentitan-deps-mk
make -rR -j$(nproc) -Otarget test || /bin/true
Expand All @@ -66,7 +66,7 @@ function run_opentitan_parse_quick(){

function run_opentitan_parse_full(){
[ -z "$GITHUB_ACTIONS" ] && echo "##/ Start Opentitan large design test \##"
export PATH="$PWD/out/current/bin:$PATH"
export PATH="$PWD/out/bin:$PATH"
cd tests/opentitan/opentitan_parsing_test
make gen-opentitan-deps-mk
make -rR -j$(nproc) TOP_DOWN_TEST:=1 -Otarget test || /bin/true
Expand Down
2 changes: 2 additions & 0 deletions tests/scripts/run_parsing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ SKIP="synthesis serv-minimal hello-uvm assignment-pattern MultiplePrints \

function read_systemverilog(){
[ -z "$GITHUB_ACTIONS" ] && echo "##/ Start testing read_systemverilog \##"
export PATH="$PATH:$(realpath out/bin)"
BUILD_TYPE=$type \
TESTS_TO_SKIP=$SKIP \
TARGET=uhdm/yosys/test-ast \
Expand All @@ -25,6 +26,7 @@ function read_systemverilog(){

function read_uhdm(){
[ -z "$GITHUB_ACTIONS" ] && echo "##/ Start testing read_uhdm \##"
export PATH="$PATH:$(realpath out/bin)"
BUILD_TYPE=$type \
TESTS_TO_SKIP=$SKIP \
TARGET=uhdm/yosys/test-ast \
Expand Down
2 changes: 2 additions & 0 deletions third_party/Build.eqy.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ ${ts}.output_files := ${${ts}.src_dir}eqy
define ${ts}.build_command
export PATH="$(realpath ${OUT_DIR})/bin:${PATH}"
ln -f -s $(realpath ${OUT_DIR}/bin/synlig-config) ${OUT_DIR}/bin/yosys-config
ln -f -s $(realpath ${OUT_DIR}/share/synlig) ${OUT_DIR}/share/yosys
${MAKE} -C ${${ts}.src_dir} PREFIX=$(realpath ${OUT_DIR})
endef

define ${ts}.install_command
export PATH="$(realpath ${OUT_DIR})/bin:${PATH}"
ln -f -s $(realpath ${OUT_DIR}/bin/synlig-config) ${OUT_DIR}/bin/yosys-config
ln -f -s $(realpath ${OUT_DIR}/share/synlig) ${OUT_DIR}/share/yosys
${MAKE} -C ${${ts}.src_dir} install PREFIX=$(realpath ${OUT_DIR})
endef

2 changes: 2 additions & 0 deletions third_party/Build.sby.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ ${ts}.output_files := ${${ts}.src_dir}sby
define ${ts}.build_command
export PATH="$(realpath ${OUT_DIR})/bin:${PATH}"
ln -f -s $(realpath ${OUT_DIR}/bin/synlig-config) ${OUT_DIR}/bin/yosys-config
ln -f -s $(realpath ${OUT_DIR}/share/synlig) ${OUT_DIR}/share/yosys
${MAKE} -C ${${ts}.src_dir} PREFIX=$(realpath ${OUT_DIR})
endef

define ${ts}.install_command
export PATH="$(realpath ${OUT_DIR})/bin:${PATH}"
ln -f -s $(realpath ${OUT_DIR}/bin/synlig-config) ${OUT_DIR}/bin/yosys-config
ln -f -s $(realpath ${OUT_DIR}/share/synlig) ${OUT_DIR}/share/yosys
${MAKE} -C ${${ts}.src_dir} install PREFIX=$(realpath ${OUT_DIR})
endef

3 changes: 2 additions & 1 deletion third_party/Build.surelog.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@ define ${ts}.build_command
-S $(call ShQuote,${${ts}.src_dir}) \
-B .
fi
${MAKE} --no-print-directory install
# reset DESTDIR as this install is only used to build synlig
${MAKE} --no-print-directory install DESTDIR=""
endef

0 comments on commit 7221971

Please sign in to comment.