Skip to content

Commit a646d29

Browse files
committed
Use tabs for v0/v1 recipes
Signed-off-by: Michał Górny <[email protected]>
1 parent 9eedc3a commit a646d29

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

docs/how-to/advanced/cross-compilation.md renamed to docs/how-to/advanced/cross-compilation.mdx

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
title: 'Cross-compilation'
33
---
44

5+
import Tabs from '@theme/Tabs';
6+
import TabItem from '@theme/TabItem';
7+
58
Cross-compiling means building a package for a different architecture than the one the build process
69
is running on. It is a common way of obtaining packages for an architecture that conda-forge does
710
not provide any runners for (the other available technique is
@@ -117,6 +120,9 @@ are a few examples.
117120

118121
A simple C library using autotools for cross-compilation might look like this:
119122

123+
<Tabs groupId="recipe">
124+
125+
<TabItem label="v0 (meta.yaml)" value="v0">
120126
```yaml
121127
requirements:
122128
build:
@@ -128,6 +134,23 @@ requirements:
128134
host:
129135
- libogg
130136
```
137+
</TabItem>
138+
139+
<TabItem label="v1 (recipe.yaml)" value="v1">
140+
```yaml
141+
requirements:
142+
build:
143+
- ${{ compiler("c") }}
144+
- ${{ stdlib("c") }}
145+
- make
146+
- pkg-config
147+
- gnuconfig
148+
host:
149+
- libogg
150+
```
151+
</TabItem>
152+
153+
</Tabs>
131154

132155
In the build script, it would need to update the config files and guard any tests when
133156
cross-compiling:
@@ -149,6 +172,9 @@ fi
149172

150173
A simple C++ library using CMake for cross-compilation might look like this:
151174

175+
<Tabs groupId="recipe">
176+
177+
<TabItem label="v0 (meta.yaml)" value="v0">
152178
```yaml
153179
requirements:
154180
build:
@@ -159,6 +185,22 @@ requirements:
159185
host:
160186
- libboost-devel
161187
```
188+
</TabItem>
189+
190+
<TabItem label="v1 (recipe.yaml)" value="v1">
191+
```yaml
192+
requirements:
193+
build:
194+
- ${{ compiler("cxx") }}
195+
- ${{ stdlib("c") }}
196+
- cmake
197+
- ninja
198+
host:
199+
- libboost-devel
200+
```
201+
</TabItem>
202+
203+
</Tabs>
162204

163205
In the build script, it would need to update `cmake` call and guard any tests when cross-compiling:
164206

@@ -177,6 +219,9 @@ fi
177219

178220
Similarly, with Meson, the `meta.yaml` needs:
179221

222+
<Tabs groupId="recipe">
223+
224+
<TabItem label="v0 (meta.yaml)" value="v0">
180225
```yaml
181226
requirements:
182227
build:
@@ -188,6 +233,23 @@ requirements:
188233
host:
189234
- libogg
190235
```
236+
</TabItem>
237+
238+
<TabItem label="v1 (recipe.yaml)" value="v1">
239+
```yaml
240+
requirements:
241+
build:
242+
- ${{ compiler("c") }}
243+
- ${{ compiler("cxx") }}
244+
- ${{ stdlib("c") }}
245+
- meson
246+
- pkg-config
247+
host:
248+
- libogg
249+
```
250+
</TabItem>
251+
252+
</Tabs>
191253

192254
And this in `build.sh`:
193255

@@ -201,6 +263,9 @@ meson compile
201263

202264
A simple Python extension using Cython and NumPy's C API would look like so:
203265

266+
<Tabs groupId="recipe">
267+
268+
<TabItem label="v0 (meta.yaml)" value="v0">
204269
```yaml
205270
requirements:
206271
build:
@@ -218,13 +283,41 @@ requirements:
218283
run:
219284
- python
220285
```
286+
</TabItem>
287+
288+
<TabItem label="v1 (recipe.yaml)" value="v1">
289+
```yaml
290+
requirements:
291+
build:
292+
- ${{ compiler("c") }}
293+
- ${{ stdlib("c") }}
294+
- if: build_platform != target_platform
295+
then:
296+
- cross-python_{{ target_platform }}
297+
- python
298+
- cython
299+
- numpy
300+
host:
301+
- python
302+
- pip
303+
- cython
304+
- numpy
305+
run:
306+
- python
307+
```
308+
</TabItem>
309+
310+
</Tabs>
221311

222312
For more details about NumPy see [Building against NumPy](/docs/maintainer/knowledge_base/#building-against-numpy).
223313

224314
### MPI
225315

226316
With MPI, openmpi is required for the build platform as the compiler wrappers are binaries, but mpich is not required as the compiler wrappers are scripts (see [example](https://github.com/conda-forge/mpi4py-feedstock/blob/743d379c4a04/recipe/meta.yaml#L37)):
227317

318+
<Tabs groupId="recipe">
319+
320+
<TabItem label="v0 (meta.yaml)" value="v0">
228321
```yaml
229322
requirements:
230323
build:
@@ -234,6 +327,22 @@ requirements:
234327
run:
235328
- {{ mpi }}
236329
```
330+
</TabItem>
331+
332+
<TabItem label="v1 (recipe.yaml)" value="v1">
333+
```yaml
334+
requirements:
335+
build:
336+
- if: build_platform != target_platform and mpi == "openmpi"
337+
then: ${{ mpi }}
338+
host:
339+
- ${{ mpi }}
340+
run:
341+
- ${{ mpi }}
342+
```
343+
</TabItem>
344+
345+
</Tabs>
237346

238347
In the build script, openmpi compiler wrappers can use host libraries by setting the environmental variable `OPAL_PREFIX` to `$PREFIX`.
239348

0 commit comments

Comments
 (0)