Skip to content
Open
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
2 changes: 1 addition & 1 deletion cmake/avendish.clap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ function(avnd_make_clap)
NEWLINE_STYLE LF
)

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${AVND_C_NAME}_clap.cpp"
)

Expand Down
7 changes: 6 additions & 1 deletion cmake/avendish.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ function(_avnd_dispatch_backend backend)
if(DEFINED ${_flag} AND NOT ${${_flag}})
return()
endif()
# Compute the prototype's object-pull-in line once; the called backend's
# configure_file picks up AVND_MAIN_IMPORT from this (calling) scope.
cmake_parse_arguments(AVND "" "MAIN_FILE;C_NAME" "" ${ARGN})
avnd_main_import(AVND_MAIN_IMPORT "${AVND_MAIN_FILE}" "${AVND_C_NAME}")
cmake_language(CALL "avnd_make_${backend}" ${ARGN})
endfunction()

Expand Down Expand Up @@ -259,6 +263,7 @@ add_library(avnd_dummy_lib OBJECT "${AVND_SOURCE_DIR}/src/dummy.cpp")
include(avendish.dependencies)
include(avendish.disableexceptions)
include(avendish.sources)
include(avendish.modules)
include(avendish.tools)

include(avendish.ui.qt)
Expand Down Expand Up @@ -286,7 +291,7 @@ function(avnd_register)
add_library("${AVND_TARGET}" STATIC $<TARGET_OBJECTS:avnd_dummy_lib>)
endif()

target_sources("${AVND_TARGET}" PRIVATE "${AVND_MAIN_FILE}")
avnd_add_object_to_base("${AVND_TARGET}" "${AVND_MAIN_FILE}")
if(AVND_COMPILE_OPTIONS)
target_compile_options("${AVND_TARGET}" PUBLIC "${AVND_COMPILE_OPTIONS}")
endif()
Expand Down
3 changes: 2 additions & 1 deletion cmake/avendish.dump.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function(avnd_make_dump)

string(MAKE_C_IDENTIFIER "${AVND_MAIN_CLASS}" MAIN_OUT_FILE)

avnd_main_import(AVND_MAIN_IMPORT "${AVND_MAIN_FILE}" "${AVND_C_NAME}")
configure_file(
"${AVND_SOURCE_DIR}/include/avnd/binding/dump/prototype.cpp.in"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_dump.cpp"
Expand All @@ -31,10 +32,10 @@ function(avnd_make_dump)
RUNTIME_OUTPUT_DIRECTORY dump
)

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_dump.cpp"
)

Expand Down
4 changes: 3 additions & 1 deletion cmake/avendish.example.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(CTest)

function(avnd_make_example_host)
cmake_parse_arguments(AVND "" "TARGET;MAIN_FILE;MAIN_CLASS" "" ${ARGN})
cmake_parse_arguments(AVND "" "TARGET;MAIN_FILE;MAIN_CLASS;C_NAME" "" ${ARGN})

set(AVND_FX_TARGET "${AVND_TARGET}_example_host")
if(TARGET "${AVND_FX_TARGET}")
Expand All @@ -11,6 +11,7 @@ function(avnd_make_example_host)

string(MAKE_C_IDENTIFIER "${AVND_MAIN_CLASS}" MAIN_OUT_FILE)

avnd_main_import(AVND_MAIN_IMPORT "${AVND_MAIN_FILE}" "${AVND_C_NAME}")
configure_file(
"${AVND_SOURCE_DIR}/include/avnd/binding/example/prototype.cpp.in"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_example_host.cpp"
Expand All @@ -25,6 +26,7 @@ function(avnd_make_example_host)
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY example
)
avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion cmake/avendish.fuzz.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ function(avnd_make_fuzz)
RUNTIME_OUTPUT_DIRECTORY fuzz
)

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_fuzz.cpp"
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/avendish.godot.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ function(avnd_make_godot)
PUBLIC
cxx_std_23
)
avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_godot.cpp"
${AVND_GODOT_SOURCES}
)
Expand Down
2 changes: 1 addition & 1 deletion cmake/avendish.gstreamer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ function(avnd_make_gstreamer)
ARCHIVE_OUTPUT_DIRECTORY gstreamer
)

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${AVND_SOURCE_DIR}/include/avnd/binding/gstreamer/audio_source.hpp"
"${AVND_SOURCE_DIR}/include/avnd/binding/gstreamer/audio_sink.hpp"
"${AVND_SOURCE_DIR}/include/avnd/binding/gstreamer/audio_filter.hpp"
Expand Down
2 changes: 1 addition & 1 deletion cmake/avendish.max.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ function(avnd_make_max)
AVND_C_NAME "${AVND_C_NAME}"
)

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_max.cpp"

"${AVND_SOURCE_DIR}/include/avnd/binding/max/all.hpp"
Expand Down
60 changes: 60 additions & 0 deletions cmake/avendish.modules.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# C++20 module support.
#
# A user object can be written as a module (`export module <c_name>; import halp;`)
# in a .cppm MAIN_FILE instead of a header. The per-backend prototype then either
# `#include`s the header or `import`s the module -- only that one line differs.
#
# GCC requires a module BMI's exception/rtti dialect to match every consumer
# exactly (a mismatch is a hard "Bad file data" error), and avendish backends
# disagree: dump/python/ossia build with exceptions+rtti, while the plugin
# backends (clap/pd/max/vst3/vintage/gstreamer/wasm/example) build with
# -fno-exceptions -fno-rtti. So a single shared halp BMI cannot serve all of
# them. Instead the slim halp module and the user object are compiled *into each
# backend target*, inheriting that backend's dialect. Both are one small object,
# so the duplication is cheap and every backend stays self-contained.
#
# Requirements for the module path: a generator with module support (Ninja --
# the Makefiles generator drops -fmodules) and -DCMAKE_CXX_SCAN_FOR_MODULES=ON
# so the generated prototype's `import` is scanned for its BMI dependency.

# Line a prototype uses to pull in the user object.
function(avnd_main_import out main_file c_name)
if("${main_file}" MATCHES "\\.cppm$")
set("${out}" "import ${c_name};" PARENT_SCOPE)
else()
set("${out}" "#include <${main_file}>" PARENT_SCOPE)
endif()
endfunction()

# Add the user object to its per-object base library. A header compiles once here
# as before; a .cppm is compiled per-backend instead (see below), so there is
# nothing to add to the base for the module case.
function(avnd_add_object_to_base base main_file)
if(NOT "${main_file}" MATCHES "\\.cppm$")
target_sources(${base} PRIVATE "${main_file}")
endif()
endfunction()

# Make a backend target consume the user object. For a module, compile the slim
# halp module and the user .cppm into the backend itself, in the backend's own
# dialect, so the prototype's `import` resolves against a BMI built with matching
# exception/rtti flags. For a header, compile it into the backend TU as before.
function(avnd_add_object_to_backend backend base main_file)
if("${main_file}" MATCHES "\\.cppm$")
# The halp module lives in the avendish tree, the user object wherever the
# caller put it; a CXX_MODULES file set requires every file under one of its
# base dirs, so cover both.
get_filename_component(_avnd_mf_dir "${main_file}" DIRECTORY)
target_sources(${backend}
PRIVATE
FILE_SET avnd_modules TYPE CXX_MODULES
BASE_DIRS "${AVND_SOURCE_DIR}/include/halp" "${_avnd_mf_dir}"
FILES
"${AVND_SOURCE_DIR}/include/halp/halp.cppm"
"${main_file}"
)
target_compile_features(${backend} PRIVATE cxx_std_23)
else()
target_sources(${backend} PRIVATE "${main_file}")
endif()
endfunction()
3 changes: 2 additions & 1 deletion cmake/avendish.ossia.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function(avnd_make_ossia)

string(MAKE_C_IDENTIFIER "${AVND_MAIN_CLASS}" MAIN_OUT_FILE)

avnd_main_import(AVND_MAIN_IMPORT "${AVND_MAIN_FILE}" "${AVND_C_NAME}")
configure_file(
"${AVND_SOURCE_DIR}/include/avnd/binding/ossia/prototype.cpp.in"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_ossia.cpp"
Expand All @@ -50,10 +51,10 @@ function(avnd_make_ossia)
RUNTIME_OUTPUT_DIRECTORY ossia
)

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_ossia.cpp"
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/avendish.pd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ function(avnd_make_pd)
ARCHIVE_OUTPUT_DIRECTORY pd
)

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_pd.cpp"
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/avendish.python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ function(avnd_make_python)
)
endif()

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_python.cpp"
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/avendish.standalone.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ function(avnd_make_standalone)
RUNTIME_OUTPUT_DIRECTORY standalone
)
endif()
avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_standalone.cpp"
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/avendish.touchdesigner.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ function(avnd_make_touchdesigner)

add_library(${AVND_FX_TARGET} MODULE)

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_touchdesigner.cpp"
${AVND_TD_SOURCES}
)
Expand Down
2 changes: 1 addition & 1 deletion cmake/avendish.vintage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ function(avnd_make_vintage)
NEWLINE_STYLE LF
)

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${AVND_C_NAME}_vintage.cpp"
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/avendish.vst3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ function(avnd_make_vst3)
NEWLINE_STYLE LF
)

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${AVND_C_NAME}_vst3.cpp"
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/avendish.wasm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ function(avnd_make_wasm)
AVND_C_NAME "${AVND_C_NAME}"
)

avnd_add_object_to_backend(${AVND_FX_TARGET} ${AVND_TARGET} "${AVND_MAIN_FILE}")
target_sources(
${AVND_FX_TARGET}
PRIVATE
"${AVND_MAIN_FILE}"
"${CMAKE_BINARY_DIR}/${MAIN_OUT_FILE}_wasm.cpp"
)

Expand Down
3 changes: 2 additions & 1 deletion include/avnd/binding/clap/prototype.cpp.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */

#include <@AVND_MAIN_FILE@>
#include <avnd/binding/clap/audio_effect.hpp>
#include <avnd/binding/clap/configure.hpp>

@AVND_MAIN_IMPORT@

// clang-format off
using plug_type = decltype(avnd::configure<avnd_clap::config, @AVND_MAIN_CLASS@>())::type;
using effect_type = avnd_clap::SimpleAudioEffect<plug_type>;
Expand Down
2 changes: 1 addition & 1 deletion include/avnd/binding/dump/prototype.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct config
};
}

#include <@AVND_MAIN_FILE@>
@AVND_MAIN_IMPORT@
int main(int argc, char** argv)
{
using type = decltype(avnd::configure<dump::config, @AVND_MAIN_CLASS@>())::type;
Expand Down
3 changes: 2 additions & 1 deletion include/avnd/binding/example/prototype.cpp.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */

#include <@AVND_MAIN_FILE@>
#include <avnd/binding/example/example_processor.hpp>

@AVND_MAIN_IMPORT@

using type = decltype(avnd::configure<exhs::config, @AVND_MAIN_CLASS@>())::type;

int main()
Expand Down
2 changes: 1 addition & 1 deletion include/avnd/binding/fuzz/prototype.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct config
};
}

#include <@AVND_MAIN_FILE@>
@AVND_MAIN_IMPORT@

// libFuzzer provides main(); we only supply the per-input entry point.
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size)
Expand Down
3 changes: 2 additions & 1 deletion include/avnd/binding/godot/prototype.cpp.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */

// clang-format off
#include <@AVND_MAIN_FILE@>
#include <avnd/binding/godot/configure.hpp>
#include <avnd/binding/godot/node.hpp>

#include <gdextension_interface.h>
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/godot.hpp>

@AVND_MAIN_IMPORT@

using type = decltype(avnd::configure<godot_binding::config, @AVND_MAIN_CLASS@>())::type;
// clang-format on

Expand Down
2 changes: 1 addition & 1 deletion include/avnd/binding/gstreamer/prototype.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// clang-format off
#include <avnd/binding/gstreamer/element.hpp>
#include <avnd/binding/gstreamer/configuration.hpp>
#include <@AVND_MAIN_FILE@>
@AVND_MAIN_IMPORT@


using type = decltype(avnd::configure<gst::config, @AVND_MAIN_CLASS@>())::type;
Expand Down
3 changes: 2 additions & 1 deletion include/avnd/binding/max/prototype.cpp.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */

// clang-format off
#include <@AVND_MAIN_FILE@>
#include <avnd/binding/max/audio_processor.hpp>
#include <avnd/binding/max/message_processor.hpp>
#include <avnd/binding/max/configure.hpp>
#include <avnd/binding/max/jitter_processor.hpp>
#include "commonsyms.h"

@AVND_MAIN_IMPORT@
using type = decltype(avnd::configure<max::config, @AVND_MAIN_CLASS@>())::type;
// clang-format on

Expand Down
3 changes: 2 additions & 1 deletion include/avnd/binding/ossia/prototype.cpp.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */

#include <@AVND_MAIN_FILE@>
#include <avnd/binding/ossia/all.hpp>
#include <avnd/binding/ossia/configure.hpp>

@AVND_MAIN_IMPORT@

using type = decltype(avnd::configure<oscr::config, @AVND_MAIN_CLASS@>())::type;

void test_instantiate(ossia::exec_state_facade st)
Expand Down
Loading
Loading