File: build-docker.sh

package info (click to toggle)
apitrace 11.1%2Brepack-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 13,648 kB
  • sloc: cpp: 183,110; python: 33,685; ansic: 25,073; sh: 143; makefile: 88
file content (75 lines) | stat: -rwxr-xr-x 1,928 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh

set -e
set -x

source_dir=$PWD

distro="$1"
shift
test -f $source_dir/ci/docker/$distro.Dockerfile

build_dir=$source_dir/build/docker-$distro
docker_tag=$distro-apitrace
uid=$(id -u)

test -t 0 && interactive=true || interactive=false

docker_run () {
    docker run \
        --rm \
        -i=$interactive \
        --tty=$interactive \
        -v "$PWD:$PWD" \
        -w "$PWD" \
        -u "$uid" \
        $docker_tag \
        "$@"
}

symbol_versions () {
    # https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html
    objdump -p "$@" | sed -n -e '/^Version References:/,$p'
}


if [ "$GITHUB_ACTIONS" = true ]
then
    # See:
    # - https://dev.to/dtinth/caching-docker-builds-in-github-actions-which-approach-is-the-fastest-a-research-18ei
    # - https://github.com/dtinth/github-actions-docker-layer-caching-poc/blob/master/.github/workflows/dockerimage.yml
    docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache || true
    docker build -t $docker_tag --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache -f $source_dir/ci/docker/$distro.Dockerfile $source_dir/ci/docker
    docker tag $docker_tag docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache || true
else
    docker build -t $docker_tag -f $source_dir/ci/docker/$distro.Dockerfile $source_dir/ci/docker
fi

if [ "$PACKAGE" = "true" ]
then
    CMAKE_BUILD_TYPE=Release
else
    CMAKE_BUILD_TYPE=Debug
fi

docker_run \
    cmake \
    -H$source_dir \
    -B$build_dir \
    -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
    "$@"

docker_run cmake --build $build_dir
if false
then
    docker_run cmake --build $build_dir --target test
fi

symbol_versions $build_dir/glretrace
symbol_versions $build_dir/eglretrace
symbol_versions $build_dir/wrappers/glxtrace.so

if [ "$PACKAGE" = true ]
then
    docker_run cmake --build $build_dir --target package
fi