| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  | cd "$(dirname "$0")" | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-18 15:48:10 -06:00
										 |  |  | ELECTRON_BUILD_TOOLS_REQUIRED_VERSION=6ba8962529c37727a778691b89c92ab0eb1d9d87 | 
					
						
							|  |  |  | if [[ -d ./electron-build-tools ]]; then | 
					
						
							|  |  |  |   cd ./electron-build-tools | 
					
						
							|  |  |  |   # Make sure required commit is part of electron-build-tools. | 
					
						
							|  |  |  |   if ! git merge-base --is-ancestor "${ELECTRON_BUILD_TOOLS_REQUIRED_VERSION}" HEAD; then | 
					
						
							|  |  |  |     cd .. | 
					
						
							|  |  |  |     rm -rf ./electron-build-tools | 
					
						
							|  |  |  |     echo "Updating electron-build-tools" | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     cd .. | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  | if [[ ! -d ./electron-build-tools ]]; then | 
					
						
							| 
									
										
										
										
											2022-03-18 15:48:10 -06:00
										 |  |  |   git clone --single-branch --branch main 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 | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   echo "$(basename "$0") [login|start|stop|--help]" | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  |   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!" | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |     echo "run '$(basename "$0") login'" | 
					
						
							| 
									
										
										
										
											2021-02-09 08:33:39 -08:00
										 |  |  |     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 | 
					
						
							|  |  |  | 
 |