-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·65 lines (54 loc) · 1.4 KB
/
build.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
#!/bin/bash
# Build configuration
CC=gcc
CFLAGS="-Wall -Wextra -I./src"
LDFLAGS=""
BUILD_DIR="build"
SRC_DIR="src"
# Create build directory if it doesn't exist
mkdir -p $BUILD_DIR
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
# Source files
SOURCES=(
"src/crawler.c"
"src/analyzers.c"
"src/syntax_map.c"
"src/syntaxes.c"
"src/grammars.c"
"src/pattern_cache.c"
"main.c"
"src/logger.c"
)
# Object files
OBJECTS=()
echo -e "${GREEN}Building Dependency Crawler...${NC}"
# Compile each source file
for source in "${SOURCES[@]}"; do
if [ -f "$source" ]; then
object="$BUILD_DIR/$(basename "${source%.*}").o"
OBJECTS+=("$object")
echo "Compiling $source..."
$CC $CFLAGS -c "$source" -o "$object"
if [ $? -ne 0 ]; then
echo -e "${RED}Error compiling $source${NC}"
exit 1
fi
else
echo -e "${RED}Warning: Source file $source not found${NC}"
fi
done
# Link the program
echo "Linking..."
$CC "${OBJECTS[@]}" $LDFLAGS -o "$BUILD_DIR/crawler"
if [ $? -eq 0 ]; then
echo -e "${GREEN}Build successful! Binary located at $BUILD_DIR/crawler${NC}"
# Create a symlink in the root directory for easier access
# ln -sf "$BUILD_DIR/crawler" crawler
# echo "Symlink 'crawler' created in root directory"
else
echo -e "${RED}Linking failed${NC}"
exit 1
fi