|
3 | 3 | # get base dir regardless of execution location |
4 | 4 | SOURCE="${BASH_SOURCE[0]}" |
5 | 5 | while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink |
6 | | - DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" |
7 | | - SOURCE="$(readlink "$SOURCE")" |
8 | | - [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located |
| 6 | + DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" |
| 7 | + SOURCE="$(readlink "$SOURCE")" |
| 8 | + [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located |
9 | 9 | done |
10 | 10 | SOURCE=$([[ "$SOURCE" == /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}") |
11 | 11 | basedir=$(dirname "$SOURCE") |
12 | 12 | . "$basedir"/scripts/init.sh |
13 | 13 |
|
14 | 14 | purpurstash() { |
15 | | - STASHED=$(git stash) |
| 15 | + STASHED=$(git stash) |
16 | 16 | } |
17 | 17 |
|
18 | 18 | purpurunstash() { |
19 | | - if [[ "$STASHED" != "No local changes to save" ]]; then |
20 | | - git stash pop |
21 | | - fi |
| 19 | + if [[ "$STASHED" != "No local changes to save" ]]; then |
| 20 | + git stash pop |
| 21 | + fi |
22 | 22 | } |
23 | 23 |
|
24 | 24 | case "$1" in |
25 | | -"am" | "amend") |
26 | | - ( |
27 | | - cd "$basedir"/Purpur-API/ |
28 | | - git add . |
29 | | - git commit --amend --no-edit |
30 | | - cd "$basedir"/Purpur-Server/ |
31 | | - git add . |
32 | | - git commit --amend --no-edit |
33 | | - cd "$basedir" |
34 | | - scripts/rebuildpatches.sh "$basedir" |
35 | | - ) |
36 | | - ;; |
37 | | -"rb" | "rbp" | "rebuild") |
38 | | - ( |
39 | | - set -e |
40 | | - cd "$basedir" |
41 | | - scripts/rebuildpatches.sh "$basedir" |
42 | | - ) |
43 | | - ;; |
44 | 25 | "p" | "patch" | "apply") |
45 | | - ( |
46 | | - set -e |
47 | | - cd "$basedir" |
48 | | - scripts/apply.sh "$basedir" |
49 | | - ) |
50 | | - ;; |
| 26 | + ( |
| 27 | + set -e |
| 28 | + cd "$basedir" |
| 29 | + if [ "$2" != "fast" ]; then |
| 30 | + scripts/upstream.sh |
| 31 | + fi |
| 32 | + scripts/apply.sh "$basedir" |
| 33 | + ) |
| 34 | + ;; |
51 | 35 | "b" | "bu" | "build") |
52 | | - ( |
53 | | - basedir |
54 | | - mvn -N install |
55 | | - cd Purpur-API |
56 | | - mvn -e clean install |
57 | | - cd ../Purpur-Server |
58 | | - mvn -e clean install |
59 | | - ) |
60 | | - ;; |
61 | | -"jar" | "purpurclip") |
62 | | - ( |
63 | | - basedir |
64 | | - cd "$basedir" |
65 | | - if [ "$2" != "fast" ]; then |
66 | | - scripts/upstream.sh |
67 | | - fi |
68 | | - ./scripts/apply.sh "$basedir" |
69 | | - ./scripts/purpurclip.sh |
70 | | - ) |
71 | | - ;; |
72 | | -"d" | "de" | "deploy") |
73 | | - ( |
74 | | - basedir |
75 | | - mvn -N install |
76 | | - cd Purpur-API |
77 | | - mvn clean deploy |
78 | | - cd ../Purpur-Server |
79 | | - mvn clean install |
80 | | - ) |
81 | | - ;; |
| 36 | + ( |
| 37 | + basedir |
| 38 | + mvn -N install |
| 39 | + cd Purpur-API |
| 40 | + mvn -e clean install |
| 41 | + cd ../Paper/Paper-MojangAPI |
| 42 | + mvn -e clean install |
| 43 | + cd ../../Purpur-Server |
| 44 | + mvn -e clean install |
| 45 | + ) |
| 46 | + ;; |
| 47 | + |
| 48 | +"rb" | "rbp" | "rebuild") |
| 49 | + ( |
| 50 | + set -e |
| 51 | + cd "$basedir" |
| 52 | + scripts/rebuildpatches.sh "$basedir" |
| 53 | + ) |
| 54 | + ;; |
| 55 | +"am" | "amend") |
| 56 | + ( |
| 57 | + cd "$basedir"/Purpur-API/ |
| 58 | + git add . |
| 59 | + git commit --amend --no-edit |
| 60 | + cd "$basedir"/Purpur-Server/ |
| 61 | + git add . |
| 62 | + git commit --amend --no-edit |
| 63 | + cd "$basedir" |
| 64 | + scripts/rebuildpatches.sh "$basedir" |
| 65 | + ) |
| 66 | + ;; |
82 | 67 | "up" | "upstream") |
83 | | - ( |
84 | | - cd "$basedir" |
85 | | - scripts/upstream.sh "$2" |
86 | | - ) |
87 | | - ;; |
88 | | -"r" | "root") |
| 68 | + ( |
89 | 69 | cd "$basedir" |
90 | | - ;; |
91 | | -"a" | "api") |
92 | | - cd "$basedir/Purpur-API" |
93 | | - ;; |
94 | | -"s" | "server") |
95 | | - cd "$basedir/Purpur-Server" |
96 | | - ;; |
97 | | -"setup") |
98 | | - if [[ -f ~/.bashrc ]]; then |
99 | | - NAME="purpur" |
100 | | - if [[ -n "${2+x}" ]]; then |
101 | | - NAME="$2" |
102 | | - fi |
103 | | - (grep "alias $NAME=" ~/.bashrc >/dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" ~/.bashrc) || (echo "alias $NAME='. $SOURCE'" >>~/.bashrc) |
104 | | - alias "$NAME=. $SOURCE" |
105 | | - echo "You can now just type '$NAME' at any time to access the purpur tool." |
| 70 | + scripts/upstream.sh "$2" |
| 71 | + ) |
| 72 | + ;; |
| 73 | +"jar" | "purpurclip") |
| 74 | + ( |
| 75 | + basedir |
| 76 | + cd "$basedir" |
| 77 | + if [ "$2" != "fast" ]; then |
| 78 | + scripts/upstream.sh |
106 | 79 | fi |
107 | | - ;; |
| 80 | + ./scripts/apply.sh "$basedir" |
| 81 | + cd "$basedir" |
| 82 | + mvn -N install |
| 83 | + cd Purpur-API |
| 84 | + mvn -e clean install |
| 85 | + cd ../Paper/Paper-MojangAPI |
| 86 | + mvn -e clean install |
| 87 | + cd ../../Purpur-Server |
| 88 | + mvn -e clean install |
| 89 | + cd "$basedir" |
| 90 | + ./scripts/purpurclip.sh |
| 91 | + ) |
| 92 | + ;; |
108 | 93 | *) |
109 | | - echo "Purpur build tool command. This provides a variety of commands to build and manage the Purpur build" |
110 | | - echo "environment. For all of the functionality of this command to be available, you must first run the" |
111 | | - echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup." |
112 | | - echo "" |
113 | | - echo " Normal commands:" |
114 | | - echo " * am, amend | Amend current edits to last patches" |
115 | | - echo " * rb, rebuild | Rebuild patches, can be called from anywhere." |
116 | | - echo " * p, patch | Apply all patches to top of Paper without building it. Can be run from anywhere." |
117 | | - echo " * up, upstream | Build Paper upstream, pass arg up to update paper. Can be run from anywhere." |
118 | | - echo " * b, build | Build API and Server but no deploy. Can be ran anywhere." |
119 | | - echo " * d, deploy | Build and Deploy API jar and build Server. Can be ran anywhere." |
120 | | - echo "" |
121 | | - echo " These commands require the setup command before use:" |
122 | | - echo " * r, root | Change directory to the root of the project." |
123 | | - echo " * a. api | Move to the Purpur-API directory." |
124 | | - echo " * s, server | Move to the Purpur-Server directory." |
125 | | - echo " * e, edit | Use to edit a specific patch, give it the argument \"server\" or \"api\"" |
126 | | - echo " | respectively to edit the correct project. Use the argument \"continue\" after" |
127 | | - echo " | the changes have been made to finish and rebuild patches. Can be called from anywhere." |
128 | | - echo "" |
129 | | - echo " * setup | Add an alias to .bashrc to allow full functionality of this script. Run as:" |
130 | | - echo " | . ./purpur setup" |
131 | | - echo " | After you run this command you'll be able to just run 'purpur' from anywhere." |
132 | | - echo " | The default name for the resulting alias is 'purpur', you can give an argument to override" |
133 | | - echo " | this default, such as:" |
134 | | - echo " | . ./purpur setup example" |
135 | | - echo " | Which will allow you to run 'example' instead." |
136 | | - ;; |
| 94 | + echo "Purpur build tool command. This provides a variety of commands to build and manage the Purpur build" |
| 95 | + echo "environment. For all of the functionality of this command to be available, you must first run the" |
| 96 | + echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup." |
| 97 | + echo "" |
| 98 | + echo " Normal commands:" |
| 99 | + echo " * p, patch | Apply all patches to top of Paper without building it" |
| 100 | + echo " * b, build | Build Purpur API and Server" |
| 101 | + echo " * rb, rebuild | Rebuild patches" |
| 102 | + echo " * am, amend | Amend current edits to last patches" |
| 103 | + echo " * up, upstream | Build Paper upstream, pass arg up to update paper" |
| 104 | + echo " * jar, purpurclip | Apply all patches and build the project, purpurclip.jar will be output" |
| 105 | + ;; |
137 | 106 | esac |
138 | 107 |
|
139 | 108 | unset -f purpurstash |
|
0 commit comments