๐Ÿ“ฆ apache / nuttx

๐Ÿ“„ cibuild-oot.sh ยท 77 lines
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#!/usr/bin/env bash
############################################################################
# tools/ci/cibuild-oot.sh
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.  The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

set -euo pipefail

CID=$(cd "$(dirname "$0")" && pwd)
CIWORKSPACE=$(cd "${CID}"/../../../ && pwd -P)
NUTTX_PATH=${CIWORKSPACE}/nuttx
APP_PATH=${CIWORKSPACE}/apps

# === CONFIGURATION ===
# Allow overriding from environment for CI
EXPORT_CONFIG=${EXPORT_CONFIG:-"stm32f4discovery:cxx-oot-build"}
OOT_SRC=${OOT_SRC:-"$APP_PATH/testing/cxx-oot-build"}
BUILD_DIR=${BUILD_DIR:-"$OOT_SRC/build"}

# Place ourselves in the nuttx dir
cd $NUTTX_PATH

echo "=== [1/5] Configuring NuttX Export ($EXPORT_CONFIG) ==="
./tools/configure.sh -E -l "$EXPORT_CONFIG"

echo "=== [2/5] Building Export Tarball ==="
make -j"$(nproc)" export

EXPORT_TARBALL=$(find . -maxdepth 1 -type f -name "nuttx-export-*.tar.gz" | sort | tail -n 1)
if [[ -z "$EXPORT_TARBALL" ]]; then
    echo "โŒ ERROR: No export tarball found"
    exit 1
fi

echo "=== [3/5] Preparing Out of Tree (OOT) Project ==="
rm -rf "$OOT_SRC"/nuttx-export-*
tar -xzf "$EXPORT_TARBALL" -C "$OOT_SRC"

TOOLCHAIN_FILE=$(find "$OOT_SRC" -type f -path "*/scripts/toolchain.cmake" | head -n 1)
if [[ ! -f "$TOOLCHAIN_FILE" ]]; then
    echo "โŒ ERROR: toolchain.cmake not found after export"
    exit 1
fi

echo "=== [4/5] Building OOT ==="
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
cmake .. -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE"
make -j"$(nproc)"

echo "=== [5/5] Verifying Output ==="
if [[ ! -f "$BUILD_DIR/oot" || ! -f "$BUILD_DIR/oot.bin" ]]; then
    echo "โŒ ERROR: oot or oot.bin not found in $BUILD_DIR"
    exit 1
fi

echo "โœ… SUCCESS: OOT build completed. Output:"
ls -lh "$BUILD_DIR"/oot*