Skip to content

Commit

Permalink
Add ability to disable some functionality via features (#23)
Browse files Browse the repository at this point in the history
Features:
- TLS - since sometimes you may not have proper libssl/libcrypt
- flameshow - required for brew package Add chdig to brew #13

And also add new build to CI to ensure that this configuration will not be broken.

* features:
  ci: switch openssl.org (not available right now) to www.openssl.org
  ci: add build configuration without any features (just a sanity check)
  Add ability to disable TLS support
  Add ability to disable flameshow (for brew)
  • Loading branch information
azat committed Dec 24, 2023
2 parents bf11eb6 + 8bbf26a commit c5de328
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: |
mkdir build-openssl
cd build-openssl
curl -L https://openssl.org/source/openssl-1.1.1w.tar.gz | tar --strip-components=1 -xzf -
curl -L https://www.openssl.org/source/openssl-1.1.1w.tar.gz | tar --strip-components=1 -xzf -
./Configure --prefix=$OPENSSL_DIR --libdir=lib linux-x86_64 -fPIC -g no-shared
make -j
make install_sw
Expand All @@ -83,6 +83,32 @@ jobs:
*.rpm
*.tar.*
build-linux-no-features:
name: Build Linux (no features)
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
with:
# To fetch tags, but can this be improved using blobless checkout?
# [1]. But anyway right it is not important, and unlikely will be,
# since the repository is small.
#
# [1]: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
fetch-depth: 0

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Build
run: |
cargo build --no-default-features # should be the same as 'make'
- name: Check package
run: |
cargo run --no-default-features -- --help
build-macos-x86_64:
name: Build MacOS (x86_64)
# This is x86-64, M1 not for free
Expand Down
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ license = "MIT"
version = "0.6.0"
edition = "2021"

[features]
default = ["flameshow", "tls"]
flameshow = ["dep:flameshow"]
tls = ["clickhouse-rs/tls"]

# TODO: convert this into feature set, but I'm not sure that it is easy right now (see [1]).
# [1]: https://github.com/rust-lang/cargo/issues/1197
[target.'cfg(not(target_family = "windows"))'.dependencies]
Expand Down Expand Up @@ -56,11 +61,12 @@ syntect = "*"
#
# Drivers
#
clickhouse-rs = { git = "https://github.com/suharev7/clickhouse-rs", branch = "async-await", features = ["tls"] }
clickhouse-rs = { git = "https://github.com/suharev7/clickhouse-rs", branch = "async-await" }
tokio = { version = "*", features = ["full"] }

[dependencies.flameshow]
path = "contrib/flameshow"
optional = true

[profile.release]
lto = true
10 changes: 9 additions & 1 deletion src/interpreter/flamegraph.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use crate::interpreter::clickhouse::Columns;
use anyhow::{Error, Result};
use flameshow::flameshow;
use futures::channel::mpsc;
use std::process::{Command, Stdio};
use tokio::time::{sleep, Duration};
use urlencoding::encode;
use warp::http::header::{HeaderMap, HeaderValue};
use warp::Filter;

#[cfg(feature = "flameshow")]
use flameshow::flameshow;

#[cfg(feature = "flameshow")]
pub fn show(block: Columns) -> Result<()> {
let data = block
.rows()
Expand All @@ -24,6 +27,11 @@ pub fn show(block: Columns) -> Result<()> {
return flameshow(&data, "ClickHouse");
}

#[cfg(not(feature = "flameshow"))]
pub fn show(_block: Columns) -> Result<()> {
return Err(Error::msg("chdig compiled without flameshow support"));
}

pub async fn open_in_speedscope(block: Columns) -> Result<()> {
let data = block
.rows()
Expand Down

0 comments on commit c5de328

Please sign in to comment.