/core/externals/google-toolbox-for-mac/BuildScripts/SDEFCompiler.sh

http://macfuse.googlecode.com/ · Shell · 45 lines · 14 code · 6 blank · 25 comment · 2 complexity · 2456da6037f4b4406c0c59755c1958fb MD5 · raw file

  1. #!/bin/sh
  2. # SDEFCompiler.sh
  3. # Copyright 2009 Google Inc.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License"); you may not
  6. # use this file except in compliance with the License. You may obtain a copy
  7. # of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. # License for the specific language governing permissions and limitations under
  15. # the License.
  16. # Takes a file (usually with a suffix of .sdefsrc) and "compiles it" using
  17. # xmllint to verify its correctness. Gets rid of a lot of the guesswork when
  18. # trying to figure out what is wrong with your SDEF file.
  19. # The best way to use SDEFCompiler is to add a custom build rule to your target
  20. # in Xcode with the following settings:
  21. # Process: "Source files with names matching:" "*.sdefsrc"
  22. # using: "Custom script:"
  23. # "Path/to/SDEFCompiler/relative/to/${SRCROOT}'
  24. # with output files:
  25. # ${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${INPUT_FILE_BASE}.sdef
  26. set -o errexit
  27. set -o nounset
  28. if [[ $# -ne 2 && $# -ne 0 ]] ; then
  29. echo "usage: ${0} INPUT OUTPUT" >&2
  30. exit 1
  31. fi
  32. if [[ $# -eq 2 ]] ; then
  33. SCRIPT_INPUT_FILE="${1}"
  34. SCRIPT_OUTPUT_FILE="${2}"
  35. else
  36. SCRIPT_INPUT_FILE="${INPUT_FILE_PATH}"
  37. SCRIPT_OUTPUT_FILE="${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${INPUT_FILE_BASE}.sdef"
  38. fi
  39. exec xmllint --xinclude --valid --postvalid --format "${SCRIPT_INPUT_FILE}" > "${SCRIPT_OUTPUT_FILE}"