Skip to content

Commit

Permalink
Improve support for cc_library (via CCInfo)
Browse files Browse the repository at this point in the history
- Fetch includes and defines from the compilation context
  only if the objc provider is not present

PiperOrigin-RevId: 288503017
  • Loading branch information
DavidGoldman authored and jparise committed Sep 8, 2021
1 parent 15fbbf9 commit 432cdb6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/TulsiGenerator/Bazel/tulsi/tulsi_aspects.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,10 @@ def _collect_module_maps(target, rule_attr):
return depset(transitive = depsets)
return depset()

def _collect_objc_defines(objc_provider, rule_attr):
def _collect_objc_defines(objc_provider, cc_provider, rule_attr):
"""Returns a depset of C-compiler defines."""
if cc_provider and not objc_provider:
return cc_provider.compilation_context.defines
depsets = [objc_provider.define] if objc_provider else []
for dep in _collect_dependencies(rule_attr, "deps"):
if CcInfo in dep:
Expand Down Expand Up @@ -885,16 +887,25 @@ def _tulsi_sources_aspect(target, ctx):
all_attributes.update(transitive_attributes)

objc_provider = _get_opt_provider(target, ObjcInfo)
cc_provider = _get_opt_provider(target, CcInfo)
objc_defines = []
target_includes = []
includes_depsets = []

if objc_provider:
includes_depsets = [objc_provider.include, objc_provider.iquote, objc_provider.include_system]
elif cc_provider:
cc_ctx = cc_provider.compilation_context
includes_depsets = [cc_ctx.includes, cc_ctx.quote_includes, cc_ctx.system_includes]

if includes_depsets:
target_includes = [
_convert_outpath_to_symlink_path(x)
for x in depset(transitive = [objc_provider.include, objc_provider.iquote, objc_provider.include_system]).to_list()
for x in depset(transitive = includes_depsets).to_list()
]
else:
target_includes = []

objc_defines = _collect_objc_defines(objc_provider, rule_attr).to_list()
objc_defines = _collect_objc_defines(objc_provider, cc_provider, rule_attr).to_list()

platform_type, os_deployment_target = _get_deployment_info(target, ctx)
non_arc_srcs = _collect_files(rule, "attr.non_arc_srcs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@
isa = XCBuildConfiguration;
buildSettings = {
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
HEADER_SEARCH_PATHS = "$(inherited) $(TULSI_WR)/. $(TULSI_WR)/bazel-tulsi-includes/x/x/ $(TULSI_WR)/external/bazel_tools $(TULSI_WR)/bazel-tulsi-includes/x/x/external/bazel_tools $(TULSI_BWRS)/. $(TULSI_BWRS)/bazel-tulsi-includes/x/x/ $(TULSI_BWRS)/external/bazel_tools $(TULSI_BWRS)/bazel-tulsi-includes/x/x/external/bazel_tools ";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_CFLAGS = "-DLIBRARY_DEFINES_DEFINE=1";
PRODUCT_NAME = _idx_ccBinary_C9583FBE_ios_min8.0;
Expand All @@ -383,7 +384,9 @@
isa = XCBuildConfiguration;
buildSettings = {
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
HEADER_SEARCH_PATHS = "$(inherited) $(TULSI_WR)/. $(TULSI_WR)/bazel-tulsi-includes/x/x/ $(TULSI_BWRS)/. $(TULSI_BWRS)/bazel-tulsi-includes/x/x/ ";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_CFLAGS = "-DLIBRARY_DEFINES_DEFINE=1";
PRODUCT_NAME = _idx_ccLibrary_CCA8EDE9_ios_min8.0;
SDKROOT = iphoneos;
USER_HEADER_SEARCH_PATHS = "$(TULSI_WR)";
Expand Down Expand Up @@ -446,6 +449,7 @@
isa = XCBuildConfiguration;
buildSettings = {
GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1";
HEADER_SEARCH_PATHS = "$(inherited) $(TULSI_WR)/. $(TULSI_WR)/bazel-tulsi-includes/x/x/ $(TULSI_WR)/external/bazel_tools $(TULSI_WR)/bazel-tulsi-includes/x/x/external/bazel_tools $(TULSI_BWRS)/. $(TULSI_BWRS)/bazel-tulsi-includes/x/x/ $(TULSI_BWRS)/external/bazel_tools $(TULSI_BWRS)/bazel-tulsi-includes/x/x/external/bazel_tools ";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_CFLAGS = "-DLIBRARY_DEFINES_DEFINE=1";
PRODUCT_NAME = _idx_ccBinary_C9583FBE_ios_min8.0;
Expand All @@ -458,7 +462,9 @@
isa = XCBuildConfiguration;
buildSettings = {
GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1";
HEADER_SEARCH_PATHS = "$(inherited) $(TULSI_WR)/. $(TULSI_WR)/bazel-tulsi-includes/x/x/ $(TULSI_BWRS)/. $(TULSI_BWRS)/bazel-tulsi-includes/x/x/ ";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_CFLAGS = "-DLIBRARY_DEFINES_DEFINE=1";
PRODUCT_NAME = _idx_ccLibrary_CCA8EDE9_ios_min8.0;
SDKROOT = iphoneos;
USER_HEADER_SEARCH_PATHS = "$(TULSI_WR)";
Expand Down

0 comments on commit 432cdb6

Please sign in to comment.