Skip to content

Commit

Permalink
Improve output directory detection
Browse files Browse the repository at this point in the history
* The output directory is determined by comparing the "Output files"
  environment variables set by Xcode
* Bump version to 3.0.1
  • Loading branch information
externl committed Sep 20, 2016
1 parent 2406259 commit c819885
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ must add the appropriate directory to the `Additional SDKs` setting:
You also need to add the following linker options to the `Other Linker Flags` setting:
| Distribution | Language | Required | Ice Plugins | Optional Services |
| ------------ | ----------- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------| ---------------------------------------------------------------------------- |
| Ice Touch 1.3 | Objective-C | `-ObjC`<br>`-lIceObjC-libc++`<br>`-lc++` | | `-lGlacier2ObjC-libc++`<br>`-lIceStormObjC-libc++`<br>`-lIceGridObjC-libc++` |
| Ice Touch 1.3 | C++ | `-lIce-libc++` | | `-lGlacier2-libc++`<br>`-lIceGrid-libc++`<br>`-lIceStorm-libc++` |
| Ice Touch 3.6 | Objective-C | `-ObjC`<br>`-lIceObjC`<br>`-lc++` | | `-lGlacier2ObjC`<br>`-lIceStormObjC`<br>`-lIceGridObjC` |
| Ice Touch 3.6 | C++ | `-lIce` | | `-lGlacier2`<br>`-lIceGrid`<br>`-lIceStorm` |
| Ice 3.7 | Objective-C | `-ObjC`<br>`-lIce`<br>`-lIceObjC`<br>`-lc++` | `-lIceDiscovery`<br> `-lIceIAP` `-lIceIAPObjC`<br> `-lIceLocatorDiscovery`<br> `-lIceSSL` `-lIceSSLObjC` | `-lGlacier2ObjC`<br>`-lIceGridObjC`<br> `-lIceStormObjC` |
| Ice 3.7 | C++ | `-lIce` | `-lIceDiscovery`<br> `-lIceIAP`<br> `-lIceLocatorDiscovery`<br> `-lIceSSL` | `-lGlacier2`<br>`-lIceGrid`<br> `-lIceStorm` |
| Distribution | Language | Required | Ice Plugins | Optional Services |
| ------------ | ----------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| Ice Touch 1.3 | Objective-C | `-ObjC`<br>`-lIceObjC-libc++`<br>`-lc++` | | `-lGlacier2ObjC-libc++`<br>`-lIceStormObjC-libc++`<br>`-lIceGridObjC-libc++` |
| Ice Touch 1.3 | C++ | `-lIce-libc++` | | `-lGlacier2-libc++`<br>`-lIceGrid-libc++`<br>`-lIceStorm-libc++` |
| Ice Touch 3.6 | Objective-C | `-ObjC`<br>`-lIceObjC`<br>`-lc++` | | `-lGlacier2ObjC`<br>`-lIceStormObjC`<br>`-lIceGridObjC` |
| Ice Touch 3.6 | C++ | `-lIce` | | `-lGlacier2`<br>`-lIceGrid`<br>`-lIceStorm` |
| Ice 3.7 | Objective-C | `-ObjC`<br>`-lIce`<br>`-lIceObjC`<br>`-lc++` | `-lIceDiscovery`<br> `-lIceIAP` `-lIceIAPObjC`<br> `-lIceLocatorDiscovery`<br> `-lIceSSL` `-lIceSSLObjC` | `-lGlacier2ObjC`<br>`-lIceGridObjC`<br> `-lIceStormObjC` |
| Ice 3.7 | C++ | `-lIce` | `-lIceDiscovery`<br> `-lIceIAP`<br> `-lIceLocatorDiscovery`<br> `-lIceSSL` | `-lGlacier2`<br>`-lIceGrid`<br> `-lIceStorm` |
With Ice 3.7 (iOS and OS X) or Ice Touch (OS X only), you also need to add `-lbz2` and `-liconv`.
Expand All @@ -95,6 +95,9 @@ To force your Slice files to be re-compiled you need to clean (⇧⌘K) your pro
The builder automatically includes the Ice Slice files directory included with the Ice or Ice Touch SDK as well as the
directory of the Slice file being compiled.
The output directory passed to the slice compiler is determined by comparing the paths of the given `Output files`.
Exactly two files must be set and both files must share the same base directory path.
[1]: https://github.com/zeroc-ice/ice-builder-xcode/tree/xcode7-plugin
[2]: https://doc.zeroc.com/display/Ice/slice2cpp+Command-Line+Options
[3]: https://doc.zeroc.com/display/Ice/slice2objc+Command-Line+Options
40 changes: 35 additions & 5 deletions icebuilder
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# **********************************************************************
set -eo pipefail

readonly ICE_BUILDER_XCODE_VERSION=3.0.0
readonly ICE_BUILDER_XCODE_VERSION=3.0.1

calledFromXcode() {
if [[ -z $XCODE_PRODUCT_BUILD_VERSION || -z $DERIVED_FILE_DIR || -z $INPUT_FILE_PATH ]]; then
Expand All @@ -18,22 +18,52 @@ calledFromXcode() {
# Run slice sliceCompiler. We always include Ice slice file directory as well as the INPUT_FILE_DIR.
compileSliceFile() {
logDebug "Compiling slice file: $INPUT_FILE_NAME"
set -x
set -x # print the executed slice compiler command
$sliceCompiler -I"$INPUT_FILE_DIR" \
-I"$sliceDir" \
--output-dir "$DERIVED_FILE_DIR" \
--output-dir "$outputDir" \
"${sliceCompilerArguments[@]}" \
"$INPUT_FILE_PATH"
}

# Output directory is detected by comparing the SCRIPT_OUTPUT_FILE_{0,1} variables.
# These are expected to the be the destination of the slice compiler generated header
# and source files. Both files must share the same base directory, as this is how we
# determine the output directory to pass to the slice compiler.
setOutputDir() {
if [ "$SCRIPT_OUTPUT_FILE_COUNT" -ne 2 ]; then
echo "Please specify a header and source output file."
return 1
fi

local -r outputFile0=${SCRIPT_OUTPUT_FILE_0}
logDebug "Output file 0: $outputFile0"
local -r outputFile1=${SCRIPT_OUTPUT_FILE_1}
logDebug "Output file 1: $outputFile1"

local -r outputFileDir0=$(dirname "$outputFile0")
local -r outputFileDir1=$(dirname "$outputFile1")

if [ "$outputFileDir0" != "$outputFileDir1" ]; then
echo "Output files must be in the same directory."
return 1
fi

outputDir="$outputFileDir0"
}

main() {
if ! calledFromXcode; then
logError "Ice Builder for Xcode must be executed from an Xcode environment."
exit 0
fi

if ! setOutputDir; then
exit 1
fi

if ! findIceSDK; then
logError "Unable to find an Ice SDK. An Ice SDK must be added to the list of 'Additional SDKs'."
logError "Unable to find an Ice or Ice Touch SDK. An Ice or Ice Touch SDK must be added to the list of 'Additional SDKs'."
exit 1
fi

Expand Down Expand Up @@ -104,7 +134,7 @@ versionGt() {
}

#
# Procress arguments and run slice compiler
# Process arguments and run slice compiler
#
logDebug "Ice Builder for Xcode version: $ICE_BUILDER_XCODE_VERSION"

Expand Down

0 comments on commit c819885

Please sign in to comment.