Skip to content

Commit ff9c8b7

Browse files
committed
Test emscripten C mode
1 parent 5be36b6 commit ff9c8b7

1 file changed

Lines changed: 1 addition & 31 deletions

File tree

src/lib.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -158,37 +158,7 @@ impl Build {
158158
_ if target.ends_with("emscripten") => {
159159
config
160160
.define("LUA_USE_POSIX", None)
161-
.cpp(true)
162-
.flag("-fexceptions")
163-
.flag("-fwasm-exceptions"); // Enable exceptions to be caught
164-
165-
let cpp_source_dir = out_dir.join("cpp_source");
166-
if cpp_source_dir.exists() {
167-
fs::remove_dir_all(&cpp_source_dir)
168-
.context(|| format!("Cannot remove '{}'", cpp_source_dir.display()))?;
169-
}
170-
fs::create_dir_all(&cpp_source_dir)
171-
.context(|| format!("Cannot create '{}'", cpp_source_dir.display()))?;
172-
173-
for file in fs::read_dir(&source_dir)
174-
.context(|| format!("Cannot read '{}'", source_dir.display()))?
175-
{
176-
let file = file?;
177-
let filename = file.file_name();
178-
let filename = &*filename.to_string_lossy();
179-
let src_file = source_dir.join(file.file_name());
180-
let dst_file = cpp_source_dir.join(file.file_name());
181-
182-
let mut content = fs::read(&src_file)
183-
.context(|| format!("Cannot read '{}'", src_file.display()))?;
184-
if ["lauxlib.h", "lua.h", "lualib.h"].contains(&filename) {
185-
content.splice(0..0, b"extern \"C\" {\n".to_vec());
186-
content.extend(b"\n}".to_vec())
187-
}
188-
fs::write(&dst_file, content)
189-
.context(|| format!("Cannot write to '{}'", dst_file.display()))?;
190-
}
191-
source_dir = cpp_source_dir
161+
.flag("-sSUPPORT_LONGJMP=wasm"); // Enable setjmp/longjmp support (WASM-specific)
192162
}
193163
_ if target.contains("wasi") => {
194164
// WASI is posix-like, but further patches are needed to the Lua

0 commit comments

Comments
 (0)