@@ -2,7 +2,7 @@ use std::env;
22use std:: path:: Path ;
33use std:: process:: Command ;
44
5- fn build_ffmpeg ( dist_dir : & Path ) {
5+ fn build_ffmpeg ( dist_dir : & Path , enable_libnpp : bool ) {
66 if dist_dir. exists ( ) {
77 return ;
88 }
@@ -11,12 +11,13 @@ fn build_ffmpeg(dist_dir: &Path) {
1111 . arg ( Path :: new ( "clean.sh" ) )
1212 . current_dir ( "deps" )
1313 . status ( )
14- . expect ( "Failed to run clean ffmpeg build!" ) ;
14+ . expect ( "Failed to clean ffmpeg build!" ) ;
1515
1616 if !Command :: new ( "bash" )
1717 . arg ( Path :: new ( "build.sh" ) )
1818 . current_dir ( "deps" )
1919 . env ( "DIST" , dist_dir)
20+ . env ( "ENABLE_LIBNPP" , if enable_libnpp { "y" } else { "n" } )
2021 . status ( )
2122 . expect ( "Failed to run bash!" )
2223 . success ( )
@@ -34,8 +35,12 @@ fn main() {
3435 . unwrap ( )
3536 . join ( format ! ( "dist_{}" , target_os) ) ;
3637
38+ let enable_libnpp = env:: var ( "I_AM_BUILDING_THIS_AT_HOME_AND_WANT_LIBNPP" ) . map_or ( false , |v| {
39+ [ "y" , "yes" , "true" , "1" ] . contains ( & v. to_lowercase ( ) . as_str ( ) )
40+ } ) ;
41+
3742 if env:: var ( "CARGO_FEATURE_FFMPEG_SYSTEM" ) . is_err ( ) {
38- build_ffmpeg ( & dist_dir) ;
43+ build_ffmpeg ( & dist_dir, enable_libnpp ) ;
3944 }
4045
4146 println ! ( "cargo:rerun-if-changed=ts/lib.ts" ) ;
@@ -88,6 +93,9 @@ fn main() {
8893 if target_os == "windows" {
8994 cc_video. define ( "HAS_MEDIAFOUNDATION" , None ) ;
9095 }
96+ if enable_libnpp {
97+ cc_video. define ( "HAS_LIBNPP" , None ) ;
98+ }
9199 cc_video. compile ( "video" ) ;
92100
93101 println ! ( "cargo:rerun-if-changed=lib/error.h" ) ;
@@ -115,6 +123,18 @@ fn main() {
115123 println ! ( "cargo:rustc-link-lib={}=avutil" , ffmpeg_link_kind) ;
116124 println ! ( "cargo:rustc-link-lib={}=postproc" , ffmpeg_link_kind) ;
117125 println ! ( "cargo:rustc-link-lib={}=x264" , ffmpeg_link_kind) ;
126+ if enable_libnpp {
127+ if let Ok ( lib_paths) = env:: var ( "LIBRARY_PATH" ) {
128+ for lib_path in lib_paths. split ( ':' ) {
129+ println ! ( "cargo:rustc-link-search={}" , lib_path) ;
130+ }
131+ }
132+ println ! ( "cargo:rustc-link-lib=dylib=nppig" ) ;
133+ println ! ( "cargo:rustc-link-lib=dylib=nppicc" ) ;
134+ println ! ( "cargo:rustc-link-lib=dylib=nppc" ) ;
135+ println ! ( "cargo:rustc-link-lib=dylib=nppidei" ) ;
136+ println ! ( "cargo:rustc-link-lib=dylib=nppif" ) ;
137+ }
118138 if env:: var ( "CARGO_FEATURE_FFMPEG_SYSTEM" ) . is_err ( ) {
119139 println ! (
120140 "cargo:rustc-link-search={}" ,
0 commit comments