diff --git a/apps/electron-backend/build-embedded-mpv.js b/apps/electron-backend/build-embedded-mpv.js index cf807133a..5a6e81f19 100644 --- a/apps/electron-backend/build-embedded-mpv.js +++ b/apps/electron-backend/build-embedded-mpv.js @@ -76,6 +76,15 @@ function cleanOutput() { ); } +function cleanNativeBuildIntermediates() { + fs.rmSync(outputFile, { force: true }); + fs.rmSync(path.join(outputDir, '.deps'), { recursive: true, force: true }); + fs.rmSync(path.join(outputDir, 'obj.target'), { + recursive: true, + force: true, + }); +} + function cleanDistNativeOutput() { fs.rmSync(distNativeDir, { recursive: true, force: true }); } @@ -441,6 +450,7 @@ function main() { log( `Building native addon against Electron ${electronVersion} using ${runtime.origin} runtime for ${targetPlatform}-${targetArch}...` ); + cleanNativeBuildIntermediates(); runNodeGyp('configure', env); runNodeGyp('build', env); diff --git a/apps/electron-backend/native/src/embedded_mpv_wid_common.h b/apps/electron-backend/native/src/embedded_mpv_wid_common.h index 3ab8bd2f7..a19f14221 100644 --- a/apps/electron-backend/native/src/embedded_mpv_wid_common.h +++ b/apps/electron-backend/native/src/embedded_mpv_wid_common.h @@ -10,6 +10,41 @@ #include +#if defined(IPTVNATOR_DYNAMIC_LIBMPV) && !defined(mpv_command_async) +#define IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(name) \ + MPV_SELECTANY decltype(&name) pfn_##name = nullptr; + +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_command_async) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_command_node_async) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_create) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_error_string) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_initialize) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_observe_property) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_request_log_messages) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_set_option_string) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_set_property) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_set_property_async) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_terminate_destroy) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_wait_event) +IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_wakeup) + +#undef IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL + +#define mpv_command_async pfn_mpv_command_async +#define mpv_command_node_async pfn_mpv_command_node_async +#define mpv_create pfn_mpv_create +#define mpv_error_string pfn_mpv_error_string +#define mpv_initialize pfn_mpv_initialize +#define mpv_observe_property pfn_mpv_observe_property +#define mpv_request_log_messages pfn_mpv_request_log_messages +#define mpv_set_option_string pfn_mpv_set_option_string +#define mpv_set_property pfn_mpv_set_property +#define mpv_set_property_async pfn_mpv_set_property_async +#define mpv_terminate_destroy pfn_mpv_terminate_destroy +#define mpv_wait_event pfn_mpv_wait_event +#define mpv_wakeup pfn_mpv_wakeup +#endif + #include #include #include diff --git a/apps/electron-backend/src/app/services/embedded-mpv-native-source.spec.ts b/apps/electron-backend/src/app/services/embedded-mpv-native-source.spec.ts index 187c6b17f..7a337e9f6 100644 --- a/apps/electron-backend/src/app/services/embedded-mpv-native-source.spec.ts +++ b/apps/electron-backend/src/app/services/embedded-mpv-native-source.spec.ts @@ -207,6 +207,19 @@ describe('Embedded MPV native source recording invariants', () => { ); }); + it('keeps dynamic libmpv symbol declarations compatible with distro headers', () => { + expect(widCommonSource).toContain( + '#if defined(IPTVNATOR_DYNAMIC_LIBMPV) && !defined(mpv_command_async)' + ); + expect(widCommonSource).toContain( + 'IPTVNATOR_DECLARE_MPV_DYNAMIC_SYMBOL(mpv_command_async)' + ); + expect(widCommonSource).toContain( + '#define mpv_command_async pfn_mpv_command_async' + ); + expect(buildScriptSource).toContain('cleanNativeBuildIntermediates();'); + }); + it('uses platform-specific embedded MPV runtime cache key inputs in CI', () => { expect(buildAndMakeWorkflowSource).toContain( "const targetPlatform = '${{ matrix.embedded_mpv_platform }}';"