Skip to content

Commit

Permalink
Allow running header-translator on just one framework at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Feb 25, 2025
1 parent d5db83b commit 944f200
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ jobs:
key: cargo-${{ github.job }}-${{ matrix.name }}-${{ hashFiles('**/Cargo.lock') }}

- name: Run header translator
run: cargo run -pheader-translator --bin=header-translator
run: cargo run -pheader-translator --bin=header-translator --release all

- name: Verify that no files changed
run: git diff --exit-code --submodule=diff
Expand Down
115 changes: 115 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions crates/header-translator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ semver = { version = "1.0", features = ["serde"] }
lenient_semver_parser = "0.4"
four-char-code = "2.2.0"
regex = "1.6"
clap = { version = "4.5.31", features = ["derive"] }

[package.metadata.release]
release = false

[features]
std = []
25 changes: 15 additions & 10 deletions crates/header-translator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,34 @@
For use in making framework crates. Run using:

```console
cargo run --bin header-translator
cargo run --bin header-translator --release all
```

Or to only generate for a single crate, do something like:

## SDKs
```console
cargo run --bin header-translator --release objc2-foundation
cargo run --bin header-translator --release CoreFoundation
cargo run --bin header-translator --release MY_FRAMEWORK
```

Make sure you have the same XCode version installed as the one documented in [`crates/objc2/src/topics/about_generated/README.md`](../objc2/src/topics/about_generated/README.md).

If you use a different operating system than macOS, or have multiple SDKs installed, you can specify the directory as the first argument:
## SDKs

```console
cargo run --bin header-translator -- /Applications/Xcode.app/Contents/Developer
```
Make sure you have the same Xcode version installed as the one documented in [`crates/objc2/src/topics/about_generated/README.md`](../objc2/src/topics/about_generated/README.md).

If you use a different operating system than macOS, or have multiple SDKs installed, you can specify the developer directory with `DEVELOPER_DIR`.

Note that you will likely need to use a newer `libclang`, such as [the one distributed with Swift `5.7.2`](https://github.com/apple/llvm-project/tree/swift-5.7.2-RELEASE). You can use a different version as follows (details might vary between operating systems):
Note that in this case, you will likely need to use a newer `libclang`, such as [the one distributed with Swift `5.7.2`](https://github.com/apple/llvm-project/tree/swift-5.7.2-RELEASE). You can use a different version as follows (details might vary between operating systems):

```console
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
export LIBCLANG_PATH=/path/to/custom/installation/usr/lib/libclang.dylib
export CPATH=/path/to/custom/installation/usr/lib/clang/14.0.0/include/
cargo run --bin header-translator -- /Applications/Xcode_new.app/Contents/Developer
cargo run --bin header-translator --release all
```

We do not redistribute SDKs, to hopefully avoid a license violation. You should download XCode (which contain the SDKs) yourself from [Apple's website](https://developer.apple.com/download/all/?q=xcode) (requires an Apple ID).
We do not redistribute SDKs, to hopefully avoid a license violation. You should download Xcode (which contain the SDKs) yourself from [Apple's website](https://developer.apple.com/download/all/?q=xcode) (requires an Apple ID).


## Test feature setup
Expand Down
1 change: 0 additions & 1 deletion crates/header-translator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ pub fn run_cargo_fmt(packages: impl IntoIterator<Item = impl Display>) {
let status = Command::new("cargo")
.arg("fmt")
.args(packages.into_iter().map(|package| format!("-p{package}")))
.arg("-ptest-frameworks")
.current_dir(Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap())
.status()
.expect("failed running cargo fmt");
Expand Down
Loading

0 comments on commit 944f200

Please sign in to comment.