-
Notifications
You must be signed in to change notification settings - Fork 5
/
install-raylib.bqn
68 lines (58 loc) · 2.42 KB
/
install-raylib.bqn
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
#!usr/bin/env bqn
⟨Realpath⋄At⋄Exists⋄CreateDir⋄Remove⋄List⋄Bytes⋄path⟩ ← •file
⟨os⟩←•platform
version ← "5.0"
binariesPath ← "lib"
⟨ ext ⋄ libFile ⋄ raylibFolder
⟩←{"darwin": ⟨".tar.gz"⋄"libraylib.dylib"⋄"raylib-"∾version∾"_macos" ⟩
; "linux": ⟨".tar.gz"⋄"libraylib.so" ⋄"raylib-"∾version∾"_linux_amd64" ⟩
; "windows": ⟨".zip" ⋄"raylib.dll" ⋄"raylib-"∾version∾"_win64_msvc16"⟩
} os
git_clone_path ← "https://github.com/raysan5/raylib/releases/download/"∾version∾"/"∾raylibFolder∾ext
# Expected library to not exist
!∘{𝕊:"raylib already installed. Delete it to re-install.
rm "∾(Realpath 𝕩)∾"
"}⍟Exists binariesPath At libFile
# ---------------
# download raylib
# ---------------
Exec ← {e‿·‿o:o!0≡e}•SH
# Download raylib zip/tar file
Exec {"windows"≡os?
⟨
"Powershell.exe" ⋄ "-Command"
"curl -o """∾(At"temp"∾ext)∾""" "∾git_clone_path
⟩
;
⟨"curl" ⋄ "-o" ⋄ At"temp"∾ext ⋄ git_clone_path, "-L"⟩
}
"Downloading raylib failed from github failed. Likely due to redirects not being followed."!⟨⟩≢•FBytes "temp"∾ext
# unzip/untar/unarchive raylib
# tar on windows handles zip files, while mac/linux get raylib as tar.gz files
Exec ⟨"tar" ⋄ "-xzf"⋄Realpath"temp"∾ext ⋄ "-C"⋄path⟩
Remove Realpath"temp"∾ext
"Extracting raylib failed"!Exists raylibFolder At "lib" At libFile
# ---------------------
# Copy binary file to binariesPath
# ---------------------
CreateDir⍟(¬Exists) binariesPath
(binariesPath At libFile) Bytes Bytes Realpath raylibFolder At "lib" At libFile
# -----------------
# Clean away raylib
# -----------------
filesToBeDeleted ← raylibFolder⊸At¨ ∾⟨
"lib" ⊸At¨•file.List raylibFolder At"lib"
"include"⊸At¨"raylib.h"‿"raymath.h"‿"rlgl.h"
"CHANGELOG"‿"LICENSE"‿"README.md"
⟩
!∘{𝕊:"Unexpected files in "∾raylibFolder∾", "∾•Repr filesToBeDeleted
}⍟(0≠≠)¬∘Exists¨⊸/filesToBeDeleted
Remove¨filesToBeDeleted
cleaupErrorMsg ← "Cleanup unsuccessful. Please delete "∾raylibFolder∾" manually "
RMDirCmd ← {
os≡"windows"?
⟨"Powershell.exe" ⋄ "-Command" ⋄ "RD '"∾𝕩∾"'"⟩
; "rmdir"⋈𝕩
}
{cleaupErrorMsg!0‿⟨⟩‿⟨⟩≡•SH RMDirCmd Realpath raylibFolder At𝕩}¨"lib"‿"include"‿""
•Out "raylib installed successfully"