Skip to content

Commit 2ceeb28

Browse files
authored
Update BUILD configuration (jpsim#312)
This has 2 important fixes from Lyft's internal config: 1. The `cc_library` is now tagged with `swift_module` which is a special tag that tells rules_swift to generate a module map for the library. This is likely why sandboxing had to be disabled. 2. This adds `-fPIC` to the `cc_library` compilation. This is required for C libraries that Swift depends on, but there's an outstanding bug in bazel where this isn't handled correctly when you use the target through the host transition. This also formats this file using buildifier
1 parent 3ed41e1 commit 2ceeb28

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

.bazelrc

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
# Force the tests to not run in sandboxed mode, since it can introduce
2-
# errors and flakes.
3-
test --spawn_strategy=local
41
build --macos_minimum_os=10.9

BUILD

+14-19
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
1-
load(
2-
"@rules_cc//cc:defs.bzl",
3-
"cc_library"
4-
)
5-
load(
6-
"@build_bazel_rules_swift//swift:swift.bzl",
7-
"swift_library"
8-
)
1+
load("@rules_cc//cc:defs.bzl", "cc_library")
2+
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
93

104
cc_library(
115
name = "CYaml",
12-
srcs = glob(["Sources/CYaml/src/*.c", "Sources/CYaml/src/*.h"]),
6+
srcs = glob([
7+
"Sources/CYaml/src/*.c",
8+
"Sources/CYaml/src/*.h",
9+
]),
1310
hdrs = ["Sources/CYaml/include/yaml.h"],
11+
# Requires because of https://github.com/bazelbuild/bazel/pull/10143 otherwise host transition builds fail
12+
copts = ["-fPIC"],
1413
includes = ["Sources/CYaml/include"],
15-
visibility = [
16-
"//Tests:__subpackages__",
17-
],
14+
linkstatic = True,
15+
tags = ["swift_module"],
16+
visibility = ["//Tests:__subpackages__"],
1817
)
1918

2019
swift_library(
2120
name = "Yams",
22-
module_name = "Yams",
2321
srcs = glob(["Sources/Yams/*.swift"]),
24-
copts = [
25-
"-DSWIFT_PACKAGE",
26-
],
27-
visibility = [
28-
"//visibility:public"
29-
],
22+
copts = ["-DSWIFT_PACKAGE"],
23+
module_name = "Yams",
24+
visibility = ["//visibility:public"],
3025
deps = ["//:CYaml"],
3126
)

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
* Update Bazel config to allow targets to be directly consumed.
1010
[Maxwell Elliott](https://github.com/maxwellE)
11+
* Fix some Bazel integration issues
12+
[Keith Smiley](https://github.com/keith)
1113

1214
##### Bug Fixes
1315

0 commit comments

Comments
 (0)