-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun-conan.sh
More file actions
executable file
·193 lines (170 loc) · 6.24 KB
/
run-conan.sh
File metadata and controls
executable file
·193 lines (170 loc) · 6.24 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# SPDX-FileCopyrightText: 2024 Howetuft
#
# SPDX-License-Identifier: Apache-2.0
# This is the main script. It installs build tools, retrieve local recipes and
# remote recipes, build everything and make the dependency cache.
# Caveat!
# LUXDEPS_VERSION, RUNNER_OS, RUNNER_ARCH are expected to be set by caller beforehand
#
die() { rc=$?; (( $# )) && printf '::error::%s\n' "$*" >&2; exit $(( rc == 0 ? 1 : rc )); }
test -n "$LUXDEPS_VERSION" || die "LUXDEPS_VERSION not set"
test -n "$RUNNER_OS" || die "RUNNER_OS not set"
test -n "$RUNNER_ARCH" || die "RUNNER_ARCH not set"
CONAN_PROFILE=conan-profile-${RUNNER_OS}-${RUNNER_ARCH}
# The following variable contains the commit where Conan Center Index will be
# checked out. This is utterly important for maintenability that Conan Center
# Index be pinned at a given commit. Otherwise, spurious unwanted updates will
# gradually happen and finally break the build.
# To the contrary, you may need to upgrade this commit when you want to upgrade
# a given dependency.
CONAN_COMMIT=d60a35f00bf85fd1abf2df0877878f54404e3df0
# Debug utility (install a specific package)
function debug() {
conan install \
--requires=$1 \
--profile:all=$CONAN_PROFILE \
--remote=mycenter \
--remote=mylocal \
--build="*"
}
# Script starts here
# 0. Initialize: set globals and install conan and ninja
set -exo pipefail
if [[ "$RUNNER_OS" == "Linux" && -n "$CI" ]]; then
echo "Linux - CI"
cache_dir=/conan-cache
elif [[ "$RUNNER_OS" == "Linux" && -z "$CI" ]]; then
# Linux - Plain local build
echo "Linux - Plain local build"
cache_dir=/tmp/conan-cache
else
# Others
echo "MacOS or Windows - CI build"
cache_dir=$WORKSPACE/conan-cache
fi
echo "::group::CIBW_BEFORE_BUILD: pip"
pipx install conan
pipx install ninja
echo "::endgroup::"
# 1. Clone conancenter at a specific commit and add this cloned repo as a
# remote ('mycenter')
# This has 2 benefits:
# - We can decide which packages will be built from sources (remote=mycenter)
# and which ones will use precompiled binaries (remote=conancenter)
# - We pin the index to a specific state (commit), which avoids spurious
# updates
# https://docs.conan.io/2/devops/devops_local_recipes_index.html
echo "::group::CIBW_BEFORE_BUILD: local recipes index repository"
# Delete conan-center-index if exists
if [ ! -d "conan-center-index" ]; then
git clone https://github.com/conan-io/conan-center-index
cd conan-center-index
git reset --hard ${CONAN_COMMIT}
git clean -df # cleans any untracked files/folders
# Workaround for temporary unavailability of giflib in conan index (2026-03-22)
# TODO Remove when patch has been accepted
#git remote add "upstream" git@github.com:conan-io/conan-center-index.git
#git fetch upstream pull/29758/head:giflib
#git cherry-pick 0e95d1b1e8380d72df48c7c48efe14f39239826a
git config --global user.name "LuxCoreDeps"
git config --global user.email "luxcoredeps@luxcore.com"
curl -L https://github.com/conan-io/conan-center-index/pull/29758.patch | git am
cd ..
fi
conan remote add mycenter ./conan-center-index --force
# 2. Add local recipe repository (as a remote)
conan remote add mylocal ./conan-local-recipes --force
conan list -r mylocal
echo "::endgroup::"
if [[ "$RUNNER_OS" == "Linux" ]]; then
# ispc
echo "::group::CIBW_BEFORE_BUILD: ispc"
source /opt/intel/oneapi/setvars.sh
echo "::endgroup::"
fi
# 3. Restore conan cache (add -vverbose to debug)
echo "::group::CIBW_BEFORE_BUILD: restore conan cache"
cachefile=$cache_dir/conan-cache-save.tgz
if [[ -e $cachefile ]]; then
conan cache restore $cachefile
else
echo "::warning::No cache file $cachefile"
fi
echo "::endgroup::"
# 4. Install profiles
echo "::group::CIBW_BEFORE_BUILD: Install profiles"
conan create $WORKSPACE/conan-profiles \
--profile:all=$WORKSPACE/conan-profiles/$CONAN_PROFILE \
--version=$LUXDEPS_VERSION
conan config install-pkg -vvv luxcoreconf/$LUXDEPS_VERSION@luxcore/luxcore
echo "::endgroup::"
# 5. Install build requirements
echo "::group::CIBW_BEFORE_BUILD: Install tool requirements"
# We specify conancenter as a remote, thus allowing to use precompiled
# binaries.
# For pkgconf and meson, we have to manually target the right version
build_deps=(b2/[*] cmake/[*] m4/[*] pkgconf/2.1.0 meson/1.2.2 yasm/[*])
if [[ $RUNNER_OS == "Windows" ]]; then
build_deps+=(msys2/[*])
fi
for d in "${build_deps[@]}"; do
conan install \
--tool-requires=${d} \
--profile:all=$CONAN_PROFILE \
--build=missing \
--remote=conancenter \
--build=b2/*
done
echo "::endgroup::"
if [[ $RUNNER_OS == "Windows" ]]; then
DEPLOY_PATH=$(cygpath "C:\\Users\\runneradmin")
else
DEPLOY_PATH=$WORKSPACE
fi
# 6. Show graph (for debug purpose)
echo "::group::CIBW_BEFORE_BUILD: Explain graph"
# This is only for debugging purpose...
cd $WORKSPACE
conan graph info $WORKSPACE \
--profile:all=$CONAN_PROFILE \
--version=$LUXDEPS_VERSION \
--remote=mycenter \
--remote=mylocal \
--build=missing \
--format=dot
echo "::endgroup::"
# (Debug) Install particular package, for debugging
#echo "::group::CIBW_BEFORE_BUILD: Debug"
#debug "onetbb/2022.2.0"
#exit 1
#echo "::endgroup::"
# 7. Create luxcoredeps package and all dependencies
# (we do not specify conancenter as a remote, so it prevents conan from using
# precompiled binaries and it forces compilation)
echo "::group::CIBW_BEFORE_BUILD: Create LuxCore Deps"
cd $WORKSPACE
conan create $WORKSPACE \
--profile:all=$CONAN_PROFILE \
--version=$LUXDEPS_VERSION \
--remote=mycenter \
--remote=mylocal \
--build=missing
echo "::endgroup::"
# 8. Save result
echo "::group::Saving dependencies in ${cache_dir}"
conan cache clean "*" # Clean non essential files
conan remove -c -vverbose "*/*#!latest" # Keep only latest version of each package
# Save only dependencies of current target (otherwise cache gets bloated)
conan graph info \
--requires=luxcoredeps/$LUXDEPS_VERSION@luxcore/luxcore \
--requires=luxcoreconf/$LUXDEPS_VERSION@luxcore/luxcore \
--format=json \
--remote=mycenter \
--remote=mylocal \
--profile:all=$CONAN_PROFILE \
> graph.json
conan list --graph=graph.json --format=json --graph-binaries=Cache > list.json
conan cache save -vverbose --file=${cache_dir}/conan-cache-save.tgz --list=list.json
# Save build info
python utils/get-build-info.py > ${cache_dir}/build-info.json
echo "::endgroup::"