From cbe051a09c19f868b7682477755011ec681ce6cb Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 13 May 2019 08:30:57 -0700 Subject: Re-enabled conformance tests. --- tools/make_cmakelists.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/make_cmakelists.py') diff --git a/tools/make_cmakelists.py b/tools/make_cmakelists.py index e320be4..36d5375 100755 --- a/tools/make_cmakelists.py +++ b/tools/make_cmakelists.py @@ -43,8 +43,8 @@ class BuildFileFunctions(object): for file in files: if os.path.isfile(file): found_files.append(file) - elif os.path.isfile("generated/" + file): - found_files.append("generated/" + file) + elif os.path.isfile("generated_for_cmake/" + file): + found_files.append("generated_for_cmake/" + file) else: print("Warning: no such file: " + file) -- cgit v1.2.3 From 0fea70b4d9e6c0fd95420893607f462c7308e490 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 13 May 2019 10:07:06 -0700 Subject: Works with Bazel 0.24.1 and Bazel 0.25.2! --- WORKSPACE | 5 +++++ build_defs.bzl | 43 +++++++++++++++++++++++++++++++++++-------- repository_defs.bzl | 16 ++++++++++++++++ tools/make_cmakelists.py | 3 +++ 4 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 repository_defs.bzl (limited to 'tools/make_cmakelists.py') diff --git a/WORKSPACE b/WORKSPACE index 4239c71..780b3c4 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,6 +3,11 @@ workspace(name = "upb") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") +load(":repository_defs.bzl", "bazel_version_repository") + +bazel_version_repository( + name = "bazel_version" +) http_archive( name = "lua", diff --git a/build_defs.bzl b/build_defs.bzl index 6f956bf..38df359 100644 --- a/build_defs.bzl +++ b/build_defs.bzl @@ -1,6 +1,8 @@ load("@bazel_skylib//lib:paths.bzl", "paths") +load("@bazel_skylib//lib:versions.bzl", "versions") load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") +load("@bazel_version//:bazel_version.bzl", "bazel_version") _shell_find_runfiles = """ # --- begin runfiles.bash initialization --- @@ -272,19 +274,42 @@ def filter_none(elems): # upb_proto_library() rule -def cc_library_func(ctx, name, hdrs, srcs, deps): - compilation_contexts = [] - linking_contexts = [] - for dep in deps: - if CcInfo in dep: - linking_contexts.append(dep[CcInfo].linking_context) - compilation_contexts.append(dep[CcInfo].compilation_context) +def cc_library_func(ctx, name, hdrs, srcs, dep_ccinfos): + compilation_contexts = [info.compilation_context for info in dep_ccinfos] + linking_contexts = [info.linking_context for info in dep_ccinfos] toolchain = find_cpp_toolchain(ctx) feature_configuration = cc_common.configure_features( cc_toolchain = toolchain, requested_features = ctx.features, unsupported_features = ctx.disabled_features, ) + + if is_bazel: + if bazel_version == "0.24.1": + # Compatibility code until gRPC is on 0.25.2 or later. + compilation_info = cc_common.compile( + ctx = ctx, + feature_configuration = feature_configuration, + cc_toolchain = toolchain, + srcs = srcs, + hdrs = hdrs, + compilation_contexts = compilation_contexts, + ) + linking_info = cc_common.link( + ctx = ctx, + feature_configuration = feature_configuration, + cc_toolchain = toolchain, + cc_compilation_outputs = compilation_info.cc_compilation_outputs, + linking_contexts = linking_contexts, + ) + return CcInfo( + compilation_context = compilation_info.compilation_context, + linking_context = linking_info.linking_context, + ) + + if not versions.is_at_least("0.25.2", bazel_version): + fail("upb requires Bazel >=0.25.2 or 0.24.1") + (compilation_context, compilation_outputs) = cc_common.compile( actions = ctx.actions, feature_configuration = feature_configuration, @@ -354,12 +379,14 @@ def _upb_proto_rule_impl(ctx): def _upb_proto_aspect_impl(target, ctx): proto_info = target[ProtoInfo] files = _compile_upb_protos(ctx, proto_info, proto_info.direct_sources, ctx.attr._ext) + deps = ctx.rule.attr.deps + [ctx.attr._upb] + dep_ccinfos = [dep[CcInfo] for dep in deps if CcInfo in dep] cc_info = cc_library_func( ctx = ctx, name = ctx.rule.attr.name, hdrs = files.hdrs, srcs = files.srcs, - deps = ctx.rule.attr.deps + [ctx.attr._upb], + dep_ccinfos = dep_ccinfos, ) return [cc_info] diff --git a/repository_defs.bzl b/repository_defs.bzl new file mode 100644 index 0000000..5bbc9cb --- /dev/null +++ b/repository_defs.bzl @@ -0,0 +1,16 @@ + +# A hacky way to work around the fact that native.bazel_version is only +# available from WORKSPACE macros, not BUILD macros or rules. +# +# Hopefully we can remove this if/when this is fixed: +# https://github.com/bazelbuild/bazel/issues/8305 + +def _impl(repository_ctx): + s = "bazel_version = \"" + native.bazel_version + "\"" + repository_ctx.file("bazel_version.bzl", s) + repository_ctx.file("BUILD", "") + +bazel_version_repository = repository_rule( + implementation=_impl, + local=True, +) diff --git a/tools/make_cmakelists.py b/tools/make_cmakelists.py index 36d5375..44cd1b0 100755 --- a/tools/make_cmakelists.py +++ b/tools/make_cmakelists.py @@ -175,6 +175,9 @@ class WorkspaceFileFunctions(object): def git_repository(self, **kwargs): pass + def bazel_version_repository(self, **kwargs): + pass + class Converter(object): def __init__(self): -- cgit v1.2.3