Skip to content

Commit

Permalink
xcCommand, add XC_DERIVED_DATA options.
Browse files Browse the repository at this point in the history
  • Loading branch information
BB9z committed Jan 19, 2024
1 parent bc254a5 commit 2120a9a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 19 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,21 @@ Environment variables:

Inputs:

- `XC_WORKSPACE`, workspace file path
- `XC_PROJECT`, project file path
- `XC_SCHEME`, scheme name
- `XC_CLEAN`, set to `true` to clean before executing the action
- `XC_WORKSPACE`, workspace file path.
- `XC_PROJECT`, project file path.
- `XC_SCHEME`, scheme name.
- `XC_CLEAN`, set to `true` to clean before executing the action.
- `XC_CONFIGURATION`, build configuration, eg. `Debug`/`Release`/...
- `XC_DESTINATION`, target device, value can be the full parameter or abbreviations like `mac`, `ios`, `watchos`, `tvos`
- `XC_DISABLE_CODE_SIGNING`, set to `true` to disable code signing
- `XC_RESULT_BUNDLE`, path to xcresult bundle
- `XC_LOG_FILE`, path to log file
- `XC_BEAUTIFY`, set to `true` to format output using xcbeautify
- `XC_DERIVED_DATA`, the xcodebuild command derivedDataPath parameter, defaults to `build/DerivedData`, set to an empty string or `0` or `false` to disable customization.
- `XC_DESTINATION`, target device, value can be the full parameter or abbreviations like `mac`, `ios`, `watchos`, `tvos`.
- `XC_DISABLE_CODE_SIGNING`, set to `true` to disable code signing.
- `XC_RESULT_BUNDLE`, path to xcresult bundle.
- `XC_LOG_FILE`, path to log file.
- `XC_BEAUTIFY`, set to `true` to format output using xcbeautify.

Outputs:

- `CI_XCBEATIFY_USED`, whether xcbeautify is actually used
- `CI_XCBEATIFY_USED`, whether xcbeautify is actually used.

## Run Tests

Expand Down
4 changes: 4 additions & 0 deletions lib/xccommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ readonly _xcParameterList=(
"XC_SCHEME"
"XC_CLEAN"
"XC_CONFIGURATION"
"XC_DERIVED_DATA"
"XC_DESTINATION"
"XC_DISABLE_CODE_SIGNING"
"XC_RESULT_BUNDLE"
Expand Down Expand Up @@ -80,6 +81,9 @@ _xcChain1() {
if [[ -n "${XC_CONFIGURATION:-}" ]]; then
xcParts+=("-configuration" "${XC_CONFIGURATION}")
fi
if [[ $(checkVar "${XC_DERIVED_DATA-1}") == 0 ]]; then
xcParts+=("-derivedDataPath" "${XC_DERIVED_DATA-"build/DerivedData"}")
fi

if [[ -n "${XC_DESTINATION:-}" ]]; then
if [[ "${XC_DESTINATION}" == "mac" ]]; then
Expand Down
43 changes: 34 additions & 9 deletions tests/test_lib_xccommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ testNoAction() {
}

testSimpleBuild() {
XC_DERIVED_DATA=0
result=$(xcCommand build)
assertEquals "parameters count:" $? 1
assertEquals "parameters:" "[build]" "$result"
Expand All @@ -37,12 +38,34 @@ testProjectParameters() {
XC_PROJECT="b 2"
XC_SCHEME="c 3"
XC_CONFIGURATION="d 4"
XC_DERIVED_DATA=0
result=$(xcCommand build)
assertEquals "parameters count:" $? 9
assertEquals "parameters:" "[-workspace a 1 -project b 2 -scheme c 3 -configuration d 4 build]" "$result"
}

testDerivedData() {
unset XC_DERIVED_DATA
result=$(xcCommand build)
assertEquals "parameters count:" $? 3
assertEquals "parameters:" "[-derivedDataPath build/DerivedData build]" "$result"

XC_DERIVED_DATA=""
result=$(xcCommand build)
assertEquals "parameters count:" $? 1

XC_DERIVED_DATA=0
result=$(xcCommand build)
assertEquals "parameters count:" $? 1

XC_DERIVED_DATA="1"
result=$(xcCommand build)
assertEquals "parameters count:" $? 3
assertEquals "parameters:" "[-derivedDataPath 1 build]" "$result"
}

testDestination() {
XC_DERIVED_DATA=0
XC_DESTINATION="ios"
result=$(xcCommand build)
assertEquals "parameters count:" $? 3
Expand All @@ -69,23 +92,25 @@ testDestination() {
assertEquals "parameters:" "[-destination custom build]" "$result"
}

testResultBundle() {
XC_RESULT_BUNDLE="xcResult"
result=$(xcCommand build)
assertEquals "parameters count:" $? 3
assertEquals "parameters:" "[-resultBundlePath xcResult build]" "$result"
}

testDisableCodeSigning() {
XC_DERIVED_DATA=0
XC_DISABLE_CODE_SIGNING="1"
result=$(xcCommand build)
assertEquals "parameters count:" $? 2
assertEquals "parameters:" "[CODE_SIGNING_ALLOWED=NO build]" "$result"
}

testResultBundle() {
XC_DERIVED_DATA=0
XC_RESULT_BUNDLE="xcResult"
result=$(xcCommand build)
assertEquals "parameters count:" $? 3
assertEquals "parameters:" "[-resultBundlePath xcResult build]" "$result"
}

testClean() {
XC_CLEAN="1"
result=$(xcCommand build)
assertEquals "parameters count:" $? 2
assertEquals "parameters:" "[clean build]" "$result"
assertEquals "parameters count:" $? 4
assertEquals "parameters:" "[-derivedDataPath build/DerivedData clean build]" "$result"
}

0 comments on commit 2120a9a

Please sign in to comment.