Repository navigation
Expand file tree
/
Copy pathpackage.sh
More file actions
executable file
·69 lines (57 loc) · 1.59 KB
/
Copy pathpackage.sh
File metadata and controls
executable file
·69 lines (57 loc) · 1.59 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
#!/bin/bash
set -e
# Get target triple
TARGET=${1:-$(rustc -vV | sed -n 's|host: ||p')}
# Determine naming convention
case "$TARGET" in
*windows*)
STATIC_EXT="lib"
LIB_PREFIX=""
;;
*apple*)
STATIC_EXT="a"
LIB_PREFIX="lib"
;;
*)
STATIC_EXT="a"
LIB_PREFIX="lib"
;;
esac
LIB_NAME="rs_dfu"
TARGET_DIR=${2:-"target"}
# Create distribution structure
rm -rf dist
mkdir -p dist/cmake dist/include dist/lib
# Copy libraries
RELEASE_LIB="${TARGET_DIR}/release/${LIB_PREFIX}${LIB_NAME}.${STATIC_EXT}"
if [ -f "$RELEASE_LIB" ]; then
cp "$RELEASE_LIB" "dist/lib/"
echo "Copied: $RELEASE_LIB"
fi
DEBUG_LIB="${TARGET_DIR}/debug/${LIB_PREFIX}${LIB_NAME}.${STATIC_EXT}"
if [ -f "$DEBUG_LIB" ]; then
cp "$DEBUG_LIB" "dist/lib/${LIB_PREFIX}${LIB_NAME}d.${STATIC_EXT}"
echo "Copied: $DEBUG_LIB -> ${LIB_PREFIX}${LIB_NAME}d.${STATIC_EXT}"
fi
if [ ! -f "$RELEASE_LIB" ] && [ ! -f "$DEBUG_LIB" ]; then
echo "Error: no library found: $RELEASE_LIB or $DEBUG_LIB" >&2
exit 1
fi
# Copy headers
HEADER_FILE="${TARGET_DIR}/cxxbridge/rs-dfu/src/lib.rs.h"
if [ ! -f "$HEADER_FILE" ]; then
echo "Error: header not found: $HEADER_FILE" >&2
exit 1
fi
cp "$HEADER_FILE" "dist/include/$LIB_NAME.h"
echo "Copied: $HEADER_FILE"
# Copy CMake configuration
CMAKE_CONFIG="cmake/${LIB_NAME}-config.cmake"
if [ -f "$CMAKE_CONFIG" ]; then
cp "$CMAKE_CONFIG" "dist/cmake/"
echo "Copied: $CMAKE_CONFIG"
fi
# Create archive
ARCHIVE_NAME="${LIB_NAME}-${TARGET}.tar.gz"
tar -czf "$ARCHIVE_NAME" --strip-component 1 dist/
echo "Created: $ARCHIVE_NAME"