summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2019-05-13 12:27:59 -0500
committerGitHub <noreply@github.com>2019-05-13 12:27:59 -0500
commit04350e1d1b7ff5457b1a36150d98d5a5efc0ed89 (patch)
tree875acb49ee5507ea9ad2bcc5146fb3c7c7d31eac
parentb08819749e6c2a6d8d771f954f6162933a8ba648 (diff)
parentf0605283962ca61f35587d542c4cd684548168bd (diff)
Merge pull request #166 from haberman/bazel25
Compatibility with Bazel 0.25.2 and 0.24.1.
-rw-r--r--BUILD4
-rw-r--r--CMakeLists.txt1
-rw-r--r--WORKSPACE27
-rw-r--r--build_defs.bzl70
-rw-r--r--ragel.BUILD2
-rw-r--r--repository_defs.bzl16
-rwxr-xr-xtools/make_cmakelists.py7
7 files changed, 93 insertions, 34 deletions
diff --git a/BUILD b/BUILD
index 5b1dd33..6ad365e 100644
--- a/BUILD
+++ b/BUILD
@@ -543,8 +543,8 @@ genrule(
name = "generate_json_ragel",
srcs = ["upb/json/parser.rl"],
outs = ["upb/json/parser.c"],
- cmd = "$(location @ragel//:ragel) -C -o upb/json/parser.c $< && mv upb/json/parser.c $@",
- tools = ["@ragel"],
+ cmd = "$(location @ragel//:ragelc) -C -o upb/json/parser.c $< && mv upb/json/parser.c $@",
+ tools = ["@ragel//:ragelc"],
)
genrule(
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3e08cd7..e6bc5b4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -115,6 +115,7 @@ target_link_libraries(upb_pb
table
upb)
add_library(upb_json
+ generated_for_cmake/upb/json/parser.c
upb/json/printer.c
upb/json/parser.h
upb/json/printer.h)
diff --git a/WORKSPACE b/WORKSPACE
index d49b894..bcb00f0 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",
@@ -17,11 +22,16 @@ http_archive(
git_repository(
name = "com_google_protobuf",
- commit = "25feb59620627b673df76813dfd66e3f565765e7",
- #sha256 = "d7a221b3d4fb4f05b7473795ccea9e05dab3b8721f6286a95fffbffc2d926f8b",
- remote = "https://github.com/haberman/protobuf.git",
- shallow_since = "1541281400 -0700"
- #tag = "conformance-build-tag",
+ remote = "https://github.com/protocolbuffers/protobuf.git",
+ commit = "78ca77ac8799f67fda7b9a01cc691cd9fe526f25",
+)
+
+http_archive(
+ name = "zlib",
+ build_file = "@com_google_protobuf//:third_party/zlib.BUILD",
+ sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
+ strip_prefix = "zlib-1.2.11",
+ urls = ["https://zlib.net/zlib-1.2.11.tar.gz"],
)
git_repository(
@@ -40,8 +50,7 @@ http_archive(
)
http_archive(
- name = "bazel_skylib",
- sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
- strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
- urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
+ name = "bazel_skylib",
+ strip_prefix = "bazel-skylib-master",
+ urls = ["https://github.com/bazelbuild/bazel-skylib/archive/master.tar.gz"],
)
diff --git a/build_defs.bzl b/build_defs.bzl
index 9deb336..38df359 100644
--- a/build_defs.bzl
+++ b/build_defs.bzl
@@ -1,3 +1,9 @@
+
+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 ---
# Copy-pasted from Bazel's Bash runfiles library (tools/bash/runfiles/runfiles.bash).
@@ -23,10 +29,6 @@ _shell_find_runfiles = """
# --- end runfiles.bash initialization ---
"""
-load("@bazel_skylib//lib:paths.bzl", "paths")
-load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
-load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "CPP_LINK_STATIC_LIBRARY_ACTION_NAME")
-
def _librule(name):
return name + "_lib"
@@ -272,38 +274,63 @@ def filter_none(elems):
# upb_proto_library() rule
-def cc_library_func(ctx, 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,
)
- compilation_info = cc_common.compile(
- ctx = ctx,
+
+ 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,
cc_toolchain = toolchain,
+ name = name,
srcs = srcs,
- hdrs = hdrs,
+ public_hdrs = hdrs,
compilation_contexts = compilation_contexts,
)
- linking_info = cc_common.link(
- ctx = ctx,
+ (linking_context, linking_outputs) = cc_common.create_linking_context_from_compilation_outputs(
+ actions = ctx.actions,
+ name = name,
feature_configuration = feature_configuration,
cc_toolchain = toolchain,
- cc_compilation_outputs = compilation_info.cc_compilation_outputs,
+ compilation_outputs = compilation_outputs,
linking_contexts = linking_contexts,
)
return CcInfo(
- compilation_context = compilation_info.compilation_context,
- linking_context = linking_info.linking_context,
+ compilation_context = compilation_context,
+ linking_context = linking_context,
)
def _compile_upb_protos(ctx, proto_info, proto_sources, ext):
@@ -352,11 +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/ragel.BUILD b/ragel.BUILD
index 5485fab..5e3b249 100644
--- a/ragel.BUILD
+++ b/ragel.BUILD
@@ -4,7 +4,7 @@ package(
)
cc_binary(
- name = "ragel",
+ name = "ragelc",
srcs = [
"ragel/rubycodegen.cpp",
"ragel/goipgoto.h",
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 e320be4..44cd1b0 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)
@@ -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):
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback