Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2017 The LUCI Authors. | |
| 2 # | |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 # you may not use this file except in compliance with the License. | |
| 5 # You may obtain a copy of the License at | |
| 6 # | |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 # | |
| 9 # Unless required by applicable law or agreed to in writing, software | |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 # See the License for the specific language governing permissions and | |
| 13 # limitations under the License. | |
| 14 | |
| 15 # This Makefile (GNU) controls the construction and deployment of the | |
| 16 # "luci-logdog" application. This is a common Makefile, and is expected to be | |
| 17 # imported by an implementation-specific Makefile. The implementation-specific | |
| 18 # Makefile must supply the following variables: | |
| 19 # | |
| 20 # - CLOUD_PROJECT | |
| 21 # | |
| 22 # The Makefile may supply the following optional variables: | |
| 23 # - TAG: The AppEngine tag. If not specified, let "gae.py" choose a | |
| 24 # tag (default, important for production). | |
| 25 | |
| 26 .PHONY: default | |
| 27 default: help | |
| 28 | |
| 29 # Assert that all required variables are provided. | |
| 30 ifndef CLOUD_PROJECT | |
| 31 $(error Missing required variable: CLOUD_PROJECT) | |
| 32 endif | |
| 33 | |
| 34 # Determine "luci-go" repository paths. | |
| 35 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) | |
| 36 APP_DIR := $(dir $(mkfile_path)) | |
| 37 LUCI_GO_DIR := $(abspath $(APP_DIR)/../../../..) | |
| 38 | |
| 39 # VPATH determines the relative paths of Makefile targets. We need to set it | |
| 40 # here, since we're expecting to be invoked from a Makefile in a different | |
| 41 # directory. This allows our relative paths to be resolved by `make`. | |
| 42 VPATH := $(APP_DIR) | |
| 43 | |
| 44 # If a tag was provided, add it to the "GAE_PY" args. | |
| 45 export LUCI_PY_USE_GCLOUD=1 | |
| 46 GAE_PY_EXTRA_ARGS = | |
| 47 ifdef TAG | |
| 48 GAE_PY_EXTRA_ARGS := $(GAE_PY_EXTRA_ARGS) -t $(TAG) | |
| 49 endif | |
| 50 | |
| 51 ALL_SERVICES = default services backend static | |
| 52 | |
| 53 define HELP_BODY | |
| 54 Manage LogDog distributions. | |
| 55 | |
| 56 Management targets: | |
| 57 web: Builds static web content into the 'static' module. | |
| 58 | |
| 59 Service Targets for: $(ALL_SERVICES) | |
| 60 upload-SERVICE: uploads an instance of the service, but doesn't migrate. | |
| 61 deploy-SERVICE: uploads an instance of the service, but doesn't migrate. | |
|
Ryan Tseng
2017/08/01 17:42:12
FR: consider switch-SERVICE:
gcloud --project <pro
dnj
2017/08/01 17:58:27
Good idea, done.
| |
| 62 upload-static-dev: special command to upload an instance of the static | |
| 63 module named "dev". This can be whitelisted for OAuth for authenticated | |
| 64 testing. | |
| 65 | |
| 66 endef | |
| 67 | |
| 68 .PHONY: help | |
| 69 help: | |
| 70 $(info $(HELP_BODY)) | |
| 71 | |
| 72 .PHONY: yamls | |
| 73 yamls: vmuser/app.yaml vmuser/dispatch.yaml vmuser/index.yaml | |
| 74 | |
| 75 .PHONY: web | |
| 76 web: | |
| 77 -rm -rf $(APP_DIR)static/dist | |
| 78 $(LUCI_GO_DIR)/web/web.py build \ | |
| 79 --build-dir $(APP_DIR)static \ | |
| 80 logdog-app \ | |
| 81 logdog-view \ | |
| 82 rpcexplorer | |
| 83 | |
| 84 # Default resources definition. | |
| 85 .PHONY: $(addsuffix -resources,$(ALL_SERVICES)) | |
| 86 $(addsuffix -resources,$(ALL_SERVICES)):: | |
| 87 | |
| 88 # The "static" module requires additional resources. | |
| 89 static-resources:: web | |
| 90 | |
| 91 ## | |
| 92 # Per-module Build Rules | |
| 93 # | |
| 94 # upload-<module>: Uploads the module, but doesn't set it to be default. | |
| 95 # deploy-<module>: Uploads the module and sets it to be default. | |
| 96 ## | |
| 97 | |
| 98 .PHONY: $(addprefix upload-,$(ALL_SERVICES)) | |
| 99 $(addprefix upload-,$(ALL_SERVICES)): upload-%: %-resources yamls | |
| 100 cd $(APP_DIR) && \ | |
| 101 gae.py upload \ | |
| 102 -A $(CLOUD_PROJECT) \ | |
| 103 $(GAE_PY_EXTRA_ARGS) \ | |
| 104 --force \ | |
| 105 $* | |
| 106 | |
| 107 .PHONY: upload | |
| 108 upload: $(addsuffix -resources,$(ALL_SERVICES)) | |
| 109 cd $(APP_DIR) && \ | |
| 110 gae.py upload \ | |
| 111 -A $(CLOUD_PROJECT) \ | |
| 112 $(GAE_PY_EXTRA_ARGS) \ | |
| 113 --force \ | |
| 114 $(ALL_SERVICES) | |
| 115 | |
| 116 .PHONY: $(addprefix deploy-,$(ALL_SERVICES)) | |
| 117 $(addprefix deploy-,$(ALL_SERVICES)): deploy-%: %-resources yamls | |
| 118 cd $(APP_DIR) && \ | |
| 119 gae.py upload \ | |
| 120 -A $(CLOUD_PROJECT) \ | |
| 121 $(GAE_PY_EXTRA_ARGS) \ | |
| 122 --force \ | |
| 123 --switch \ | |
| 124 $* | |
| 125 | |
| 126 .PHONY: deploy | |
| 127 deploy: $(addsuffix -resources,$(ALL_SERVICES)) | |
| 128 cd $(APP_DIR) && \ | |
| 129 gae.py upload \ | |
| 130 -A $(CLOUD_PROJECT) \ | |
| 131 $(GAE_PY_EXTRA_ARGS) \ | |
| 132 --force \ | |
| 133 --switch \ | |
| 134 $(ALL_SERVICES) | |
| 135 | |
| 136 # This is a special make target to upload the static module named "dev". This | |
| 137 # version can be specifically whitelisted by the service account to enable | |
| 138 # authentication and test a production instance. | |
| 139 .PHONY: upload-static-dev | |
| 140 upload-static-dev: static-resources yamls | |
| 141 cd $(APP_DIR) && \ | |
| 142 gcloud app deploy \ | |
| 143 --project $(CLOUD_PROJECT) \ | |
| 144 --version "dev" \ | |
| 145 --quiet \ | |
| 146 static/module-static.yaml | |
| OLD | NEW |