Skip to content

Commit b1ae93b

Browse files
committed
iox-eclipse-iceoryx#1542 Add files needed for bazel build support
Signed-off-by: Karl Wallner <karl.wallner@apex.ai>
1 parent c30d930 commit b1ae93b

File tree

40 files changed

+2097
-0
lines changed

40 files changed

+2097
-0
lines changed

BUILD.bazel

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
18+
19+
exports_files(["VERSION"])
20+
21+
alias(
22+
name = "iceoryx_hoofs",
23+
actual = "//iceoryx_hoofs",
24+
visibility = ["//visibility:public"],
25+
)
26+
27+
alias(
28+
name = "iceoryx_posh",
29+
actual = "//iceoryx_posh",
30+
visibility = ["//visibility:public"],
31+
)
32+
33+
alias(
34+
name = "iceoryx_binding_c",
35+
actual = "//iceoryx_binding_c",
36+
visibility = ["//visibility:public"],
37+
)
38+
39+
alias(
40+
name = "roudi",
41+
actual = "//iceoryx_posh:iox-roudi",
42+
visibility = ["//visibility:public"],
43+
)
44+
45+
# Execute `bazel run //:buildifier` to fix formating of all starlark files in the workspace
46+
buildifier(
47+
name = "buildifier",
48+
verbose = True,
49+
)
50+
51+
# Execute `bazel run //:buildifier_test` to check all starlark files for correctness
52+
buildifier(
53+
name = "buildifier_test",
54+
mode = "check",
55+
verbose = True,
56+
)
57+
58+
# Execute `bazel run //:buildifier_lint` to reformat and run the linter on all starlark files
59+
buildifier(
60+
name = "buildifier_lint",
61+
lint_mode = "fix",
62+
lint_warnings = ["all"],
63+
verbose = True,
64+
)
65+
66+
# Execute `bazel run //:buildifier_lint_check` to reformat and run the linter on all starlark files
67+
buildifier(
68+
name = "buildifier_lint_check",
69+
lint_mode = "warn",
70+
lint_warnings = ["all"],
71+
mode = "check",
72+
verbose = True,
73+
)

WORKSPACE.bazel

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
workspace(name = "org_eclipse_iceoryx")
18+
19+
# Load dependency googletest
20+
load("//bazel:load_repositories.bzl", "load_repositories")
21+
22+
load_repositories()
23+
24+
# Load dependency cpptoml
25+
load("//bazel:setup_repositories.bzl", "setup_repositories")
26+
27+
setup_repositories()

bazel/BUILD.bazel

Whitespace-only changes.

bazel/bazelbuild/BUILD.bazel

Whitespace-only changes.

bazel/bazelbuild/repositories.bzl

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
"""
2+
Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
SPDX-License-Identifier: Apache-2.0
17+
18+
Loads dependent repositories from https://github.com/bazelbuild
19+
"""
20+
21+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
23+
24+
BAZELBUILD_RULES_CC_VERSION = "0.0.1"
25+
26+
def load_com_github_bazelbuild_rules_cc_repositories():
27+
maybe(
28+
name = "bazelbuild_rules_cc",
29+
repo_rule = http_archive,
30+
sha256 = "4dccbfd22c0def164c8f47458bd50e0c7148f3d92002cdb459c2a96a68498241",
31+
urls = [
32+
"https://github.com/bazelbuild/rules_cc/releases/download/{version}/rules_cc-{version}.tar.gz".format(version = BAZELBUILD_RULES_CC_VERSION),
33+
],
34+
)
35+
36+
COM_GITHUB_BAZELBUILD_BUILDTOOLS_VERSION = "5.1.0"
37+
38+
def load_com_github_bazelbuild_buildtools_repositories():
39+
maybe(
40+
name = "com_github_bazelbuild_buildtools",
41+
repo_rule = http_archive,
42+
sha256 = "e3bb0dc8b0274ea1aca75f1f8c0c835adbe589708ea89bf698069d0790701ea3",
43+
strip_prefix = "buildtools-{version}".format(version = COM_GITHUB_BAZELBUILD_BUILDTOOLS_VERSION),
44+
urls = [
45+
"https://github.com/bazelbuild/buildtools/archive/refs/tags/{version}.tar.gz".format(version = COM_GITHUB_BAZELBUILD_BUILDTOOLS_VERSION),
46+
],
47+
)
48+
49+
IO_BAZEL_RULES_GO_VERSION = "0.29.0"
50+
51+
def load_io_bazel_rules_go_repositories():
52+
maybe(
53+
name = "io_bazel_rules_go",
54+
repo_rule = http_archive,
55+
sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f",
56+
urls = [
57+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v{version}/rules_go-v{version}.zip".format(version = IO_BAZEL_RULES_GO_VERSION),
58+
"https://github.com/bazelbuild/rules_go/releases/download/v{version}/rules_go-v{version}.zip".format(version = IO_BAZEL_RULES_GO_VERSION),
59+
],
60+
)
61+
62+
COM_GOOGLE_PROTOBUF_VERSION = "3.13.0"
63+
64+
def load_com_google_protobuf_repositories():
65+
maybe(
66+
name = "com_google_protobuf",
67+
repo_rule = http_archive,
68+
sha256 = "9b4ee22c250fe31b16f1a24d61467e40780a3fbb9b91c3b65be2a376ed913a1a",
69+
strip_prefix = "protobuf-{version}".format(version = COM_GOOGLE_PROTOBUF_VERSION),
70+
urls = [
71+
"https://github.com/protocolbuffers/protobuf/archive/v{version}.tar.gz".format(version = COM_GOOGLE_PROTOBUF_VERSION),
72+
],
73+
)

bazel/bazelbuild/setup.bzl

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
SPDX-License-Identifier: Apache-2.0
17+
18+
Macro for setting the dependencies for the buildtools of bazel
19+
"""
20+
21+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
22+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
23+
24+
def setup_go_protobuf_for_bazelbuild():
25+
go_rules_dependencies()
26+
27+
go_register_toolchains(version = "1.17.2")
28+
29+
protobuf_deps()

bazel/configure_file.bzl

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
SPDX-License-Identifier: Apache-2.0
17+
18+
The configure_file rule imitates the similar CMake function for template expansion: https://cmake.org/cmake/help/latest/command/configure_file.html
19+
"""
20+
21+
def _configure_file_impl(ctx):
22+
ctx.actions.expand_template(
23+
template = ctx.file.src,
24+
output = ctx.outputs.out,
25+
substitutions = {
26+
"@" + k + "@": v
27+
for k, v in ctx.attr.config.items()
28+
},
29+
)
30+
files = depset(direct = [ctx.outputs.out])
31+
runfiles = ctx.runfiles(files = [ctx.outputs.out])
32+
return [DefaultInfo(files = files, runfiles = runfiles)]
33+
34+
configure_file = rule(
35+
implementation = _configure_file_impl,
36+
provides = [DefaultInfo],
37+
attrs = {
38+
"config": attr.string_dict(mandatory = True),
39+
"out": attr.output(mandatory = True),
40+
"src": attr.label(mandatory = True, allow_single_file = True),
41+
},
42+
)

bazel/configure_version.bzl

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""
2+
Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
SPDX-License-Identifier: Apache-2.0
17+
18+
This module set compile-time variables and set them accordingly in generated files
19+
"""
20+
21+
SCRIPT = """#!/bin/bash
22+
23+
set -e
24+
25+
version_file="{version_file}"
26+
input_file="{input_file}"
27+
output_file="{output_file}"
28+
29+
IFS="-" read version_number version_suffix <<< $(<"$version_file")
30+
IFS="." read major_version minor_version patch_version tweak_version <<< $version_number
31+
[ -z "$version_suffix" ] && version_delim="" || version_delim="-"
32+
33+
data="$(<"$input_file")"
34+
data=${{data/@PROJECT_VERSION_MAJOR@/${{major_version:-0}}}}
35+
data=${{data/@PROJECT_VERSION_MINOR@/${{minor_version:-0}}}}
36+
data=${{data/@PROJECT_VERSION_PATCH@/${{patch_version:-0}}}}
37+
data=${{data/@IOX_VERSION_TWEAK@/${{tweak_version:-0}}}}
38+
data=${{data/@PROJECT_VERSION@/${{version_number}}}}
39+
data=${{data/@IOX_VERSION_SUFFIX@/${{version_delim}}${{version_suffix}}}}
40+
data=${{data/@ICEORYX_BUILDDATE@/builddate_not_set}}
41+
data=${{data/@ICEORYX_SHA1@/sha1_not_set}}
42+
43+
echo "$data" > $output_file
44+
"""
45+
46+
def _configure_version_impl(ctx):
47+
ctx.actions.run_shell(
48+
command = SCRIPT.format(
49+
version_file = ctx.files.version_from[0].path,
50+
input_file = ctx.files.src[0].path,
51+
output_file = ctx.outputs.out.path,
52+
),
53+
inputs = ctx.files.src + ctx.files.version_from,
54+
outputs = [ctx.outputs.out],
55+
)
56+
files = depset(direct = [ctx.outputs.out])
57+
return [DefaultInfo(files = files)]
58+
59+
configure_version = rule(
60+
implementation = _configure_version_impl,
61+
provides = [DefaultInfo],
62+
attrs = {
63+
"out": attr.output(mandatory = True),
64+
"src": attr.label(mandatory = True, allow_single_file = True),
65+
"version_from": attr.label(mandatory = True, allow_single_file = True),
66+
},
67+
)

bazel/cpptoml/BUILD.bazel

Whitespace-only changes.

bazel/cpptoml/cpptoml.BUILD

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
load("@rules_cc//cc:defs.bzl", "cc_library")
18+
19+
cc_library(
20+
name = "cpptoml",
21+
hdrs = ["include/cpptoml.h"],
22+
strip_include_prefix = "include",
23+
visibility = ["//visibility:public"],
24+
)

bazel/cpptoml/repositories.bzl

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
SPDX-License-Identifier: Apache-2.0
17+
18+
This module downloads the cpptoml project: https://github.com/skystrife/cpptoml
19+
"""
20+
21+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
23+
24+
CPPTOML_VERSION = "0.1.1"
25+
26+
def load_cpptoml_repositories():
27+
maybe(
28+
name = "cpptoml",
29+
repo_rule = http_archive,
30+
sha256 = "23af72468cfd4040984d46a0dd2a609538579c78ddc429d6b8fd7a10a6e24403",
31+
url = "https://github.com/skystrife/cpptoml/archive/refs/tags/v{version}.tar.gz".format(version = CPPTOML_VERSION),
32+
strip_prefix = "cpptoml-{version}".format(version = CPPTOML_VERSION),
33+
build_file = "//bazel/cpptoml:cpptoml.BUILD",
34+
)

bazel/googletest/BUILD.bazel

Whitespace-only changes.

0 commit comments

Comments
 (0)