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

Add: gowin nextpnr build #10

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
64 changes: 64 additions & 0 deletions .github/workflows/apicula.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Authors:
# Unai Martinez-Corral
# Lucas Teske
#
# Copyright 2019-2021 Unai Martinez-Corral <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#
# SPDX-License-Identifier: Apache-2.0

name: 'apicula'

on:
pull_request:
push:
schedule:
- cron: '0 0 * * 5'
workflow_dispatch:
repository_dispatch:
types: [ apicula ]

env:
DOCKER_BUILDKIT: 1

jobs:

apicula:
runs-on: ubuntu-latest
steps:

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

- run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH

- run: dockerBuild pkg:apicula apicula pkg
- run: dockerBuild apicula apicula

- run: dockerTestPkg apicula
- run: dockerTest apicula

- name: Login to DockerHub
if: github.event_name != 'pull_request' && github.repository == 'hdl/containers'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}

- run: dockerPush pkg:apicula
if: github.event_name != 'pull_request' && github.repository == 'hdl/containers'

- run: dockerPush apicula
if: github.event_name != 'pull_request' && github.repository == 'hdl/containers'
6 changes: 6 additions & 0 deletions .github/workflows/nextpnr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ jobs:
- run: dockerBuild nextpnr:icestorm nextpnr icestorm
- run: dockerBuild nextpnr:ecp5 nextpnr ecp5
- run: dockerBuild nextpnr:prjtrellis nextpnr prjtrellis
- run: dockerBuild nextpnr:gowin nextpnr gowin
- run: dockerBuild nextpnr:apicula nextpnr apicula
- run: dockerBuild nextpnr nextpnr

- run: dockerTest nextpnr:ice40
- run: dockerTest nextpnr:icestorm
- run: dockerTest nextpnr:ecp5
- run: dockerTest nextpnr:prjtrellis
- run: dockerTest nextpnr:gowin
- run: dockerTest nextpnr

- name: Login to DockerHub
Expand All @@ -74,5 +77,8 @@ jobs:
- run: dockerPush nextpnr:prjtrellis
if: github.event_name != 'pull_request' && github.repository == 'hdl/containers'

- run: dockerPush nextpnr:gowin
if: github.event_name != 'pull_request' && github.repository == 'hdl/containers'

- run: dockerPush nextpnr
if: github.event_name != 'pull_request' && github.repository == 'hdl/containers'
40 changes: 40 additions & 0 deletions apicula.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Authors:
# Unai Martinez-Corral
# Lucas Teske
#
# Copyright 2019-2021 Unai Martinez-Corral <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#
# SPDX-License-Identifier: Apache-2.0

FROM hdlc/build:build AS build

RUN apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends python3-setuptools python3-pip

RUN mkdir /tmp/apicula \
&& cd /tmp/apicula \
&& pip3 install apycula --target /tmp/apicula

#---

FROM scratch AS pkg
COPY --from=build /tmp/apicula /apicula

#---

FROM hdlc/build:base
RUN apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends python3-setuptools python3-pip \
&& pip3 install apycula
40 changes: 36 additions & 4 deletions nextpnr.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,43 @@ COPY --from=build-ecp5 /opt/nextpnr /
FROM ecp5 AS prjtrellis
COPY --from=hdlc/pkg:prjtrellis /prjtrellis /


#---

FROM build-ice40 AS build-all
COPY --from=hdlc/pkg:prjtrellis /prjtrellis /
FROM build AS build-gowin
COPY --from=hdlc/apicula /usr/local/bin/gowin* /usr/local/bin
COPY --from=hdlc/apicula /usr/local/lib/python3.7/dist-packages /usr/local/lib/python3.7/dist-packages

RUN mkdir -p /tmp/nextpnr/build \
&& cd /tmp/nextpnr \
&& curl -fsSL https://codeload.github.com/YosysHQ/nextpnr/tar.gz/master | tar xzf - --strip-components=1 \
&& cd build \
&& cmake .. \
-DARCH=gowin \
-DBUILD_GUI=OFF \
-DBUILD_PYTHON=ON \
-DUSE_OPENMP=ON \
&& make -j $(nproc) \
&& make DESTDIR=/opt/nextpnr install

#---

FROM base AS gowin
Copy link
Member

Choose a reason for hiding this comment

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

There should be two stages here:

FROM base AS gowin

and

FROM gowin AS apicula
COPY --from=hdlc/pkg:apicula /apicula /

The first one would contain artifacts of nextpnr-gowin only; and the second one would include apicula/apycula too.

COPY --from=build-gowin /opt/nextpnr /

#---

FROM gowin AS apicula
COPY --from=hdlc/apicula /usr/local/bin/gowin* /usr/local/bin
COPY --from=hdlc/apicula /usr/local/lib/python3.7/dist-packages /usr/local/lib/python3.7/dist-packages

#---

FROM build AS build-generic

RUN cd /tmp/nextpnr/build \
&& cmake .. \
-DARCH=all \
-DARCH=generic \
-DBUILD_GUI=OFF \
-DBUILD_PYTHON=ON \
-DUSE_OPENMP=ON \
Expand All @@ -109,4 +138,7 @@ RUN cd /tmp/nextpnr/build \
#---

FROM base AS all
Copy link
Member

Choose a reason for hiding this comment

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

This last "all" stage should include all nextpnr-* artifacts: nextpnr-ice40, nextpnr-ecp5, nextpnr-gowin and nextpnr-generic. Maybe it would be desirable to change this to build generic only, since others are built before:

#---

FROM build AS build-all

RUN cd /tmp/nextpnr/build \
 && cmake .. \
   -DARCH=generic \
   -DBUILD_GUI=OFF \
   -DBUILD_PYTHON=ON \
   -DUSE_OPENMP=ON \
 && make -j $(nproc) \
 && make DESTDIR=/opt/nextpnr install

#---

FROM base AS all
COPY --from=build-ice40 /opt/nextpnr /
COPY --from=build-ecp5 /opt/nextpnr /
COPY --from=build-gowin /opt/nextpnr /
COPY --from=build-generic /opt/nextpnr /

Note that this last image does not include icestorm, prjtrellis or apicula/apycula. We can later add another image for that, on top of this stage. But I think it's better to handle that after this PR is done.

Copy link
Member

Choose a reason for hiding this comment

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

Updating build-all to build-generic was contributed by @se-bi. Adding gowin after (#11) should be more straightforward now.

COPY --from=build-all /opt/nextpnr /
COPY --from=build-ice40 /opt/nextpnr /
COPY --from=build-ecp5 /opt/nextpnr /
COPY --from=build-gowin /opt/nextpnr /
COPY --from=build-generic /opt/nextpnr /
28 changes: 28 additions & 0 deletions test/apicula.pkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# Authors:
# Unai Martinez-Corral
#
# Copyright 2020-2021 Unai Martinez-Corral <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#
# SPDX-License-Identifier: Apache-2.0

set -e

cd $(dirname "$0")

./_tree.sh

./_todo.sh
30 changes: 30 additions & 0 deletions test/apicula.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env sh

# Authors:
# Unai Martinez-Corral
#
# Copyright 2020-2021 Unai Martinez-Corral <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#
# SPDX-License-Identifier: Apache-2.0

set -e

cd $(dirname "$0")

./_env.sh

./smoke-tests/apicula.sh

./_todo.sh
31 changes: 31 additions & 0 deletions test/nextpnr--gowin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env sh

# Authors:
# Unai Martinez-Corral
# Lucas Teske
#
# Copyright 2020-2021 Unai Martinez-Corral <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#
# SPDX-License-Identifier: Apache-2.0

set -e

cd $(dirname "$0")

./_env.sh

./smoke-tests/nextpnr-gowin.sh

./_todo.sh
2 changes: 1 addition & 1 deletion test/smoke-tests