go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/common/api/update_gensupport.sh (about) 1 #!/bin/bash 2 # Copyright 2020 The LUCI Authors. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 set -e 17 18 cd $(dirname $0) 19 20 # It is important to use the exact same code as used by 21 # `google-api-go-generator` binary which is pulled in tools.go from 22 #`google.golang.org/api` module. Otherwise we may be generating incompatible 23 # code. 24 api_mod_dir=$(go mod download -json google.golang.org/api | \ 25 python3 -c "import sys, json; print(json.load(sys.stdin)['Dir'])") 26 27 # Copy internal/gensupport package from there into our tree. 28 rm -f internal/gensupport/*.go 29 cp ${api_mod_dir}/internal/gensupport/* internal/gensupport 30 chmod -R u+w internal/gensupport 31 32 # Avoid linking to internal.Version, this is impossible. 33 sed -i 's/internal.Version/"luci-go"/g' internal/gensupport/*.go 34 goimports -w internal/gensupport/*.go 35 36 # We don't really care about tests nor can really run them with a partial copy. 37 rm internal/gensupport/*_test.go