Skip to content

Commit

Permalink
Provide AppImages for Linux (amd64) (#29)
Browse files Browse the repository at this point in the history
+ Add capability to build an AppImage based on the Docker file, which can be download on any Linux distribution with a glibc greater than or equal to CentOS 7.
+ Add a smoke-test script to the Docker image and the AppImage (to ensure everything is okay)
+ Added Python/Pyverilog version checkers
~ Greatly reduced Docker image size by using a multi-layer image
~ Changed CLI slightly so output files have full names and not prefices
- Removed Jinja2 from dependencies
  • Loading branch information
donn authored Jun 25, 2022
1 parent e5dd86e commit 080f4be
Show file tree
Hide file tree
Showing 24 changed files with 379 additions and 61 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/.build
/Netlists
/Dockerfile
/Dockerfile
/appimage
/.git
/.github
/.dockerignore
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Tech/* linguist-detectable=false
*.v linguist-detectable=false
*.sv linguist-detectable=false
*.sv linguist-detectable=false
.github/* linguist-detectable=false
1 change: 1 addition & 0 deletions .github/scripts/generate_tag.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2022 The American University in Cairo
# Copyright 2020 Efabless Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions .github/scripts/gh.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2022 The American University in Cairo
# Copyright 2020 Efabless Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/appimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
push:
tags:
- "*"

name: AppImage

jobs:
build_appimage:
name: Build AppImage
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get the version
id: get_version
run: |
export VERSION_NUM=$(ruby -e "print '$GITHUB_REF'.split('/')[2]")
echo ::set-output name=value::${VERSION_NUM}
- name: Build
run: |
cd appimage
export FAULT_IMAGE_NAME=ghcr.io/aucohl/fault:${{ steps.get_version.outputs.value }}
make
- name: Test AppImage
run: |
./appimage/Fault-x86_64.AppImage smoke-test
- name: Copy AppImage
run: |
cp ./appimage/Fault-x86_64.AppImage /tmp/Fault-${{ steps.get_version.outputs.value }}-x86_64.AppImage
- name: Upload Release Asset
uses: softprops/action-gh-release@v1
with:
files: /tmp/Fault-${{ steps.get_version.outputs.value }}-x86_64.AppImage
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
push_to_pypi:
name: Build (and publish, if applicable)
name: Build/Publish Docker
runs-on: ubuntu-20.04
steps:
- name: Check out Git repository
Expand All @@ -23,20 +23,14 @@ jobs:
run: echo "NEW_TAG=NO_NEW_TAG" >> $GITHUB_ENV
- name: Build Image
run: |
docker build -t aucohl/fault:latest .
docker build --target runner -t aucohl/fault:latest .
- name: Run Smoke Test
run: |
docker run --rm -w /fault aucohl/fault:latest swift test
docker run --rm -w /test aucohl/fault:latest python3 /test/smoke_test.py
- name: Check for new version
if: ${{ env.BRANCH_NAME == 'main' }}
run: |
cd ${GITHUB_WORKSPACE}/ && python3 .github/scripts/generate_tag.py
- name: Tag Commit
if: ${{ env.NEW_TAG != 'NO_NEW_TAG' }}
uses: tvdias/[email protected]
with:
tag: "${{ env.NEW_TAG }}"
repo-token: "${{ secrets.MY_TOKEN }}"
python3 .github/scripts/generate_tag.py
- name: Log in to the Container registry
if: ${{ env.NEW_TAG != 'NO_NEW_TAG' }}
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
Expand All @@ -51,3 +45,10 @@ jobs:
docker image tag aucohl/fault:latest ghcr.io/aucohl/fault:$NEW_TAG
docker push ghcr.io/aucohl/fault:$NEW_TAG
docker push ghcr.io/aucohl/fault:latest
# Last, because this triggers the AppImage CI
- name: Tag Commit
if: ${{ env.NEW_TAG != 'NO_NEW_TAG' }}
uses: tvdias/[email protected]
with:
tag: "${{ env.NEW_TAG }}"
repo-token: "${{ secrets.MY_TOKEN }}"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Netlists
*.bench
*.test
*.log
*.vvp
*.vvp
parsetab.py
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

88 changes: 57 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
FROM efabless/openlane-tools:yosys-cfe940a98b08f1a5d08fb44427db155ba1f18b62-centos-7 AS yosys
# ---

FROM swift:5.6-centos7
FROM swift:5.6-centos7 AS builder

# Setup Build Environment
RUN yum install -y --setopt=skip_missing_names_on_install=False https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm centos-release-scl
RUN yum install -y --setopt=skip_missing_names_on_install=False git curl python36 python3-pip devtoolset-8 devtoolset-8-libatomic-devel flex bison readline-devel ncurses-devel autoconf libtool gperf tcl-devel libcurl-devel
RUN yum install -y --setopt=skip_missing_names_on_install=False git gettext curl devtoolset-8 devtoolset-8-libatomic-devel

ENV CC=/opt/rh/devtoolset-8/root/usr/bin/gcc \
CPP=/opt/rh/devtoolset-8/root/usr/bin/cpp \
CXX=/opt/rh/devtoolset-8/root/usr/bin/g++ \
PATH=/opt/rh/devtoolset-8/root/usr/bin:$PATH \
LD_LIBRARY_PATH=/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:$LD_LIBRARY_PATH

# Install Python3
WORKDIR /python3
RUN curl -L https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz | tar --strip-components=1 -xzC . \
&& ./configure --enable-shared --prefix=/build \
&& make -j$(nproc) \
&& make install \
&& rm -rf /python3

# Set environment
ENV PATH=/build/bin:$PATH
ENV PYTHON_LIBRARY /build/lib/libpython3.6m.so
ENV PYTHONPATH /build/lib/pythonpath

# Install Other Dependencies
RUN yum install -y flex bison autoconf libtool gperf tcl-devel libcurl-devel openssl-devel zlib-devel

# ---

# Install Yosys
COPY --from=yosys /build /build
ENV PATH=/build/bin:$PATH

# Install git
RUN yum install -y gettext
# Install Git (Build-only dependency)
WORKDIR /git
RUN curl -L https://github.com/git/git/tarball/e9d7761bb94f20acc98824275e317fa82436c25d/ |\
tar -xzC . --strip-components=1 &&\
make configure &&\
./configure --prefix=/build &&\
./configure --prefix=/usr &&\
make -j$(nproc) &&\
make install &&\
rm -rf *
Expand All @@ -34,37 +50,47 @@ RUN curl -L https://github.com/steveicarus/iverilog/archive/refs/tags/v11_0.tar.
tar --strip-components=1 -xzC . &&\
aclocal &&\
autoconf &&\
./configure &&\
./configure --prefix=/build &&\
make -j$(nproc) &&\
make install &&\
rm -rf *

# Install Atalanta
WORKDIR /atalanta
RUN curl -L https://github.com/hsluoyz/Atalanta/archive/12d405311c3dc9f371a9009bb5cdc8844fe34f90.tar.gz |\
tar --strip-components=1 -xzC . &&\
make &&\
cp atalanta /usr/bin &&\
rm -rf *

# Install PODEM
WORKDIR /podem
RUN curl -L http://tiger.ee.nctu.edu.tw/course/Testing2018/assignments/hw0/podem.tgz |\
tar --strip-components=1 -xzC . &&\
make &&\
cp atpg /usr/bin &&\
rm -rf *

# Install PIP dependencies
# Python Setup
WORKDIR /
RUN python3 -m pip install --upgrade pip
COPY requirements.txt /requirements.txt
RUN python3 -m pip install --upgrade -r /requirements.txt
RUN python3 -m pip install --target /build/lib/pythonpath --upgrade -r ./requirements.txt

# Install Fault
ENV FAULT_YOSYS "yosys"
ENV PYTHON_LIBRARY /lib64/libpython3.so
# Copy Libraries for AppImage
RUN cp /lib64/libtinfo.so.5 /build/lib
RUN cp /lib64/libffi.so.6 /build/lib
RUN cp /lib64/libz.so.1 /build/lib
RUN cp /lib64/libreadline.so.6 /build/lib
RUN cp /lib64/libtcl8.5.so /build/lib

# Fault Setup
WORKDIR /fault
COPY . .
RUN INSTALL_DIR=/usr/bin swift install.swift
WORKDIR /
RUN swift build --static-swift-stdlib -c release
RUN cp /fault/.build/x86_64-unknown-linux-gnu/release/Fault /build/bin/fault
WORKDIR /
# ---

FROM centos:centos7 AS runner
COPY --from=builder /build /build
WORKDIR /test
COPY ./Tests/smoke_test.py .
COPY ./Tests/RTL/spm.v .
COPY ./Tech/osu035 ./osu035

WORKDIR /

# Set environment
ENV PATH=/build/bin:$PATH\
PYTHON_LIBRARY=/build/lib/libpython3.6m.so\
PYTHONPATH=/build/lib/pythonpath\
LD_LIBRARY_PATH=/build/lib\
FAULT_IVL_BASE=/build/lib/ivl\
FAULT_IVERILOG=/build/bin/iverilog\
FAULT_VVP=/build/bin/vvp

CMD [ "/bin/bash" ]
18 changes: 16 additions & 2 deletions OSAcknowledgements
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Fault depends on these great open source projects:

Pyverilog, Tensorflow for Swift/PythonKit, CommandLineKit
Pyverilog, Tensorflow for Swift/PythonKit, CommandLineKit, OpenLane
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -202,7 +202,21 @@ Pyverilog, Tensorflow for Swift/PythonKit, CommandLineKit
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
---
Magic (AppImage Build Files)

Copyright (C) 2022 R. Timothy Edwards

Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies. The University of California
makes no representations about the suitability of this
software for any purpose. It is provided "as is" without
express or implied warranty. Export of this software outside
of the United States of America may require an export license.

---
Python Lex-Yacc

Copyright (C) 2001-2019 David M. Beazley (Dabeaz LLC) All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 🧪 Fault
![Swift 5.2+](https://img.shields.io/badge/Swift-5.2-orange?logo=swift)
![Swift 5.2+](https://img.shields.io/badge/Swift-5.2-orange?logo=swift) ![Docker Image Available for x86-64](https://img.shields.io/static/v1?logo=docker&label=docker&message=x86_64) ![AppImage Available for Linux x86-64](https://img.shields.io/static/v1?label=appimage&message=x86_64&color=blue)

Fault is a complete open source design for testing (DFT) Solution that includes automatic test pattern generation for netlists, scan chain stitching, synthesis scripts and a number of other convenience features.

Expand Down
14 changes: 11 additions & 3 deletions Sources/Fault/Entries/asm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ func assemble(arguments: [String]) -> Int32 {
let filePath = StringOption(
shortFlag: "o",
longFlag: "output",
helpMessage: "Path to the output file. (Default: <json input> + .bin)"
helpMessage: "Path to the output vector file. (Default: <json input> + .vec.bin)"
)
cli.addOptions(filePath)


let goldenFilePath = StringOption(
shortFlag: "O",
longFlag: "goldenOutput",
helpMessage: "Path to the golden output file. (Default: <json input> + .out.bin)"
)
cli.addOptions(goldenFilePath)

do {
try cli.parse()
} catch {
Expand All @@ -51,8 +59,8 @@ func assemble(arguments: [String]) -> Int32 {
let json = jsonArgs[0]
let netlist = vArgs[0]

let vectorOutput = (filePath.value ?? json) + ".vec.bin"
let goldenOutput = (filePath.value ?? json) + ".out.bin"
let vectorOutput = filePath.value ?? "\(json).vec.bin"
let goldenOutput = goldenFilePath.value ?? "\(json).out.bin"

guard let jsonString = File.read(json) else {
Stderr.print("Could not read file '\(json)'")
Expand Down
2 changes: 1 addition & 1 deletion Sources/Fault/Entries/cut.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func cut(arguments: [String]) -> Int32 {
let ignored = StringOption(
shortFlag: "i",
longFlag: "ignoring",
helpMessage: "Hard module inputs to ignore when cutting seperated by commas. (Defautl: none)"
helpMessage: "Hard module inputs to ignore when cutting seperated by commas. (Default: none)"
)
cli.addOptions(ignored)

Expand Down
Loading

0 comments on commit 080f4be

Please sign in to comment.