|
@@ -6,6 +6,7 @@ use structopt::StructOpt;
|
|
|
use ar::Archive;
|
|
|
use std::fs::File;
|
|
|
use std::io;
|
|
|
+use std::io::Write;
|
|
|
|
|
|
#[derive(Debug, StructOpt)]
|
|
|
#[structopt(name = "Localize", about = "Localize a static library into a single object archive")]
|
|
@@ -112,8 +113,11 @@ struct PluginEntry
|
|
|
prefix: String,
|
|
|
}
|
|
|
|
|
|
-fn generate_plugin(plugins: &Vec<PluginEntry>, output: &PathBuf)
|
|
|
-{
|
|
|
+fn generate_plugin(
|
|
|
+ plugins: &Vec<PluginEntry>,
|
|
|
+ output_directory: &PathBuf,
|
|
|
+ output: &PathBuf
|
|
|
+) {
|
|
|
|
|
|
let plugins_entries : Vec<String> = plugins
|
|
|
.iter()
|
|
@@ -137,15 +141,15 @@ typedef int (*vlc_plugin_entry) (vlc_set_cb, void *);
|
|
|
{prototypes}
|
|
|
|
|
|
vlc_plugin_entry vlc_plugin_entries[] = {{
|
|
|
- {entries} NULL,
|
|
|
+ {entries} 0,
|
|
|
}};
|
|
|
|
|
|
int vlc_entry(vlc_set_cb func_set, void *opaque)
|
|
|
{{
|
|
|
for(vlc_plugin_entry *entry=vlc_plugin_entries;
|
|
|
- entry != NULL; entry++)
|
|
|
+ entry != 0; entry++)
|
|
|
{{
|
|
|
- int ret = entry(func_set, opaque);
|
|
|
+ int ret = (*entry)(func_set, opaque);
|
|
|
if (ret != 0)
|
|
|
return ret;
|
|
|
}}
|
|
@@ -173,6 +177,15 @@ const char * vlc_entry_api_version()
|
|
|
api_version = "\"4.0.0\"");
|
|
|
|
|
|
println!("Generated:\n{}", sources);
|
|
|
+
|
|
|
+ let mut filename = output_directory.clone();
|
|
|
+ filename.push("main.c");
|
|
|
+
|
|
|
+ let mut file = File::create(filename)
|
|
|
+ .expect("cannot create temporary file");
|
|
|
+
|
|
|
+ file.write(&sources.as_bytes())
|
|
|
+ .expect("cannot write source to temporary file");
|
|
|
}
|
|
|
|
|
|
fn main() {
|
|
@@ -180,8 +193,12 @@ fn main() {
|
|
|
println!("{:?}", opt);
|
|
|
link(opt);
|
|
|
|
|
|
+ let output_dir = fs::canonicalize("./output_dir/")
|
|
|
+ .unwrap();
|
|
|
+
|
|
|
generate_plugin(&vec![
|
|
|
PluginEntry{ prefix: "vlc_video_output_test_truc".into(),
|
|
|
- lib: PathBuf::new() }
|
|
|
- ], &PathBuf::new());
|
|
|
+ lib: PathBuf::new() } ],
|
|
|
+ &output_dir,
|
|
|
+ &PathBuf::new());
|
|
|
}
|