From e3c93573f3d935d43984f31373368c319bd94ee4 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 17 Mar 2025 12:15:04 +0100 Subject: [PATCH] [cmake] add explicit instructions to turn off unmaintained modules * Add detailed CMake warning to disable unmaintained modules * Add sample shadow subsystem implementation * Allow building shadow server with dummy subsystem --- client/CMakeLists.txt | 16 ++- client/Wayland/CMakeLists.txt | 3 + client/Windows/CMakeLists.txt | 3 + client/iOS/CMakeLists.txt | 3 + cmake/WarnUnmaintained.cmake | 1 + server/Mac/CMakeLists.txt | 3 + server/Windows/CMakeLists.txt | 2 +- server/shadow/CMakeLists.txt | 17 ++- server/shadow/Mac/CMakeLists.txt | 2 +- server/shadow/Sample/CMakeLists.txt | 1 + server/shadow/Sample/sample_shadow.c | 177 +++++++++++++++++++++++++++ server/shadow/Sample/sample_shadow.h | 43 +++++++ server/shadow/Win/CMakeLists.txt | 2 +- 13 files changed, 259 insertions(+), 14 deletions(-) create mode 100644 server/shadow/Sample/CMakeLists.txt create mode 100644 server/shadow/Sample/sample_shadow.c create mode 100644 server/shadow/Sample/sample_shadow.h diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 6bf942797..14b69c2ff 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -26,7 +26,10 @@ endif() if(FREERDP_VENDOR AND WITH_CLIENT) if(WIN32 AND NOT UWP) - add_subdirectory(Windows) + option(WITH_CLIENT_WINDOWS "Build native windows client" ON) + if(WITH_CLIENT_WINDOWS) + add_subdirectory(Windows) + endif() else() if(WITH_SAMPLE) add_subdirectory(Sample) @@ -47,10 +50,13 @@ if(FREERDP_VENDOR AND WITH_CLIENT) if(APPLE) if(IOS) - if(NOT WITHOUT_FREERDP_3x_DEPRECATED) - if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/iOS") - message(STATUS "Adding iOS client") - add_subdirectory(iOS) + option(WITH_CLIENT_IOS "Build native iOS client" ON) + if(WITH_CLIENT_IOS) + if(NOT WITHOUT_FREERDP_3x_DEPRECATED) + if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/iOS") + message(STATUS "Adding iOS client") + add_subdirectory(iOS) + endif() endif() endif() else() diff --git a/client/Wayland/CMakeLists.txt b/client/Wayland/CMakeLists.txt index 5a237a599..f036fae55 100644 --- a/client/Wayland/CMakeLists.txt +++ b/client/Wayland/CMakeLists.txt @@ -19,6 +19,9 @@ set(MODULE_NAME "wlfreerdp") set(MODULE_PREFIX "FREERDP_CLIENT_WAYLAND") +include(WarnUnmaintained) +warn_unmaintained(${MODULE_NAME} "-DWITH_CLIENT_WAYLAND=OFF") + include_directories(SYSTEM ${WAYLAND_INCLUDE_DIR}) set(${MODULE_PREFIX}_SRCS diff --git a/client/Windows/CMakeLists.txt b/client/Windows/CMakeLists.txt index 110f24e3d..d5dd95f8d 100644 --- a/client/Windows/CMakeLists.txt +++ b/client/Windows/CMakeLists.txt @@ -18,6 +18,9 @@ set(MODULE_NAME "wfreerdp-client") set(MODULE_PREFIX "FREERDP_CLIENT_WINDOWS_CONTROL") +include(WarnUnmaintained) +warn_unmaintained(${MODULE_NAME} "-DWITH_CLIENT_WINDOWS=OFF") + set(${MODULE_PREFIX}_SRCS wf_gdi.c wf_gdi.h diff --git a/client/iOS/CMakeLists.txt b/client/iOS/CMakeLists.txt index f69dd692d..b3099b14e 100644 --- a/client/iOS/CMakeLists.txt +++ b/client/iOS/CMakeLists.txt @@ -28,6 +28,9 @@ message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}") list(APPEND CMAKE_MODULE_PATH ${PROJECT_CURRENT_SOURCE_DIR}/../../cmake/) include(CommonConfigOptions) +include(WarnUnmaintained) +warn_unmaintained(${PROJECT_NAME} "-DWITH_CLIENT_IOS=OFF") + set(MODULE_NAME "iFreeRDP") set(MODULE_PREFIX "IFREERDP_CLIENT") set(APP_TYPE MACOSX_BUNDLE) diff --git a/cmake/WarnUnmaintained.cmake b/cmake/WarnUnmaintained.cmake index aa1746fa0..0cdb26051 100644 --- a/cmake/WarnUnmaintained.cmake +++ b/cmake/WarnUnmaintained.cmake @@ -11,4 +11,5 @@ macro(warn_unmaintained name) "[unmaintained] - don't hesitate to ask some questions. (replies might take some time depending on your timezone)" ) message(WARNING "[unmaintained] - if you intend using this component write us a message") + message(WARNING "[unmaintained] use ${ARGN} to disable") endmacro() diff --git a/server/Mac/CMakeLists.txt b/server/Mac/CMakeLists.txt index dd5792d36..4b6ecadd0 100644 --- a/server/Mac/CMakeLists.txt +++ b/server/Mac/CMakeLists.txt @@ -18,6 +18,9 @@ set(MODULE_NAME "mfreerdp-server") set(MODULE_PREFIX "FREERDP_SERVER_MAC") +include(WarnUnmaintained) +warn_unmaintained(${MODULE_NAME} "-DWITH_PLATFORM_SERVER=OFF") + find_library(AUDIO_TOOL AudioToolbox) find_library(CORE_AUDIO CoreAudio) find_library(CORE_VIDEO CoreVideo) diff --git a/server/Windows/CMakeLists.txt b/server/Windows/CMakeLists.txt index e052beb0f..570af40f1 100644 --- a/server/Windows/CMakeLists.txt +++ b/server/Windows/CMakeLists.txt @@ -19,7 +19,7 @@ set(MODULE_NAME "wfreerdp-server") set(MODULE_PREFIX "FREERDP_SERVER_WINDOWS") include(WarnUnmaintained) -warn_unmaintained(${MODULE_NAME}) +warn_unmaintained(${MODULE_NAME} "-DWITH_PLATFORM_SERVER=OFF") include_directories(.) diff --git a/server/shadow/CMakeLists.txt b/server/shadow/CMakeLists.txt index ea10b649b..1d7818f09 100644 --- a/server/shadow/CMakeLists.txt +++ b/server/shadow/CMakeLists.txt @@ -92,12 +92,17 @@ set(MODULE_NAME "freerdp-shadow-subsystem") set(SRCS shadow_subsystem_builtin.c) -if(WIN32) - add_subdirectory(Win) -elseif(NOT APPLE) - add_subdirectory(X11) -elseif(APPLE AND NOT IOS) - add_subdirectory(Mac) +option(WITH_SHADOW_SUBSYSTEM "Build actual shadow platform subsystem implementation" ON) +if(WITH_SHADOW_SUBSYSTEM) + if(WIN32) + add_subdirectory(Win) + elseif(NOT APPLE) + add_subdirectory(X11) + elseif(APPLE AND NOT IOS) + add_subdirectory(Mac) + endif() +else() + add_subdirectory(Sample) endif() addtargetwithresourcefile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" SRCS) diff --git a/server/shadow/Mac/CMakeLists.txt b/server/shadow/Mac/CMakeLists.txt index a66015683..791c7efd4 100644 --- a/server/shadow/Mac/CMakeLists.txt +++ b/server/shadow/Mac/CMakeLists.txt @@ -1,5 +1,5 @@ include(WarnUnmaintained) -warn_unmaintained("mac shadow server subsystem") +warn_unmaintained("mac shadow server subsystem" "-DWITH_SHADOW_SUBSYSTEM=OFF") find_library(IOKIT IOKit REQUIRED) find_library(IOSURFACE IOSurface REQUIRED) diff --git a/server/shadow/Sample/CMakeLists.txt b/server/shadow/Sample/CMakeLists.txt new file mode 100644 index 000000000..4fab84371 --- /dev/null +++ b/server/shadow/Sample/CMakeLists.txt @@ -0,0 +1 @@ +add_library(freerdp-shadow-subsystem-impl STATIC sample_shadow.c sample_shadow.h) diff --git a/server/shadow/Sample/sample_shadow.c b/server/shadow/Sample/sample_shadow.c new file mode 100644 index 000000000..cd34cf709 --- /dev/null +++ b/server/shadow/Sample/sample_shadow.c @@ -0,0 +1,177 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * Copyright 2025 Armin Novak + * Copyright 2025 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include "sample_shadow.h" + +#define TAG SERVER_TAG("shadow.sample") + +static BOOL sample_shadow_input_synchronize_event(WINPR_ATTR_UNUSED rdpShadowSubsystem* subsystem, + WINPR_ATTR_UNUSED rdpShadowClient* client, + WINPR_ATTR_UNUSED UINT32 flags) +{ + WLog_WARN(TAG, "TODO: Implement!"); + return TRUE; +} + +static BOOL sample_shadow_input_keyboard_event(WINPR_ATTR_UNUSED rdpShadowSubsystem* subsystem, + WINPR_ATTR_UNUSED rdpShadowClient* client, + WINPR_ATTR_UNUSED UINT16 flags, + WINPR_ATTR_UNUSED UINT8 code) +{ + WLog_WARN(TAG, "TODO: Implement!"); + return TRUE; +} + +static BOOL sample_shadow_input_unicode_keyboard_event( + WINPR_ATTR_UNUSED rdpShadowSubsystem* subsystem, WINPR_ATTR_UNUSED rdpShadowClient* client, + WINPR_ATTR_UNUSED UINT16 flags, WINPR_ATTR_UNUSED UINT16 code) +{ + WLog_WARN(TAG, "TODO: Implement!"); + return TRUE; +} + +static BOOL sample_shadow_input_mouse_event(WINPR_ATTR_UNUSED rdpShadowSubsystem* subsystem, + WINPR_ATTR_UNUSED rdpShadowClient* client, + WINPR_ATTR_UNUSED UINT16 flags, + WINPR_ATTR_UNUSED UINT16 x, WINPR_ATTR_UNUSED UINT16 y) +{ + WLog_WARN(TAG, "TODO: Implement!"); + return TRUE; +} + +static BOOL sample_shadow_input_extended_mouse_event( + WINPR_ATTR_UNUSED rdpShadowSubsystem* subsystem, WINPR_ATTR_UNUSED rdpShadowClient* client, + WINPR_ATTR_UNUSED UINT16 flags, WINPR_ATTR_UNUSED UINT16 x, WINPR_ATTR_UNUSED UINT16 y) +{ + WLog_WARN(TAG, "TODO: Implement!"); + return TRUE; +} + +static UINT32 sample_shadow_enum_monitors(WINPR_ATTR_UNUSED MONITOR_DEF* monitors, + WINPR_ATTR_UNUSED UINT32 maxMonitors) +{ + WLog_WARN(TAG, "TODO: Implement!"); + return 0; +} + +static int sample_shadow_subsystem_init(rdpShadowSubsystem* arg) +{ + sampleShadowSubsystem* subsystem = (sampleShadowSubsystem*)arg; + WINPR_ASSERT(subsystem); + + subsystem->base.numMonitors = sample_shadow_enum_monitors(subsystem->base.monitors, 16); + + WLog_WARN(TAG, "TODO: Implement!"); + + MONITOR_DEF* virtualScreen = &(subsystem->base.virtualScreen); + virtualScreen->left = 0; + virtualScreen->top = 0; + virtualScreen->right = 0; + virtualScreen->bottom = 0; + virtualScreen->flags = 1; + return 1; +} + +static int sample_shadow_subsystem_uninit(rdpShadowSubsystem* arg) +{ + sampleShadowSubsystem* subsystem = (sampleShadowSubsystem*)arg; + + if (!subsystem) + return -1; + + WLog_WARN(TAG, "TODO: Implement!"); + return 1; +} + +static int sample_shadow_subsystem_start(rdpShadowSubsystem* arg) +{ + sampleShadowSubsystem* subsystem = (sampleShadowSubsystem*)arg; + + if (!subsystem) + return -1; + + WLog_WARN(TAG, "TODO: Implement!"); + + return 1; +} + +static int sample_shadow_subsystem_stop(rdpShadowSubsystem* arg) +{ + sampleShadowSubsystem* subsystem = (sampleShadowSubsystem*)arg; + + if (!subsystem) + return -1; + + WLog_WARN(TAG, "TODO: Implement!"); + + return 1; +} + +static void sample_shadow_subsystem_free(rdpShadowSubsystem* arg) +{ + sampleShadowSubsystem* subsystem = (sampleShadowSubsystem*)arg; + + if (!subsystem) + return; + + sample_shadow_subsystem_uninit(arg); + free(subsystem); +} + +static rdpShadowSubsystem* sample_shadow_subsystem_new(void) +{ + sampleShadowSubsystem* subsystem = + (sampleShadowSubsystem*)calloc(1, sizeof(sampleShadowSubsystem)); + + if (!subsystem) + return NULL; + + subsystem->base.SynchronizeEvent = sample_shadow_input_synchronize_event; + subsystem->base.KeyboardEvent = sample_shadow_input_keyboard_event; + subsystem->base.UnicodeKeyboardEvent = sample_shadow_input_unicode_keyboard_event; + subsystem->base.MouseEvent = sample_shadow_input_mouse_event; + subsystem->base.ExtendedMouseEvent = sample_shadow_input_extended_mouse_event; + return &subsystem->base; +} + +const char* ShadowSubsystemName(void) +{ + return "Sample"; +} + +int ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints) +{ + pEntryPoints->New = sample_shadow_subsystem_new; + pEntryPoints->Free = sample_shadow_subsystem_free; + pEntryPoints->Init = sample_shadow_subsystem_init; + pEntryPoints->Uninit = sample_shadow_subsystem_uninit; + pEntryPoints->Start = sample_shadow_subsystem_start; + pEntryPoints->Stop = sample_shadow_subsystem_stop; + pEntryPoints->EnumMonitors = sample_shadow_enum_monitors; + return 1; +} diff --git a/server/shadow/Sample/sample_shadow.h b/server/shadow/Sample/sample_shadow.h new file mode 100644 index 000000000..cbe1ff279 --- /dev/null +++ b/server/shadow/Sample/sample_shadow.h @@ -0,0 +1,43 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * Copyright 2025 Armin Novak + * Copyright 2025 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct sample_shadow_subsystem sampleShadowSubsystem; + + struct sample_shadow_subsystem + { + rdpShadowSubsystem base; + + /* Additional platform specific stuff goes here */ + }; + + FREERDP_API const char* ShadowSubsystemName(void); + FREERDP_API int ShadowSubsystemEntry(RDP_SHADOW_ENTRY_POINTS* pEntryPoints); + +#ifdef __cplusplus +} +#endif diff --git a/server/shadow/Win/CMakeLists.txt b/server/shadow/Win/CMakeLists.txt index 48f5d14c4..544fc9083 100644 --- a/server/shadow/Win/CMakeLists.txt +++ b/server/shadow/Win/CMakeLists.txt @@ -1,5 +1,5 @@ include(WarnUnmaintained) -warn_unmaintained("windows shadow server subsystem") +warn_unmaintained("windows shadow server subsystem" "-DWITH_SHADOW_SUBSYSTEM=OFF") add_compile_definitions(WITH_SHADOW_WIN) add_library(