@@ -18,41 +18,53 @@ struct Dirs {
1818}
1919
2020fn main ( ) -> std:: io:: Result < ( ) > {
21- const BROWSER_ROOT : & str = "../browser/" ;
22- let dirs: Dirs = {
23- Dirs {
24- js_dist_source : PathBuf :: from ( "../browser/data-browser/dist" ) ,
25- js_dist_tmp : PathBuf :: from ( "./assets_tmp" ) ,
26- src_browser : PathBuf :: from ( "../browser/data-browser/src" ) ,
27- browser_root : PathBuf :: from ( BROWSER_ROOT ) ,
28- }
29- } ;
30- println ! ( "cargo:rerun-if-changed={}" , BROWSER_ROOT ) ;
21+ // Check if we're likely running in a check-like context
22+ let opt_level = std:: env:: var ( "OPT_LEVEL" ) . unwrap_or_else ( |_| "0" . to_string ( ) ) ;
23+ let profile = std:: env:: var ( "PROFILE" ) . unwrap_or_else ( |_| "release" . to_string ( ) ) ;
24+
25+ let is_check_like = profile == "debug" && opt_level == "0" ;
3126
32- if should_build ( & dirs) {
33- build_js ( & dirs) ;
34- let _ = fs:: remove_dir_all ( & dirs. js_dist_tmp ) ;
35- dircpy:: copy_dir ( & dirs. js_dist_source , & dirs. js_dist_tmp ) ?;
36- } else if dirs. js_dist_tmp . exists ( ) {
37- p ! ( "Found {}, skipping copy" , dirs. js_dist_tmp. display( ) ) ;
27+ if is_check_like {
28+ println ! ( "cargo:rerun-if-changed=build.rs" ) ;
29+ // Skip the heavy logic
30+ println ! ( "Skipping build.rs logic for cargo check/clippy." ) ;
3831 } else {
39- p ! (
40- "Could not find {} , copying from {}" ,
41- dirs. js_dist_tmp. display( ) ,
42- dirs. js_dist_source. display( )
43- ) ;
44- dircpy:: copy_dir ( & dirs. js_dist_source , & dirs. js_dist_tmp ) ?;
45- }
32+ const BROWSER_ROOT : & str = "../browser/" ;
33+ println ! ( "cargo:rerun-if-changed={}" , BROWSER_ROOT ) ;
34+ let dirs: Dirs = {
35+ Dirs {
36+ js_dist_source : PathBuf :: from ( "../browser/data-browser/dist" ) ,
37+ js_dist_tmp : PathBuf :: from ( "./assets_tmp" ) ,
38+ src_browser : PathBuf :: from ( "../browser/data-browser/src" ) ,
39+ browser_root : PathBuf :: from ( BROWSER_ROOT ) ,
40+ }
41+ } ;
42+ //
43+ if should_build ( & dirs) {
44+ build_js ( & dirs) ;
45+ let _ = fs:: remove_dir_all ( & dirs. js_dist_tmp ) ;
46+ dircpy:: copy_dir ( & dirs. js_dist_source , & dirs. js_dist_tmp ) ?;
47+ } else if dirs. js_dist_tmp . exists ( ) {
48+ p ! ( "Found {}, skipping copy" , dirs. js_dist_tmp. display( ) ) ;
49+ } else {
50+ p ! (
51+ "Could not find {} , copying from {}" ,
52+ dirs. js_dist_tmp. display( ) ,
53+ dirs. js_dist_source. display( )
54+ ) ;
55+ dircpy:: copy_dir ( & dirs. js_dist_source , & dirs. js_dist_tmp ) ?;
56+ }
4657
47- // Makes the static files available for compilation
48- static_files:: resource_dir ( & dirs. js_dist_tmp )
49- . build ( )
50- . unwrap_or_else ( |_e| {
51- panic ! (
52- "failed to open data browser assets from {}" ,
53- dirs. js_dist_tmp. display( )
54- )
55- } ) ;
58+ // Makes the static files available for compilation
59+ static_files:: resource_dir ( & dirs. js_dist_tmp )
60+ . build ( )
61+ . unwrap_or_else ( |_e| {
62+ panic ! (
63+ "failed to open data browser assets from {}" ,
64+ dirs. js_dist_tmp. display( )
65+ )
66+ } ) ;
67+ }
5668
5769 Ok ( ( ) )
5870}
0 commit comments