Skip to content

Commit b7301dc

Browse files
committed
make it work nicely
1 parent 7f1d01b commit b7301dc

File tree

8 files changed

+26
-27
lines changed

8 files changed

+26
-27
lines changed

src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ pub fn incremental_build(
452452
pub fn write_build_ninja(build_state: &BuildState) {
453453
for package in build_state.packages.values() {
454454
// write empty file:
455-
let mut f = File::create(std::path::Path::new(&package.get_bs_build_path()).join("build.ninja"))
455+
let mut f = File::create(std::path::Path::new(&package.get_build_path()).join("build.ninja"))
456456
.expect("Unable to write file");
457457
f.write_all(b"").expect("unable to write to ninja file");
458458
}

src/build/clean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ pub fn clean(path: &str, show_progress: bool, bsc_path: Option<String>) -> Resul
356356
let path = std::path::Path::new(&path_str);
357357
let _ = std::fs::remove_dir_all(path);
358358

359-
let path_str = package.get_bs_build_path();
359+
let path_str = package.get_ocaml_build_path();
360360
let path = std::path::Path::new(&path_str);
361361
let _ = std::fs::remove_dir_all(path);
362362
});

src/build/compile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,13 +611,13 @@ fn compile_file(
611611
// and in lib/ocaml when referencing modules in other packages
612612
let _ = std::fs::copy(
613613
std::path::Path::new(&package.path).join(path),
614-
std::path::Path::new(&package.get_bs_build_path()).join(path),
614+
std::path::Path::new(&package.get_build_path()).join(path),
615615
)
616616
.expect("copying source file failed");
617617

618618
let _ = std::fs::copy(
619619
std::path::Path::new(&package.path).join(path),
620-
std::path::Path::new(&package.get_bs_build_path())
620+
std::path::Path::new(&package.get_build_path())
621621
.join(std::path::Path::new(path).file_name().unwrap()),
622622
)
623623
.expect("copying source file failed");

src/build/logs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ enum Location {
1616

1717
fn get_log_file_path(package: &packages::Package, subfolder: Location) -> String {
1818
let build_folder = match subfolder {
19-
Location::Bs => package.get_bs_build_path(),
20-
Location::Ocaml => package.get_build_path(),
19+
Location::Bs => package.get_build_path(),
20+
Location::Ocaml => package.get_ocaml_build_path(),
2121
};
2222

2323
build_folder.to_owned() + "/.compiler.log"

src/build/packages.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ pub struct Package {
6363
}
6464

6565
pub fn get_build_path(canonical_path: &str) -> String {
66-
format!("{}/lib/ocaml", canonical_path)
66+
format!("{}/lib/bs", canonical_path)
6767
}
6868

6969
impl Package {
70-
pub fn get_bs_build_path(&self) -> String {
71-
format!("{}/lib/bs", self.path)
70+
pub fn get_ocaml_build_path(&self) -> String {
71+
format!("{}/lib/ocaml", self.path)
7272
}
7373

7474
pub fn get_build_path(&self) -> String {
@@ -553,13 +553,14 @@ pub fn make(
553553
* the IO */
554554
let result = extend_with_children(filter, map);
555555

556-
result.values().for_each(|package| {
557-
if let Some(dirs) = &package.dirs {
558-
dirs.iter().for_each(|dir| {
559-
let _ = std::fs::create_dir_all(std::path::Path::new(&package.get_bs_build_path()).join(dir));
560-
})
561-
}
562-
});
556+
// not necessary anymore because we create the dirs in parse
557+
// result.values().for_each(|package| {
558+
// if let Some(dirs) = &package.dirs {
559+
// dirs.iter().for_each(|dir| {
560+
// let _ = std::fs::create_dir_all(std::path::Path::new(&package.get_bs_build_path()).join(dir));
561+
// })
562+
// }
563+
// });
563564

564565
Ok(result)
565566
}
@@ -581,7 +582,7 @@ pub fn parse_packages(build_state: &mut BuildState) {
581582
build_state.module_names.extend(package_modules)
582583
}
583584
let build_path_abs = package.get_build_path();
584-
let bs_build_path = package.get_bs_build_path();
585+
let bs_build_path = package.get_ocaml_build_path();
585586
helpers::create_build_path(&build_path_abs);
586587
helpers::create_build_path(&bs_build_path);
587588

src/build/parse.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,24 +218,23 @@ pub fn generate_asts(
218218
.namespace
219219
.to_suffix()
220220
.expect("namespace should be set for mlmap module");
221-
// copy the mlmap to the bs build path for editor tooling
222221
let base_build_path = package.get_build_path() + "/" + &suffix;
223-
let base_bs_build_path = package.get_bs_build_path() + "/" + &suffix;
222+
let base_ocaml_build_path = package.get_ocaml_build_path() + "/" + &suffix;
224223
let _ = std::fs::copy(
225224
base_build_path.to_string() + ".cmi",
226-
base_bs_build_path.to_string() + ".cmi",
225+
base_ocaml_build_path.to_string() + ".cmi",
227226
);
228227
let _ = std::fs::copy(
229228
base_build_path.to_string() + ".cmt",
230-
base_bs_build_path.to_string() + ".cmt",
229+
base_ocaml_build_path.to_string() + ".cmt",
231230
);
232231
let _ = std::fs::copy(
233232
base_build_path.to_string() + ".cmj",
234-
base_bs_build_path.to_string() + ".cmj",
233+
base_ocaml_build_path.to_string() + ".cmj",
235234
);
236235
let _ = std::fs::copy(
237236
base_build_path.to_string() + ".mlmap",
238-
base_bs_build_path.to_string() + ".mlmap",
237+
base_ocaml_build_path.to_string() + ".mlmap",
239238
);
240239
match (mlmap_hash, mlmap_hash_after) {
241240
(Some(digest), Some(digest_after)) => !digest.eq(&digest_after),
@@ -367,7 +366,6 @@ fn generate_ast(
367366
))
368367
};
369368
if let Ok((ast_path, _)) = &result {
370-
// let dir = std::path::Path::new(filename).parent().unwrap();
371369
let _ = std::fs::copy(
372370
Path::new(&build_path_abs).join(&ast_path),
373371
std::path::Path::new(&package.get_build_path()).join(ast_path.file_name().unwrap()),

src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub fn get_bs_compiler_asset(
236236

237237
let dir = std::path::Path::new(&source_file).parent().unwrap();
238238

239-
std::path::Path::new(&package.get_bs_build_path())
239+
std::path::Path::new(&package.get_build_path())
240240
.join(dir)
241241
.join(file_path_to_compiler_asset_basename(source_file, namespace) + extension)
242242
.to_str()

src/sourcedirs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub fn print(buildstate: &BuildState) {
8585

8686
// Write sourcedirs.json
8787
write_sourcedirs_files(
88-
package.get_bs_build_path(),
88+
package.get_build_path(),
8989
&SourceDirs {
9090
dirs: &dirs.clone().into_iter().collect::<Vec<Dir>>(),
9191
pkgs: &pkgs.clone().flatten().collect::<Vec<Pkg>>(),
@@ -109,7 +109,7 @@ pub fn print(buildstate: &BuildState) {
109109

110110
// Write sourcedirs.json
111111
write_sourcedirs_files(
112-
root_package.get_bs_build_path(),
112+
root_package.get_build_path(),
113113
&SourceDirs {
114114
dirs: &merged_dirs.into_iter().collect::<Vec<Dir>>(),
115115
pkgs: &merged_pkgs.into_iter().collect::<Vec<Pkg>>(),

0 commit comments

Comments
 (0)