Skip to content

Commit

Permalink
Added support for libjavascriptcoregtk-6.0.
Browse files Browse the repository at this point in the history
Appears Apple might be using an older version of the JavaScriptCore API.
Remove unused JSCore4GTK functions.
  • Loading branch information
nmoinvaz committed Dec 25, 2024
1 parent 6444b36 commit c744b88
Show file tree
Hide file tree
Showing 6 changed files with 493 additions and 151 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
compiler: clang
cxx-compiler: clang++
cmake-args: -G Ninja -D PROXYRES_CODE_COVERAGE=ON
packages: llvm-14 libjavascriptcoregtk-4.0-dev libgconf2-dev
packages: llvm-14 libjavascriptcoregtk-4.1-dev libgconf2-dev
gcov-exec: llvm-cov-14 gcov
codecov: ubuntu

Expand All @@ -34,7 +34,7 @@ jobs:
compiler: clang
cxx-compiler: clang++
cmake-args: -G Ninja -D PROXYRES_CODE_COVERAGE=ON
packages: llvm-15 libjavascriptcoregtk-4.1-dev gsettings-desktop-schemas
packages: llvm-15 libjavascriptcoregtk-6.0-dev gsettings-desktop-schemas
gcov-exec: llvm-cov-15 gcov
codecov: ubuntu

Expand All @@ -43,7 +43,7 @@ jobs:
compiler: clang
cxx-compiler: clang++
cmake-args: -G Ninja -D PROXYRES_CODE_COVERAGE=ON -D PROXYRES_CURL=ON
packages: llvm-15 libjavascriptcoregtk-4.1-dev gsettings-desktop-schemas
packages: llvm-15 libjavascriptcoregtk-6.0-dev gsettings-desktop-schemas
gcov-exec: llvm-cov-15 gcov
codecov: ubuntu_curl

Expand Down
24 changes: 18 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ elseif(UNIX)
if (GConf_FOUND)
list(APPEND PROXYRES_SRCS config_gnome2.c config_gnome2.h)
endif()

list(APPEND PROXYRES_SRCS
config_env.c
config_env.h
Expand All @@ -128,8 +129,8 @@ elseif(UNIX)
config_kde.c
config_kde.h
event_pthread.c
execute_jscore.c
execute_jscore.h
execute_jsc.c
execute_jsc.h
mutex_pthread.c
net_adapter_linux.c
resolver_gnome3.c
Expand Down Expand Up @@ -186,7 +187,7 @@ if(PROXYRES_CODE_COVERAGE AND NOT MSVC)
endif()

add_library(proxyres ${PROXYRES_SRCS})
set_property(TARGET proxyres PROPERTY C_STANDARD 99)
set_property(TARGET proxyres PROPERTY C_STANDARD 11)
target_include_directories(proxyres PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include/proxyres)
Expand Down Expand Up @@ -284,6 +285,8 @@ elseif(APPLE)
target_link_libraries(proxyres ${CMAKE_THREAD_LIBS_INIT})

set_target_properties(proxyres PROPERTIES LINK_FLAGS -Wl,-F/Library/Frameworks)

target_compile_definitions(proxyres PRIVATE HAVE_JSCORE)
elseif(UNIX)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET glib-2.0)
target_link_libraries(proxyres PkgConfig::deps)
Expand All @@ -294,9 +297,18 @@ elseif(UNIX)
target_compile_definitions(proxyres PRIVATE HAVE_GCONF)
endif()

pkg_search_module(JSCoreGTK REQUIRED javascriptcoregtk-4.1 javascriptcoregtk-4.0 javascriptcoregtk-3.0 javascriptcoregtk-1.0)
# Don't link libraries at compile time since we dynamically load them at runtime
target_include_directories(proxyres PRIVATE ${JSCoreGTK_INCLUDE_DIRS})
pkg_search_module(JSCoreGTK REQUIRED javascriptcoregtk-6.0 javascriptcoregtk-4.1 javascriptcoregtk-4.0)
if(JSCoreGTK_FOUND)
# Don't link libraries at compile time since we dynamically load them at runtime
target_include_directories(proxyres PRIVATE ${JSCoreGTK_INCLUDE_DIRS})
target_compile_definitions(proxyres PRIVATE HAVE_JSC)

pkg_check_modules(GObject REQUIRED gobject-2.0)
if(GObject_FOUND)
target_include_directories(proxyres PRIVATE ${GObject_INCLUDE_DIRS})
target_link_libraries(proxyres ${GObject_LIBRARIES})
endif()
endif()

find_package(Threads REQUIRED)
target_compile_definitions(proxyres PRIVATE HAVE_PTHREADS)
Expand Down
15 changes: 13 additions & 2 deletions execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
# include "execute_wsh.h"
# endif
#else
# include "execute_jscore.h"
# ifdef HAVE_JSC
# include "execute_jsc.h"
# endif
# ifdef HAVE_JSCORE
# include "execute_jscore.h"
# endif
#endif

typedef struct g_proxy_execute_s {
Expand Down Expand Up @@ -64,8 +69,14 @@ bool proxy_execute_global_init(void) {
g_proxy_execute.proxy_execute_i = proxy_execute_wsh_get_interface();
# endif
#else
if (proxy_execute_jscore_global_init())
# ifdef HAVE_JSC
if (proxy_execute_jsc_global_init())
g_proxy_execute.proxy_execute_i = proxy_execute_jsc_get_interface();
# endif
# ifdef HAVE_JSCORE
if (!g_proxy_execute.proxy_execute_i && proxy_execute_jscore_global_init())
g_proxy_execute.proxy_execute_i = proxy_execute_jscore_get_interface();
# endif
#endif
if (!g_proxy_execute.proxy_execute_i)
return false;
Expand Down
Loading

0 comments on commit c744b88

Please sign in to comment.