Skip to content

Commit 69ceae2

Browse files
committed
build: Restore the generated AUv2 Info.plist on every build
1 parent fb9d6e4 commit 69ceae2

2 files changed

Lines changed: 62 additions & 5 deletions

File tree

‎.github/workflows/pullreq.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,27 @@ jobs:
194194
find build -name downloadplug.vst3 -print
195195
find build -name downloadplug.component -print
196196
197+
# A reconfigure rewrites a bundle's Info.plist with CMake's default, which has no
198+
# AudioComponents, so no host registers the AU. The next build must restore it.
199+
- name: AUv2 Info.plist survives a reconfigure
200+
if: runner.os == 'macOS'
201+
shell: bash
202+
run: |
203+
cmake ./build
204+
cmake --build ./build --config Debug
205+
found=0
206+
while IFS= read -r c; do
207+
[ -f "$c/Contents/MacOS/downloadplug" ] || continue
208+
found=1
209+
if plutil -extract AudioComponents json -o /dev/null "$c/Contents/Info.plist"; then
210+
echo "$c: AudioComponents present"
211+
else
212+
echo "::error::$c/Contents/Info.plist has no AudioComponents after a reconfigure and rebuild"
213+
exit 1
214+
fi
215+
done < <(find build -name downloadplug.component -type d)
216+
[ "$found" = 1 ] || { echo "::error::no built downloadplug.component"; exit 1; }
217+
197218
198219
build_feature_clapfirst-test:
199220
name: ${{ matrix.name }}
@@ -289,6 +310,16 @@ jobs:
289310
run: |
290311
"${{ matrix.vst3_validator }}" "${{ matrix.vst3_path }}"
291312
313+
# Xcode re-processes CMake's default Info.plist after a reconfigure. The rebuilt
314+
# bundle must keep AudioComponents, and auval below then checks that same bundle.
315+
- name: AUv2 Info.plist survives a reconfigure
316+
shell: bash
317+
if: ${{ matrix.auv2_path }}
318+
run: |
319+
cmake ./build
320+
cmake --build ./build --config Debug --target clap-first-distortion_all
321+
plutil -extract AudioComponents json -o /dev/null "${{ matrix.auv2_path }}/Contents/Info.plist" || { echo "::error::${{ matrix.auv2_path }} has no AudioComponents after a reconfigure and rebuild"; exit 1; }
322+
292323
- name: Run auval
293324
shell: bash
294325
if: ${{ matrix.auv2_path }}

‎cmake/wrap_auv2.cmake‎

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,37 @@ function(target_add_auv2_wrapper)
276276
MACOSX_BUNDLE_SHORT_VERSION_STRING ${AUV2_BUNDLE_VERSION}
277277
)
278278

279-
# This is "PRE_BUILD" because the target is created at cmake time and we want to beat xcode signing in order
280-
# it is *not* a MACOSX_BUNDLE_INFO_PLIST since that is a configure not build time concept so doesn't work
281-
# with compile time generated files
282-
add_custom_command(TARGET ${AUV2_TARGET} PRE_BUILD
283-
COMMAND ${CMAKE_COMMAND} -E copy ${bhtgoutdir}/auv2_Info.plist $<TARGET_FILE_DIR:${AUV2_TARGET}>/../Info.plist)
279+
# The real Info.plist is written by the build helper at build time, so it can't be a
280+
# MACOSX_BUNDLE_INFO_PLIST (a configure time concept). But a BUNDLE target without one
281+
# still gets CMake's default plist, which has no AudioComponents, so no host registers
282+
# the AU. Each generator writes that default at a different time, so each needs the
283+
# real plist to be a tracked build input rather than a one-off copy.
284+
if (${CMAKE_GENERATOR} STREQUAL "Xcode")
285+
# Xcode writes the default plist while building the target, after any PRE_BUILD
286+
# step and before signing. Hand it the build helper's plist to process instead.
287+
set_target_properties(${AUV2_TARGET} PROPERTIES XCODE_ATTRIBUTE_INFOPLIST_FILE "${bhtgoutdir}/auv2_Info.plist")
288+
else()
289+
# Ninja and Makefiles write the default plist into the bundle at generate time,
290+
# on every reconfigure, and nothing in the build graph notices. So copy the real
291+
# plist through a stamp that every configure deletes, and relink when the stamp
292+
# changes so POST_BUILD steps that patch or sign the bundle run again. The stamp
293+
# is a source of the AUv2 target itself: in a separate target, the bundle path
294+
# genex would depend back on the AUv2 target in projects older than CMP0112.
295+
set(plist_stamp_dir "${CMAKE_CURRENT_BINARY_DIR}/${AUV2_TARGET}-info-plist")
296+
set(plist_stamp "${plist_stamp_dir}/$<CONFIG>.stamp")
297+
file(REMOVE_RECURSE "${plist_stamp_dir}")
298+
# Makefiles, unlike Ninja, don't create the directory of a custom command's OUTPUT.
299+
add_custom_command(
300+
OUTPUT "${plist_stamp}"
301+
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_BUNDLE_CONTENT_DIR:${AUV2_TARGET}>" "${plist_stamp_dir}"
302+
COMMAND ${CMAKE_COMMAND} -E copy "${bhtgoutdir}/auv2_Info.plist" "$<TARGET_BUNDLE_CONTENT_DIR:${AUV2_TARGET}>/Info.plist"
303+
COMMAND ${CMAKE_COMMAND} -E touch "${plist_stamp}"
304+
DEPENDS "${bhtgoutdir}/auv2_Info.plist"
305+
COMMENT "clap-wrapper: restoring the generated Info.plist in ${AUV2_OUTPUT_NAME}.component"
306+
VERBATIM)
307+
target_sources(${AUV2_TARGET} PRIVATE "${plist_stamp}")
308+
set_property(TARGET ${AUV2_TARGET} APPEND PROPERTY LINK_DEPENDS "${plist_stamp}")
309+
endif()
284310

285311
# XCode needs a special extra flag
286312
set_target_properties(${AUV2_TARGET} PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${AUV2_BUNDLE_IDENTIFIER}.component")

0 commit comments

Comments
 (0)