Merge pull request #2183 from joelspadin/fix-windows-build-wasm

fix: use / paths in docker when building WASM on Windows
This commit is contained in:
Andrew Hlynskyi 2023-04-10 09:33:55 +03:00 committed by GitHub
commit 9f7166790e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 5 deletions

7
Cargo.lock generated
View file

@ -440,6 +440,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "path-slash"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42"
[[package]]
name = "percent-encoding"
version = "2.2.0"
@ -774,6 +780,7 @@ dependencies = [
"indexmap",
"lazy_static",
"log",
"path-slash",
"pretty_assertions",
"rand",
"regex",

View file

@ -30,6 +30,7 @@ glob = "0.3.0"
html-escape = "0.2.6"
indexmap = "1"
lazy_static = "1.2.0"
path-slash = "0.2.1"
regex = "1"
regex-syntax = "0.6.4"
rustc-hash = "1"

View file

@ -1,5 +1,6 @@
use super::generate::parse_grammar::GrammarJSON;
use anyhow::{anyhow, Context, Result};
use path_slash::PathExt as _;
use std::ffi::{OsStr, OsString};
use std::fs;
use std::path::Path;
@ -41,7 +42,7 @@ pub fn compile_language_to_wasm(language_dir: &Path, force_docker: bool) -> Resu
volume_string = OsString::from(parent);
volume_string.push(":/src:Z");
command.arg("--workdir");
command.arg(&Path::new("/src").join(filename));
command.arg(Path::new("/src").join(filename).to_slash_lossy().as_ref());
} else {
volume_string = OsString::from(language_dir);
volume_string.push(":/src:Z");
@ -103,14 +104,18 @@ pub fn compile_language_to_wasm(language_dir: &Path, force_docker: bool) -> Resu
let scanner_cpp_path = src.join("scanner.cpp");
if language_dir.join(&scanner_cc_path).exists() {
command.arg("-xc++").arg(&scanner_cc_path);
command
.arg("-xc++")
.arg(scanner_cc_path.to_slash_lossy().as_ref());
} else if language_dir.join(&scanner_cpp_path).exists() {
command.arg("-xc++").arg(&scanner_cpp_path);
command
.arg("-xc++")
.arg(scanner_cpp_path.to_slash_lossy().as_ref());
} else if language_dir.join(&scanner_c_path).exists() {
command.arg(&scanner_c_path);
command.arg(scanner_c_path.to_slash_lossy().as_ref());
}
command.arg(&parser_c_path);
command.arg(parser_c_path.to_slash_lossy().as_ref());
let output = command
.output()