Skip to content

Commit e30c0ad

Browse files
Create mini-build.sh
1 parent 71828c2 commit e30c0ad

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

usr/local/bin/mini-build.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
SOURCE=$1
3+
OUTPUT=$2
4+
5+
if [[ -z "$SOURCE" ]]; then
6+
echo "Usage: $0 <source-code-dir> <output-name>"
7+
exit 1
8+
fi
9+
10+
detect_language() {
11+
if ls $SOURCE/*.c >/dev/null 2>&1; then echo "c"
12+
elif ls $SOURCE/*.cpp >/dev/null 2>&1; then echo "cpp"
13+
elif ls $SOURCE/*.rs >/dev/null 2>&1; then echo "rust"
14+
elif ls $SOURCE/*.go >/dev/null 2>&1; then echo "go"
15+
elif ls $SOURCE/*.py >/dev/null 2>&1; then echo "python"
16+
elif ls $SOURCE/*.js >/dev/null 2>&1; then echo "node"
17+
elif ls $SOURCE/*.java >/dev/null 2>&1; then echo "java"
18+
elif ls $SOURCE/pubspec.yaml >/dev/null 2>&1; then echo "flutter"
19+
elif ls $SOURCE/package.json >/dev/null 2>&1; then echo "node"
20+
else echo "unknown"
21+
fi
22+
}
23+
24+
LANG=$(detect_language)
25+
echo "⚡ Detected language: $LANG"
26+
27+
case $LANG in
28+
c) gcc $SOURCE/*.c -o $OUTPUT ;;
29+
cpp) g++ $SOURCE/*.cpp -o $OUTPUT ;;
30+
rust) cargo build --release --manifest-path $SOURCE/Cargo.toml ;;
31+
go) go build -o $OUTPUT $SOURCE ;;
32+
python) pyinstaller --onefile $SOURCE/*.py -n $OUTPUT ;;
33+
node) npm --prefix $SOURCE install && npm --prefix $SOURCE run build ;;
34+
java) javac $SOURCE/*.java -d build && jar cf $OUTPUT.jar -C build . ;;
35+
flutter) flutter build apk --release --target $SOURCE/lib/main.dart ;;
36+
*) echo "❌ Unknown source type. Manual build required." ;;
37+
esac

0 commit comments

Comments
 (0)