-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_toolchain.sh
More file actions
executable file
·111 lines (92 loc) · 2.98 KB
/
test_toolchain.sh
File metadata and controls
executable file
·111 lines (92 loc) · 2.98 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
#!/bin/bash
# Create a simple test toolchain for MoonBit
# This creates a minimal working toolchain for testing purposes
echo "Creating test MoonBit toolchain..."
# Create the toolchain directory structure
mkdir -p moonbit_toolchain
# Create a simple moon executable (placeholder)
cat > moonbit_toolchain/moon << 'EOF'
#!/bin/bash
# MoonBit compiler placeholder for testing
echo "MoonBit compiler placeholder - version 0.6.33"
echo "This is a test toolchain, not the real MoonBit compiler"
echo "Command: $@"
# For build commands, create a dummy output file
if [[ "$1" == "build" ]]; then
shift
OUTPUT_FILE=""
SOURCES=()
# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--output)
OUTPUT_FILE="$2"
shift 2
;;
--target)
TARGET="$2"
shift 2
;;
*)
if [[ "$1" == -* ]]; then
shift
else
SOURCES+=("$1")
shift
fi
;;
esac
done
# Create a dummy output file
if [[ -n "$OUTPUT_FILE" ]]; then
echo "// MoonBit compiled output (test)" > "$OUTPUT_FILE"
echo "// Sources: ${SOURCES[*]}" >> "$OUTPUT_FILE"
echo "// Target: ${TARGET:-native}" >> "$OUTPUT_FILE"
echo "// This is a test file generated by the placeholder compiler" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
# Make it look like a real compiled file
for src in "${SOURCES[@]}"; do
echo "// Included: $src" >> "$OUTPUT_FILE"
done
echo "MoonBit test compilation successful: $OUTPUT_FILE"
exit 0
fi
fi
# For other commands
if [[ "$1" == "test" ]]; then
echo "MoonBit test execution successful"
exit 0
fi
echo "MoonBit placeholder completed successfully"
EOF
# Make the moon executable executable
chmod +x moonbit_toolchain/moon
# Create a BUILD file for the toolchain
cat > moonbit_toolchain/BUILD.bazel << 'EOF'
# BUILD file for test MoonBit toolchain
package(default_visibility = ["//visibility:public"])
# Export the moon executable
exports_files(["moon"])
# Create a filegroup for all toolchain files
filegroup(
name = "moonbit_toolchain_files",
srcs = ["moon"],
output_group = "toolchain_files",
)
# Create the toolchain info provider
load("//moonbit:providers.bzl", "moonbit_toolchain_info")
moonbit_toolchain_info(
name = "moonbit_toolchain",
moon_executable = "moon",
version = "0.6.33",
target_platform = "linux_amd64",
all_files = ":moonbit_toolchain_files",
supports_wasm = True,
supports_native = True,
supports_js = True,
supports_c = True,
)
EOF
echo "Test MoonBit toolchain created successfully in moonbit_toolchain/"
echo "You can use this for testing by pointing to this directory in your WORKSPACE:"
echo "local_repository(name = 'moonbit_toolchain', path = '<path_to_this_dir>')"