Comments (4)
Looks like I will need to parse the Package.swift to get any C-specific settings/options.
Example: swift-nio with CSetting
Example: Yams with CSetting
Example code to parse Package.swift.
from rules_spm.
Notes on getting libwebp
in interesting_deps
example to build:
- Need to add the following includes to find the private headers.
includes = [
"include/webp",
"libwebp",
"libwebp/src",
],
from rules_spm.
Over the past week or so, I have been working on a proof-of-concept to understand what it would take to introduce a build_mode
to spm_repositories
. Setting this attribute to bazel
would change how rules_spm
works underneath the covers. Instead of building the dependent packages using SPM, it would generate Bazel build files allowing the targets to be built using the normal Bazel toolchains. I was able to successfully build and use Swift packages with Swift targets and generic clang targets. Unfortunately, configuring clang targets with custom build settings requires more information than a package description provides.
To be able to properly build clang targets with custom build settings, one needs to retrieve and apply these settings (e.g. defines, public header paths). The current scheme for downloading and reading these manifest files during the repository fetch phase requires code that can parse the manifest and present the information in a means that is readable by Starlark code. Unfortunately, there is no Swift package manifest parser written in Starlark. One can write a parser in Starlark and maintain it as SPM evolves. The question is whether that is the best path forward.
This conundrum is not new to this project. The same decision had to be made when figuring out how to read data from module.modulemap
files. At the time, we opted to write a modulemap parser in Starlark thinking that the format was fairly mature and did not appear to be changing much.
To avoid having to write a custom parser, I wrote a simple Swift binary that reads a Swift package manifest and dumps information about it to JSON. The JSON is then read by Starlark code. The approach works. The problem is how one gets and uses the binary from code that is run during Bazel's fetch phase. As of this writing, the current code uses swift run
to build and execute the parser. This works OK if there is only one spm_repositories
declaration. However, if there are multiple declarations, one will experience an error due to two Swift processes trying to build the same package. I could work around this by ensuring that two processes never build the same code simultaneously. However, that would require duplicating the code and the compilation (ugh) or inventing some kind of semaphore that only allows one build to run (double ugh).
So, I am left with one of a few options:
- Solve the duplicate build problem for
spm_parser
. (Yuck) - Write a Swift package manifest parser in Starlark. This would allow
rules_spm
to provide a repository rule that magically does the heavy lifting that it does today. - Go completely different direction with
rules_spm
. Instead of providing a repository rule, it would provide an executable target that generates Bazel build files similar to google/cargo-raze. (Thanks to @keith for making me aware of this project.)
from rules_spm.
Created #157 asking the community how they would like to move forward.
from rules_spm.
Related Issues (20)
- Depend on package but not its dependencies HOT 3
- Ask the community how they would like to move forward with `rules_spm` design/behavior HOT 1
- Write design doc describing path forward
- Unable to add dependency on `Stripe` HOT 7
- SPM packages that include the DocC output in repo fail to build HOT 1
- Update `spm_xcode_toolchain.bzl` to use `DefaultInfo.files_to_run`.
- spm_repositories - doesn't seem to work HOT 5
- spm_swift_binary - use local binary / or how to use local spm files HOT 1
- Undefined symbols for architecture x86_64 when using ios_unit_test HOT 2
- tools/spm_parser fails building with swiftc 5.7 HOT 4
- Error in fail: A clang target must have at least one public header. target: GoogleSignIn HOT 1
- Cannot include package with binary (not executable) library target HOT 1
- Dependency Dashboard
- Error building package in both modes
- Bazel mode regression in `0.11.1` HOT 5
- Enable `incompatible_xcode_` integration tests to run on `macos-12` CI
- Not all outputs were created or valid when building for IOS device HOT 7
- attribute 'srcs' in 'filegroup' rule: invalid target name '_:).json': HOT 2
- Deprecate `rules_spm`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rules_spm.