@@ -17,6 +17,7 @@ pub struct Build {
1717}
1818
1919pub struct Artifacts {
20+ include_dir : PathBuf ,
2021 lib_dir : PathBuf ,
2122 libs : Vec < String > ,
2223}
@@ -50,7 +51,11 @@ impl Build {
5051 let out_dir = self . out_dir . as_ref ( ) . expect ( "OUT_DIR is not set" ) ;
5152 let manifest_dir = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
5253 let mut source_dir = manifest_dir. join ( version. source_dir ( ) ) ;
53- let build_dir = out_dir. join ( "lua-build" ) ;
54+ let include_dir = out_dir. join ( "include" ) ;
55+
56+ if !include_dir. exists ( ) {
57+ fs:: create_dir_all ( & include_dir) . unwrap ( ) ;
58+ }
5459
5560 let mut config = cc:: Build :: new ( ) ;
5661 config. warnings ( false ) . cargo_metadata ( false ) ;
@@ -124,11 +129,16 @@ impl Build {
124129 . flag ( "-w" ) // Suppress all warnings
125130 . flag_if_supported ( "-fno-common" ) // Compile common globals like normal definitions
126131 . add_files_by_ext ( & source_dir, "c" )
127- . out_dir ( & build_dir )
132+ . out_dir ( out_dir )
128133 . compile ( version. lib_name ( ) ) ;
129134
135+ for f in & [ "lauxlib.h" , "lua.h" , "luaconf.h" , "lualib.h" ] {
136+ fs:: copy ( source_dir. join ( f) , include_dir. join ( f) ) . unwrap ( ) ;
137+ }
138+
130139 Artifacts {
131- lib_dir : build_dir,
140+ include_dir,
141+ lib_dir : out_dir. clone ( ) ,
132142 libs : vec ! [ version. lib_name( ) . to_string( ) ] ,
133143 }
134144 }
@@ -155,6 +165,10 @@ impl Version {
155165}
156166
157167impl Artifacts {
168+ pub fn include_dir ( & self ) -> & Path {
169+ & self . include_dir
170+ }
171+
158172 pub fn lib_dir ( & self ) -> & Path {
159173 & self . lib_dir
160174 }
0 commit comments