Update BUILD configuration (#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
This commit is contained in:
Keith Smiley 2021-03-23 18:17:34 -07:00 committed by GitHub
parent 3ed41e1acf
commit 2ceeb28a28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 22 deletions

View File

@ -1,4 +1 @@
# Force the tests to not run in sandboxed mode, since it can introduce
# errors and flakes.
test --spawn_strategy=local
build --macos_minimum_os=10.9

33
BUILD
View File

@ -1,31 +1,26 @@
load(
"@rules_cc//cc:defs.bzl",
"cc_library"
)
load(
"@build_bazel_rules_swift//swift:swift.bzl",
"swift_library"
)
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
cc_library(
name = "CYaml",
srcs = glob(["Sources/CYaml/src/*.c", "Sources/CYaml/src/*.h"]),
srcs = glob([
"Sources/CYaml/src/*.c",
"Sources/CYaml/src/*.h",
]),
hdrs = ["Sources/CYaml/include/yaml.h"],
# Requires because of https://github.com/bazelbuild/bazel/pull/10143 otherwise host transition builds fail
copts = ["-fPIC"],
includes = ["Sources/CYaml/include"],
visibility = [
"//Tests:__subpackages__",
],
linkstatic = True,
tags = ["swift_module"],
visibility = ["//Tests:__subpackages__"],
)
swift_library(
name = "Yams",
module_name = "Yams",
srcs = glob(["Sources/Yams/*.swift"]),
copts = [
"-DSWIFT_PACKAGE",
],
visibility = [
"//visibility:public"
],
copts = ["-DSWIFT_PACKAGE"],
module_name = "Yams",
visibility = ["//visibility:public"],
deps = ["//:CYaml"],
)

View File

@ -8,6 +8,8 @@
* Update Bazel config to allow targets to be directly consumed.
[Maxwell Elliott](https://github.com/maxwellE)
* Fix some Bazel integration issues
[Keith Smiley](https://github.com/keith)
##### Bug Fixes