tree: 419234f85b8893efa269c0f201aa5c588f247981 [path history] [tgz]
  1. AbstractObjcRuleSet.java
  2. AppleBinary.java
  3. AppleBinaryRule.java
  4. AppleCrosstoolTransition.java
  5. AppleDebugOutputsInfo.java
  6. AppleDylibBinaryInfo.java
  7. AppleDynamicFrameworkInfo.java
  8. AppleExecutableBinaryInfo.java
  9. AppleLoadableBundleBinaryInfo.java
  10. AppleSkylarkCommon.java
  11. AppleStaticLibrary.java
  12. AppleStaticLibraryInfo.java
  13. AppleStaticLibraryRule.java
  14. ArtifactListAttribute.java
  15. Attribute.java
  16. BUILD
  17. CompilationArtifacts.java
  18. CompilationAttributes.java
  19. CompilationSupport.java
  20. IntermediateArtifacts.java
  21. Interspersing.java
  22. IterableWrapper.java
  23. J2ObjcAspect.java
  24. J2ObjcCommandLineOptions.java
  25. J2ObjcConfiguration.java
  26. J2ObjcEntryClassProvider.java
  27. J2ObjcLibrary.java
  28. J2ObjcLibraryBaseRule.java
  29. J2ObjcLibraryRule.java
  30. J2ObjcMappingFileProvider.java
  31. J2ObjcSource.java
  32. LipoSupport.java
  33. MultiArchBinarySupport.java
  34. MultiArchSplitTransitionProvider.java
  35. ObjcBuildInfoFactory.java
  36. ObjcCommandLineOptions.java
  37. ObjcCommon.java
  38. ObjcCompilationContext.java
  39. ObjcConfiguration.java
  40. ObjcConfigurationLoader.java
  41. ObjcCppSemantics.java
  42. ObjcImport.java
  43. ObjcImportRule.java
  44. ObjcLibrary.java
  45. ObjcLibraryRule.java
  46. ObjcProtoAspect.java
  47. ObjcProtoProvider.java
  48. ObjcProvider.java
  49. ObjcProviderSkylarkConverters.java
  50. ObjcRuleClasses.java
  51. ObjcVariablesExtension.java
  52. ProtoAttributes.java
  53. ProtobufSupport.java
  54. README.md
  55. SdkFramework.java
  56. Value.java
src/main/java/com/google/devtools/build/lib/rules/objc/README.md

The Apple Rule Implementations:

The packages devtools/build/lib/rules/objc and devtools/build/lib/rules/apple implement the objc and ios Bazel rules.

Interfacing from Skylark

Information exchange between skylark rules and native objc_* or ios_* rules occurs by three mechanisms:

  1. AppleToolchain:

AppleToolchain.java houses constants and static methods for use in rule implementations. It is accessed in skylark through the global apple_common namespace:

def __impl(ctx):
    platform_dir = apple_common.apple_toolchain().platform_dir('iphoneos')
    sdk_dir = apple_common.apple_toolchain().sdk_dir()
  1. AppleConfiguration and ObjcConfiguration:

In Bazel, configuration fragments are used as containers for invocation-specific build information (that is, information that cannot always be derived strictly from BUILD files). The contents of these configurations can be inspected by looking at rules/objc/ObjcConfiguration.java and rules/apple/AppleConfiguration.java. To access a configuration fragment from skylark, the fragment must be declared in the rule definition:

def __impl(ctx):
    cpu = ctx.fragments.apple.ios_cpu()
my_rule = rule(
  implementation = __impl
  fragments = ['apple']
)
  1. ObjcProvider:

The ObjcProvider maps “keys” to NestedSet instances, where “keys” are singleton objects defined in ObjcProvider that identify a category of transitive information to be communicated between targets in a dependency chain.

Native objc/ios rules export ObjcProvider instances, which are made available to skylark dependants:

def __impl(ctx):
    dep = ctx.attr.deps[0]
    objc_provider = dep.objc

The provider can be queried by accessing fields that correspond to ObjcProvider keys.

    libraries = objc_provider.library  # A Depset of Artifacts

A skylark rule that is intended to be a dependency of native objc rules should export an ObjcProvider itself. An ObjcProvider is constructed using a constructor exposed on the apple_common namespace.

def __impl(ctx):
    define = 'some_define'
    objc_provider = apple_common.new_objc_provider(define=define)
    return struct(objc = objc_provider)

Arguments to new_objc_provider should correspond to ObjcProvider keys, and values should be skylark sets that should be added to the provider. Other instances of ObjcProvider can also be used in provider construction.

def __impl(ctx):
    dep = ctx.attr.deps[0]
    define = 'some_define'
    objc_provider = apple_common.new_objc_provider(providers=[dep.objc], define=define)
    return struct(objc = objc_provider)