Skip to content

Commit

Permalink
Add support for macos-14-arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
frozenlib committed May 20, 2024
1 parent abddd05 commit 09fdf61
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-13]
os: [ubuntu-latest, windows-latest, macos-13, macos-latest]
link: [static, dynamic]
exclude:
- os: macos-13
link: static
- os: macos-latest
link: static

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -57,11 +59,17 @@ jobs:
cmake ..
make -j4
- name: Install LightGBM (macos - dynamic)
- name: Install LightGBM (macos-13 - dynamic)
if: matrix.os == 'macos-13' && matrix.link == 'dynamic'
run: |
brew install lightgbm
- name: Install LightGBM (macos - dynamic)
if: matrix.os == 'macos-latest' && matrix.link == 'dynamic'
run: |
brew install lightgbm
echo "LIGHTGBM_LIB_DIR=/opt/homebrew/Cellar/lightgbm/4.3.0/lib/" >> $GITHUB_ENV
- name: Rustup update stable
run: rustup update stable
- name: Show cargo version
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ Unofficial Rust bindings for [LightGBM](https://lightgbm.readthedocs.io/en/lates

### MacOS

Run the following command to install LightGBM on your system.
1. Run `brew install lightgbm` and install LightGBM on your system.
2. Set the environment variable `LIGHTGBM_LIB_PATH` to the directory containing `lib_lightgbm.dylib`.

```sh
brew install lightgbm
export LIGHTGBM_LIB_PATH=/opt/homebrew/Cellar/lightgbm/4.3.0/lib/
```

## Example
Expand Down
9 changes: 8 additions & 1 deletion lgbm-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ fn build_linux() {
}
}
fn build_macos() {
if let Some(dir) = try_env_var("LIGHTGBM_LIB_DIR") {
println!("cargo:rustc-link-search={dir}");
}
println!("cargo:rustc-link-lib=dylib=_lightgbm");
}

fn env_var(key: &str) -> String {
try_env_var(key).unwrap_or_else(|| panic!("environment variable `{key}` is not set"))
}
fn try_env_var(key: &str) -> Option<String> {
println!("cargo:rerun-if-env-changed={key}");
env::var(key).unwrap_or_else(|_| panic!("environment variable `{key}` is not set"))
env::var(key).ok()
}

fn rerun_if_changed(path: &Path) {
println!("cargo:rerun-if-changed={}", path.display());
}

0 comments on commit 09fdf61

Please sign in to comment.