|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | 3 | mkdir artifacts |
4 | | -cp **/**/*.px4 artifacts/ |
5 | | -cp **/**/*.elf artifacts/ |
| 4 | +mkdir -p artifacts/cannode |
| 5 | + |
| 6 | +# Function to check if a build is a CAN node |
| 7 | +is_cannode() { |
| 8 | + local build_path=$1 |
| 9 | + local boardconfig="$build_path/boardconfig" |
| 10 | + |
| 11 | + if [ -f "$boardconfig" ]; then |
| 12 | + # Check if CONFIG_BOARD_ROMFSROOT is set to "cannode" |
| 13 | + if grep -q '^CONFIG_BOARD_ROMFSROOT="cannode"' "$boardconfig"; then |
| 14 | + return 0 |
| 15 | + fi |
| 16 | + fi |
| 17 | + return 1 |
| 18 | +} |
| 19 | + |
| 20 | +# First pass: identify and package CAN nodes |
| 21 | +for build_dir_path in build/*/ ; do |
| 22 | + # Remove trailing slash |
| 23 | + build_dir_path=${build_dir_path::${#build_dir_path}-1} |
| 24 | + build_dir=${build_dir_path#*/} |
| 25 | + |
| 26 | + if is_cannode "$build_dir_path"; then |
| 27 | + # Find the .uavcan.bin file |
| 28 | + uavcan_bin=$(find "$build_dir_path" -maxdepth 1 -name "*.uavcan.bin" -type f) |
| 29 | + |
| 30 | + if [ -n "$uavcan_bin" ]; then |
| 31 | + # Extract the target name (e.g., ark_can-flow from ark_can-flow_default) |
| 32 | + target_name=${build_dir%_default} |
| 33 | + |
| 34 | + # Create a directory for this CAN node |
| 35 | + mkdir -p "artifacts/cannode/$target_name" |
| 36 | + |
| 37 | + # Copy the .uavcan.bin file |
| 38 | + cp "$uavcan_bin" "artifacts/cannode/$target_name/" |
| 39 | + |
| 40 | + echo "Packaged CAN node: $target_name" |
| 41 | + fi |
| 42 | + fi |
| 43 | +done |
| 44 | + |
| 45 | +# Second pass: package regular firmware binaries (excluding CAN nodes) |
| 46 | +for build_dir_path in build/*/ ; do |
| 47 | + build_dir_path=${build_dir_path::${#build_dir_path}-1} |
| 48 | + |
| 49 | + # Skip CAN nodes |
| 50 | + if is_cannode "$build_dir_path"; then |
| 51 | + continue |
| 52 | + fi |
| 53 | + |
| 54 | + # Copy .px4 files |
| 55 | + find "$build_dir_path" -maxdepth 1 -name "*.px4" -type f -exec cp {} artifacts/ \; |
| 56 | + |
| 57 | + # Copy .elf files |
| 58 | + find "$build_dir_path" -maxdepth 1 -name "*.elf" -type f -exec cp {} artifacts/ \; |
| 59 | +done |
| 60 | + |
| 61 | +# Third pass: package metadata for each non-CAN node build directory |
6 | 62 | for build_dir_path in build/*/ ; do |
7 | 63 | build_dir_path=${build_dir_path::${#build_dir_path}-1} |
8 | 64 | build_dir=${build_dir_path#*/} |
| 65 | + |
| 66 | + # Skip CAN node builds for metadata packaging (they only need the .uavcan.bin) |
| 67 | + if is_cannode "$build_dir_path"; then |
| 68 | + continue |
| 69 | + fi |
| 70 | + |
9 | 71 | mkdir artifacts/$build_dir |
10 | 72 | find artifacts/ -maxdepth 1 -type f -name "*$build_dir*" |
11 | 73 | # Airframe |
|
0 commit comments