-
Notifications
You must be signed in to change notification settings - Fork 2
*: add tirocks-sys and xtask #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
links = "tirocks" | ||
|
||
[dependencies] | ||
# native library >=1.0.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means the version of bzip2 package >= 1.0.8.
Cargo.toml
Outdated
|
||
[patch.crates-io] | ||
# Use cmake to build the binary, so it can be compiled on all supported platform. | ||
snappy-sys = { git = "https://github.com/busyjay/rust-snappy.git", branch = "static-link" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In rust-rocksdb, DBStatisticsTickerType
is generated by librocksdb_sys/src/generated.rs
. We did some changes in it. It can't simply follow the original c.h
.
#[cfg(feature = "update-bindings")] | ||
fn bindgen_rocksdb(file_path: &Path) { | ||
println!("cargo:rerun-if-env-changed=TEST_BIND"); | ||
let gen_tests = env::var("TEST_BIND").map_or(false, |s| s == "1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it will be used in tests.
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
I add the missing ticker and histogram types by including them into whitelist. So they are generated by bindgen automatically instead of custom scripts. I also define all the properties names in c.h, so they can also be maintained by bindgen. |
Signed-off-by: Jay Lee <[email protected]>
@@ -0,0 +1,2718 @@ | |||
/* Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wish we can use C API defined in rocksdb and Titan instead of maintaining it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Maybe we need to have rocksdb headers, titan headers and custom headers maintained by ourselves. This can be done later.
} | ||
|
||
fn clang_format() { | ||
exec(cmd("clang-format").args(&[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about calling it in make format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no Makefile. The point of using xtask is to use cargo flow completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I have some changes, then I need to call cargo fmt
and cargo xtask clang-format
separately. I don't think it's friendly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a new command cargo xtask format
.
## Build | ||
|
||
``` | ||
$ cargo xtask submodule # if you just cloned the repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest provide a make build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a one time task. And update submodule every time may not be a good idea if I want to checkout submodule to a different version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we need to provide a Makfile. update_rocksdb
and update_titan
are needed by the auto-update bot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is auto-update bot? All functionality can be implemented as a new command of xtask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the rocksdb/titan submodule when any rocksdb/titan's PRs get merged, and then file a PR to update rust-rocksdb
dependency in tikv repo
figure_link_lib(&dst, "rocksdb"); | ||
|
||
if cfg!(target_os = "windows") { | ||
build.define("OS_WIN", None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a question: as the rocksdb has already been built above, do these defines make any sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it will be used in the headers included in c.h.
let mut builder = bindgen::Builder::default(); | ||
|
||
if env::var("CARGO_CFG_TARGET_OS").map_or(false, |s| s == "windows") { | ||
builder = builder.clang_arg("-D _WIN32_WINNT=0x600"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's it for. Please add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's copied from grpc-rs. Some file may require to define minimal supported windows version at compile time.
.whitelist_type(r"\brocksdb::Histograms") | ||
.whitelist_type(r"\brocksdb::titandb::TickerType") | ||
.whitelist_type(r"\brocksdb::titandb::HistogramType") | ||
.blacklist_type(r"\b__.*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is it for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To filter symbols like __uint32
.
tirocks-sys/build.rs
Outdated
.whitelist_type(r"\brocksdb::titandb::HistogramType") | ||
.blacklist_type(r"\b__.*") | ||
.derive_copy(false) | ||
.opaque_type(r"\bctitandb_.*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why titan's type are opaque type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually all structs are opaque types as the current way they are defined. But this is a stale change, I will remove it.
#[doc = " 4. Add the enum conversions from Java and C++ to portal.h's toJavaTickerType"] | ||
#[doc = " and toCppTickers"] | ||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] | ||
pub enum rocksdb_Tickers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have a way to add a prefix c
for these enums to make them consistent with other types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or cancel the prefix c
in the crocksdb.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we can't. rust-lang/rust-bindgen#1098. I think the c prefix is fine as it can tell what types are defined by ourselves and what types are defined by rocksdb itself.
tirocks-sys/src/lib.rs
Outdated
@@ -0,0 +1,32 @@ | |||
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. | |
// Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest LGTM
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The version of titan and rocksdb submodules are the same as master branch of rust-rocksdb. xtask crate are copied from grpc-rs. Build script are refactored.
Compared to rust-rocksdb, the main differences are: