Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AUv2 PList Generator - step one #114

Merged
merged 2 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 107 additions & 26 deletions cmake/enable_sdks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,17 @@ function(DefineCLAPASVST3Sources)
list(REMOVE_ITEM vst3sources "${full_path_test_cpp}")
endif()


if(WIN32)
set(os_wrappersources src/detail/os/windows.cpp)
set(os_wrappersources src/detail/vst3/os/windows.cpp)
endif()

if (APPLE)
set(os_wrappersources
src/detail/clap/mac_helpers.mm
src/detail/os/macos.mm
)
set(os_wrappersources src/detail/vst3/os/macos.mm)
endif()

if(UNIX AND NOT APPLE)
set(os_wrappersources
src/detail/os/linux.cpp
)
set(os_wrappersources src/detail/vst3/os/linux.cpp)
endif()

set(wrappersources_vst3
Expand All @@ -184,12 +180,6 @@ function(DefineCLAPASVST3Sources)
src/detail/vst3/process.cpp
src/detail/vst3/categories.h
src/detail/vst3/categories.cpp
src/detail/sha1.h
src/detail/sha1.cpp
src/detail/clap/fsutil.h
src/detail/clap/fsutil.cpp
src/detail/os/osutil.h
src/detail/clap/automation.h
${os_wrappersources}
CACHE STRING "Clap Wrapper Library Sources")

Expand Down Expand Up @@ -333,7 +323,7 @@ function(target_add_vst3_wrapper)

# clap-wrapper-extensions are PUBLIC, so a clap linking the library can access the clap-wrapper-extensions
target_compile_definitions(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC -D${CLAP_WRAPPER_PLATFORM}=1)
target_link_libraries(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC clap-wrapper-extensions)
target_link_libraries(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC clap-wrapper-extensions clap-wrapper-shared-detail)

target_compile_options(${V3_TARGET}-clap-wrapper-vst3-lib PRIVATE
-DCLAP_SUPPORTS_ALL_NOTE_EXPRESSIONS=$<IF:$<BOOL:${V3_SUPPORTS_ALL_NOTE_EXPRESSIONS}>,1,0>
Expand Down Expand Up @@ -469,6 +459,8 @@ if (APPLE)
SUBTYPE_CODE
INSTRUMENT_TYPE

CLAP_TARGET_FOR_CONFIG

MACOS_EMBEDDED_CLAP_LOCATION
)
cmake_parse_arguments(AUV2 "" "${oneValueArgs}" "" ${ARGN} )
Expand All @@ -477,8 +469,8 @@ if (APPLE)
message(FATAL_ERROR "clap-wrapper: target_add_auv2_wrapper requires a target")
endif()

if (NOT DEFINED AUV2_OUTPUT_NAME)
message(FATAL_ERROR "clap-wrapper: target_add_auv2_wrapper requires an output name")
if (NOT TARGET ${AUV2_TARGET})
message(FATAL_ERROR "clap-wrapper: auv2-target must be a target")
endif()

if (NOT DEFINED AUV2_MANUFACTURER_NAME)
Expand All @@ -489,18 +481,81 @@ if (APPLE)
message(FATAL_ERROR "clap-wrapper: For now please specify AUV2 manufacturer code (4 chars)")
endif()

if (NOT DEFINED AUV2_SUBTYPE_CODE)
message(FATAL_ERROR "clap-wrapper: For now please specify AUV2 subtype code (4 chars)")
if (NOT DEFINED AUV2_BUNDLE_VERSION)
message(WARNING "clap-wrapper: bundle version not defined. Chosing 1")
set(AUV2_BUNDLE_VERSION 1)
endif()

if (NOT DEFINED AUV2_INSTRUMENT_TYPE)
message(WARNING "clap-wrapper: auv2 instrument type not specified. Using aumu")
# We need a build helper which ejects our config code for info-plist and entry points
set(bhtg ${AUV2_TARGET}-build-helper)
set(bhsc "${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/detail/auv2/build-helper/")
add_executable(${bhtg} ${bhsc}/build-helper.cpp)
target_link_libraries(${bhtg} PRIVATE
clap-wrapper-shared-detail
macos_filesystem_support
"-framework Foundation"
"-framework CoreFoundation"
)
set(bhtgoutdir "${CMAKE_CURRENT_BINARY_DIR}/${AUV2_TARGET}-build-helper-output")
add_custom_command(TARGET ${bhtg} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "clap-wrapper: auv2 configuration output dir is ${bhtgoutdir}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${bhtgoutdir}"
)

add_dependencies(${AUV2_TARGET} ${bhtg})

if (DEFINED AUV2_CLAP_TARGET_FOR_CONFIG)
set(clpt ${AUV2_CLAP_TARGET_FOR_CONFIG})
message(STATUS "clap-wrapper: building auv2 based on target ${AUV2_CLAP_TARGET_FOR_CONFIG}")
get_property(ton TARGET ${clpt} PROPERTY LIBRARY_OUTPUT_NAME)
set(AUV2_OUTPUT_NAME "${ton}")
set(AUV2_SUBTYPE_CODE "Fooo")
set(AUV2_INSTRUMENT_TYPE "aumu")

add_dependencies(${AUV2_TARGET} ${clpt})
add_dependencies(${bhtg} ${clpt})

add_custom_command(
TARGET ${bhtg}
POST_BUILD
WORKING_DIRECTORY ${bhtgoutdir}
BYPRODUCTS ${bhtgoutdir}/auv2_Info.plist ${bhtgoutdir}/generated_entrypoints.hxx
COMMAND $<TARGET_FILE:${bhtg}> --fromclap
"$<TARGET_FILE:${clpt}>"
"${AUV2_MANUFACTURER_CODE}" "${AUV2_MANUFACTURER_NAME}"
)
else()
if (NOT DEFINED AUV2_OUTPUT_NAME)
message(FATAL_ERROR "clap-wrapper: target_add_auv2_wrapper requires an output name")
endif()

if (NOT DEFINED AUV2_SUBTYPE_CODE)
message(FATAL_ERROR "clap-wrapper: For now please specify AUV2 subtype code (4 chars)")
endif()

if (NOT DEFINED AUV2_INSTRUMENT_TYPE)
message(WARNING "clap-wrapper: auv2 instrument type not specified. Using aumu")
set(AUV2_INSTRUMENT_TYPE "aumu")
endif()

add_custom_command(
TARGET ${bhtg}
POST_BUILD
WORKING_DIRECTORY ${bhtgoutdir}
BYPRODUCTS ${bhtgoutdir}/auv2_Info.plist ${bhtgoutdir}/generated_entrypoints.hxx
COMMAND $<TARGET_FILE:${bhtg}> --explicit
"${AUV2_OUTPUT_NAME}" "${AUV2_BUNDLE_VERSION}"
"${AUV2_INSTRUMENT_TYPE}" "${AUV2_SUBTYPE_CODE}"
"${AUV2_MANUFACTURER_CODE}" "${AUV2_MANUFACTURER_NAME}"
)
endif()

set(AUV2_INSTRUMENT_TYPE ${AUV2_INSTRUMENT_TYPE} PARENT_SCOPE)
set(AUV2_MANUFACTURER_NAME ${AUV2_MANUFACTURER_NAME} PARENT_SCOPE)
set(AUV2_MANUFACTURER_CODE ${AUV2_MANUFACTURER_CODE} PARENT_SCOPE)
configure_file(${bhsc}/auv2_infoplist_top.in
${bhtgoutdir}/auv2_infoplist_top)

set(AUV2_INSTRUMENT_TYPE ${AUV2_INSTRUMENT_TYPE} PARENT_SCOPE)
set(AUV2_SUBTYPE_CODE ${AUV2_SUBTYPE_CODE} PARENT_SCOPE)

message(STATUS "clap-wrapper: Adding AUV2 Wrapper to target ${AUV2_TARGET} generating '${AUV2_OUTPUT_NAME}.component'")
Expand All @@ -512,13 +567,15 @@ if (APPLE)
# is a placeholder. When we write it we will follow a similar
# split trick as for the vst3, mostly (but AUV2 is a bit different
# with info.plist and entrypoint-per-instance stuff)
target_sources(${AUV2_TARGET} PRIVATE ${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/wrapasauv2.cpp)
target_sources(${AUV2_TARGET} PRIVATE
${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/wrapasauv2.cpp
${bhtgoutdir}/generated_entrypoints.hxx)


if (NOT TARGET ${AUV2_TARGET}-clap-wrapper-auv2-lib)
# For now make this an interface
add_library(${AUV2_TARGET}-clap-wrapper-auv2-lib INTERFACE )
target_include_directories(${AUV2_TARGET}-clap-wrapper-auv2-lib INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories(${AUV2_TARGET}-clap-wrapper-auv2-lib INTERFACE "${bhtgoutdir}" "${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(${AUV2_TARGET}-clap-wrapper-auv2-lib INTERFACE clap auv2_sdk)

# clap-wrapper-extensions are PUBLIC, so a clap linking the library can access the clap-wrapper-extensions
Expand Down Expand Up @@ -551,10 +608,15 @@ if (APPLE)
MACOSX_BUNDLE_BUNDLE_NAME ${AUV2_OUTPUT_NAME}
MACOSX_BUNDLE_BUNDLE_VERSION ${AUV2_BUNDLE_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${AUV2_BUNDLE_VERSION}
MACOSX_BUNDLE_INFO_PLIST ${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/cmake/auv2_Info.plist.in
)
# This is "PRE_BUILD" because the target is created at cmake time and we want to beat xcode signing in order
# it is *not* a MACOSX_BUNDLE_INFO_PLIST since that is a configure not build time concept so doesn't work
# with compile time generated files
add_custom_command(TARGET ${AUV2_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${bhtgoutdir}/auv2_Info.plist $<TARGET_FILE_DIR:${AUV2_TARGET}>/../Info.plist)

if (NOT ${CMAKE_GENERATOR} STREQUAL "Xcode")
add_custom_command(TARGET ${AUV2_TARGET} POST_BUILD
add_custom_command(TARGET ${AUV2_TARGET} PRE_BUILD
WORKING_DIRECTORY $<TARGET_PROPERTY:${AUV2_TARGET},LIBRARY_OUTPUT_DIRECTORY>
COMMAND SetFile -a B "$<TARGET_PROPERTY:${AUV2_TARGET},MACOSX_BUNDLE_BUNDLE_NAME>.$<TARGET_PROPERTY:${AUV2_TARGET},BUNDLE_EXTENSION>")
endif()
Expand All @@ -579,6 +641,25 @@ if ( NOT TARGET clap-wrapper-extensions)
target_include_directories(clap-wrapper-extensions INTERFACE include)
endif()

add_library(clap-wrapper-shared-detail STATIC
src/detail/sha1.h
src/detail/sha1.cpp
src/detail/clap/fsutil.h
src/detail/clap/fsutil.cpp
src/detail/clap/automation.h
)
target_compile_options(clap-wrapper-shared-detail PUBLIC -D${CLAP_WRAPPER_PLATFORM}=1)
target_link_libraries(clap-wrapper-shared-detail PUBLIC clap clap-wrapper-extensions)
target_include_directories(clap-wrapper-shared-detail PUBLIC libs/fmt)
target_include_directories(clap-wrapper-shared-detail PUBLIC src)

if (APPLE)
target_sources(clap-wrapper-shared-detail PRIVATE
src/detail/clap/mac_helpers.mm
)
target_link_libraries(clap-wrapper-shared-detail PRIVATE macos_filesystem_support)
endif()

if(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
# a 32 bit build is odd enough that it might be an error. Chirp.
message(STATUS "clap-wrapper: configured as 32 bit build. Intentional?")
Expand Down
3 changes: 3 additions & 0 deletions libs/fmt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a copy of the fmt:: library from github. License is in header files in
the "fmt" directory

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
61 changes: 61 additions & 0 deletions src/detail/auv2/base_classes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* document
*/

#pragma once

#include <AudioUnitSDK/AUEffectBase.h>
#include <AudioUnitSDK/AUMIDIEffectBase.h>
#include <AudioUnitSDK/MusicDeviceBase.h>

#include <iostream>

// -------------------------------------------------------------------------------------------------

class ClapWrapper_AUV2_Effect : public ausdk::AUEffectBase
{
using Base = ausdk::AUEffectBase;

public:
explicit ClapWrapper_AUV2_Effect(const std::string &clapid, int clapidx,
AudioComponentInstance ci)
: Base{ci, true}
{
std::cout << "[clap-wrapper] auv2: creating effect" << std::endl;
std::cout << "[clap-wrapper] auv2: id='" << clapid << "' index=" << clapidx << std::endl;
}
};

class ClapWrapper_AUV2_NoteEffect : public ausdk::AUMIDIEffectBase
{
using Base = ausdk::AUMIDIEffectBase;

public:
explicit ClapWrapper_AUV2_NoteEffect(const std::string &clapid, int clapidx,
AudioComponentInstance ci)
: Base{ci, true}
{
std::cout << "[clap-wrapper] auv2: creating note effect" << std::endl;
std::cout << "[clap-wrapper] auv2: id='" << clapid << "' index=" << clapidx << std::endl;
}
};

// -------------------------------------------------------------------------------------------------

class ClapWrapper_AUV2_Instrument : public ausdk::MusicDeviceBase
{
using Base = ausdk::MusicDeviceBase;

public:
explicit ClapWrapper_AUV2_Instrument(const std::string &clapid, int clapidx,
AudioComponentInstance ci)
: Base{ci, 0, 1}
{
std::cout << "[clap-wrapper] auv2: creating instrument" << std::endl;
std::cout << "[clap-wrapper] auv2: id='" << clapid << "' index=" << clapidx << std::endl;
}

bool StreamFormatWritable(AudioUnitScope, AudioUnitElement) override { return true; }

bool CanScheduleParameters() const override { return false; }
};
26 changes: 26 additions & 0 deletions src/detail/auv2/build-helper/auv2_infoplist_top.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${AUV2_OUTPUT_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${AUV2_BUNDLE_VERSION}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${AUV2_OUTPUT_NAME}</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>${AUV2_BUNDLE_VERSION}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${AUV2_BUNDLE_VERSION}</string>
<key>NSPrincipalClass</key>
<string/>
<key>NSHighResolutionCapable</key>
<true/>
Loading