Skip to content

Commit

Permalink
layout gvfs-fuse project
Browse files Browse the repository at this point in the history
  • Loading branch information
diqiu50 committed Nov 20, 2024
1 parent 306c0e8 commit ae2d5f6
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 1 deletion.
20 changes: 20 additions & 0 deletions clients/gvfs-fuse/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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.

[build]
target-dir = "build"

1 change: 1 addition & 0 deletions clients/gvfs-fuse/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Cargo.lock
30 changes: 30 additions & 0 deletions clients/gvfs-fuse/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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.

[package]
name = "gvfs-fuse"
version = "0.1.0"
edition = "2021"
rust-version = "1.75"

[dependencies]
fuse3 = { version = "0.8.1", "features" = ["tokio-runtime", "unprivileged"] }
tokio = { version = "1.38.0", features = ["full"] }
futures-util = "0.3.30"
libc = "0.2.164"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
log = "0.4.22"
52 changes: 52 additions & 0 deletions clients/gvfs-fuse/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.
*/

import org.gradle.api.tasks.Exec

val checkRustEnvironment by tasks.registering(Exec::class) {
description = "Check if Rust environment is properly set up using an external script"
group = "verification"
commandLine("bash", "$projectDir/check_rust_env.sh")
isIgnoreExitValue = false
}

val compileRust by tasks.registering(Exec::class) {
dependsOn(checkRustEnvironment)
description = "Compile the Rust submodule"
workingDir = file("$projectDir")
commandLine("cargo", "build", "--release")
}

tasks.register("testRust", Exec::class) {
dependsOn(checkRustEnvironment)
description = "Run tests in the Rust submodule"
group = "verification"
workingDir = file("$projectDir")
commandLine("cargo", "test")

standardOutput = System.out
errorOutput = System.err
}

tasks.named("build") {
dependsOn(compileRust)
}
tasks.named("test") {
dependsOn("testRust")
}
50 changes: 50 additions & 0 deletions clients/gvfs-fuse/check_rust_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
#
# 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.

set -e

#!/bin/bash

if ! command -v cargo &> /dev/null; then
echo "Rust is not installed. Installing Rust..."

if command -v curl &> /dev/null; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
elif command -v wget &> /dev/null; then
wget -qO- https://sh.rustup.rs | sh -s -- -y
else
echo "Error: Neither curl nor wget is available. Please install one of them to proceed."
exit 1
fi

export PATH="$HOME/.cargo/bin:$PATH"
echo "Rust has been installed successfully."
else
echo "Rust is already installed: $(cargo --version)"
fi

if command -v cargo &> /dev/null; then
echo "Rust environment is set up correctly."
else
echo "Error: Rust installation failed. Please check your setup."
exit 1
fi


exit 1
30 changes: 30 additions & 0 deletions clients/gvfs-fuse/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.
*/

use fuse3::Result;
use log::info;
use log::debug;

#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt().with_env_filter("debug").init();
info!("Starting filesystem...");
debug!("Shutdown filesystem...");
Ok(())
}
23 changes: 23 additions & 0 deletions clients/gvfs-fuse/tests/it.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.
*/

#[test]
fn test_math_add() {
assert_eq!(1, 1);
}
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ include(
"clients:filesystem-hadoop3",
"clients:filesystem-hadoop3-runtime",
"clients:client-python",
"clients:cli"
"clients:cli",
"clients:gvfs-fuse"
)
include("iceberg:iceberg-common")
include("iceberg:iceberg-rest-server")
Expand Down

0 comments on commit ae2d5f6

Please sign in to comment.