@@ -2,64 +2,114 @@ extern crate cc;
22use std:: fs;
33use std:: process:: { Command , Stdio } ;
44
5+ fn build_win_msvc ( ) {
6+ cc:: Build :: new ( )
7+ . cpp ( true )
8+ . flag ( "-Zi" )
9+ . flag ( "-Gm" )
10+ . flag ( "-INCREMENTAL" )
11+ . warnings ( false )
12+ . define ( "WIN32" , None )
13+ . include ( "./src" )
14+ . include ( "./src/osg" )
15+ . file ( "./src/tileset.cpp" )
16+ . file ( "./src/shp23dtile.cpp" )
17+ . file ( "./src/osgb23dtile.cpp" )
18+ . compile ( "3dtile" ) ;
19+ // -------------
20+ println ! ( "cargo:rustc-link-search=native=./lib" ) ;
21+ // -------------
22+ println ! ( "cargo:rustc-link-lib=gdal_i" ) ;
23+ println ! ( "cargo:rustc-link-lib=osg" ) ;
24+ println ! ( "cargo:rustc-link-lib=osgDB" ) ;
25+ println ! ( "cargo:rustc-link-lib=osgUtil" ) ;
26+
27+ Command :: new ( "cmd" )
28+ . args (
29+ & [ "/C" , "xcopy" , r#".\bin"# , r#".\target\debug"# , "/y" , "/e" ] ,
30+ )
31+ . stdout ( Stdio :: inherit ( ) )
32+ . output ( )
33+ . unwrap ( ) ;
34+ Command :: new ( "cmd" )
35+ . args (
36+ & [ "/C" , "xcopy" , r#".\bin"# , r#".\target\release"# , "/y" , "/e" ] ,
37+ )
38+ . stdout ( Stdio :: inherit ( ) )
39+ . output ( )
40+ . unwrap ( ) ;
41+ }
42+
43+ fn build_win_gun ( ) {
44+ cc:: Build :: new ( )
45+ . cpp ( true )
46+ . flag ( "-std=c++11" )
47+ . warnings ( false )
48+ . define ( "WIN32" , None )
49+ . include ( "./src" )
50+ . include ( "./src/osg" )
51+ . file ( "./src/tileset.cpp" )
52+ . file ( "./src/shp23dtile.cpp" )
53+ . file ( "./src/osgb23dtile.cpp" )
54+ . compile ( "3dtile" ) ;
55+ // -------------
56+ println ! ( "cargo:rustc-link-search=native=./lib" ) ;
57+ // -------------
58+ println ! ( "cargo:rustc-link-lib=gdal_i" ) ;
59+ println ! ( "cargo:rustc-link-lib=osg" ) ;
60+ println ! ( "cargo:rustc-link-lib=osgDB" ) ;
61+ println ! ( "cargo:rustc-link-lib=osgUtil" ) ;
62+ println ! ( "cargo:rustc-link-lib=OpenThreads" ) ;
63+
64+ Command :: new ( "cmd" )
65+ . args (
66+ & [ "/C" , "xcopy" , r#".\bin"# , r#".\target\debug"# , "/y" , "/e" ] ,
67+ )
68+ . stdout ( Stdio :: inherit ( ) )
69+ . output ( )
70+ . unwrap ( ) ;
71+ Command :: new ( "cmd" )
72+ . args (
73+ & [ "/C" , "xcopy" , r#".\bin"# , r#".\target\release"# , "/y" , "/e" ] ,
74+ )
75+ . stdout ( Stdio :: inherit ( ) )
76+ . output ( )
77+ . unwrap ( ) ;
78+ }
79+
80+ fn build_linux_unkonw ( ) {
81+ cc:: Build :: new ( )
82+ . cpp ( true )
83+ . flag ( "-std=c++11" )
84+ . warnings ( false )
85+ . include ( "./src" )
86+ . include ( "./src/osg" )
87+ . file ( "./src/tileset.cpp" )
88+ . file ( "./src/osgb23dtile.cpp" )
89+ . compile ( "3dtile" ) ;
90+ // -------------
91+ println ! ( "cargo:rustc-link-search=native=./lib" ) ;
92+ // -------------
93+ // println!("cargo:rustc-link-lib=gdal");
94+ println ! ( "cargo:rustc-link-lib=OpenThreads" ) ;
95+ println ! ( "cargo:rustc-link-lib=osg" ) ;
96+ println ! ( "cargo:rustc-link-lib=osgDB" ) ;
97+ println ! ( "cargo:rustc-link-lib=osgUtil" ) ;
98+ }
99+
5100fn main ( ) {
6101 fs:: create_dir_all ( "target/debug" ) . unwrap ( ) ;
7102 fs:: create_dir_all ( "target/release" ) . unwrap ( ) ;
8-
9- if cfg ! ( windows) {
10- cc:: Build :: new ( )
11- . cpp ( true )
12- . flag ( "-Zi" )
13- . flag ( "-Gm" )
14- . flag ( "-INCREMENTAL" )
15- . warnings ( false )
16- . define ( "WIN32" , None )
17- . include ( "./src" )
18- . include ( "./src/osg" )
19- . file ( "./src/tileset.cpp" )
20- . file ( "./src/shp23dtile.cpp" )
21- . file ( "./src/osgb23dtile.cpp" )
22- . compile ( "3dtile" ) ;
23- // -------------
24- println ! ( "cargo:rustc-link-search=native=./lib" ) ;
25- // -------------
26- println ! ( "cargo:rustc-link-lib=gdal_i" ) ;
27- println ! ( "cargo:rustc-link-lib=osg" ) ;
28- println ! ( "cargo:rustc-link-lib=osgDB" ) ;
29- println ! ( "cargo:rustc-link-lib=osgUtil" ) ;
30-
31- Command :: new ( "cmd" )
32- . args (
33- & [ "/C" , "xcopy" , r#".\bin"# , r#".\target\debug"# , "/y" , "/e" ] ,
34- )
35- . stdout ( Stdio :: inherit ( ) )
36- . output ( )
37- . unwrap ( ) ;
38- Command :: new ( "cmd" )
39- . args (
40- & [ "/C" , "xcopy" , r#".\bin"# , r#".\target\release"# , "/y" , "/e" ] ,
41- )
42- . stdout ( Stdio :: inherit ( ) )
43- . output ( )
44- . unwrap ( ) ;
45- } else {
46- cc:: Build :: new ( )
47- . cpp ( true )
48- . flag ( "-std=c++11" )
49- . warnings ( false )
50- . include ( "./src" )
51- . include ( "./src/osg" )
52- . file ( "./src/tileset.cpp" )
53- // .file("./src/shp23dtile.cpp")
54- . file ( "./src/osgb23dtile.cpp" )
55- . compile ( "3dtile" ) ;
56- // -------------
57- println ! ( "cargo:rustc-link-search=native=./lib" ) ;
58- // -------------
59- // println!("cargo:rustc-link-lib=gdal");
60- println ! ( "cargo:rustc-link-lib=OpenThreads" ) ;
61- println ! ( "cargo:rustc-link-lib=osg" ) ;
62- println ! ( "cargo:rustc-link-lib=osgDB" ) ;
63- println ! ( "cargo:rustc-link-lib=osgUtil" ) ;
103+ use std:: env;
104+ match env:: var ( "TARGET" ) {
105+ Ok ( val) => {
106+ match val. as_str ( ) {
107+ "x86_64-pc-windows-gnu" => build_win_gun ( ) ,
108+ "x86_64-unknown-linux-gnu" => build_linux_unkonw ( ) ,
109+ "x86_64-pc-windows-msvc" => build_win_msvc ( ) ,
110+ & _ => { }
111+ }
112+ }
113+ _ => { }
64114 }
65115}
0 commit comments