Skip to content

Commit b170fa5

Browse files
cyphalization of c_cpp (#15)
1 parent 48f6687 commit b170fa5

File tree

9 files changed

+144
-80
lines changed

9 files changed

+144
-80
lines changed

.github/workflows/c_cpp.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: ghcr.io/opencyphal/c_cpp container build and publish.
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
defaults:
9+
run:
10+
working-directory: ./c_cpp
11+
12+
jobs:
13+
14+
build:
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: pull
22+
run: docker pull ghcr.io/opencyphal/c_cpp:ubuntu-20.04
23+
- name: build
24+
run: docker build . --tag ghcr.io/opencyphal/c_cpp:ubuntu-20.04
25+
- name: push
26+
if: ${{ github.event_name != 'pull_request' }}
27+
run: docker push ghcr.io/OpenCyphal/c_cpp:ubuntu-20.04

LICENSE

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
MIT License
1+
The MIT License (MIT)
22

3-
Copyright (c) 2020 UAVCAN
3+
Copyright (c) 2014 Pavel Kirienko
4+
Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
45

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
1112

1213
The above copyright notice and this permission notice shall be included in all
1314
copies or substantial portions of the Software.
1415

1516
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
![UAVCAN](uavcan_logo.svg) UAVCAN Containerized Toolchains
1+
![OpenCyphal](opencyphal_logo.svg) OpenCyphal Containerized Toolchains
22
===================
33

4-
This repository contains the Dockerfiles, instructions, and some utilities for building containers to be used as common toolchains for the UAVCAN project. These containers are published to the [uavcan organization on Docker Hub](https://cloud.docker.com/u/uavcan) and are used by the build automation for UAVCAN projects. You can use these same containers to get consistent build results in your local development environment.
4+
This repository contains the Dockerfiles, instructions, and some utilities for building containers to be used as common
5+
toolchains for OpenCyphal projects. These containers are published to the
6+
[opencyphal organization on Github](https://github.com/orgs/OpenCyphal/packages) and are used by the build automation
7+
for OpenCyphal projects. You can use these same containers to get consistent build results in your local development
8+
environment.

c_cpp/Dockerfile

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,45 @@ RUN /provision.sh
2020
# +---------------------------------------------------------------------------+
2121
# | INSTALL TOOLCHAINS
2222
# +---------------------------------------------------------------------------+
23-
ARG GCC_ARM_NONE_EABI_PLATFORM=x86_64-linux
24-
ARG GCC_ARM_NONE_EABI_VERSION=10-2020-q4-major
23+
24+
# ARM: M-Cores, Bare Metal
25+
ARG GCC_ARM_NONE_EABI_PLATFORM=x86_64
26+
ARG GCC_ARM_NONE_EABI_VERSION=11.2-2022.02
27+
ARG GCC_ARM_NONE_EABI_TRIPLE=arm-none-eabi
28+
ARG GCC_ARM_NONE_EABI_BASENAME=gcc-arm-${GCC_ARM_NONE_EABI_VERSION}-${GCC_ARM_NONE_EABI_PLATFORM}-${GCC_ARM_NONE_EABI_TRIPLE}
29+
ARG GCC_ARM_NONE_EABI_REV=99a2bce6f4464be08eca01eda13e4e96
30+
ARG GCC_ARM_NONE_EABI_HASH=C371F8D384D7F8DC08BFE154352AA3AE
2531

2632
WORKDIR /tmp
27-
ADD https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2?revision=ca0cbf9c-9de2-491c-ac48-898b5bbc0443&la=en&hash=68760A8AE66026BCF99F05AC017A6A50C6FD832A /tmp/gcc-arm-none-eabi-${GCC_ARM_NONE_EABI_VERSION}-${GCC_ARM_NONE_EABI_PLATFORM}.tar.bz2
28-
RUN tar xjf gcc-arm-none-eabi-${GCC_ARM_NONE_EABI_VERSION}-${GCC_ARM_NONE_EABI_PLATFORM}.tar.bz2 -C /usr/share/
29-
RUN rm gcc-arm-none-eabi-${GCC_ARM_NONE_EABI_VERSION}-${GCC_ARM_NONE_EABI_PLATFORM}.tar.bz2
33+
ADD https://developer.arm.com/-/media/Files/downloads/gnu/${GCC_ARM_NONE_EABI_VERSION}/binrel/${GCC_ARM_NONE_EABI_BASENAME}.tar.xz?rev=${GCC_ARM_NONE_EABI_REV}&hash=${GCC_ARM_NONE_EABI_HASH} /tmp/${GCC_ARM_NONE_EABI_BASENAME}.tar.xz
34+
RUN tar xJf ${GCC_ARM_NONE_EABI_BASENAME}.tar.xz -C /usr/share/
35+
RUN rm ${GCC_ARM_NONE_EABI_BASENAME}.tar.xz
36+
37+
ENV PATH="/usr/share/${GCC_ARM_NONE_EABI_BASENAME}/bin:${PATH}"
38+
39+
RUN ${GCC_ARM_NONE_EABI_TRIPLE}-gcc --version
40+
41+
# ARM: A-Cores, Linux
42+
ARG GCC_ARM_NONE_LINUX_PLATFORM=x86_64
43+
ARG GCC_ARM_NONE_LINUX_VERSION=11.2-2022.02
44+
ARG GCC_ARM_NONE_LINUX_TRIPLE=arm-none-linux-gnueabihf
45+
ARG GCC_ARM_NONE_LINUX_BASENAME=gcc-arm-${GCC_ARM_NONE_LINUX_VERSION}-${GCC_ARM_NONE_LINUX_PLATFORM}-${GCC_ARM_NONE_LINUX_TRIPLE}
46+
ARG GCC_ARM_NONE_LINUX_REV=ffc49e4af4cb4c298c2110a4d887716c
47+
ARG GCC_ARM_NONE_LINUX_HASH=13DC7A96AEA6FB1D479EB23B782E79EB
48+
49+
ADD https://developer.arm.com/-/media/Files/downloads/gnu/${GCC_ARM_NONE_LINUX_VERSION}/binrel/${GCC_ARM_NONE_LINUX_BASENAME}.tar.xz?rev=${GCC_ARM_NONE_LINUX_REV}&hash=${GCC_ARM_NONE_LINUX_HASH} /tmp/${GCC_ARM_NONE_LINUX_BASENAME}.tar.xz
50+
RUN tar xJf ${GCC_ARM_NONE_LINUX_BASENAME}.tar.xz -C /usr/share/
51+
RUN rm ${GCC_ARM_NONE_LINUX_BASENAME}.tar.xz
3052

31-
ENV PATH="/usr/share/gcc-arm-none-eabi-${GCC_ARM_NONE_EABI_VERSION}/bin:${PATH}"
53+
ENV PATH="/usr/share/${GCC_ARM_NONE_LINUX_BASENAME}/bin:${PATH}"
54+
55+
RUN ${GCC_ARM_NONE_LINUX_TRIPLE}-gcc --version
3256

33-
HEALTHCHECK CMD arm-none-eabi-gcc --version
3457

3558
# +---------------------------------------------------------------------------+
3659
# | INSTALL SONAR SCANNER
3760
# +---------------------------------------------------------------------------+
38-
ENV SONAR_SCANNER_VERSION 4.2.0.1873
61+
ENV SONAR_SCANNER_VERSION 4.7.0.2747
3962
ENV SONAR_SCANNER_HOME=/sonar-scanner-${SONAR_SCANNER_VERSION}-linux
4063
ENV SONAR_SCANNER_OPTS="-server"
4164

@@ -45,6 +68,11 @@ ENV PATH="${SONAR_SCANNER_HOME}/sonar-scanner-${SONAR_SCANNER_VERSION}-linux/bin
4568
COPY sonar_qube.sh /
4669
RUN /sonar_qube.sh
4770

71+
# +---------------------------------------------------------------------------+
72+
# | INSTALL THE PATH FOR INTERATIVE SESSIONS
73+
# +---------------------------------------------------------------------------+
74+
RUN echo "export PATH=$PATH" >> ~/.bashrc
75+
4876
# +---------------------------------------------------------------------------+
4977
# | INSTALL PYTHON AND NPM STUFF
5078
# +---------------------------------------------------------------------------+

c_cpp/README.md

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
# C/C++ Toolchain Docker
22

3-
The `uavcan/c_cpp` docker image provides a consistent build and test environment
3+
The `opencyphal/c_cpp` docker image provides a consistent build and test environment
44
for development, continuous-integration, and test automation of C and C++ based projects.
55

66
## Manual Build and Push
77

8-
These instructions are for maintainers with permissions to push to the [uavcan organization on Docker Hub](https://cloud.docker.com/u/uavcan).
8+
These instructions are for maintainers with permissions to push to the
9+
[OpenCyphal organization on Github](https://github.com/OpenCyphal/). Normally the container should be published by
10+
a github action but these instructions provide a way to manually update the container from any developer environment.
911

10-
```bash
11-
docker build .
12-
```
12+
First create a temporary (7-day expiration please) personal access token (classic) with write:packages and read:packages
13+
scope. See [this github help page](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
14+
for instructions.
1315

14-
```bash
15-
docker images
16+
Next, make sure you can login:
1617

17-
REPOSITORY TAG IMAGE ID CREATED SIZE
18-
<none> <none> 736647481ad3 About a minute ago 1GB
18+
```bash
19+
export FGP = (fine-grained permission for OpenCyphal organization)
20+
echo $FGP | docker login ghcr.io -u (github username) --password-stdin
1921
```
2022

23+
... now build:
24+
2125
```bash
22-
docker tag 736647481ad3 uavcan/c_cpp:ubuntu-20.04
23-
docker login --username=yourhubusername
24-
docker push uavcan/c_cpp:ubuntu-20.04
26+
docker build -t ghcr.io/opencyphal/c_cpp:ubuntu-20.04 .
2527
```
2628

27-
Use this pattern for tags:
29+
... and finally, push.
2830

2931
```bash
30-
uavcan/[toolchain]:[build environment]
32+
docker push ghcr.io/opencyphal/c_cpp:ubuntu-20.04
3133
```
3234

3335
## Testing out the container
3436

3537
To login to an interactive session do:
3638

3739
```bash
38-
docker run --rm -it -v ${PWD}:/repo uavcan/c_cpp:ubuntu-20.04
40+
docker run --rm -it -v ${PWD}:/repo ghcr.io/opencyphal/c_cpp:ubuntu-20.04
3941
```
4042

4143
## Toolchain Documentation
@@ -52,8 +54,8 @@ Upload the results:
5254

5355
```bash
5456
sonar-scanner \
55-
-Dsonar.organization=uavcan \
56-
-Dsonar.projectKey=UAVCAN_myproject \
57+
-Dsonar.organization=OpenCyphal \
58+
-Dsonar.projectKey=OpenCyphal_myproject \
5759
-Dsonar.sources=. \
5860
-Dsonar.host.url=https://sonarcloud.io \
5961
-Dsonar.cfamily.build-wrapper-output=bw-output \
@@ -62,33 +64,13 @@ sonar-scanner \
6264

6365
A [CMake example on github](https://github.com/SonarSource/sonarcloud_example_cpp-cmake-linux-otherci)
6466

65-
## Travis CI
67+
## Github Actions
6668

67-
You can use this in your .travis.yml like this:
69+
You can use this in your workflow yaml like this:
6870

6971
```none
70-
services:
71-
- docker
72-
73-
before_install:
74-
- docker pull uavcan/c_cpp:ubuntu-20.04
75-
76-
script:
77-
- docker run --rm -v $TRAVIS_BUILD_DIR:/repo uavcan/c_cpp:ubuntu-20.04 /bin/sh -c mybuild_command
78-
79-
```
80-
81-
## BuildKite
82-
83-
Example pipeline.yml:
84-
85-
```yaml
86-
- label: ":github: my containerized build"
87-
command: "my_build_command"
88-
plugins:
89-
- docker#v3.5.0:
90-
workdir: /repo
91-
image: "uavcan/c_cpp:ubuntu-20.04"
92-
propagate-environment: true
93-
mount-ssh-agent: true
72+
jobs:
73+
my-job:
74+
runs-on: ubuntu-latest
75+
container: ghcr.io/opencyphal/c_cpp:ubuntu-20.04
9476
```

c_cpp/provision.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export ENV LANGUAGE=en_US:en
3232
export ENV LC_ALL=en_US.UTF-8
3333

3434
apt-get -y install software-properties-common
35+
add-apt-repository -y ppa:deadsnakes/ppa
3536
apt-get update
3637
apt-get -y install apt-utils
37-
apt-get -y install python3
38+
apt-get -y install python3.10
3839
apt-get -y install python3-pip
39-
apt-get -y install python3-venv
4040
apt-get -y install cmake
4141
apt-get -y install git
4242
apt-get -y install clang
@@ -56,7 +56,6 @@ apt-get -y install qemu
5656
apt-get -y install ninja-build
5757
apt-get -y install can-utils
5858

59-
echo "export PATH=$PATH" >> ~/.bashrc
6059
echo "export LANG=en_US.UTF-8" >> ~/.bashrc
6160
echo "export LANGUAGE=en_US:en" >> ~/.bashrc
6261
echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc

opencyphal_logo.svg

Lines changed: 33 additions & 0 deletions
Loading

toxic/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ARG DEBIAN_FRONTEND=noninteractive
1212
RUN apt-get update && apt-get -y install apt-utils && apt-get -y install locales
1313
RUN locale-gen en_US.UTF-8
1414

15-
ENV SONAR_SCANNER_VERSION 4.6.2.2472
15+
ENV SONAR_SCANNER_VERSION 4.8.0.2856
1616
ENV LANG=en_US.UTF-8
1717
ENV LANGUAGE=en_US:en
1818
ENV LC_ALL=en_US.UTF-8

0 commit comments

Comments
 (0)