migrate_cpp.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash -eux
  2. #
  3. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  4. # Exceptions. See /LICENSE for license information.
  5. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. #
  7. # Runs an example migration of woff2 C++ code.
  8. # cd to the carbon-lang root.
  9. cd "$(dirname "$0")/../../.."
  10. EXAMPLE=third_party/examples/woff2
  11. # Remove any previous conversion. Each time this is run, it should demonstrate
  12. # on a fresh copy of woff2.
  13. rm -rf "${EXAMPLE}/carbon/"
  14. # Initialize the carbon directory with C++ code only.
  15. mkdir -p "${EXAMPLE}/carbon/"
  16. for x in LICENSE include src; do
  17. cp -R "${EXAMPLE}/original/${x}" "${EXAMPLE}/carbon/${x}"
  18. done
  19. # Copy files into the carbon directory to simplify the setup.
  20. cp "${EXAMPLE}/BUILD.original" \
  21. "${EXAMPLE}/carbon/BUILD"
  22. cp "${EXAMPLE}/WORKSPACE.original" \
  23. "${EXAMPLE}/carbon/WORKSPACE"
  24. cp "${EXAMPLE}/compile_flags.carbon.txt" \
  25. "${EXAMPLE}/carbon/compile_flags.txt"
  26. # Run the migration tool.
  27. bazel build -c opt //migrate_cpp
  28. # Not sure why, but execution of cpp_refactoring fails while saving refactorings
  29. # if not in the directory. Ideally shouldn't be required, passing the path to
  30. # migrate_cpp should work.
  31. cd "${EXAMPLE}/carbon"
  32. ../../../../bazel-bin/migrate_cpp/migrate_cpp .