@@ -17,8 +17,13 @@ fn main() {
1717 println ! ( "cargo:rerun-if-env-changed=TA_LIBRARY_PATH" ) ;
1818 println ! ( "cargo:rerun-if-env-changed=DEPS_PATH" ) ;
1919
20- // Only build if TA lib is not already installed
20+ // Always build TA lib from source to ensure it's available
2121 let deps_path = env:: var ( "DEPS_PATH" ) . unwrap_or_else ( |_| "dependencies" . to_string ( ) ) ;
22+
23+ // Create dependencies directory structure
24+ std:: fs:: create_dir_all ( format ! ( "{}/lib" , deps_path) ) . expect ( "Failed to create lib directory" ) ;
25+ std:: fs:: create_dir_all ( format ! ( "{}/include" , deps_path) ) . expect ( "Failed to create include directory" ) ;
26+
2227 let lib_file = if target_os == "windows" {
2328 format ! ( "{}/lib/ta_lib.lib" , deps_path)
2429 } else {
@@ -31,8 +36,14 @@ fn main() {
3136 }
3237
3338 println ! ( "cargo:rustc-link-lib=static=ta_lib" ) ;
34- println ! ( "cargo:rustc-link-search=native={ta_library_path}" ) ;
35- println ! ( "cargo:rustc-link-search=native=../dependencies/lib" ) ;
39+ println ! ( "cargo:rustc-link-search=native={}" , ta_library_path) ;
40+ println ! ( "cargo:rustc-link-search=native={}/lib" , deps_path) ;
41+
42+ // Add additional search paths for system-installed ta-lib
43+ if target_os != "windows" {
44+ println ! ( "cargo:rustc-link-search=native=/usr/local/lib" ) ;
45+ println ! ( "cargo:rustc-link-search=native=/usr/lib" ) ;
46+ }
3647 // let cb = ParseCallbacks::add_derives();
3748 let mut bindings_builder = bindgen:: Builder :: default ( )
3849 // The input header we would like to generate
@@ -42,9 +53,11 @@ fn main() {
4253 . clang_arg ( "-I../dependencies/include" )
4354 . clang_arg ( "-v" ) ;
4455
45- // Only add --no-size_t-is-usize for cross-compilation targets that need it
56+ // Add target-specific bindgen flags
4657 if target_arch == "aarch64" && target_os == "linux" {
47- bindings_builder = bindings_builder. clang_arg ( "--no-size_t-is-usize" ) ;
58+ // Only add this flag for Linux ARM cross-compilation if bindgen supports it
59+ // Skip if it causes issues
60+ println ! ( "cargo:warning=Skipping --no-size_t-is-usize for Linux ARM build" ) ;
4861 }
4962
5063 let bindings = bindings_builder
@@ -133,9 +146,22 @@ fn build_windows_talib(src_dir: &str, deps_path: &str, current_dir: &PathBuf) {
133146 std:: fs:: create_dir_all ( & lib_dir) . expect ( "Failed to create lib directory" ) ;
134147 std:: fs:: create_dir_all ( & include_dir) . expect ( "Failed to create include directory" ) ;
135148
136- // Copy headers
137- let headers_src = format ! ( "{}/src/include" , extract_dir) ;
138- copy_dir_recursive ( & headers_src, & include_dir) . expect ( "Failed to copy headers" ) ;
149+ // Copy headers - try multiple possible locations
150+ let mut headers_copied = false ;
151+ for headers_path in [
152+ format ! ( "{}/src/include" , extract_dir) ,
153+ format ! ( "{}/include" , extract_dir) ,
154+ format ! ( "{}/ta-lib/include" , extract_dir) ,
155+ ] {
156+ if std:: path:: Path :: new ( & headers_path) . exists ( ) {
157+ copy_dir_recursive ( & headers_path, & include_dir) . expect ( "Failed to copy headers" ) ;
158+ headers_copied = true ;
159+ break ;
160+ }
161+ }
162+ if !headers_copied {
163+ panic ! ( "Could not find Ta-Lib headers in any expected location" ) ;
164+ }
139165
140166 // Build the library using nmake
141167 env:: set_current_dir ( & extract_dir) . expect ( "Failed to change to ta-lib directory" ) ;
0 commit comments