|
|
The C example uses the `make` tool to build a simple C program with several compilers. As in the [Python example](python-example), we will make heavy use of the `ligo/software` image as a build environment.
|
|
|
|
|
|
We'll make additional use of `ccache` to reuse `*.o` object files from previous builds when the C code has not changed. This particular example is so simple, it doesn't actually produce `.o` files, but ccache does significantly decrease build time for more complex software. You must include sections like this in your build to take advantage of `ccache`.
|
|
|
```yaml
|
|
|
before_script:
|
|
|
- export PATH=/usr/lib/ccache:/usr/lib64/ccache:$PATH
|
|
|
- export CCACHE_DIR=${CI_PROJECT_DIR}/ccache
|
|
|
|
|
|
# each job's cache is identified by key and it helps to use a reasonably
|
|
|
# unique key that might still be shared between forks of a project
|
|
|
cache:
|
|
|
key: "$CI_PROJECT_NAME/$CI_JOB_NAME"
|
|
|
paths:
|
|
|
- ccache
|
|
|
```
|
|
|
The example jobs combine the building and testing into a single stage because each are so simple. If you have more complicated builds -- or want to test against more current releases of software dependencies -- it may make sense to split the pipeline into multiple stages [using build artifacts](using-build-artifacts).
|
|
|
```yaml
|
|
|
# test against GCC released in Debian 8 "jessie"
|
|
|
jessie:
|
|
|
image: ligo/software:jessie
|
|
|
script:
|
|
|
- make V=1
|
|
|
- ./example
|
|
|
|
|
|
# test against GCC released in RHEL7
|
|
|
el7:
|
|
|
image: ligo/software:el7
|
|
|
script:
|
|
|
- make V=1
|
|
|
- ./example
|
|
|
```
|
|
|
We then test against a variety of [official DockerHub gcc images](https://hub.docker.com/_/gcc/) as well as with `clang`.
|
|
|
```yaml
|
|
|
# test against LLVM/clang released in Debian 8 "jessie"
|
|
|
clang:
|
|
|
image: ligo/software:jessie
|
|
|
script:
|
|
|
- export CC="clang"
|
|
|
- make V=1
|
|
|
- ./example
|
|
|
``` |
|
|
\ No newline at end of file |