diff options
author | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2010-02-02 22:03:46 +0000 |
---|---|---|
committer | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2010-02-02 22:03:46 +0000 |
commit | b7c220eef1c55426c5a7c003c4890a5b2ed97e2b (patch) | |
tree | 28240eda335000cdee4aba0b7a0d94adb3c1113c /BuildScripts | |
parent | 8352c13af31be429bd5fd5c36d169fe0ff4c354e (diff) |
[Author: dmaclach]
Add PListCompiler to Google Toolbox for Mac.
R=thomasvl
DELTA=65 (65 added, 0 deleted, 0 changed)
Diffstat (limited to 'BuildScripts')
-rwxr-xr-x | BuildScripts/PListCompiler.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/BuildScripts/PListCompiler.sh b/BuildScripts/PListCompiler.sh new file mode 100755 index 0000000..2bc9c57 --- /dev/null +++ b/BuildScripts/PListCompiler.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# PlistCompiler.sh + +# Copyright 2010 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +# Takes a file (usually with a suffix of .plistsrc) and "compiles it" using +# the gcc preprocessor. +# The best way to use PlistCompiler is to add a custom build rule to your target +# in Xcode with the following settings: +# Process: "Source files with names matching:" "*.plistsrc" +# using: "Custom script:" +# "Path/to/PlistCompiler/relative/to/${SRCROOT}' +# with output files: +# ${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${INPUT_FILE_BASE}.plist +# You can control the include paths by setting the +# GTM_PLIST_COMPILER_INCLUDE_PATHS environment variable to a colon delimited +# path string. It defaults to "." + + +set -o errexit +set -o nounset + +GTM_PLIST_COMPILER_INCLUDE_PATHS=${GTM_PLIST_COMPILER_INCLUDE_PATHS:="."} + +if [[ $# -ne 2 && $# -ne 0 ]] ; then + echo "usage: ${0} INPUT OUTPUT" >&2 + exit 1 +fi + +if [[ $# -eq 2 ]] ; then + SCRIPT_INPUT_FILE="${1}" + SCRIPT_OUTPUT_FILE="${2}" +else + SCRIPT_INPUT_FILE="${INPUT_FILE_PATH}" + SCRIPT_OUTPUT_FILE="${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${INPUT_FILE_BASE}.plist" +fi + +# Split up the passed in include paths +SaveIFS=$IFS +IFS=":" +split_include_paths="" +for a in ${GTM_PLIST_COMPILER_INCLUDE_PATHS}; +do +split_include_paths="$split_include_paths -I '$a'" +done +IFS=$SaveIFS + +# run gcc and strip out lines starting with # that the preprocessor leaves behind. +eval gcc ${split_include_paths} -E -x c "${SCRIPT_INPUT_FILE}" | sed 's/^#.*//g' > "${SCRIPT_OUTPUT_FILE}"
\ No newline at end of file |