| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  | #!/bin/bash
 | 
					
						
							|  |  |  | set -e | 
					
						
							| 
									
										
										
										
											2021-02-16 09:34:13 -07:00
										 |  |  | set -x | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | trap "cd $(pwd -P)" EXIT | 
					
						
							|  |  |  | cd "$(dirname $0)" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [[ ! -d ./electron-build-tools ]]; then | 
					
						
							| 
									
										
										
										
											2021-05-25 15:16:23 -07:00
										 |  |  |   git clone --single-branch --branch master https://github.com/electron/build-tools/ electron-build-tools | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  |   cd electron-build-tools | 
					
						
							|  |  |  |   npm install | 
					
						
							|  |  |  |   mkdir -p third_party | 
					
						
							|  |  |  |   ./src/e update-goma msftGoma | 
					
						
							|  |  |  |   cd .. | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-12 11:01:49 -08:00
										 |  |  | cd electron-build-tools/third_party/goma | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-19 14:23:09 -08:00
										 |  |  | export GOMA_START_COMPILER_PROXY=true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  | if [[ $1 == "--help" ]]; then | 
					
						
							|  |  |  |   echo "$(basename $0) [login|start|stop|--help]" | 
					
						
							|  |  |  |   exit 0 | 
					
						
							|  |  |  | elif [[ $1 == "login" ]]; then | 
					
						
							| 
									
										
										
										
											2021-02-09 11:00:53 -07:00
										 |  |  |   if [[ $(uname) == "MINGW"* ]]; then | 
					
						
							| 
									
										
										
										
											2021-02-12 11:01:49 -08:00
										 |  |  |     /c/Windows/System32/cmd.exe "/c $(cygpath -w $(pwd)/goma_auth.bat) login" | 
					
						
							| 
									
										
										
										
											2021-02-09 11:00:53 -07:00
										 |  |  |   else | 
					
						
							| 
									
										
										
										
											2021-02-12 11:01:49 -08:00
										 |  |  |     python ./goma_auth.py login | 
					
						
							| 
									
										
										
										
											2021-02-09 11:00:53 -07:00
										 |  |  |   fi | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  | elif [[ $1 == "start" ]]; then | 
					
						
							| 
									
										
										
										
											2021-02-09 08:56:29 -08:00
										 |  |  |   # We have to prefix ENV with `PLAYWRIGHT` since `GOMA_` env variables | 
					
						
							|  |  |  |   # have special treatment by goma. | 
					
						
							|  |  |  |   if [[ ! -z "$PLAYWRIGHT_GOMA_LOGIN_COOKIE" ]]; then | 
					
						
							|  |  |  |     echo "$PLAYWRIGHT_GOMA_LOGIN_COOKIE" > "$HOME/.goma_oauth2_config" | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  |   fi | 
					
						
							|  |  |  |   if [[ ! -f "$HOME/.goma_oauth2_config" ]]; then | 
					
						
							|  |  |  |     echo "ERROR: goma is not logged in!" | 
					
						
							|  |  |  |     echo "run '$(basename $0) login'" | 
					
						
							|  |  |  |     exit 1 | 
					
						
							|  |  |  |   fi | 
					
						
							| 
									
										
										
										
											2021-02-09 11:00:53 -07:00
										 |  |  |   if [[ $(uname) == "MINGW"* ]]; then | 
					
						
							| 
									
										
										
										
											2021-02-12 11:01:49 -08:00
										 |  |  |     /c/Windows/System32/cmd.exe "/c $(cygpath -w $(pwd)/goma_ctl.bat) ensure_start" | 
					
						
							| 
									
										
										
										
											2021-02-09 11:00:53 -07:00
										 |  |  |   else | 
					
						
							| 
									
										
										
										
											2021-02-12 11:01:49 -08:00
										 |  |  |     python ./goma_ctl.py ensure_start | 
					
						
							| 
									
										
										
										
											2021-02-09 11:00:53 -07:00
										 |  |  |   fi | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  | elif [[ $1 == "stop" ]]; then | 
					
						
							| 
									
										
										
										
											2021-02-09 11:00:53 -07:00
										 |  |  |   if [[ $(uname) == "MINGW"* ]]; then | 
					
						
							| 
									
										
										
										
											2021-02-12 11:01:49 -08:00
										 |  |  |     /c/Windows/System32/cmd.exe "/c $(cygpath -w $(pwd)/goma_ctl.bat) stop" | 
					
						
							| 
									
										
										
										
											2021-02-09 11:00:53 -07:00
										 |  |  |   else | 
					
						
							| 
									
										
										
										
											2021-02-12 11:01:49 -08:00
										 |  |  |     python ./goma_ctl.py stop | 
					
						
							| 
									
										
										
										
											2021-02-09 11:00:53 -07:00
										 |  |  |   fi | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  | else | 
					
						
							|  |  |  |   echo "ERROR: unknown command - $1" | 
					
						
							|  |  |  |   echo "Use --help to list all available commands" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 |