forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new-stdlib.sh
executable file
·74 lines (55 loc) · 1.76 KB
/
new-stdlib.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
#!/bin/sh
# This file is a part of Julia. License is MIT: https://julialang.org/license
set -eu # stop on failure
printf -- "Julia Stdlib Creator Helper Wizard\n"
printf -- "----------------------------------\n"
ROOT=$(dirname "$0")/../stdlib
read -p "Name: " NAME
read -p "Github User account (empty for local): " USER
if [ -z "$USER" ]; then
UUID=$(uuidgen | tr [A-Z] [a-z])
sed -e "/^STDLIBS =/,/^\$/s!^\$!\\
STDLIBS += $NAME\\
!" "$ROOT/Makefile" >"$ROOT/Makefile.tmp"
mv "$ROOT/Makefile.tmp" "$ROOT/Makefile"
mkdir "$ROOT/$NAME"
mkdir "$ROOT/$NAME/src"
mkdir "$ROOT/$NAME/test"
cat >"$ROOT/$NAME/Project.toml" <<EOF
name = "$NAME"
uuid = "$UUID"
EOF
cat >"$ROOT/$NAME/src/$NAME.jl" <<EOF
module $NAME
end
EOF
cat >"$ROOT/$NAME/test/runtests.jl" <<EOF
using $NAME
using Test
@test "your tests here"
EOF
git add "$ROOT/$NAME"
git add -p "$ROOT/Makefile"
else
read -p "Git SHA1 hash of commit: " SHA1
UNAME=$(echo "$NAME" | tr [a-z] [A-Z])
sed -e "/^STDLIBS_EXT =/,/^\$/s!^\$!\\
STDLIBS_EXT += $NAME\\
!" "$ROOT/Makefile" >"$ROOT/Makefile.tmp"
mv "$ROOT/Makefile.tmp" "$ROOT/Makefile"
cat >"$ROOT/$NAME.version" <<EOF
${UNAME}_BRANCH = master
${UNAME}_SHA1 = $SHA1
${UNAME}_GIT_URL := https://github.com/$USER/$NAME.jl.git
${UNAME}_TAR_URL = https://api.github.com/repos/$USER/$NAME.jl/tarball/\$1
EOF
git add "$ROOT/$NAME.version"
git add -p "$ROOT/Makefile"
fi
printf -- "\n-------------------------------------------------------------------------------\n"
printf -- "\n\
Manually add this now to test/precompile.jl (Base.cache_dependencies),
test/choosetests.jl (net_required_for), and base/sysimg.jl (stdlibs), sorted
by top-down dependency order.\n"
printf -- "\n-------------------------------------------------------------------------------\n"
printf -- "Wizard finished.\n"