Skip to content

Commit 676ae1c

Browse files
logist322alexlapa
andauthored
Fix OpenAL build (#126)
- build OpenAL in release mode - build OpenAL as universal lib with both x64 and arm64 arches for MacOS Co-authored-by: alexlapa <[email protected]>
1 parent b1d6edc commit 676ae1c

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

crates/libwebrtc-sys/build.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ fn get_path_to_openal() -> anyhow::Result<PathBuf> {
190190
/// Downloads and compiles OpenAL dynamic library.
191191
///
192192
/// Copies OpenAL headers and compiled library to the required locations.
193+
#[allow(clippy::too_many_lines)]
193194
fn compile_openal() -> anyhow::Result<()> {
194195
let openal_version = OPENAL_URL.split('/').last().unwrap();
195196
let manifest_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
@@ -249,18 +250,20 @@ fn compile_openal() -> anyhow::Result<()> {
249250
)
250251
.unwrap();
251252

253+
let mut cmake_cmd = Command::new("cmake");
254+
cmake_cmd.current_dir(&openal_src_path).args([
255+
".",
256+
".",
257+
"-DCMAKE_BUILD_TYPE=Release",
258+
]);
259+
#[cfg(target_os = "macos")]
260+
cmake_cmd.arg("-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64");
261+
drop(cmake_cmd.output()?);
262+
252263
drop(
253264
Command::new("cmake")
254265
.current_dir(&openal_src_path)
255-
.arg(".")
256-
.arg(".")
257-
.output()?,
258-
);
259-
drop(
260-
Command::new("cmake")
261-
.current_dir(&openal_src_path)
262-
.arg("--build")
263-
.arg(".")
266+
.args(["--build", ".", "--config", "Release"])
264267
.output()?,
265268
);
266269

@@ -285,19 +288,22 @@ fn compile_openal() -> anyhow::Result<()> {
285288
}
286289
"x86_64-pc-windows-msvc" => {
287290
fs::copy(
288-
openal_src_path.join("Debug").join("OpenAL32.dll"),
291+
openal_src_path.join("Release").join("OpenAL32.dll"),
289292
openal_path.join("OpenAL32.dll"),
290293
)?;
291294
fs::copy(
292-
openal_src_path.join("Debug").join("OpenAL32.lib"),
295+
openal_src_path.join("Release").join("OpenAL32.lib"),
293296
openal_path.join("OpenAL32.lib"),
294297
)?;
295298
let path = manifest_path
296299
.join("lib")
297300
.join(get_target()?.as_str())
298301
.join("release")
299302
.join("OpenAL32.lib");
300-
fs::copy(openal_src_path.join("Debug").join("OpenAL32.lib"), path)?;
303+
fs::copy(
304+
openal_src_path.join("Release").join("OpenAL32.lib"),
305+
path,
306+
)?;
301307
}
302308
_ => (),
303309
}

0 commit comments

Comments
 (0)