-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
build-linux.sh
executable file
·62 lines (55 loc) · 1.21 KB
/
build-linux.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
#!/bin/bash
# Set the output executable name
output="salam"
# List all source files
sources=(
"src/log.c"
"src/file.c"
"src/memory.c"
"src/array.c"
"src/parser.c"
"src/downloader.c"
"src/parser_layout.c"
"src/generator.c"
"src/generator_layout.c"
"src/generator_salam.c"
"src/generator_layout_style.c"
"src/generator_identifier.c"
"src/string_buffer.c"
"src/validator.c"
"src/validator_style.c"
"src/hashmap.c"
"src/hashmap_custom.c"
"src/array_custom.c"
"src/lexer.c"
"src/ast.c"
"src/ast_layout.c"
"src/ast_layout_style.c"
"src/main.c"
)
# Compile each source file into an object file
for src in "${sources[@]}"; do
echo "Compiling $src..."
gcc -c "$src" -o "${src%.c}.o"
if [ $? -ne 0 ]; then
echo "Error: Compilation failed for $src"
exit 1
fi
done
# Link all object files into the final executable
echo "Linking object files..."
gcc -o "$output" *.o
if [ $? -ne 0 ]; then
echo "Error: Linking failed"
exit 1
fi
# Clean up object files (optional)
# rm *.o
# Run the executable with the provided argument
echo "Running the executable..."
./"$output" ../example/test6.salam ../out/
if [ $? -ne 0 ]; then
echo "Error: Execution failed"
exit 1
fi
echo "Build and execution completed successfully."