Skip to content

Commit

Permalink
add get_test_path in project
Browse files Browse the repository at this point in the history
  • Loading branch information
rjodinchr committed Dec 24, 2024
1 parent 297a1ca commit 4a7d0d3
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fn generate_project(
) -> Result<(), String> {
let project_name = project.get_name();
let android_path = project.get_android_path(ctx);
let test_path = project.get_test_path(ctx);
let project_ctx = if !is_dependency {
print_info!("Generating '{project_name}'");
ctx.clone()
Expand All @@ -39,7 +40,7 @@ fn generate_project(
print_debug!("Writing soong file...");

const ANDROID_BP: &str = "Android.bp";
let file_path = ctx.test_path.join(project_name).join(ANDROID_BP);
let file_path = test_path.join(ANDROID_BP);
write_file(file_path.as_path(), &package.print())?;
print_verbose!("{file_path:#?} created");

Expand Down
1 change: 1 addition & 0 deletions src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pub trait Project {
fn get_id(&self) -> ProjectId;
fn get_name(&self) -> &'static str;
fn get_android_path(&self, ctx: &Context) -> PathBuf;
fn get_test_path(&self, ctx: &Context) -> PathBuf;
fn generate_package(
&mut self,
ctx: &Context,
Expand Down
5 changes: 4 additions & 1 deletion src/project/angle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ impl Project for Angle {
fn get_android_path(&self, ctx: &Context) -> PathBuf {
ctx.android_path.join("external").join(self.get_name())
}
fn get_test_path(&self, ctx: &Context) -> PathBuf {
ctx.test_path.join(self.get_name())
}
fn generate_package(
&mut self,
ctx: &Context,
Expand All @@ -63,7 +66,7 @@ impl Project for Angle {
execute_cmd!(
"bash",
vec![
&path_to_string(ctx.test_path.join(self.get_name()).join("gen-ninja.sh")),
&path_to_string(self.get_test_path(ctx).join("gen-ninja.sh")),
&path_to_string(&self.src_path),
&path_to_string(&self.build_path),
ANDROID_CPU,
Expand Down
5 changes: 4 additions & 1 deletion src/project/clspv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ impl Project for Clspv {
fn get_android_path(&self, ctx: &Context) -> PathBuf {
ctx.android_path.join("external").join(self.get_name())
}
fn get_test_path(&self, ctx: &Context) -> PathBuf {
ctx.test_path.join(self.get_name())
}
fn generate_package(
&mut self,
ctx: &Context,
Expand All @@ -38,7 +41,7 @@ impl Project for Clspv {
execute_cmd!(
"bash",
vec![
&path_to_string(ctx.test_path.join(self.get_name()).join("gen-ninja.sh")),
&path_to_string(self.get_test_path(ctx).join("gen-ninja.sh")),
&path_to_string(&self.src_path),
&path_to_string(&self.build_path),
&path_to_string(&self.ndk_path),
Expand Down
5 changes: 4 additions & 1 deletion src/project/clvk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ impl Project for Clvk {
fn get_android_path(&self, ctx: &Context) -> PathBuf {
ctx.android_path.join("external").join(self.get_name())
}
fn get_test_path(&self, ctx: &Context) -> PathBuf {
ctx.test_path.join(self.get_name())
}
fn generate_package(
&mut self,
ctx: &Context,
Expand All @@ -34,7 +37,7 @@ impl Project for Clvk {
execute_cmd!(
"bash",
vec![
&path_to_string(ctx.test_path.join(self.get_name()).join("gen-ninja.sh")),
&path_to_string(self.get_test_path(ctx).join("gen-ninja.sh")),
&path_to_string(&self.src_path),
&path_to_string(&self.build_path),
&path_to_string(&self.ndk_path),
Expand Down
9 changes: 5 additions & 4 deletions src/project/llvm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ impl Project for LlvmProject {
fn get_android_path(&self, ctx: &Context) -> PathBuf {
ctx.android_path.join("external").join(self.get_name())
}
fn get_test_path(&self, ctx: &Context) -> PathBuf {
ctx.test_path.join(self.get_name())
}
fn generate_package(
&mut self,
ctx: &Context,
Expand All @@ -35,7 +38,7 @@ impl Project for LlvmProject {
execute_cmd!(
"bash",
vec![
&path_to_string(ctx.test_path.join(self.get_name()).join("gen-ninja.sh")),
&path_to_string(self.get_test_path(ctx).join("gen-ninja.sh")),
&path_to_string(self.src_path.join("llvm")),
&path_to_string(&self.build_path),
&path_to_string(&self.ndk_path),
Expand Down Expand Up @@ -95,9 +98,7 @@ impl Project for LlvmProject {
package.filter_local_include_dirs(CMAKE_GENERATED, &gen_deps);
gen_deps.sort();
write_file(
&ctx.test_path
.join(self.get_name())
.join("generated_deps.txt"),
&self.get_test_path(ctx).join("generated_deps.txt"),
&format!("{0:#?}", &gen_deps),
)?;
if ctx.copy_to_aosp {
Expand Down
14 changes: 7 additions & 7 deletions src/project/mesa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ impl Project for Mesa {
fn get_android_path(&self, ctx: &Context) -> PathBuf {
ctx.android_path.join("external").join(self.get_name())
}
fn get_test_path(&self, ctx: &Context) -> PathBuf {
ctx.test_path.join(self.get_name())
}
fn generate_package(
&mut self,
ctx: &Context,
Expand All @@ -60,26 +63,25 @@ impl Project for Mesa {
self.ndk_path = get_ndk_path(&ctx.temp_path)?;
self.build_path = ctx.temp_path.join(self.get_name());

let mesa_test_path = ctx.test_path.join(self.get_name());
let intel_clc_path = if !ctx.skip_build {
let intel_clc_build_path = ctx.temp_path.join("intel_clc");
execute_cmd!(
"bash",
vec![
&path_to_string(mesa_test_path.join("build_intel_clc.sh")),
&path_to_string(self.get_test_path(ctx).join("build_intel_clc.sh")),
&path_to_string(&self.src_path),
&path_to_string(&intel_clc_build_path)
]
)?;
intel_clc_build_path.join("src/intel/compiler")
} else {
mesa_test_path.clone()
self.get_test_path(ctx)
};
if !ctx.skip_gen_ninja {
execute_cmd!(
"bash",
vec![
&path_to_string(&mesa_test_path.join("gen-ninja.sh")),
&path_to_string(&self.get_test_path(ctx).join("gen-ninja.sh")),
&path_to_string(&self.src_path),
&path_to_string(&self.build_path),
&path_to_string(intel_clc_path),
Expand Down Expand Up @@ -116,9 +118,7 @@ impl Project for Mesa {
package.filter_local_include_dirs(MESON_GENERATED, &gen_deps);
gen_deps.sort();
write_file(
&ctx.test_path
.join(self.get_name())
.join("generated_deps.txt"),
&self.get_test_path(ctx).join("generated_deps.txt"),
&format!("{0:#?}", &gen_deps),
)?;
if ctx.copy_to_aosp {
Expand Down
3 changes: 3 additions & 0 deletions src/project/spirv_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ impl Project for SpirvHeaders {
fn get_android_path(&self, ctx: &Context) -> PathBuf {
ctx.android_path.join("external").join(self.get_name())
}
fn get_test_path(&self, ctx: &Context) -> PathBuf {
ctx.test_path.join(self.get_name())
}
fn generate_package(
&mut self,
ctx: &Context,
Expand Down
3 changes: 3 additions & 0 deletions src/project/spirv_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ impl Project for SpirvTools {
fn get_android_path(&self, ctx: &Context) -> PathBuf {
ctx.android_path.join("external").join(self.get_name())
}
fn get_test_path(&self, ctx: &Context) -> PathBuf {
ctx.test_path.join(self.get_name())
}
fn generate_package(
&mut self,
ctx: &Context,
Expand Down

0 comments on commit 4a7d0d3

Please sign in to comment.