-
Notifications
You must be signed in to change notification settings - Fork 29
/
build-bindings-job.yml
executable file
·201 lines (174 loc) · 7.09 KB
/
build-bindings-job.yml
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
194
195
196
197
198
199
200
201
parameters:
name: 'Generate bindings'
vmImage: 'ubuntu-latest'
py_maj: '3'
py_min: '11'
py_min_build:
- 9
- 10
- 11
- 12
config_file: 'ocp.toml'
conda_bld: '3.27.0'
conda_env_file: 'environment.devenv.yml'
CXX: g++-12
jobs:
- job: ${{ parameters.name }}
timeoutInMinutes: 360
pool:
vmImage: ${{ parameters.vmImage }}
variables:
n_cores: 2
steps:
- checkout: self
submodules: true
- ${{ if contains(parameters.vmImage, 'Ubuntu') }}:
- bash: sudo apt-get update && sudo apt-get install ${{ parameters.CXX }} mesa-common-dev libegl1-mesa-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev
displayName: 'Install gl headers and the requested compiler'
- ${{ if contains(parameters.vmImage, 'mac') }}:
- bash: |
curl -L -O https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz && \
sudo mkdir -p /opt && \
sudo tar -xf MacOSX11.3.sdk.tar.xz -C /opt && \
sudo mkdir -p /opt/usr/local/ && \
sudo ln -s /opt/MacOSX11.3.sdk/usr/include /opt/usr/local/include && \
sudo ln -s /opt/MacOSX11.3.sdk/System/Library/Frameworks/OpenGL.framework/Headers /usr/local/include/OpenGL
displayName: 'SDK install and symlink'
- template: conda-enable.yml@templates
parameters:
vmImage: ${{ parameters.vmImage }}
- bash: |
mamba-devenv -f ${{ parameters.conda_env_file }}
displayName: 'Prepare conda environment'
- bash: |
source activate cpp-py-bindgen && \
conda info -a && \
conda list && \
which python && \
env
displayName: 'Conda env sanity checks'
- bash: |
source activate cpp-py-bindgen && \
OUTPUT=`python -c'import toml; print(toml.load("${{ parameters.config_file }}")["output_folder"])'` && \
echo $OUTPUT && \
echo "##vso[task.setvariable variable=OUTPUT;isOutput=true]$OUTPUT"
displayName: 'Read output dir from the config file'
name: 'conf'
- bash: |
source activate cpp-py-bindgen && \
cmake -DPython_ROOT_DIR=$CONDA_PREFIX -DPython3_ROOT_DIR=$CONDA_PREFIX -DPython_FIND_VIRTUALENV=ONLY -DPython3_FIND_VIRTUALENV=ONLY -B new -S . -G Ninja
displayName: 'CMake based pywrap call'
name: 'Generate'
- task: CopyFiles@2
inputs:
contents: '*.pkl'
targetFolder: $(conf.OUTPUT)_pkl
displayName: 'Copy pkl outputs'
- publish: $(conf.OUTPUT)
artifact: OCP_src_${{ parameters.vmImage }}
- publish: $(conf.OUTPUT)_pkl
artifact: OCP_pkl_${{ parameters.vmImage }}
- ${{ each py_min in parameters.py_min_build }}:
- job: ${{ parameters.name }}_${{ parameters.py_maj }}_${{ py_min }}
timeoutInMinutes: 360
dependsOn: ${{ parameters.name }}
pool:
vmImage: ${{ parameters.vmImage }}
variables:
n_cores: 2
OCP_src: OCP_src_${{ parameters.vmImage }}
steps:
- download: current
artifact: OCP_src_${{ parameters.vmImage }}
- ${{ if contains(parameters.vmImage, 'Ubuntu') }}:
- bash: sudo apt-get update && sudo apt-get install ${{ parameters.CXX }} mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev
displayName: 'Install gl headers and the requested compiler'
- ${{ if contains(parameters.vmImage, 'mac') }}:
- bash: |
curl -L -O https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.15.sdk.tar.xz && \
sudo mkdir -p /opt && \
sudo tar -xf MacOSX10.15.sdk.tar.xz -C /opt
displayName: 'SDK install'
- ${{ if contains(parameters.vmImage, 'win') }}:
- script: |
choco install --accept-license -y Ninja llvm
displayName: 'Install clang'
- template: conda-enable.yml@templates
parameters:
vmImage: ${{ parameters.vmImage }}
- bash: |
mamba-devenv -f ${{ parameters.conda_env_file }}
displayName: 'Prepare conda environment'
env:
PYTHON_VERSION: ${{ parameters.py_maj }}.${{ py_min }}
STAGE: "compile"
- ${{ if contains(parameters.vmImage, 'Ubuntu') }}:
- bash: |
source activate cpp-py-bindgen && \
mamba list && \
cmake -B build -S "../$(OCP_src)" -G Ninja -DCMAKE_BUILD_TYPE=Release && \
cmake --build build -j $(n_cores) -- -k 0 && \
rm -rf build/CMakeFiles
displayName: 'Compile'
- ${{ if contains(parameters.vmImage, 'mac') }}:
- bash: |
source activate cpp-py-bindgen && \
cp -rf opencascade $CONDA_PREFIX/include && \
cat $CONDA_PREFIX/include/opencascade/OpenGl_HaltonSampler.hxx &&\
cmake -B build -S "../$(OCP_src)" -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT=/opt/MacOSX10.15.sdk/ && \
cmake --build build -j $(n_cores) -- -k 0 && \
rm -rf build/CMakeFiles
displayName: 'Compile'
- ${{ if contains(parameters.vmImage, 'win') }}:
- script: |
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat"
call activate cpp-py-bindgen
cmake -B build -S "../$(OCP_src)" -G Ninja -DCMAKE_BUILD_TYPE=Release -DPython3_FIND_STRATEGY=LOCATION -DPython3_ROOT_DIR=%CONDA_PREFIX% -DCMAKE_LINKER=lld-link.exe
cmake --build build -j $(n_cores) -- -v -k 0
rmdir /S /Q build\CMakeFiles
displayName: 'Compile'
env:
CXX: "cl.exe"
- bash: |
source activate cpp-py-bindgen && \
cd build && \
python -m pybind11_stubgen -o . OCP && \
rm -rf OCP-stubs/setup.py OCP-stubs/__pycache__ OCP-stubs/MANIFEST.in && \
cp -r "../../$(OCP_src)" ../upload && \
cp -r OCP-stubs ../upload
displayName: 'Generate stubs and prepare for upload'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: 'upload'
artifactName: OCP_src_stubs_${{ parameters.vmImage }}
displayName: 'Publish stubs and sources together'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: 'build'
artifactName: OCP_${{ parameters.vmImage }}
displayName: 'Publish compilation result'
- bash: |
source activate cpp-py-bindgen && \
cd build && \
LD_DEBUG=libs python -c"import OCP"
displayName: 'Test'
- bash: |
conda create -n build -y -c conda-forge python=3.11 conda-build anaconda-client && \
source activate build && \
conda build --token $TOKEN --user cadquery --label dev -c conda-forge --override-channels conda
displayName: 'Build conda package'
condition: ne(variables['Build.Reason'], 'PullRequest')
env:
BUILD_STRING: "1"
PYTHON_VERSION: ${{ parameters.py_maj }}.${{ py_min }}
TOKEN: $(anaconda.TOKEN)
- bash: |
conda create -n build -y -c conda-forge python=3.11 conda-build anaconda-client && \
source activate build && \
conda build -c conda-forge --override-channels conda
displayName: 'Build conda package'
condition: eq(variables['Build.Reason'], 'PullRequest')
env:
BUILD_STRING: "1"
PYTHON_VERSION: ${{ parameters.py_maj }}.${{ py_min }}
TOKEN: $(anaconda.TOKEN)