FROM ubuntu:focal-20201106

ENV DEBIAN_FRONTEND=noninteractive

RUN set -e -x ;\
    apt-get -y update ;\
    apt-get -y upgrade ;\
    apt-get -y install \
        build-essential autoconf cmake clang bison wget flex gperf \
        libreadline-dev gawk tcl-dev libffi-dev graphviz xdot python3-dev \
        libboost-all-dev qt5-default git libftdi-dev pkg-config libeigen3-dev \
        zlib1g-dev curl python3-pip libcapnp-dev capnproto


RUN set -e -x ;\
    mkdir -p /usr/local/src ;\
    cd /usr/local/src ;\
    git clone --recursive https://github.com/steveicarus/iverilog.git ;\
    cd iverilog ;\
    git reset --hard 84b4ebee0cfcda28a242d89a07020cd70b1d3e7f ;\
    sh autoconf.sh ;\
    ./configure ;\
    make -j $(nproc) ;\
    make install ;\
    rm -rf /usr/local/src/iverilog

RUN set -e -x ;\
    mkdir -p /usr/local/src ;\
    cd /usr/local/src ;\
    git clone --recursive https://github.com/YosysHQ/icestorm.git ;\
    cd icestorm ;\
    git reset --hard 4bc68c9620e6be20f8fe10d20f84681d80beac23 ;\
    make -j $(nproc) ;\
    make install

RUN set -e -x ;\
    mkdir -p /usr/local/src ;\
    cd /usr/local/src ;\
    git clone --recursive https://github.com/YosysHQ/yosys.git ;\
    cd yosys ;\
    git reset --hard cd8b2ed4e6f9447c94d801de7db7ae6ce0976d57 ;\
    make -j $(nproc) ;\
    make install ;\
    rm -rf /usr/local/src/yosys

RUN set -e -x ;\
    mkdir -p /usr/local/src ;\
    cd /usr/local/src ;\
    git clone --recursive https://github.com/YosysHQ/prjtrellis.git ;\
    cd prjtrellis ;\
    git reset --hard 7239331d5463321d4864164f320beef67310f1e5 ;\
    cd libtrellis ;\
    cmake . ;\
    make -j $(nproc) ;\
    make install

RUN set -e -x ;\
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ;\
    mkdir -p /usr/local/src ;\
    cd /usr/local/src ;\
    git clone --recursive https://github.com/gatecat/prjoxide.git ;\
    cd prjoxide ;\
    git reset --hard 318331f8b30c2e2a31cc41d51f104b671e180a8a ;\
    cd libprjoxide ;\
    PATH=$PATH:$HOME/.cargo/bin cargo install --path prjoxide

RUN set -e -x ;\
    pip3 install apycula==0.2a4
