Skip to content

Commit

Permalink
Misc build and source fixes to get //iree/base/... building/testing u…
Browse files Browse the repository at this point in the history
…nder bazel.

Still need to do some corresponding submodule maintenance (will do in a separate PR).

PiperOrigin-RevId: 273773161
  • Loading branch information
Stella Laurenzo authored and iree-copybara-bot committed Oct 9, 2019
1 parent c06d20f commit 196ad74
Show file tree
Hide file tree
Showing 45 changed files with 504 additions and 401 deletions.
37 changes: 37 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
# Workspace file for the IREE project.
workspace(name = "iree")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Abseil depends on starlark rules that are currently maintained outside
# of Bazel.
# Source: https://github.com/abseil/abseil-cpp/blob/master/WORKSPACE
http_archive(
name = "rules_cc",
sha256 = "67412176974bfce3f4cf8bdaff39784a72ed709fc58def599d1f68710b58d68b",
strip_prefix = "rules_cc-b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e.zip",
"https://github.com/bazelbuild/rules_cc/archive/b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e.zip",
],
)

local_repository(
name = "com_google_absl",
path = "third_party/abseil-cpp",
)

local_repository(
name = "com_google_googletest",
path = "third_party/googletest",
)

local_repository(
name = "flatbuffers",
path = "third_party/flatbuffers",
)

new_local_repository(
name = "com_google_tracing_framework_cpp",
path = "third_party/google_tracing_framework/bindings/cpp",
build_file = "build_tools/third_party/google_tracing_framework_cpp/BUILD.bazel",
)
48 changes: 48 additions & 0 deletions build_tools/third_party/google_tracing_framework_cpp/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package(
default_visibility = ["//visibility:public"],
)

# There are two ways to enable WTF at compile time:
# 1) Arrange to add a --copt=-DWTF_ENABLE to your build.
# 2) Add --define=GLOBAL_WTF_ENABLE=1 to the bazel command line
# The disadvantage to #1 is that you end up building the entire codebase
# with a non-standard copt. Depending on the size of your deps, this
# can use a lot of resources due to inability to hit the forge cache.
#
# The advantage to #2 is that it narrowly scopes the copt change just to
# things that depend on WTF, limiting the scope of things that need to
# be compiled differently.
config_setting(
name = "wtf_enable",
define_values = {
"GLOBAL_WTF_ENABLE": "1",
},
)

cc_library(
name = "tracing_framework_bindings_cpp",
srcs = glob(
["*.cc"],
exclude = ["*_test.cc"],
) + glob(["include/wtf/platform/*.h"]),
hdrs = glob(["include/wtf/*.h"]),
defines = select({
":wtf_enable": ["WTF_ENABLE"],
"//conditions:default": [],
}),
includes = ["include"],
)
10 changes: 10 additions & 0 deletions iree/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# Main IREE build file.
# Note that project-wide, bazel repo aliases are used:
# "@absl_py//absl"
# "@com_google_absl//absl"
# "@local_config_mlir//"
# "@llvm//"
# "@flatbuffers//:flatbuffers"
# "@tensorflow//"
#
# Various scripts and helpers operate on these prefixes textually, so
# avoid doing any systematic construction that would break the matching.

package(
default_visibility = ["//visibility:public"],
Expand Down
95 changes: 48 additions & 47 deletions iree/base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ cc_library(
hdrs = ["arena.h"],
deps = [
":logging",
"//third_party/absl/base:core_headers",
"//third_party/absl/types:span",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/types:span",
],
)

Expand All @@ -50,15 +50,15 @@ cc_test(
srcs = ["arena_test.cc"],
deps = [
":arena",
"//testing/base/public:gunit_main",
"@com_google_googletest//:gtest_main",
],
)

cc_library(
name = "bitfield",
hdrs = ["bitfield.h"],
deps = [
"//third_party/absl/types:span",
"@com_google_absl//absl/types:span",
],
)

Expand All @@ -67,8 +67,8 @@ cc_test(
srcs = ["bitfield_test.cc"],
deps = [
":bitfield",
"//testing/base/public:gunit_main",
"//third_party/absl/base:core_headers",
"@com_google_absl//absl/base:core_headers",
"@com_google_googletest//:gtest_main",
],
)

Expand All @@ -78,9 +78,9 @@ cc_library(
deps = [
":status",
":target_platform",
"//third_party/absl/memory",
"//third_party/absl/strings",
"//third_party/absl/types:span",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
] + platform_trampoline_deps("file_io"),
)

Expand All @@ -96,9 +96,9 @@ cc_library(
deps = [
":ref_ptr",
":status",
"//third_party/absl/memory",
"//third_party/absl/strings",
"//third_party/absl/types:span",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
] + platform_trampoline_deps("file_mapping"),
)

Expand All @@ -108,7 +108,7 @@ cc_library(
deps = [
":ref_ptr",
":status",
"//third_party/absl/types:span",
"@com_google_absl//absl/types:span",
],
)

Expand All @@ -117,7 +117,7 @@ cc_library(
srcs = ["file_path.cc"],
hdrs = ["file_path.h"],
deps = [
"//third_party/absl/strings",
"@com_google_absl//absl/strings",
],
)

Expand All @@ -131,12 +131,12 @@ cc_library(
":source_location",
":status",
":tracing",
"//third_party/absl/base:core_headers",
"//third_party/absl/memory",
"//third_party/absl/strings",
"//third_party/absl/types:optional",
"//third_party/absl/types:span",
"//third_party/flatbuffers",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/types:span",
"@flatbuffers",
],
)

Expand Down Expand Up @@ -168,7 +168,8 @@ cc_test(
],
deps = [
":intrusive_list",
"//testing/base/public:gunit_main",
"@com_google_absl//absl/memory",
"@com_google_googletest//:gtest_main",
],
)

Expand All @@ -182,15 +183,15 @@ cc_library(
name = "math",
hdrs = ["math.h"],
deps = [
"//third_party/absl/base:core_headers",
"@com_google_absl//absl/base:core_headers",
],
)

cc_library(
name = "memory",
hdrs = ["memory.h"],
deps = [
"//third_party/absl/types:span",
"@com_google_absl//absl/types:span",
],
)

Expand All @@ -199,7 +200,7 @@ cc_library(
hdrs = ["ref_ptr.h"],
deps = [
":logging",
"//third_party/absl/base:core_headers",
"@com_google_absl//absl/base:core_headers",
],
)

Expand All @@ -209,7 +210,7 @@ cc_test(
srcs = ["ref_ptr_test.cc"],
deps = [
":ref_ptr",
"//testing/base/public:gunit_main",
"@com_google_googletest//:gtest_main",
],
)

Expand All @@ -221,9 +222,9 @@ cc_library(
":logging",
":source_location",
":status",
"//third_party/absl/meta:type_traits",
"//third_party/absl/strings",
"//third_party/absl/types:span",
"@com_google_absl//absl/meta:type_traits",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
],
)

Expand All @@ -234,7 +235,7 @@ cc_test(
":shape",
":status",
":status_matchers",
"//testing/base/public:gunit_main",
"@com_google_googletest//:gtest_main",
],
)

Expand Down Expand Up @@ -268,7 +269,7 @@ cc_library(
name = "time",
hdrs = ["time.h"],
deps = [
"//third_party/absl/time",
"@com_google_absl//absl/time",
],
)

Expand All @@ -277,9 +278,9 @@ cc_library(
hdrs = ["tracing.h"],
deps = [
"//iree:target_config",
"//third_party/tracing_framework_bindings_cpp",
"@com_google_tracing_framework_cpp//:tracing_framework_bindings_cpp",
] + select({
"//third_party/tracing_framework_bindings_cpp:wtf_enable": [":tracing_enabled"],
"@com_google_tracing_framework_cpp//:wtf_enable": [":tracing_enabled"],
"//conditions:default": [":tracing_disabled"],
}),
)
Expand All @@ -294,8 +295,8 @@ cc_library(
deps = [
":init",
":logging",
"//third_party/absl/flags:flag",
"//third_party/tracing_framework_bindings_cpp",
"@com_google_absl//absl/flags:flag",
"@com_google_tracing_framework_cpp//:tracing_framework_bindings_cpp",
],
alwayslink = 1,
)
Expand All @@ -313,12 +314,12 @@ cc_library(
":init",
":logging",
":status",
"//third_party/absl/base:core_headers",
"//third_party/absl/flags:flag",
"//third_party/absl/strings",
"//third_party/absl/synchronization",
"//third_party/absl/time",
"//third_party/tracing_framework_bindings_cpp",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/time",
"@com_google_tracing_framework_cpp//:tracing_framework_bindings_cpp",
],
alwayslink = 1,
)
Expand All @@ -333,11 +334,11 @@ cc_library(
":source_location",
":status",
":time",
"//third_party/absl/base:core_headers",
"//third_party/absl/container:fixed_array",
"//third_party/absl/strings",
"//third_party/absl/time",
"//third_party/absl/types:span",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:fixed_array",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:span",
],
)

Expand All @@ -348,7 +349,7 @@ cc_test(
":status",
":status_matchers",
":wait_handle",
"//testing/base/public:gunit_main",
"//third_party/absl/time",
"@com_google_absl//absl/time",
"@com_google_googletest//:gtest_main",
],
)
2 changes: 1 addition & 1 deletion iree/base/api_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class StatusAdaptorForApiMacros {
#define IREE_API_RETURN_IF_ERROR(expr) \
IREE_API_STATUS_MACROS_IMPL_ELSE_BLOCKER_ \
if (::iree::status_macro_internal::StatusAdaptorForApiMacros \
status_adaptor = (expr)) { \
status_adaptor = {expr}) { \
} else /* NOLINT */ \
return ::iree::ToApiStatus(status_adaptor.Consume().code())

Expand Down
Loading

0 comments on commit 196ad74

Please sign in to comment.