Skip to content

Commit b18d699

Browse files
emir-signalPehrsons
authored andcommitted
Provide the ability to prevent usage of private APIs in the rust coreaudio backend
For more information see: mozilla/cubeb-coreaudio-rs#283
1 parent 7e6ad0c commit b18d699

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ option(BUNDLE_SPEEX "Bundle the speex library" OFF)
1414
option(LAZY_LOAD_LIBS "Lazily load shared libraries" ON)
1515
option(USE_SANITIZERS "Use sanitizers" ON)
1616
option(USE_STATIC_MSVC_RUNTIME "Use /MT instead of /MD in MSVC" OFF)
17+
option(NO_PRIVATE_APIS_IN_COREAUDIO, "Do not include features that rely on private APIs in the coreaudio rust backend" OFF)
1718
if(USE_STATIC_MSVC_RUNTIME)
1819
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
1920
endif()
@@ -73,9 +74,16 @@ if (BUILD_RUST_LIBS)
7374
endif()
7475
if(EXISTS "${PROJECT_SOURCE_DIR}/src/cubeb-coreaudio-rs")
7576
set(USE_AUDIOUNIT_RUST 1)
77+
if(NO_PRIVATE_APIS_IN_COREAUDIO)
78+
set(DISABLE_PRIVATE_APIS_IN_COREAUDIO 1)
79+
endif()
7680
endif()
7781
endif()
7882

83+
if(NO_PRIVATE_APIS_IN_COREAUDIO AND NOT DISABLE_PRIVATE_APIS_IN_COREAUDIO)
84+
message(WARNING "NO_PRIVATE_APIS_IN_COREAUDIO is not applicable for this configuration.")
85+
endif()
86+
7987
# On OS/2, visibility attribute is not supported.
8088
if(NOT OS2)
8189
set(CMAKE_C_VISIBILITY_PRESET hidden)
@@ -385,13 +393,16 @@ if(USE_PULSE AND USE_PULSE_RUST)
385393
endif()
386394

387395
if(USE_AUDIOUNIT AND USE_AUDIOUNIT_RUST)
396+
if(DISABLE_PRIVATE_APIS_IN_COREAUDIO)
397+
set(FEATURE_NO_PRIVATE_APIS_TOGGLE "--features=no-private-apis")
398+
endif()
388399
include(ExternalProject)
389400
set_directory_properties(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/rust)
390401
ExternalProject_Add(
391402
cubeb_coreaudio_rs
392403
DOWNLOAD_COMMAND ""
393404
CONFIGURE_COMMAND ""
394-
BUILD_COMMAND cargo build --features=gecko-in-tree "$<IF:$<CONFIG:Release,RelWithDebInfo,MinSizeRel>,--release,>"
405+
BUILD_COMMAND cargo build --features=gecko-in-tree "$<IF:$<CONFIG:Release,RelWithDebInfo,MinSizeRel>,--release,>" "${FEATURE_NO_PRIVATE_APIS_TOGGLE}"
395406
BUILD_ALWAYS ON
396407
BINARY_DIR "${PROJECT_SOURCE_DIR}/src/cubeb-coreaudio-rs"
397408
INSTALL_COMMAND ""

0 commit comments

Comments
 (0)