mirror of
https://fuchsia.googlesource.com/third_party/pigweed.googlesource.com/pigweed/pigweed
synced 2024-09-19 21:29:48 +00:00
Add bazel build system files.
Build everything with 'bazel build //...' and run all tests with 'bazel test //...'. Change-Id: Ia912e999e33caa9b490002d639dc4c9a80034afc
This commit is contained in:
parent
e899dcf4a3
commit
be98ead12a
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
# Build artifacts
|
||||
out/
|
||||
bazel-*
|
||||
|
||||
# IDE artifacts
|
||||
.idea/
|
||||
|
|
21
BUILD
Normal file
21
BUILD
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2019 The Pigweed Authors
|
||||
#
|
||||
# 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.
|
||||
|
||||
SUBDIRS = [
|
||||
"pw_build",
|
||||
"pw_preprocessor",
|
||||
"pw_span",
|
||||
"pw_status",
|
||||
"pw_unit_test",
|
||||
]
|
13
WORKSPACE
Normal file
13
WORKSPACE
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2019 The Pigweed Authors
|
||||
#
|
||||
# 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.
|
15
pw_build/BUILD
Normal file
15
pw_build/BUILD
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Copyright 2019 The Pigweed Authors
|
||||
#
|
||||
# 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"])
|
87
pw_build/pigweed.bzl
Normal file
87
pw_build/pigweed.bzl
Normal file
|
@ -0,0 +1,87 @@
|
|||
# Copyright 2019 The Pigweed Authors
|
||||
#
|
||||
# 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.
|
||||
|
||||
def reduced_size_copts():
|
||||
"""Standard compiler flags to reduce output binary size."""
|
||||
|
||||
return [
|
||||
"-fno-common",
|
||||
"-fno-exceptions",
|
||||
"-ffunction-sections",
|
||||
"-fdata-sections",
|
||||
"-fno-rtti",
|
||||
]
|
||||
|
||||
def strict_warnings_copts():
|
||||
return [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
|
||||
# Make all warnings errors, except for the exemptions below.
|
||||
"-Werror",
|
||||
"-Wno-error=cpp", # preprocessor #warning statement
|
||||
"-Wno-error=deprecated-declarations", # [[deprecated]] attribute
|
||||
]
|
||||
|
||||
def cpp17_copts():
|
||||
return [
|
||||
"-std=c++17",
|
||||
|
||||
# Allow uses of the register keyword, which may appear in C headers.
|
||||
"-Wno-register",
|
||||
]
|
||||
|
||||
def includes_copts():
|
||||
includes = [
|
||||
"pw_preprocessor/public",
|
||||
"pw_span/public",
|
||||
"pw_status/public",
|
||||
"pw_unit_test/public",
|
||||
]
|
||||
return ["-I" + x for x in includes]
|
||||
|
||||
def pw_default_copts():
|
||||
return (
|
||||
reduced_size_copts() +
|
||||
strict_warnings_copts() +
|
||||
cpp17_copts() +
|
||||
includes_copts()
|
||||
)
|
||||
|
||||
def pw_default_linkopts():
|
||||
return []
|
||||
|
||||
def pw_test(
|
||||
name,
|
||||
srcs,
|
||||
deps = None,
|
||||
**kwargs):
|
||||
"""Create a Pigweed test.
|
||||
|
||||
Args:
|
||||
name: name of target to create
|
||||
srcs: test source files
|
||||
deps: dependencies of target
|
||||
"""
|
||||
|
||||
if not deps:
|
||||
deps = []
|
||||
deps.append("//pw_unit_test:main")
|
||||
|
||||
native.cc_test(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
deps = deps,
|
||||
**kwargs
|
||||
)
|
47
pw_preprocessor/BUILD
Normal file
47
pw_preprocessor/BUILD
Normal file
|
@ -0,0 +1,47 @@
|
|||
# Copyright 2019 The Pigweed Authors
|
||||
#
|
||||
# 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"])
|
||||
|
||||
load(
|
||||
"//pw_build:pigweed.bzl",
|
||||
"pw_default_copts",
|
||||
"pw_default_linkopts",
|
||||
"pw_test",
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "pw_preprocessor",
|
||||
hdrs = glob(["public/pw_preprocessor/*.h"]),
|
||||
copts = pw_default_copts(),
|
||||
linkopts = pw_default_linkopts(),
|
||||
)
|
||||
|
||||
TESTS = [
|
||||
"boolean_test",
|
||||
"concat_test",
|
||||
"macro_arg_count_test",
|
||||
"util_test",
|
||||
]
|
||||
|
||||
[
|
||||
pw_test(
|
||||
name = t,
|
||||
srcs = [t + ".cc"],
|
||||
copts = pw_default_copts(),
|
||||
linkopts = pw_default_linkopts(),
|
||||
deps = ["//pw_preprocessor"],
|
||||
)
|
||||
for t in TESTS
|
||||
]
|
36
pw_span/BUILD
Normal file
36
pw_span/BUILD
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Copyright 2019 The Pigweed Authors
|
||||
#
|
||||
# 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.
|
||||
|
||||
load(
|
||||
"//pw_build:pigweed.bzl",
|
||||
"pw_default_copts",
|
||||
"pw_default_linkopts",
|
||||
"pw_test",
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "pw_span",
|
||||
srcs = [],
|
||||
hdrs = ["public/pw_span/span.h"],
|
||||
copts = pw_default_copts(),
|
||||
linkopts = pw_default_linkopts(),
|
||||
)
|
||||
|
||||
pw_test(
|
||||
name = "span_test",
|
||||
srcs = ["span_test.cc"],
|
||||
copts = pw_default_copts(),
|
||||
linkopts = pw_default_linkopts(),
|
||||
deps = ["//pw_span"],
|
||||
)
|
25
pw_status/BUILD
Normal file
25
pw_status/BUILD
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Copyright 2019 The Pigweed Authors
|
||||
#
|
||||
# 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"])
|
||||
|
||||
load("//pw_build:pigweed.bzl", "pw_default_copts", "pw_default_linkopts")
|
||||
|
||||
cc_library(
|
||||
name = "pw_status",
|
||||
srcs = ["status.cc"],
|
||||
hdrs = ["public/pw_status/status.h"],
|
||||
copts = pw_default_copts(),
|
||||
linkopts = pw_default_linkopts(),
|
||||
)
|
15
pw_toolchain/BUILD
Normal file
15
pw_toolchain/BUILD
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Copyright 2019 The Pigweed Authors
|
||||
#
|
||||
# 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"])
|
61
pw_unit_test/BUILD
Normal file
61
pw_unit_test/BUILD
Normal file
|
@ -0,0 +1,61 @@
|
|||
# Copyright 2019 The Pigweed Authors
|
||||
#
|
||||
# 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"])
|
||||
|
||||
load(
|
||||
"//pw_build:pigweed.bzl",
|
||||
"pw_default_copts",
|
||||
"pw_default_linkopts",
|
||||
"pw_test",
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "simple_printing_event_handler",
|
||||
srcs = [
|
||||
"public/pw_unit_test/event_handler.h",
|
||||
"public/pw_unit_test/simple_printing_event_handler.h",
|
||||
"simple_printing_event_handler.cc",
|
||||
],
|
||||
copts = pw_default_copts(),
|
||||
linkopts = pw_default_linkopts(),
|
||||
deps = ["//pw_preprocessor"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "main",
|
||||
srcs = [
|
||||
"framework.cc",
|
||||
"main.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"public/gtest/gtest.h",
|
||||
"public/pw_unit_test/event_handler.h",
|
||||
"public/pw_unit_test/framework.h",
|
||||
],
|
||||
copts = pw_default_copts(),
|
||||
linkopts = pw_default_linkopts(),
|
||||
deps = [
|
||||
":simple_printing_event_handler",
|
||||
"//pw_preprocessor",
|
||||
"//pw_status",
|
||||
],
|
||||
)
|
||||
|
||||
pw_test(
|
||||
name = "framework_test",
|
||||
srcs = ["framework_test.cc"],
|
||||
copts = pw_default_copts(),
|
||||
linkopts = pw_default_linkopts(),
|
||||
)
|
Loading…
Reference in New Issue
Block a user