Skip to content

Commit

Permalink
[freerdp] Fix tools
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt committed Jul 10, 2023
1 parent 28775a0 commit e31f8f8
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 5 deletions.
27 changes: 27 additions & 0 deletions ports/freerdp/fix-install-destination.patch
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8894a58..d2f8b2f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -960,6 +960,9 @@ else()
set(FREERDP_LIBRARY_PATH "${CMAKE_INSTALL_LIBDIR}")
set(FREERDP_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/freerdp${FREERDP_VERSION_MAJOR}")
endif()
+set(FREERDP_DATA_PATH "share/freerdp")
+set(FREERDP_LIBRARY_PATH "${CMAKE_INSTALL_LIBDIR}")
+set(FREERDP_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/freerdp${FREERDP_VERSION_MAJOR}")
set(FREERDP_ADDIN_PATH "${FREERDP_PLUGIN_PATH}")

# Path to put extensions
diff --git a/client/Windows/CMakeLists.txt b/client/Windows/CMakeLists.txt
index 6274571..b0a5d27 100644
--- a/client/Windows/CMakeLists.txt
Expand Down Expand Up @@ -63,6 +77,19 @@ index c94a209..7c533b7 100644
if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS)
get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME)
install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols)
diff --git a/server/shadow/CMakeLists.txt b/server/shadow/CMakeLists.txt
index 3e0df0b..e54fb04 100644
--- a/server/shadow/CMakeLists.txt
+++ b/server/shadow/CMakeLists.txt
@@ -86,7 +86,7 @@ if (WITH_LIBRARY_VERSIONING)
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION})
endif()

-install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT server EXPORT FreeRDP-ShadowTargets)
+install(TARGETS ${MODULE_NAME} COMPONENT server EXPORT FreeRDP-ShadowTargets)

if (WITH_DEBUG_SYMBOLS AND MSVC)
get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME)
diff --git a/winpr/libwinpr/CMakeLists.txt b/winpr/libwinpr/CMakeLists.txt
index 2df8d89..da23a1b 100644
--- a/winpr/libwinpr/CMakeLists.txt
Expand Down
23 changes: 20 additions & 3 deletions ports/freerdp/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ vcpkg_from_github(
DontInstallSystemRuntimeLibs.patch
fix-include-path.patch
fix-install-destination.patch
wfreerdp-server-cli.patch
pr-7060-jni-onload.patch
)
file(REMOVE "${SOURCE_PATH}/cmake/FindOpenSSL.cmake")
file(WRITE "${SOURCE_PATH}/.source_version" "${VERSION}-vcpkg")
Expand All @@ -23,6 +25,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
server WITH_SERVER
urbdrc CHANNEL_URBDRC
wayland WITH_WAYLAND
winpr-tools WITH_WINPR_TOOLS
x11 WITH_X11
)

Expand Down Expand Up @@ -52,18 +55,30 @@ vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()

set(tools winpr-hash winpr-makecert)
vcpkg_list(SET tools)
if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND tools wfreerdp)
if("server" IN_LIST FEATURES)
list(APPEND tools wfreerdp-server)
endif()
elseif(VCPKG_TARGET_IS_OSX)
list(APPEND tools mfreerdp)
file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/client/Mac/cli/MacFreeRDP.app"
DESTINATION "${CURRENT_PACKAGES_DIR}/bin"
)
list(APPEND tools MacFreeRDP)
if("server" IN_LIST FEATURES)
list(APPEND tools mfreerdp-server)
endif()
endif()
if("wayland" IN_LIST FEATURES)
list(APPEND tools wlfreerdp)
endif()
if("x11" IN_LIST FEATURES)
list(APPEND tools xfreerdp)
endif()
if("winpr-tools" IN_LIST FEATURES)
list(APPEND tools winpr-hash winpr-makecert)
endif()
if("server" IN_LIST FEATURES)
list(APPEND tools freerdp-proxy freerdp-shadow-cli)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/FreeRDP-Server2 PACKAGE_NAME freerdp-server2 DO_NOT_DELETE_PARENT_CONFIG_PATH)
Expand All @@ -73,7 +88,9 @@ vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/FreeRDP-Client2 PACKAGE_NAME free
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/WinPR2 PACKAGE_NAME winpr2 DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/FreeRDP2 PACKAGE_NAME freerdp)

vcpkg_copy_tools(TOOL_NAMES ${tools} AUTO_CLEAN)
if(tools)
vcpkg_copy_tools(TOOL_NAMES ${tools} AUTO_CLEAN)
endif()

vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/freerdp/build-config.h" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" ".")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/freerdp/build-config.h" "${CURRENT_PACKAGES_DIR}/" "")
Expand Down
89 changes: 89 additions & 0 deletions ports/freerdp/pr-7060-jni-onload.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
diff --git a/client/Android/android_freerdp.c b/client/Android/android_freerdp.c
index 0fd987f446e..014c4d4db96 100644
--- a/client/Android/android_freerdp.c
+++ b/client/Android/android_freerdp.c
@@ -1093,7 +1093,10 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
(*env)->RegisterNatives(env, activityClass, methods, sizeof(methods) / sizeof(methods[0]));
/* create global reference for class */
gJavaActivityClass = (*env)->NewGlobalRef(env, activityClass);
+
g_JavaVm = vm;
+ winpr_set_java_vm((void*)vm);
+
return init_callback_environment(vm, env);
}

diff --git a/winpr/include/winpr/sysinfo.h b/winpr/include/winpr/sysinfo.h
index c14e999d970..7af615947bd 100644
--- a/winpr/include/winpr/sysinfo.h
+++ b/winpr/include/winpr/sysinfo.h
@@ -344,6 +344,20 @@ extern "C"
#define PF_SSE_INSTRUCTIONS_AVAILABLE PF_XMMI_INSTRUCTIONS_AVAILABLE
#define PF_SSE2_INSTRUCTIONS_AVAILABLE PF_XMMI64_INSTRUCTIONS_AVAILABLE

+#ifdef ANDROID
+
+ /*
+ * Call winpr_set_java_vm() from JNI_OnLoad in a shared library:
+ * JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
+ * and then call winpr_get_java_vm to obtain the JavaVM* handle.
+ * The functions use void* to avoid including jni.h in exported headers.
+ */
+
+ WINPR_API void winpr_set_java_vm(void* vm);
+ WINPR_API void* winpr_get_java_vm();
+
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/winpr/libwinpr/sysinfo/sysinfo.c b/winpr/libwinpr/sysinfo/sysinfo.c
index dd15bb374e2..a4d0ddf90cc 100644
--- a/winpr/libwinpr/sysinfo/sysinfo.c
+++ b/winpr/libwinpr/sysinfo/sysinfo.c
@@ -988,3 +988,20 @@ BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature)
#endif
return ret;
}
+
+#ifdef ANDROID
+
+#include <jni.h>
+static JavaVM* g_JavaVM = NULL;
+
+void winpr_set_java_vm(void* vm)
+{
+ g_JavaVM = (JavaVM*)vm;
+}
+
+void* winpr_get_java_vm()
+{
+ return (void*)g_JavaVM;
+}
+
+#endif
diff --git a/winpr/libwinpr/timezone/timezone.c b/winpr/libwinpr/timezone/timezone.c
index b29ecab33dd..c42928d6738 100644
--- a/winpr/libwinpr/timezone/timezone.c
+++ b/winpr/libwinpr/timezone/timezone.c
@@ -151,18 +151,12 @@ static char* winpr_get_timezone_from_link(void)

#if defined(ANDROID)
#include <jni.h>
-static JavaVM* jniVm = NULL;
-
-JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
-{
- jniVm = vm;
- return JNI_VERSION_1_6;
-}

static char* winpr_get_android_timezone_identifier(void)
{
char* tzid = NULL;
JNIEnv* jniEnv;
+ JavaVM* jniVm = (JavaVM*)winpr_get_java_vm();

/* Preferred: Try to get identifier from java TimeZone class */
if (jniVm && ((*jniVm)->GetEnv(jniVm, (void**)&jniEnv, JNI_VERSION_1_6) == JNI_OK))
4 changes: 4 additions & 0 deletions ports/freerdp/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
"wayland"
]
},
"winpr-tools": {
"description": "Build winpr tools",
"supports": "!android & !ios & !uwp"
},
"x11": {
"description": "Enable X11 support",
"supports": "!windows & !android & !ios",
Expand Down
12 changes: 12 additions & 0 deletions ports/freerdp/wfreerdp-server-cli.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/server/Windows/cli/CMakeLists.txt b/server/Windows/cli/CMakeLists.txt
index fcfa811..e4d4360 100644
--- a/server/Windows/cli/CMakeLists.txt
+++ b/server/Windows/cli/CMakeLists.txt
@@ -41,6 +41,7 @@ set (${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})

set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "wfreerdp-server")
+set_target_properties(${MODULE_NAME} PROPERTIES PDB_NAME "${MODULE_NAME}.pdb")

set(${MODULE_PREFIX}_LIBS wfreerdp-server)

3 changes: 2 additions & 1 deletion scripts/test_ports/vcpkg-ci-freerdp/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
{
"name": "freerdp",
"features": [
"server"
"server",
"winpr-tools"
],
"platform": "linux | osx | windows"
}
Expand Down
2 changes: 1 addition & 1 deletion versions/f-/freerdp.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"versions": [
{
"git-tree": "1cfe1d66672148a5fe0937f6319433f6944f6f34",
"git-tree": "8fdcd3d604c41a055ad0c0644b8112f2db0067cd",
"version": "2.10.0",
"port-version": 0
},
Expand Down

0 comments on commit e31f8f8

Please sign in to comment.