Skip to content

Commit

Permalink
Update CI, Makefile and build.rs
Browse files Browse the repository at this point in the history
Signed-off-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
  • Loading branch information
FedericoBruzzone committed Jun 23, 2024
1 parent aad1a5d commit 0c215f8
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Run cargo test
run: cargo test --verbose --workspace --exclude tdlib-rs -- --nocapture --test-threads=1
- name: Run cargo clippy
run: cargo clippy --features ${{ matrix.feature }} -- -D warnings
run: cargo clippy --all-targets --features ${{ matrix.feature }} -- -D warnings
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Run cargo run
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Run cargo test
run: cargo test --verbose --workspace --exclude tdlib-rs -- --nocapture --test-threads=1
- name: Run cargo clippy
run: cargo clippy --features ${{ matrix.feature }} -- -D warnings
run: cargo clippy --all-targets --features ${{ matrix.feature }} -- -D warnings
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Run cargo run
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Run cargo test
run: cargo test --verbose --workspace --exclude tdlib-rs -- --nocapture --test-threads=1
- name: Run cargo clippy
run: cargo clippy --features ${{ matrix.feature }} -- -D warnings
run: cargo clippy --all-targets --features ${{ matrix.feature }} -- -D warnings
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Run cargo run
Expand Down
58 changes: 0 additions & 58 deletions Justfile

This file was deleted.

32 changes: 29 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
export RUST_BACKTRACE := 1

# Usage: make <command> ARGS="--features <feature> --bin <bin_name>"
#
# Avaialble commands:
# all
# build
# run
# test
# clippy
# fmt
# clean
#
# Available features:
# local-tdlib
# download-tdlib
# pkg-config
#
# Available bin_name:
# get_me

all: fmt clippy test build
all:
$(MAKE) fmt
$(MAKE) clippy # ARGS="--features download-tdlib"
$(MAKE) test # ARGS="--features download-tdlib"

build_local:
cargo build --no-default-features --features local-tdlib

# Example 1: make build ARGS="--features download-tdlib"
# Example 2: make build ARGS="--features download-tdlib --example telegram"
build:
cargo build $(ARGS)
cargo build $(ARGS)

# Example: make run ARGS="--package tdlib-rs --example get_me"
# Example: make run ARGS="--package tdlib-rs --example get_me --features download-tdlib"
run:
cargo run $(ARGS)

Expand Down
3 changes: 0 additions & 3 deletions tdlib-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ fn download_tdlib() {
}

fn main() -> std::io::Result<()> {

#[cfg(all(feature = "docs", feature = "pkg-config"))]
compile_error!(
"feature \"docs\" and feature \"pkg-config\" cannot be enabled at the same time"
Expand Down Expand Up @@ -244,8 +243,6 @@ fn main() -> std::io::Result<()> {
generic_build();
}



let out_dir = env::var("OUT_DIR").unwrap();

let definitions = load_tl("tl/api.tl")?;
Expand Down
20 changes: 11 additions & 9 deletions tdlib-rs/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/// - `local-tdlib`
/// - `pkg-config`
/// - `download-tdlib`
///

#[allow(dead_code)]
#[cfg(not(any(feature = "docs", feature = "pkg-config")))]
Expand Down Expand Up @@ -258,13 +257,14 @@ pub fn set_rerun_if() {
/// If the variables are not set, the function will panic.
///
/// # Example
/// Cargo.toml:
/// ```toml
/// // Cargo.toml
/// [dependencies]
/// tdlib = { version = "...", features = ["pkg-config"] }
/// ```
///
/// build.rs:
/// ```rust
/// // build.rs
/// fn main() {
/// tdlib_rs::build::check_features();
/// tdlib_rs::build::set_rerun_if();
Expand Down Expand Up @@ -303,17 +303,17 @@ pub fn build_pkg_config() {
/// If the OS or architecture is not supported, the function will panic.
///
/// # Example
/// Cargo.toml:
/// ```toml
/// // Cargo.toml
/// [dependencies]
/// tdlib = { version = "...", features = ["download-tdlib"] }
///
//// [build-dependencies]
/// tdlib = { version = "...", features = [ "download-tdlib" ] }
/// ```
///
/// build.rs:
/// ```rust
/// // build.rs
/// fn main() {
/// tdlib_rs::build::check_features();
/// tdlib_rs::build::set_rerun_if();
Expand Down Expand Up @@ -357,17 +357,17 @@ pub fn build_download_tdlib(dest_path: Option<String>) {
/// If the `LOCAL_TDLIB_PATH` environment variable is not set, the function will panic.
///
/// # Example
/// Cargo.toml:
/// ```toml
/// // Cargo.toml
/// [dependencies]
/// tdlib = { version = "...", features = ["local-tdlib"] }
///
/// [build-dependencies]
/// tdlib = { version = "...", features = [ "download-tdlib" ] }
/// ```
///
/// build.rs:
/// ```rust
/// // build.rs
/// fn main() {
/// tdlib_rs::build::check_features();
/// tdlib_rs::build::set_rerun_if();
Expand All @@ -385,6 +385,7 @@ pub fn build_local_tdlib() {
}
}

#[allow(clippy::needless_doctest_main)]
/// Build the project using the enabled features.
///
/// # Arguments
Expand All @@ -398,22 +399,23 @@ pub fn build_local_tdlib() {
/// The function will build the project using the enabled feature.
///
/// # Example
/// Cargo.toml:
/// ```toml
/// // Cargo.toml
/// [dependencies]
/// tdlib = { version = "...", features = ["download-tdlib"] }
///
/// [build-dependencies]
/// tdlib = { version = "...", features = [ "download-tdlib" ] }
/// ```
///
/// build.rs:
/// ```rust
/// // build.rs
/// fn main() {
/// tdlib_rs::build::build(None);
/// // Other build configurations
/// // ...
/// }
/// ```
pub fn build(_dest_path: Option<String>) {
check_features();
set_rerun_if();
Expand Down

0 comments on commit 0c215f8

Please sign in to comment.