-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS and OS X library dependencies #506
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,11 +307,13 @@ class NativeCompilation { | |
// https://docs.gradle.org/current/userguide/nativeBinaries.html#N161B3 | ||
task('j2objcBuildObjcDebug').configure { | ||
dependsOn binaries.withType(NativeLibraryBinary).matching { NativeLibraryBinary lib -> | ||
// Internal build type is lowercase 'debug' | ||
lib.buildable && lib.buildType.name == 'debug' | ||
} | ||
} | ||
task('j2objcBuildObjcRelease').configure { | ||
dependsOn binaries.withType(NativeLibraryBinary).matching { NativeLibraryBinary lib -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must revert this change. Internally the build type is lower case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted to 'release' |
||
// Internal build type is lowercase 'release' | ||
lib.buildable && lib.buildType.name == 'release' | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ import groovy.transform.CompileStatic | |
import org.gradle.api.DefaultTask | ||
import org.gradle.api.InvalidUserDataException | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.InputDirectory | ||
import org.gradle.api.tasks.OutputFile | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
|
@@ -89,29 +88,57 @@ class PodspecTask extends DefaultTask { | |
|
||
// podspec creation | ||
// TODO: allow custom list of libraries | ||
String libDirDebug = new File(getDestLibDirFile(), '/iosDebug').absolutePath | ||
String libDirRelease = new File(getDestLibDirFile(), '/iosRelease').absolutePath | ||
// iOS packed libraries are shared with watchOS | ||
String libDirIosDebug = new File(getDestLibDirFile(), '/iosDebug').absolutePath | ||
String libDirIosRelease = new File(getDestLibDirFile(), '/iosRelease').absolutePath | ||
String libDirOsxDebug = new File(getDestLibDirFile(), '/x86_64Debug').absolutePath | ||
String libDirOsxRelease = new File(getDestLibDirFile(), '/x86_64Release').absolutePath | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm having second thoughts about the ordering here. Until the AssembleLibrariesTask has run, j2objcOutputs/lib/BLAH is never created. Does this work for you after a ./gradlew clean then ./gradlew build? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ordering is fine. The absolutePath is resolved internally without referencing the FS. I can run |
||
|
||
J2objcConfig j2objcConfig = J2objcConfig.from(project) | ||
|
||
String minIos = j2objcConfig.minIosVersion | ||
String minOsx = j2objcConfig.minOsxVersion | ||
String minWatchos = j2objcConfig.minWatchosVersion | ||
validateNumericVersion(minIos, 'minIosVersion') | ||
validateNumericVersion(minOsx, 'minOsxVersion') | ||
validateNumericVersion(minWatchos, 'minWatchosVersion') | ||
|
||
String podspecContentsDebug = | ||
genPodspec(getPodNameDebug(), libDirDebug, libName, getJ2objcHome(), | ||
headerIncludePath, resourceIncludePath) | ||
genPodspec(getPodNameDebug(), headerIncludePath, resourceIncludePath, | ||
libName, getJ2objcHome(), | ||
libDirIosDebug, libDirOsxDebug, libDirIosDebug, | ||
minIos, minOsx, minWatchos) | ||
String podspecContentsRelease = | ||
genPodspec(getPodNameRelease(), libDirRelease, libName, getJ2objcHome(), | ||
headerIncludePath, resourceIncludePath) | ||
genPodspec(getPodNameRelease(), headerIncludePath, resourceIncludePath, | ||
libName, getJ2objcHome(), | ||
libDirIosRelease, libDirOsxRelease, libDirIosRelease, | ||
minIos, minOsx, minWatchos) | ||
|
||
logger.debug("Writing debug podspec... ${getPodspecDebug()}") | ||
getPodspecDebug().write(podspecContentsDebug) | ||
logger.debug("Writing release podspec... ${getPodspecRelease()}") | ||
getPodspecRelease().write(podspecContentsRelease) | ||
} | ||
|
||
@VisibleForTesting | ||
void validateNumericVersion(String version, String type) { | ||
// Requires at least a major and minor version number | ||
Matcher versionMatcher = (version =~ /^[0-9]*(\.[0-9]+)+$/) | ||
if (!versionMatcher.find()) { | ||
logger.warn("Non-numeric version for $type: $version") | ||
} | ||
} | ||
|
||
// Podspec references are relative to project.buildDir | ||
@VisibleForTesting | ||
static String genPodspec(String podname, String libDir, String libName, String j2objcHome, | ||
String publicHeadersDir, String resourceDir) { | ||
static String genPodspec(String podname, String publicHeadersDir, String resourceDir, | ||
String libName, String j2objcHome, | ||
String libDirIos, String libDirOsx, String libDirWatchos, | ||
String minIos, String minOsx, String minWatchos) { | ||
|
||
// Absolute paths for Xcode command line | ||
validatePodspecPath(libDir, false) | ||
validatePodspecPath(libDirIos, false) | ||
validatePodspecPath(libDirOsx, false) | ||
validatePodspecPath(j2objcHome, false) | ||
|
||
// Relative paths for content referenced by CocoaPods | ||
|
@@ -121,8 +148,8 @@ class PodspecTask extends DefaultTask { | |
// TODO: CocoaPods strongly recommends switching from 'resources' to 'resource_bundles' | ||
// http://guides.cocoapods.org/syntax/podspec.html#resource_bundles | ||
|
||
// TODO: Distinguish ios to OS X builds: | ||
// https://github.com/j2objc-contrib/j2objc-gradle/issues/488 | ||
// TODO: replace xcconfig with {pod|user}_target_xcconfig | ||
// See 'Split of xcconfig' from: http://blog.cocoapods.org/CocoaPods-0.38/ | ||
|
||
// File and line separators assumed to be '/' and '\n' as podspec can only be used on OS X | ||
return "Pod::Spec.new do |spec|\n" + | ||
|
@@ -134,9 +161,22 @@ class PodspecTask extends DefaultTask { | |
" spec.libraries = " + // continuation of same line | ||
"'ObjC', 'guava', 'javax_inject', 'jre_emul', 'jsr305', 'z', 'icucore', '$libName'\n" + | ||
" spec.xcconfig = {\n" + | ||
" 'HEADER_SEARCH_PATHS' => '$j2objcHome/include $publicHeadersDir',\n" + | ||
" 'LIBRARY_SEARCH_PATHS' => '$j2objcHome/lib $libDir'\n" + | ||
" 'HEADER_SEARCH_PATHS' => '$j2objcHome/include $publicHeadersDir'\n" + | ||
" }\n" + | ||
" spec.ios.xcconfig = {\n" + | ||
" 'LIBRARY_SEARCH_PATHS' => '$j2objcHome/lib $libDirIos'\n" + | ||
" }\n" + | ||
" spec.osx.xcconfig = {\n" + | ||
" 'LIBRARY_SEARCH_PATHS' => '$j2objcHome/lib/macosx $libDirOsx'\n" + | ||
" }\n" + | ||
" spec.watchos.xcconfig = {\n" + | ||
" 'LIBRARY_SEARCH_PATHS' => '$j2objcHome/lib $libDirWatchos'\n" + | ||
" }\n" + | ||
// http://guides.cocoapods.org/syntax/podspec.html#deployment_target | ||
" spec.ios.deployment_target = '$minIos'\n" + | ||
" spec.osx.deployment_target = '$minOsx'\n" + | ||
" spec.watchos.deployment_target = '$minWatchos'\n" + | ||
" spec.osx.frameworks = 'ExceptionHandling'\n" + | ||
"end\n" | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must revert this change. Internally the build type is lower case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted to 'debug'