Skip to content

Commit

Permalink
Fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
songww committed May 7, 2022
1 parent 9eb4814 commit dd38d4b
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 49 deletions.
105 changes: 78 additions & 27 deletions .github/workflows/main.yml
Expand Up @@ -8,27 +8,28 @@ on:

jobs:
linux-ci-static:
name: stable, Linux, shared library
name: stable, Linux, static library, no pkg-config
runs-on: ubuntu-latest
env:
HARFBUZZ_SYS_NO_PKG_CONFIG: 1
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

# Install harfbuzz from the source in harfbuzz-sys. Use an out-of-tree
# build to avoid contaminating the source tree.
- name: Build harfbuzz
env:
PREFIX: /usr/local
run: |
make -f harfbuzz-sys/makefile.touch touch HARFBUZZ=harfbuzz-sys/harfbuzz
HARFDIR=`pwd`
pushd $RUNNER_TEMP
$HARFDIR/harfbuzz-sys/harfbuzz/configure --prefix=$PREFIX --without-icu --without-freetype --without-glib
make
sudo make install
# Make harfbuzz available for linking and confirm expected location
TEMP_PATH="$(pkg-config --variable=libdir harfbuzz)"
sudo pip install meson
sudo apt update
sudo apt install ninja-build -y
meson $RUNNER_TEMP/build harfbuzz-sys/harfbuzz --prefix $PREFIX --libdir lib --default-library static -Dicu=disabled -Dfreetype=disabled -Dglib=disabled
meson compile -C $RUNNER_TEMP/build
sudo meson install -C $RUNNER_TEMP/build
TEMP_PATH="$PREFIX/lib"
echo "LD_LIBRARY_PATH=$TEMP_PATH" >> $GITHUB_ENV
[[ "$TEMP_PATH" == "$PREFIX/lib" ]] || exit 1
popd
Expand All @@ -40,6 +41,34 @@ jobs:
toolchain: stable
override: true

- name: Cargo build
run: cargo build --all --no-default-features

- name: Cargo test
run: cargo test --all --no-default-features
env:
RUST_BACKTRACE: 1

- name: ctest tests
run: cargo run --manifest-path=harfbuzz-sys-test/Cargo.toml --no-default-features

linux-ci-static-buildrs:
name: stable, Linux, build by build.rs, static library, no pkg-config
runs-on: ubuntu-latest
env:
HARFBUZZ_SYS_NO_PKG_CONFIG: 1
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Cargo build
run: cargo build --all

Expand All @@ -52,12 +81,14 @@ jobs:
run: cargo run --manifest-path=harfbuzz-sys-test/Cargo.toml

linux-ci-shared:
name: stable, Linux, static linking, no pkg-config
name: stable, Linux, shared linking, no pkg-config
runs-on: ubuntu-latest
env:
HARFBUZZ_SYS_NO_PKG_CONFIG: 1
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -66,25 +97,40 @@ jobs:
toolchain: stable
override: true

- name: Build harfbuzz
env:
PREFIX: /usr/local
run: |
sudo pip install meson
sudo apt update
sudo apt install ninja-build -y
meson $RUNNER_TEMP/build harfbuzz-sys/harfbuzz --prefix $PREFIX --libdir lib --default-library shared -Dicu=disabled -Dfreetype=disabled -Dglib=disabled
meson compile -C $RUNNER_TEMP/build
sudo meson install -C $RUNNER_TEMP/build
TEMP_PATH="$PREFIX/lib"
echo "LD_LIBRARY_PATH=$TEMP_PATH" >> $GITHUB_ENV
[[ "$TEMP_PATH" == "$PREFIX/lib" ]] || exit 1
popd
# Test the harfbuzz-sys package build to check the 'exclude's. We should
# do this where the embedded harfbuzz is statically linked, but we don't
# need to do it for every environment.
- name: Cargo package
run: cargo package --manifest-path=harfbuzz-sys/Cargo.toml
run: cargo package --manifest-path=harfbuzz-sys/Cargo.toml --no-default-features

- name: Cargo build
run: cargo build --all
run: cargo build --all --no-default-features

- name: Cargo test
run: cargo test --all
run: cargo test --all --no-default-features
env:
RUST_BACKTRACE: 1

- name: ctest tests
run: cargo run --manifest-path=harfbuzz-sys-test/Cargo.toml
run: cargo run --manifest-path=harfbuzz-sys-test/Cargo.toml --no-default-features

linux-ci-bindgen:
name: stable, Linux, system pkg-config
name: stable, Linux, system pkg-config and bindgen
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -96,28 +142,32 @@ jobs:
toolchain: stable
override: true
- name: Install harfbuzz
run: sudo apt install libharfbuzz-dev -y
run: |
sudo apt update
sudo apt install libharfbuzz-dev -y
- name: Cargo package
run: cargo package --manifest-path=harfbuzz-sys/Cargo.toml --features bindgen
run: cargo package --manifest-path=harfbuzz-sys/Cargo.toml --no-default-features --features bindgen

- name: Cargo build
run: cargo build --all --features bindgen
run: cargo build --all --no-default-features --features bindgen

- name: Cargo test
run: cargo test --all --features bindgen
run: cargo test --all --no-default-features --features bindgen
env:
RUST_BACKTRACE: 1

- name: ctest tests
run: cargo run --manifest-path=harfbuzz-sys-test/Cargo.toml --features bindgen
run: cargo run --manifest-path=harfbuzz-sys-test/Cargo.toml --no-default-features --features bindgen

mac-ci-shared:
name: stable, macOS, shared library
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -156,26 +206,25 @@ jobs:
- name: install harfbuzz latest
run: brew install harfbuzz

- name: harfbuzz version
run: pkg-config --modversion harfbuzz

- name: Cargo build
run: cargo build --all --features bindgen
run: cargo build --all --no-default-features --features bindgen

- name: Cargo test
run: cargo test --all --features bindgen
run: cargo test --all --no-default-features --features bindgen
env:
RUST_BACKTRACE: 1

- name: ctest tests
run: cargo run --manifest-path=harfbuzz-sys-test/Cargo.toml --features bindgen
run: cargo run --manifest-path=harfbuzz-sys-test/Cargo.toml --no-default-features --features bindgen

windows-ci:
name: Windows
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -199,8 +248,10 @@ jobs:
name: homu build finished
runs-on: ubuntu-latest
needs:
- "linux-ci-static"
- "linux-ci-bindgen"
- "linux-ci-shared"
- "linux-ci-static"
- "linux-ci-static-buildrs"
- "mac-ci-shared"
- "mac-ci-shared-bindgen-latest"
- "windows-ci"
Expand Down
5 changes: 4 additions & 1 deletion harfbuzz-sys-test/Cargo.toml
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
build = "build.rs"

[dependencies]
harfbuzz-sys = { path = "../harfbuzz-sys" }
harfbuzz-sys = { path = "../harfbuzz-sys", default-features = false }
libc = "0.2"

[build-dependencies]
Expand All @@ -15,3 +15,6 @@ ctest = { package = "ctest2", version = "0.4" }

[features]
bindgen = ["harfbuzz-sys/bindgen"]
default = ["build-native-harfbuzz", "build-native-freetype"]
build-native-harfbuzz = ["harfbuzz-sys/build-native-harfbuzz"]
build-native-freetype = ["harfbuzz-sys/build-native-freetype"]
2 changes: 1 addition & 1 deletion harfbuzz-sys/Cargo.toml
Expand Up @@ -26,7 +26,7 @@ build = "build.rs"
cc = { version = "1", optional = true }
regex = { version = "1", optional = true }
bindgen_ = { version = "0.59", optional = true, package = "bindgen" }
pkg-config = { version = "0.3", optional = true }
pkg-config = { version = "0.3" }

[target.'cfg(target_vendor = "apple")'.dependencies]
core-graphics = "0.22"
Expand Down
44 changes: 24 additions & 20 deletions harfbuzz-sys/build.rs
Expand Up @@ -81,25 +81,6 @@ fn main() {

let target = env::var("TARGET").unwrap();

println!("cargo:rerun-if-env-changed=HARFBUZZ_SYS_NO_PKG_CONFIG");
if target.contains("wasm32") || env::var_os("HARFBUZZ_SYS_NO_PKG_CONFIG").is_none() {
match pkg_config::Config::new()
.range_version("4.2".."5")
.probe("harfbuzz")
{
Ok(_lib) => {
#[cfg(feature = "bindgen")]
{
bindings::gen(&_lib.include_paths);
}
return;
}
Err(_) => {
println!("cargo:warning=harfbuzz >= 4.2 not found, building from source.");
}
}
}

let mut cfg = cc::Build::new();
cfg.cpp(true)
.flag_if_supported("-std=c++11") // for unix
Expand Down Expand Up @@ -132,4 +113,27 @@ fn main() {
}

#[cfg(not(feature = "build-native-harfbuzz"))]
fn main() {}
fn main() {
println!("cargo:rerun-if-env-changed=HARFBUZZ_SYS_NO_PKG_CONFIG");
if target.contains("wasm32") || env::var_os("HARFBUZZ_SYS_NO_PKG_CONFIG").is_none() {
#[allow(unused_mut)]
let mut pkgcfg = pkg_config::Config::new();

// allow other version of harfbuzz when bindgen enabled.
#[cfg(not(feature = "bindgen"))]
pkgcfg.range_version("4.2".."5");

match pkgcfg.probe("harfbuzz") {
Ok(_lib) => {
#[cfg(feature = "bindgen")]
{
bindings::gen(&_lib.include_paths);
}
return;
}
Err(_) => {
// println!("cargo:warning=harfbuzz >= 4.2 not found by pkgconfig.");
}
}
}
}

0 comments on commit dd38d4b

Please sign in to comment.