Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@ jobs:
runs-on: macos-latest
env:
RUST_BACKTRACE: "1"
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: setup sccache
uses: mozilla-actions/[email protected]
with:
version: "v0.7.7"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
Expand Down
69 changes: 69 additions & 0 deletions src/build/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,75 @@ fn compile_file(
);
}

match &module.source_type {
SourceType::SourceFile(SourceFile {
interface: Some(Interface { path, .. }),
..
}) => {
// we need to copy the source file to the build directory.
// editor tools expects the source file in lib/bs for finding the current package
// and in lib/ocaml when referencing modules in other packages
let _ = std::fs::copy(
std::path::Path::new(&package.path).join(path),
std::path::Path::new(&package.get_build_path()).join(path),
)
.expect("copying source file failed");

let _ = std::fs::copy(
std::path::Path::new(&package.path).join(path),
std::path::Path::new(&package.get_ocaml_build_path())
.join(std::path::Path::new(path).file_name().unwrap()),
)
.expect("copying source file failed");
}
_ => (),
}
match &module.source_type {
SourceType::SourceFile(SourceFile {
implementation: Implementation { path, .. },
..
}) => {
// we need to copy the source file to the build directory.
// editor tools expects the source file in lib/bs for finding the current package
// and in lib/ocaml when referencing modules in other packages
let _ = std::fs::copy(
std::path::Path::new(&package.path).join(path),
std::path::Path::new(&package.get_build_path()).join(path),
)
.expect("copying source file failed");

let _ = std::fs::copy(
std::path::Path::new(&package.path).join(path),
std::path::Path::new(&package.get_ocaml_build_path())
.join(std::path::Path::new(path).file_name().unwrap()),
)
.expect("copying source file failed");
}
_ => (),
}

// copy js file
match &module.source_type {
SourceType::SourceFile(SourceFile {
implementation: Implementation { path, .. },
..
}) => {
let source = helpers::get_source_file_from_rescript_file(
&std::path::Path::new(&package.path).join(path),
&root_package.config.get_suffix(),
);
let destination = helpers::get_source_file_from_rescript_file(
&std::path::Path::new(&package.get_build_path()).join(path),
&root_package.config.get_suffix(),
);

if source.exists() {
let _ = std::fs::copy(&source, &destination).expect("copying source file failed");
}
}
_ => (),
}

if helpers::contains_ascii_characters(&err) {
if package.is_pinned_dep || package.is_local_dep {
// supress warnings of external deps
Expand Down
7 changes: 7 additions & 0 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,10 @@ pub fn read_file(path: &Path) -> Result<String, std::io::Error> {
file.read_to_string(&mut contents)?;
Ok(contents)
}

pub fn get_source_file_from_rescript_file(path: &Path, suffix: &str) -> PathBuf {
path.with_extension(
// suffix.to_string includes the ., so we need to remove it
&suffix.to_string()[1..],
)
}
2 changes: 1 addition & 1 deletion tests/suffix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fi
# Count files with new extension
file_count=$(find . -name *.res.js | wc -l)

if [ "$file_count" -eq 10 ];
if [ "$file_count" -eq 20 ];
then
success "Found files with correct suffix"
else
Expand Down