forked from apache/cordova-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apacheGH-540: Fix copy-www-build-step without shelljs
There didn't seem to be a compelling reason to keep this as JavaScript since it was primarily just shelling out to run various commands. By keeping it in bash, we can significantly simplify the invocation in the xcodeproj file and we can run it without a dependency on shelljs. I also moved it into a Scripts folder inside the project so that our xcodeproj file isn't reliant on the cordova/lib folder existing, and this particular script isn't actually a "lib" in the standard sense.
- Loading branch information
Showing
7 changed files
with
129 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
bin/templates/project/__PROJECT_NAME__/Scripts/copy-www-build-step.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/sh | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
# | ||
# | ||
# This script copies the www directory into the Xcode project. | ||
# | ||
# This script should not be called directly. | ||
# It is called as a build step from Xcode. | ||
|
||
SRC_DIR="www" | ||
DST_DIR="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME" | ||
DST_DIR_WWW="$DST_DIR/www" | ||
COPY_HIDDEN= | ||
ORIG_IFS=$IFS | ||
IFS=$(echo -en "\n\b") | ||
|
||
if [[ -z "$BUILT_PRODUCTS_DIR" ]]; then | ||
echo "The script is meant to be run as an Xcode build step and relies on env variables set by Xcode." | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -e "$SRC_DIR" ]]; then | ||
echo "error: Path does not exist: $SRC_DIR" | ||
exit 2 | ||
fi | ||
|
||
rm -rf "$DST_DIR_WWW" | ||
|
||
# Copy www dir recursively | ||
CODE= | ||
if [[ -n $COPY_HIDDEN ]]; then | ||
rsync -Lra "$SRC_DIR" "$DST_DIR" | ||
CODE=$? | ||
else | ||
rsync -Lra --exclude="- .*" "$SRC_DIR" "$DST_DIR" | ||
CODE=$? | ||
fi | ||
|
||
if [ $CODE -ne 0 ]; then | ||
echo "error: Error occurred on copying www. Code $CODE" | ||
exit 3 | ||
fi | ||
|
||
# Copy the config.xml file. | ||
cp -f "${PROJECT_FILE_PATH%.xcodeproj}/config.xml" "$DST_DIR" | ||
|
||
IFS=$ORIG_IFS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
tests/spec/unit/fixtures/ios-config-xml/SampleApp/Scripts/copy-www-build-step.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/sh | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
# | ||
# | ||
# This script copies the www directory into the Xcode project. | ||
# | ||
# This script should not be called directly. | ||
# It is called as a build step from Xcode. | ||
|
||
SRC_DIR="www" | ||
DST_DIR="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME" | ||
DST_DIR_WWW="$DST_DIR/www" | ||
COPY_HIDDEN= | ||
ORIG_IFS=$IFS | ||
IFS=$(echo -en "\n\b") | ||
|
||
if [[ -z "$BUILT_PRODUCTS_DIR" ]]; then | ||
echo "The script is meant to be run as an Xcode build step and relies on env variables set by Xcode." | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -e "$SRC_DIR" ]]; then | ||
echo "error: Path does not exist: $SRC_DIR" | ||
exit 2 | ||
fi | ||
|
||
rm -rf "$DST_DIR_WWW" | ||
|
||
# Copy www dir recursively | ||
CODE= | ||
if [[ -n $COPY_HIDDEN ]]; then | ||
rsync -Lra "$SRC_DIR" "$DST_DIR" | ||
CODE=$? | ||
else | ||
rsync -Lra --exclude="- .*" "$SRC_DIR" "$DST_DIR" | ||
CODE=$? | ||
fi | ||
|
||
if [ $CODE -ne 0 ]; then | ||
echo "error: Error occurred on copying www. Code $CODE" | ||
exit 3 | ||
fi | ||
|
||
# Copy the config.xml file. | ||
cp -f "${PROJECT_FILE_PATH%.xcodeproj}/config.xml" "$DST_DIR" | ||
|
||
IFS=$ORIG_IFS |