summaryrefslogtreecommitdiff
path: root/.travis/cmake-freebsd-stage2
blob: 6db74542a3c9c34eb6a2241c892f6a359b2cd593 (plain)
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
76
77
78
#!/bin/bash

# Toxcore building

ACTION="$1"

set -eux

. .travis/cmake-freebsd-env.sh

travis_install() {
  sudo apt-get update
  sudo apt-get install -y qemu screen

  OLD_PWD="$PWD"

  mkdir -p /opt/freebsd/cache
  cd /opt/freebsd/cache

  # Extract the cached image
  tar -Sxzvf "$IMAGE_NAME.tgz"

  # Get the image we will be using out of the cached directory
  mv "$IMAGE_NAME" ..
  ls -lh

  cd ..

  ls -lh

  # === Get VM ready to build the code ===

  start_vm

  cd "$OLD_PWD"

  # Copy over toxcore code from Travis to qemu
  scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -P "$SSH_PORT" -r ./* root@localhost:~

  RUN ls -lh
}

travis_script() {
  CACHEDIR="none"
  . ".travis/flags-$CC.sh"

  add_ld_flag -Wl,-z,defs

  # Make compilation error on a warning
  add_flag -Werror

  RUN 'cmake -B_build -H. \
    -DCMAKE_C_FLAGS="$C_FLAGS" \
    -DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
    -DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
    -DCMAKE_SHARED_LINKER_FLAGS="$LD_FLAGS" \
    -DCMAKE_INSTALL_PREFIX:PATH="_install" \
    -DMIN_LOGGER_LEVEL=TRACE \
    -DMUST_BUILD_TOXAV=ON \
    -DNON_HERMETIC_TESTS=ON \
    -DSTRICT_ABI=ON \
    -DTEST_TIMEOUT_SECONDS=300 \
    -DUSE_IPV6=OFF \
    -DAUTOTEST=ON'

  # We created the VM with the same number of cores as the host, so the host-ran `nproc` here is fine
  RUN 'gmake "-j$NPROC" -k install -C_build'
  RUN 'gmake "-j$NPROC" test ARGS="-j50" -C_build || \
    gmake "-j1" -C_build test ARGS="-j1 --rerun-failed" || \
    gmake "-j1" -C_build test ARGS="-j1 --rerun-failed" CTEST_OUTPUT_ON_FAILURE=1 || \
    true'
}

if [ "-z" "$ACTION" ]; then
  "travis_script"
else
  "travis_$ACTION"
fi