Skip to content

Add copts and linkopts to swift_proto_library #1497

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion proto/swift_proto_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ load(
# buildifier: disable=bzl-visibility
load(
"//swift/internal:utils.bzl",
"expand_make_variables",
"get_providers",
"include_developer_search_paths",
)
Expand Down Expand Up @@ -258,12 +259,18 @@ def compile_swift_protos_for_target(
unsupported_features = ctx.disabled_features,
)

# These can't use additional_inputs since expand_locations needs targets,
# not files.
copts = expand_make_variables(ctx, getattr(attr, "copts", []), "copts")
linkopts = expand_make_variables(ctx, getattr(attr, "linkopts", []), "linkopts")

# Compile the generated Swift source files as a module:
include_dev_srch_paths = include_developer_search_paths(attr)
compile_result = swift_common.compile(
actions = ctx.actions,
cc_infos = get_providers(compiler_deps, CcInfo),
copts = ["-parse-as-library"] + getattr(attr, "copts", []),
defines = ctx.attr.defines,
copts = ["-parse-as-library"] + copts,
feature_configuration = feature_configuration,
include_dev_srch_paths = include_dev_srch_paths,
module_name = module_name,
Expand Down Expand Up @@ -294,6 +301,7 @@ def compile_swift_protos_for_target(
],
module_context = module_context,
swift_toolchain = swift_toolchain,
user_link_flags = linkopts,
)
)

Expand Down