run_in_workspace.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # Copyright 2015 gRPC 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. # Create a workspace in a subdirectory to allow running multiple builds in isolation.
  17. # WORKSPACE_NAME env variable needs to contain name of the workspace to create.
  18. # All cmdline args will be executed as a command.
  19. set -ex
  20. cd "$(dirname "$0")/../../.."
  21. repo_root=$(pwd)
  22. export repo_root
  23. # TODO: fix file to pass shellcheck
  24. rm -rf "${WORKSPACE_NAME}"
  25. git clone . "${WORKSPACE_NAME}"
  26. # clone gRPC submodules, use data from locally cloned submodules where possible
  27. # shellcheck disable=SC1004,SC2016
  28. git submodule foreach 'cd "${repo_root}/${WORKSPACE_NAME}" \
  29. && git submodule update --init --reference ${repo_root}/${name} ${name}'
  30. echo "Running in workspace ${WORKSPACE_NAME}"
  31. cd "${WORKSPACE_NAME}"
  32. # shellcheck disable=SC2068
  33. $@