Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Mac build, update GHA build to take into account latest Surelog compatibility changes, remove conda #485

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,34 @@ fi

start_section Building

if [ "$PLUGIN_NAME" == "xdc" ] || [ "$PLUGIN_NAME" == "sdc" ]; then
make design_introspection.so -j`nproc`
make install_design_introspection -j`nproc`
fi
if [ "$PLUGIN_NAME" == "xdc" ] || [ "$PLUGIN_NAME" == "sdc" ]; then
make design_introspection.so -j$NPROC
sudo make install_design_introspection -j$NPROC
fi

export CXXFLAGS=-Werror
make ${PLUGIN_NAME}.so -j`nproc`
make ${PLUGIN_NAME}.so -j$NPROC

unset CXXFLAGS

end_section

##########################################################################

start_section Installing
make install_${PLUGIN_NAME} -j`nproc`
sudo make install_${PLUGIN_NAME} -j$NPROC
end_section

##########################################################################

start_section Testing
make test_${PLUGIN_NAME} -j`nproc`
make test_${PLUGIN_NAME} -j$NPROC
end_section

##########################################################################

start_section Cleanup
make clean_${PLUGIN_NAME} -j`nproc`
make clean_${PLUGIN_NAME} -j$NPROC
end_section

##########################################################################
75 changes: 61 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ on: [push, pull_request]
jobs:

Run-tests:
runs-on: ubuntu-20.04

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11]
plugin:
- fasm
- xdc
Expand All @@ -39,40 +39,87 @@ jobs:

steps:

- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install
- name: Install Ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get install git g++-9 build-essential bison flex \
libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot \
pkg-config libboost-system-dev libboost-python-dev \
libboost-filesystem-dev zlib1g-dev clang-format-8 cmake
libboost-filesystem-dev zlib1g-dev clang-format-8 cmake \
nlohmann-json3-dev iverilog
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't there googletest dependencies available in Ubuntu and homebrew that we can use directly from the package manager ?

That way we don't need the separate googletest compilation step below.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if they compile to support c++ 17 string views which are needed, I can test though

if: ${{ runner.os != 'macOS'}}

- name: Setup homebrew cache
uses: actions/cache@v3
with:
path: |
~/Library/Caches/Homebrew/boost--*
~/Library/Caches/Homebrew/downloads/*--boost-*
key: brew-${{ matrix.os }}
restore-keys: brew-
if: ${{ runner.os == 'macOS' }}

- name: Install Mac Dependencies
run: |
brew install bison boost ccache cmake flex graphviz icarus-verilog make nlohmann-json
sudo ln -s /usr/local/bin/gmake /usr/local/bin/make
env:
HOMEBREW_NO_AUTO_UPDATE: "1"
if: ${{ runner.os == 'macOS'}}

- name: Format
run: source .github/workflows/format-check.sh
env:
OS: ${{ runner.os }}
if: ${{ runner.os != 'macOS'}}

- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ccache-${{ matrix.os }}-${{ matrix.plugin }}

- name: Install Yosys
- name: Install yosys
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
source .github/workflows/setup.sh
env:
OS: ${{ runner.os }}
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
set -ex

git clone https://github.com/YosysHQ/yosys.git --branch yosys-0.17
pushd yosys
make CONFIG=gcc -j`nproc` && sudo make CONFIG=gcc install
if: ${{ runner.os != 'macOS' }}

- name: Install yosys
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
set -ex

git clone https://github.com/YosysHQ/yosys.git --branch yosys-0.17
pushd yosys
make -j`nproc` && sudo make install
if: ${{ runner.os == 'macOS' }}

- name: Install Googletest
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
set -ex

git clone --branch release-1.8.1 https://github.com/google/googletest.git
pushd googletest
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 . && cmake --build build && sudo cmake --install build
popd

- name: Build and test plugins
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
source env/conda/bin/activate yosys-plugins
source .github/workflows/build-and-test.sh
.github/workflows/build-and-test.sh
env:
OS: ${{ runner.os }}
PLUGIN_NAME: ${{ matrix.plugin }}
Expand All @@ -85,7 +132,7 @@ jobs:
contents: write

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ fi
# Parallel builds!
MAKEFLAGS="-j 2"

export UNAME=`uname`
if [ "$UNAME" == "Darwin" ]; then
export NPROC=`sysctl -n hw.physicalcpu`
else
export NPROC=`nproc`
fi

function action_fold() {
if [ "$1" = "start" ]; then
echo "::group::$2"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ source .github/workflows/common.sh
##########################################################################

start_section Formatting
make format -j`nproc`
make format -j$NPROC
test $(git status --porcelain | wc -l) -eq 0 || { git diff; false; }
end_section

Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/licensing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ jobs:
Checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: SymbiFlow/actions/checks@main
with:
exclude_license: |
./design_introspection-plugin/tests/selection_to_tcl_list/selection_to_tcl_list.v
./third_party/minilitex_ddr_arty/minilitex_ddr_arty.v
./third_party/VexRiscv_Lite/VexRiscv_Lite.v
third_party: |
./third_party/googletest/
69 changes: 0 additions & 69 deletions .github/workflows/setup.sh

This file was deleted.

11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@
*.swp
*.log
/*/build
pmgen.py


# Test assets
*/tests/*/ok
*/tests/*/*.eblif
*/tests/*/*.json
*/tests/*/*.sdc
*/tests/*/*.test
*/tests/*/tmp
*/tests/*/*.txt
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ PLUGINS_TEST := $(foreach plugin,$(PLUGIN_LIST),test_$(plugin))
all: plugins

TOP_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
REQUIREMENTS_FILE ?= requirements.txt
ENVIRONMENT_FILE ?= environment.yml

-include third_party/make-env/conda.mk
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
NPROC = $(shell nproc)
endif
ifeq ($(UNAME), Darwin)
NPROC = $(shell sysctl -n hw.physicalcpu)
endif

define install_plugin =
.PHONY: $(1).so
Expand All @@ -60,7 +64,7 @@ endef
$(foreach plugin,$(PLUGIN_LIST),$(eval $(call install_plugin,$(plugin))))

pmgen.py:
wget -nc -O $@ https://raw.githubusercontent.com/YosysHQ/yosys/master/passes/pmgen/pmgen.py
wget -nc -O $@ https://raw.githubusercontent.com/YosysHQ/yosys/yosys-0.17/passes/pmgen/pmgen.py

.PHONY: plugins
plugins: $(PLUGINS)
Expand All @@ -81,7 +85,7 @@ clean:: plugins_clean
CLANG_FORMAT ?= clang-format-8
.PHONY: format
format:
find . \( -name "*.h" -o -name "*.cc" \) -and -not -path '*/third_party/*' -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
find . \( -name "*.h" -o -name "*.cc" \) -and -not -path '*/third_party/*' -print0 | xargs -0 -P ${NPROC} ${CLANG_FORMAT} -style=file -i

VERIBLE_FORMAT ?= verible-verilog-format
.PHONY: format-verilog
Expand Down
11 changes: 9 additions & 2 deletions Makefile_plugin.common
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ TOP_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))

_MAKEFILES := $(abspath $(filter-out %.d,$(MAKEFILE_LIST)))

UNAME := $(shell uname)

# Either find yosys in system and use its path or use the given path
YOSYS_PATH ?= $(realpath $(dir $(shell command -v yosys))/..)

Expand All @@ -61,6 +63,10 @@ LDFLAGS := $(shell $(YOSYS_CONFIG) --ldflags) $(LDFLAGS)
LDLIBS := $(shell $(YOSYS_CONFIG) --ldlibs) $(LDLIBS)
EXTRA_FLAGS ?=

ifeq ($(shell uname), Linux)
EXTRA_FLAGS := $(EXTRA_FLAGS) -MMD
endif

YOSYS_DATA_DIR = $(DESTDIR)$(shell $(YOSYS_CONFIG) --datdir)
YOSYS_PLUGINS_DIR = $(YOSYS_DATA_DIR)/plugins

Expand Down Expand Up @@ -93,7 +99,7 @@ endef
$(foreach source,$(SOURCES),$(eval $(value _process-single-source-file)))

$(_ALL_OBJECTS): $(_MAKEFILES)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(EXTRA_FLAGS) -MMD -c -o $@ $(TARGET_SOURCES)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(EXTRA_FLAGS) -c -o $@ $(TARGET_SOURCES)

# Objects list for the purpose of adding extra dependencies after inclusion.
# Example use: `$(OBJECTS): $(BUILD_DIR)/some-file.h`
Expand Down Expand Up @@ -126,7 +132,8 @@ endif
# Installation

$(YOSYS_PLUGINS_DIR)/$(NAME).so: $(SO_LIB) | $(YOSYS_PLUGINS_DIR)
install -D $(SO_LIB) $@
mkdir -p $(YOSYS_PLUGINS_DIR)
install $(SO_LIB) $@

.PHONY: install_plugin
install_plugin: $(YOSYS_PLUGINS_DIR)/$(NAME).so
Expand Down
Loading
Loading