-
Notifications
You must be signed in to change notification settings - Fork 1
/
copy_od_gen_code.sh
executable file
·72 lines (61 loc) · 2.11 KB
/
copy_od_gen_code.sh
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
#!/bin/bash
# This script copies the generated C code
# that implements the CANOpen object dictionaries
# into the correct directory for compilation
# Variable declarations -------------------------
MY_DIR=$(dirname $(readlink -f $0))
DEST_DIR="$MY_DIR/gen/"
# Check that the destination directory exists ---
if [[ ! -d $DEST_DIR ]]; then
echo "[ERROR] Destination directory $DEST_DIR doesn't exist"
exit 1
fi
# Check arguments -------------------------------
SRC_DIR="$1"
echo "[INFO ] Copying generated OD C code from $SRC_DIR to $DEST_DIR"
if [[ ! -d $SRC_DIR ]]; then
echo "[ERROR] Source directory $SRC_DIR doesn't exist"
exit 1
fi
# Check that all expected files are present -----
MISSING_FILES="NO"
if [[ ! -f "$SRC_DIR/OSCOGenNodeID.h" ]]; then
echo "[ERROR] Missing generated file : OSCOGenNodeID.h"
MISSING_FILES="YES"
fi
if [[ ! -f "$SRC_DIR/OSCOGenOD.h" ]]; then
echo "[ERROR] Missing generated file : OSCOGenOD.h"
MISSING_FILES="YES"
fi
if [[ ! -f "$SRC_DIR/OSCOGenOD.c" ]]; then
echo "[ERROR] Missing generated file : OSCOGenOD.c"
MISSING_FILES="YES"
fi
if [[ ! -f "$SRC_DIR/OSCOGenOD_Values.c" ]]; then
echo "[ERROR] Missing generated file : OSCOGenOD_Values.c"
MISSING_FILES="YES"
fi
if [[ ! -f "$SRC_DIR/OSCOGenOD_DefaultValues.c" ]]; then
echo "[ERROR] Missing generated file : OSCOGenOD_DefaultValues.c"
MISSING_FILES="YES"
fi
if [[ ! -f "$SRC_DIR/OSCOGenOD_MaxValues.c" ]]; then
echo "[ERROR] Missing generated file : OSCOGenOD_MaxValues.c"
MISSING_FILES="YES"
fi
if [[ ! -f "$SRC_DIR/OSCOGenOD_MinValues.c" ]]; then
echo "[ERROR] Missing generated file : OSCOGenOD_MinValues.c"
MISSING_FILES="YES"
fi
if [[ "YES" == "$MISSING_FILES" ]]; then
echo "[ERROR] Missing files, aborting..."
exit 1
fi
# Backup the CMakeLists.txt ---------------------
mv $DEST_DIR/CMakeLists.txt $MY_DIR/CMakeLists.txt.bak
# Clear the destination directory ---------------
rm -rf $DEST_DIR/*
# Copy files to the destination directory -------
cp -rv $SRC_DIR/* $DEST_DIR/
# Restore CMakeLists.txt ------------------------
mv $MY_DIR/CMakeLists.txt.bak $DEST_DIR/CMakeLists.txt