@@ -21,8 +21,6 @@ use ark_ff::{BigInt, PrimeField, Zero};
2121use num_bigint:: BigUint ;
2222use std:: fs;
2323use std:: path:: PathBuf ;
24- use std:: process:: Command ;
25- use std:: string:: String ;
2624
2725macro_rules! write_constant_array {
2826 ( $data: expr, $name: expr, $values: expr, $size: expr) => {
@@ -36,108 +34,6 @@ macro_rules! write_constant_array {
3634 } ;
3735}
3836
39- /// Get the shader directory path using CARGO_MANIFEST_DIR for proper OS file location
40- /// This function provides robust path resolution that works across different build environments
41- pub fn get_shader_dir ( ) -> PathBuf {
42- let manifest_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
43- let shader_path = manifest_dir
44- . join ( "src" )
45- . join ( "msm" )
46- . join ( "metal_msm" )
47- . join ( "shader" ) ;
48-
49- // Verify the path exists, if not try alternative locations
50- if shader_path. exists ( ) {
51- shader_path
52- } else {
53- // Fallback: try relative path from workspace root
54- let workspace_shader_path = manifest_dir
55- . parent ( ) // go up one level from mopro-msm to workspace root
56- . unwrap_or ( & manifest_dir)
57- . join ( "mopro-msm" )
58- . join ( "src" )
59- . join ( "msm" )
60- . join ( "metal_msm" )
61- . join ( "shader" ) ;
62-
63- if workspace_shader_path. exists ( ) {
64- workspace_shader_path
65- } else {
66- // Final fallback: use the original path and let error handling take care of it
67- shader_path
68- }
69- }
70- }
71-
72- pub fn compile_metal ( path_from_cargo_manifest_dir : & str , input_filename : & str ) -> String {
73- let input_path = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) )
74- . join ( path_from_cargo_manifest_dir)
75- . join ( input_filename) ;
76- let c = input_path. clone ( ) . into_os_string ( ) . into_string ( ) . unwrap ( ) ;
77-
78- let lib = input_path. clone ( ) . into_os_string ( ) . into_string ( ) . unwrap ( ) ;
79- let lib = format ! ( "{}.lib" , lib) ;
80-
81- let exe = if cfg ! ( target_os = "ios" ) {
82- Command :: new ( "xcrun" )
83- . args ( [
84- "-sdk" ,
85- "iphoneos" ,
86- "metal" ,
87- "-std=metal3.2" ,
88- "-target" ,
89- "air64-apple-ios18.0" ,
90- "-fmetal-enable-logging" ,
91- "-o" ,
92- lib. as_str ( ) ,
93- c. as_str ( ) ,
94- ] )
95- . output ( )
96- . expect ( "failed to compile" )
97- } else if cfg ! ( target_os = "macos" ) {
98- let macos_version = std:: process:: Command :: new ( "sw_vers" )
99- . args ( [ "-productVersion" ] )
100- . output ( )
101- . ok ( )
102- . and_then ( |output| String :: from_utf8 ( output. stdout ) . ok ( ) )
103- . and_then ( |version| {
104- version
105- . trim ( )
106- . split ( '.' )
107- . next ( )
108- . and_then ( |major| major. parse :: < u32 > ( ) . ok ( ) )
109- } )
110- . unwrap_or ( 0 ) ;
111-
112- let mut args = vec ! [ "-sdk" , "macosx" , "metal" ] ;
113-
114- // Only specify Metal 3.2 for metal logging if macOS version is 15.0 or higher
115- if macos_version >= 15 {
116- args. extend ( [
117- "-std=metal3.2" ,
118- "-target" ,
119- "air64-apple-macos15.0" ,
120- "-fmetal-enable-logging" ,
121- ] ) ;
122- }
123-
124- args. extend ( [ "-o" , lib. as_str ( ) , c. as_str ( ) ] ) ;
125-
126- Command :: new ( "xcrun" )
127- . args ( args)
128- . output ( )
129- . expect ( "failed to compile" )
130- } else {
131- panic ! ( "Unsupported architecture" ) ;
132- } ;
133-
134- if exe. stderr . len ( ) != 0 {
135- panic ! ( "{}" , String :: from_utf8( exe. stderr) . unwrap( ) ) ;
136- }
137-
138- lib
139- }
140-
14137pub fn write_constants (
14238 filepath : & str ,
14339 num_limbs : usize ,
@@ -293,16 +189,6 @@ pub fn write_constants(
293189pub mod tests {
294190 use super :: * ;
295191
296- #[ test]
297- #[ serial_test:: serial]
298- pub fn test_compile ( ) {
299- let lib_filepath = compile_metal (
300- "../mopro-msm/src/msm/metal_msm/shader" ,
301- "bigint/bigint_add_unsafe.metal" ,
302- ) ;
303- println ! ( "{}" , lib_filepath) ;
304- }
305-
306192 #[ test]
307193 #[ serial_test:: serial]
308194 pub fn test_write_constants ( ) {
0 commit comments