Skip to content

Commit

Permalink
feat: support standard format of code style (#45)
Browse files Browse the repository at this point in the history
* feat: support standard format

* add CI

* fix

* remove style check for generated file
  • Loading branch information
zuston authored Jul 23, 2023
1 parent 9b121e7 commit 1507620
Show file tree
Hide file tree
Showing 25 changed files with 1,750 additions and 1,123 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ jobs:
restore-keys: ${{ runner.os }}-cargo-
- name: Build
run: cargo build --verbose
- name: Code style check
run: cargo fmt --check
- name: Run tests
run: cargo test --verbose
24 changes: 12 additions & 12 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{env, fs};
use std::path::Path;
use std::{env, fs};

fn main() -> Result<(), Box<dyn std::error::Error>> {
// generate the uniffle code for grpc server
Expand Down Expand Up @@ -30,37 +30,37 @@ fn rename_file(file_path: impl AsRef<Path>, renamed_path: impl AsRef<Path>) {
fs::rename(&f, renamed_path).expect("Errors on renaming file.");
}


fn setup_ld_library_path() {
// java_home is required now to build and test
let java_home = env::var("JAVA_HOME").expect("JAVA_HOME must be set");
let possible_lib_paths = vec![
format!("{java_home}/jre/lib/amd64/server/"),
format!("{java_home}/lib/server"),
format!("{java_home}/jre/lib/server"),
format!("{java_home}/jre/lib/amd64/server")
format!("{java_home}/jre/lib/amd64/server"),
];
let lib_jvm_path = possible_lib_paths.iter().find(|&path| {
let path = Path::new(&path);
path.exists()
}).expect("java_home is not valid");
let lib_jvm_path = possible_lib_paths
.iter()
.find(|&path| {
let path = Path::new(&path);
path.exists()
})
.expect("java_home is not valid");
match env::consts::OS {
"linux" => {
let ld_path = env::var_os("LD_LIBRARY_PATH").unwrap_or("".parse().unwrap());
let ld_path = format!("{}:{}",
ld_path.to_str().unwrap(), lib_jvm_path);
let ld_path = format!("{}:{}", ld_path.to_str().unwrap(), lib_jvm_path);
// this might be anti-pattern, but it works for our current setup
println!("cargo:rustc-env=LD_LIBRARY_PATH={}", ld_path);
}
"macos" => {
let ld_path = env::var_os("DYLD_LIBRARY_PATH").unwrap_or("".parse().unwrap());
let ld_path = format!("{}:{}",
ld_path.to_str().unwrap(), lib_jvm_path);
let ld_path = format!("{}:{}", ld_path.to_str().unwrap(), lib_jvm_path);
// this might be anti-pattern, but it works for our current setup
println!("cargo:rustc-env=DYLD_LIBRARY_PATH={}", ld_path);
}
_ => {
// do nothing
}
}
}
}
26 changes: 26 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

edition = "2021"
reorder_imports = true

# format_code_in_doc_comments = true
# group_imports = "StdExternalCrate"
# imports_granularity = "Item"
# overflow_delimited_expr = true
# trailing_comma = "Vertical"
# where_single_line = true
Loading

0 comments on commit 1507620

Please sign in to comment.