Skip to content

Commit 068e195

Browse files
committed
fix headers not being copied properly to package
1 parent 3cfd327 commit 068e195

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/package.rs

+24-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub enum Package {
3636
root_path: PathBuf,
3737

3838
/// Add binary file
39-
#[clap(short, long, num_args(0..))]
39+
#[clap(short, long, num_args(1..))]
4040
binary: Vec<PathBuf>,
4141

4242
/// Location of output file
@@ -333,8 +333,10 @@ fn create_package(
333333
// Copy headers
334334
if let Some(ref api) = mod_file_info.api {
335335
for header in &api.include {
336-
fs::copy(root_path.join(&header), working_dir.join(header))
337-
.expect("Unable to copy headers");
336+
let out = working_dir.join(header.strip_prefix(&root_path).unwrap_or(header));
337+
out.parent().map(fs::create_dir_all);
338+
fs::copy(root_path.join(&header), &out)
339+
.expect(&format!("Unable to copy header {} to {}", header.to_string_lossy(), out.display()));
338340
}
339341
}
340342

@@ -345,8 +347,6 @@ fn create_package(
345347
binary_name = mod_file_info.id.to_string() + ext;
346348
}
347349

348-
println!("name {}", binary_name);
349-
350350
std::fs::copy(binary, working_dir.join(binary_name))
351351
.expect(&format!("Unable to copy binary at '{}'", binary.display()));
352352
}
@@ -538,6 +538,23 @@ fn find_dependency(
538538
fn setup(config: &Config, input: PathBuf, output: PathBuf, externals: Vec<String>) {
539539
let mod_info = parse_mod_info(&input);
540540

541+
// if let Some(ref api) = mod_info.api {
542+
// // copy headers elsewhere because they are still used by the build tool
543+
// // when package new
544+
// let api_dir = output.join(format!("{}.geode_build", mod_info.id));
545+
// if api_dir.exists() {
546+
// fs::remove_dir_all(&api_dir).expect("Unable to clear directory for mod headers");
547+
// }
548+
// fs::create_dir_all(&api_dir).expect("Unable to create directory for mod headers");
549+
550+
// for header in &api.include {
551+
// let out = api_dir.join(header);
552+
// out.parent().map(fs::create_dir_all);
553+
// fs::copy(input.join(&header), out)
554+
// .expect(&format!("Unable to copy header {}", header.to_string_lossy()));
555+
// }
556+
// }
557+
541558
// If no dependencies, skippy wippy
542559
if mod_info.dependencies.is_empty() {
543560
return;
@@ -697,7 +714,7 @@ fn setup(config: &Config, input: PathBuf, output: PathBuf, externals: Vec<String
697714

698715
let path_to_dep_geode;
699716
let geode_info;
700-
match (found_in_index, found_in_installed) {
717+
match (found_in_installed, found_in_index) {
701718
(Found::Some(inst_path, inst_info), Found::Some(_, _)) => {
702719
info!("Dependency '{}' found", dep.id);
703720
path_to_dep_geode = inst_path;
@@ -754,7 +771,7 @@ fn setup(config: &Config, input: PathBuf, output: PathBuf, externals: Vec<String
754771
);
755772
path_to_dep_geode = install_mod(
756773
config, &indx_info.id,
757-
&VersionReq::parse(&format!("=={}", indx_info.version.to_string())).unwrap()
774+
&VersionReq::parse(&format!("={}", indx_info.version.to_string())).unwrap()
758775
);
759776
geode_info = indx_info;
760777
}

0 commit comments

Comments
 (0)