Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #40 from Sage-Bionetworks/fix-gradle-build
Browse files Browse the repository at this point in the history
Add back in work-around to allow building for Android
  • Loading branch information
liujoshua authored Jul 8, 2021
2 parents 9b12ad1 + efedaa0 commit f37d113
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 25 deletions.
37 changes: 35 additions & 2 deletions bridge-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,26 @@ kotlin {
publishAllLibraryVariants()
}

ios {
// This bit is here to build the XCFramework. syoung 07/02/21
if (project.findProperty("XCFRAMEWORK") == "true") {
ios {
binaries {
framework {
baseName = iosFrameworkName
}
}
}
}

// This bit is here so that running `./gradlew build` will work. syoung 07/02/21
// Block from https://github.com/cashapp/sqldelight/issues/2044#issuecomment-721299517.
val iOSTargetName = System.getenv("SDK_NAME") ?: project.findProperty("XCODE_SDK_NAME") as? String ?: "iphonesimulator"
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (iOSTargetName.startsWith("iphoneos"))
::iosArm64
else
::iosX64
iOSTarget("ios") {
binaries {
framework {
baseName = iosFrameworkName
Expand Down Expand Up @@ -134,6 +153,20 @@ publishing {
}
}

val packForXcode by tasks.creating(Sync::class) {
group = "build"
val mode = System.getenv("CONFIGURATION") ?: project.findProperty("XCODE_CONFIGURATION") as? String ?: "DEBUG"
//val sdkName = System.getenv("SDK_NAME") ?: project.findProperty("XCODE_SDK_NAME") as? String ?: "iphonesimulator"
val targetName = "ios" //+ if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
val framework = kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, "xcode-frameworks")
from({ framework.outputDirectory })
into(targetDir)
}
tasks.getByName("build").dependsOn(packForXcode)

//region XcFramework tasks
val xcFrameworkPath = "build/xcframework/$iosFrameworkName.xcframework"
val swiftPMPath = "${project.rootDir}/SwiftPackage/Binaries/$iosFrameworkName.xcframework"
Expand All @@ -150,7 +183,7 @@ val buildXcFramework by tasks.registering {
}
group = "build"
val defaultMode = if (isSwiftPM) "RELEASE" else "DEBUG"
val mode = System.getenv("CONFIGURATION") ?: project.findProperty("XCODE_CONFIGURATION") as? String ?: defaultMode
val mode = project.findProperty("XCODE_CONFIGURATION") as? String ?: defaultMode
val frameworks = arrayOf("iosArm64", "iosX64")
.map { kotlin.targets.getByName<KotlinNativeTarget>(it).binaries.getFramework(mode) }
inputs.property("mode", mode)
Expand Down
21 changes: 0 additions & 21 deletions iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */;
buildPhases = (
7555FFB5242A651A00829871 /* ShellScript */,
7555FF77242A565900829871 /* Sources */,
7555FF78242A565900829871 /* Frameworks */,
7555FF79242A565900829871 /* Resources */,
Expand Down Expand Up @@ -407,26 +406,6 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
7555FFB5242A651A00829871 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cd \"$SRCROOT/..\"\n./gradlew :bridge-client:buildXcFramework -PXCODE_CONFIGURATION=${CONFIGURATION}\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
7555FF77242A565900829871 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "# Type a script or drag a script file from your workspace to insert its path.&#10;cd &quot;$SRCROOT/..&quot;&#10;./gradlew :bridge-client:buildXcFramework -PXCFRAMEWORK=&quot;true&quot; -PXCODE_CONFIGURATION=${CONFIGURATION}&#10;">
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
3 changes: 1 addition & 2 deletions xcframework_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
# iosApp
#

./gradlew :bridge-client:buildXcFramework -PSWIFT_PM="true"

./gradlew :bridge-client:buildXcFramework -PXCFRAMEWORK="true" -PSWIFT_PM="true"

0 comments on commit f37d113

Please sign in to comment.