-
Notifications
You must be signed in to change notification settings - Fork 1
/
compile-ir.sh
121 lines (104 loc) · 3.42 KB
/
compile-ir.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
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
#!/bin/bash
# Copyright 2023-2024 The Jule Programming Language.
# Use of this source code is governed by a BSD 3-Clause
# license that can be found in the LICENSE file.
declare unknown=255
declare arch_i386=0
declare arch_amd64=1
declare arch_arm64=2
declare os_windows=0
declare os_linux=1
declare os_darwin=2
declare ir_name=ir.cpp
function get_arch() {
arch=$(uname -m)
if [[ $arch == x86_64* ]]; then
return $arch_amd64
elif [[ $arch == i*86 ]]; then
return $arch_i386
elif [[ $arch == arm64* || $arch == aarch64* ]]; then
return $arch_arm64
else
return $unknown
fi
}
function get_os() {
if [[ "$OSTYPE" == "linux-gnu" ]]; then
return $os_linux
elif [[ "$OSTYPE" == "darwin"* ]]; then
return $os_darwin
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" || "$OSTYPE" == "cygwin" ]]; then
return $os_windows
else
return $unknown
fi
}
curl_ir() {
curl -o $ir_name $1
}
get_ir() {
get_arch
declare arch=$?
if [[ $arch == $unknown ]]; then
echo "Your architecture is not supported."
exit 1
fi
get_os
declare os=$?
if [[ $os == $unknown ]]; then
echo "Your operating system is not supported."
exit 1
fi
if [[ $os == $os_windows ]]; then
if [[ $arch == $arch_i386 ]]; then
curl_ir https://raw.githubusercontent.com/julelang/julec-ir/main/src/windows-i386.cpp
elif [[ $arch == $arch_amd64 ]]; then
curl_ir https://raw.githubusercontent.com/julelang/julec-ir/main/src/windows-amd64.cpp
elif [[ $arch == $arch_arm64 ]]; then
curl_ir https://raw.githubusercontent.com/julelang/julec-ir/main/src/windows-arm64.cpp
else
echo "Your operating system and architecture combinations is not supported"
exit 1
fi
elif [[ $os == $os_linux ]]; then
if [[ $arch == $arch_i386 ]]; then
curl_ir https://raw.githubusercontent.com/julelang/julec-ir/main/src/linux-i386.cpp
elif [[ $arch == $arch_amd64 ]]; then
curl_ir https://raw.githubusercontent.com/julelang/julec-ir/main/src/linux-amd64.cpp
elif [[ $arch == $arch_arm64 ]]; then
curl_ir https://raw.githubusercontent.com/julelang/julec-ir/main/src/linux-arm64.cpp
else
echo "Your operating system and architecture combinations is not supported"
exit 1
fi
elif [[ $os == $os_darwin ]]; then
if [[ $arch == $arch_amd64 ]]; then
curl_ir https://raw.githubusercontent.com/julelang/julec-ir/main/src/darwin-amd64.cpp
elif [[ $arch == $arch_arm64 ]]; then
curl_ir https://raw.githubusercontent.com/julelang/julec-ir/main/src/darwin-arm64.cpp
else
echo "Your operating system and architecture combinations is not supported"
exit 1
fi
fi
}
function log() {
echo ">>> " $1
echo ""
}
log "Getting latest Jule@master source tree..."
curl -Lko julec.zip https://github.com/julelang/jule/archive/refs/heads/master.tar.gz
tar -xzf julec.zip -C .
echo ""
log "Getting latest JuleC IR distribution..."
cd jule-master
get_ir
echo ""
log "Compiling IR distribution..."
mkdir bin
clang++ -Wno-everything --std=c++17 -O3 -flto -DNDEBUG -fomit-frame-pointer -o bin/julec $ir_name
if [[ $? == 0 ]]; then
echo "Your IR JuleC compilation is read-to-use."
else
echo "Compilation failed."
fi