Skip to content

Commit

Permalink
feat: add build script
Browse files Browse the repository at this point in the history
  • Loading branch information
omdxp committed Jan 2, 2024
1 parent 9f278d8 commit 6b14de6
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.
8 changes: 8 additions & 0 deletions java/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
Expand Down
4 changes: 2 additions & 2 deletions java/.project
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
</natures>
<filteredResources>
<filter>
<id>1605991603586</id>
<id>1704216278876</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
Expand Down
3 changes: 2 additions & 1 deletion rust/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
target
src/_data
1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "kuliya"
version = "0.1.0"
edition = "2021"
build = "gen_data.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
19 changes: 19 additions & 0 deletions rust/gen_data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::{fs, io, path::Path};

fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
fs::create_dir_all(&dst)?;
for entry in fs::read_dir(src)? {
let entry = entry?;
let ty = entry.file_type()?;
if ty.is_dir() {
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
} else {
fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
}
}
Ok(())
}

fn main() {
copy_dir_all(Path::new("../_data"), Path::new("./src/_data")).unwrap();
}
4 changes: 2 additions & 2 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fs;

use serde::{Deserialize, Serialize};

const DATA_PREFIX_PATH: &'static str = "../_data";
const DATA_FOLDER: &'static str = "src/_data";

#[derive(Debug, Serialize, Deserialize)]
struct Name {
Expand Down Expand Up @@ -47,7 +47,7 @@ pub struct Schema {
}

pub fn get_node_by_path(path: &str) -> Option<Schema> {
let fs_path = format!("{}/{}/info.json", DATA_PREFIX_PATH, path);
let fs_path = format!("{}/{}/info.json", DATA_FOLDER, path);
let Ok(info) = fs::read_to_string(fs_path) else {
return None;
};
Expand Down

0 comments on commit 6b14de6

Please sign in to comment.