-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Karim Alweheshy
committed
Jan 21, 2025
1 parent
46c38b9
commit 80ec224
Showing
10 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary") | ||
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy") | ||
|
||
tidy( | ||
name = "tidy", | ||
targets = [ | ||
":update_build_files", | ||
], | ||
) | ||
|
||
# MARK: - Gazelle | ||
|
||
# Ignore the Swift build folder | ||
# gazelle:exclude .build | ||
|
||
gazelle_binary( | ||
name = "gazelle_bin", | ||
languages = [ | ||
"@bazel_skylib_gazelle_plugin//bzl", | ||
"@rules_swift_package_manager//gazelle", | ||
], | ||
) | ||
|
||
gazelle( | ||
name = "update_build_files", | ||
data = [ | ||
"@swift_deps_info//:swift_deps_index", | ||
], | ||
extra_args = [ | ||
"-swift_dependency_index=$(location @swift_deps_info//:swift_deps_index)", | ||
], | ||
gazelle = ":gazelle_bin", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
bazel_dep( | ||
name = "rules_swift_package_manager", | ||
version = "0.0.0", | ||
) | ||
local_path_override( | ||
module_name = "rules_swift_package_manager", | ||
path = "../..", | ||
) | ||
|
||
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.23.0") | ||
bazel_dep(name = "bazel_skylib", version = "1.7.1") | ||
|
||
# The apple_support bazel_dep must come before the rules_cc. | ||
# https://github.com/bazelbuild/apple_support#incompatible-toolchain-resolution | ||
bazel_dep(name = "apple_support", version = "1.17.1") | ||
bazel_dep( | ||
name = "rules_swift", | ||
version = "2.3.1", | ||
repo_name = "build_bazel_rules_swift", | ||
) | ||
bazel_dep( | ||
name = "rules_apple", | ||
version = "3.16.1", | ||
repo_name = "build_bazel_rules_apple", | ||
) | ||
|
||
bazel_dep( | ||
name = "bazel_skylib_gazelle_plugin", | ||
version = "1.7.1", | ||
dev_dependency = True, | ||
) | ||
bazel_dep( | ||
name = "gazelle", | ||
version = "0.41.0", | ||
dev_dependency = True, | ||
repo_name = "bazel_gazelle", | ||
) | ||
|
||
apple_cc_configure = use_extension( | ||
"@apple_support//crosstool:setup.bzl", | ||
"apple_cc_configure_extension", | ||
) | ||
use_repo(apple_cc_configure, "local_config_apple_cc") | ||
|
||
swift_deps = use_extension( | ||
"@rules_swift_package_manager//:extensions.bzl", | ||
"swift_deps", | ||
) | ||
swift_deps.from_package( | ||
declare_swift_deps_info = True, | ||
resolved = "//:Package.resolved", | ||
swift = "//:Package.swift", | ||
) | ||
use_repo( | ||
swift_deps, | ||
"swift_deps_info", | ||
"swift_package", | ||
"swiftpkg_yoga", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "yoga", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/facebook/yoga", | ||
"state" : { | ||
"revision" : "69b8934429702bd3ab06e8d6f709112a761b474b", | ||
"version" : "3.1.0" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// swift-tools-version: 6.0 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "YogaKitExample", | ||
dependencies: [ | ||
.package(url: "https://github.com/facebook/yoga.git", from: "3.1.0"), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Yoga Example | ||
|
||
This example demonstrates support for clang, with a root public headers search paths. For example, the file | ||
`external/swiftpkg_yoga/yoga/module.modulemap` will be duplicated when we have both `sources: ["yoga"],` and `publicHeadersPath: ".",` in `Package.swift`. Removing duplicate from the srcs read is useful in this case. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_test") | ||
|
||
swift_test( | ||
name = "YogaTests", | ||
srcs = [ | ||
"YogaTests.swift", | ||
], | ||
module_name = "YogaTests", | ||
deps = [ | ||
"@swiftpkg_yoga//:yoga", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@testable import Yoga | ||
import XCTest | ||
|
||
class YogaTests: XCTestCase { | ||
func testSomething() { | ||
let view = UIView() | ||
view.flex.isEnabled = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Intentionally blank: Using bzlmod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Intentionally blank | ||
# This exists to force Bazel in bzlmod mode to be strict. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)" | ||
|
||
# Use the Bazel binary specified by the integration test. Otherise, fall back | ||
# to bazel. | ||
bazel="${BIT_BAZEL_BINARY:-bazel}" | ||
|
||
# Generate Swift external deps and update build files | ||
"${bazel}" run //:tidy | ||
|
||
# Ensure that it builds and tests pass | ||
"${bazel}" test //... |