-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·169 lines (141 loc) · 4.17 KB
/
build.sh
File metadata and controls
executable file
·169 lines (141 loc) · 4.17 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# SPDX-License-Identifier: MIT OR Apache-2.0
# Build script for semcode project
set -e
echo "=== Building Semcode ==="
# Check for required dependencies
echo "Checking dependencies..."
if ! command -v cargo &> /dev/null; then
echo "Error: Cargo not found. Please install Rust."
exit 1
fi
if ! pkg-config --exists clang; then
echo "Warning: libclang not found via pkg-config"
echo "Make sure you have installed clang development libraries:"
echo " Ubuntu/Debian: sudo apt-get install libclang-dev"
echo " Fedora: sudo dnf install clang-devel"
echo " macOS: brew install llvm"
fi
if ! command -v protoc &> /dev/null; then
echo "Error: protoc (Protocol Buffers compiler) not found."
echo "This is required by LanceDB. Please install it:"
echo " Ubuntu/Debian: sudo apt-get install protobuf-compiler libprotobuf-dev"
echo " Fedora: sudo dnf install protobuf-compiler protobuf-devel"
echo " macOS: brew install protobuf"
echo " Or download from: https://github.com/protocolbuffers/protobuf/releases"
exit 1
else
# Check if protobuf includes are available
if ! protoc --version > /dev/null 2>&1; then
echo "Error: protoc is installed but not working properly."
echo "You may need to install the protobuf development package:"
echo " Ubuntu/Debian: sudo apt-get install libprotobuf-dev"
echo " Fedora: sudo dnf install protobuf-devel"
exit 1
fi
fi
# Build the project
echo "Building release binaries..."
cargo build --release
# Create symlinks for easier access
echo "Creating symlinks..."
mkdir -p bin
ln -sf ../target/release/semcode-index bin/semcode-index
ln -sf ../target/release/semcode bin/semcode
ln -sf ../target/release/semcode-mcp bin/semcode-mcp
ln -sf ../target/release/semcode-lsp bin/semcode-lsp
echo ""
echo "=== Build Complete ==="
echo ""
echo "Binaries are available in ./bin/"
echo ""
echo "To index a codebase:"
echo " ./bin/semcode-index --source /path/to/code --database ./code.db"
echo ""
echo "To query the database:"
echo " ./bin/semcode --database ./code.db"
echo ""
echo "To run MCP server:"
echo " ./bin/semcode-mcp --database ./code.db"
echo ""
echo "To run LSP server (for editor integration):"
echo " ./bin/semcode-lsp"
echo " See docs/lsp-server.md for Neovim/editor setup"
echo ""
# Optional: Create a small test directory with sample C files
if [ "$1" == "--with-test" ]; then
echo "Creating test directory with sample C files..."
mkdir -p test_code
cat > test_code/main.c << 'EOF'
#include <stdio.h>
#include <stdlib.h>
#include "utils.h"
struct config {
int debug_level;
char name[256];
void (*handler)(int);
};
void signal_handler(int sig) {
printf("Received signal: %d\n", sig);
}
int main(int argc, char *argv[]) {
struct config cfg = {
.debug_level = 1,
.name = "test",
.handler = signal_handler
};
printf("Starting program: %s\n", cfg.name);
int *data = allocate_buffer(1024);
if (data) {
process_data(data, 1024);
free(data);
}
return 0;
}
EOF
cat > test_code/utils.h << 'EOF'
#ifndef UTILS_H
#define UTILS_H
int* allocate_buffer(size_t size);
void process_data(int* data, size_t size);
void debug_print(const char* msg);
typedef struct {
int id;
char* name;
float value;
} data_item_t;
enum status_code {
STATUS_OK = 0,
STATUS_ERROR = -1,
STATUS_TIMEOUT = -2
};
#endif /* UTILS_H */
EOF
cat > test_code/utils.c << 'EOF'
#include <stdio.h>
#include <stdlib.h>
#include "utils.h"
int* allocate_buffer(size_t size) {
int* buffer = malloc(size * sizeof(int));
if (buffer) {
debug_print("Buffer allocated");
}
return buffer;
}
void process_data(int* data, size_t size) {
debug_print("Processing data");
for (size_t i = 0; i < size; i++) {
data[i] = i * 2;
}
}
void debug_print(const char* msg) {
printf("[DEBUG] %s\n", msg);
}
EOF
echo ""
echo "Test code created in ./test_code/"
echo "You can test the indexer with:"
echo " ./bin/semcode-index --source ./test_code --database ./test.db"
echo "Then query with:"
echo " ./bin/semcode --database ./test.db"
fi