From 3811c091e5ee423ea2e3c9f8bb65b42c342f54e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=2E=20R=C3=B8dseth?= Date: Tue, 22 Dec 2020 13:40:24 +0100 Subject: [PATCH 1/4] Port from GTK 2 to GTK 3 --- CMakeLists.txt | 2 +- README.md | 10 ++--- azure-pipelines.yml | 2 +- cmake/{FindGTK2.cmake => FindGTK3.cmake} | 54 ++++++++++++------------ extra/azure-pipelines/build-linux.yml | 4 +- libs/ui/CMakeLists.txt | 8 ++-- libs/ui/ui.c | 4 +- 7 files changed, 42 insertions(+), 42 deletions(-) rename cmake/{FindGTK2.cmake => FindGTK3.cmake} (56%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 930c1ab6..0e150cb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,7 @@ set(NEKO_VERSION ${NEKO_VERSION_MAJOR}.${NEKO_VERSION_MINOR}.${NEKO_VERSION_PATC TEST_BIG_ENDIAN(NEKO_BIG_ENDIAN) option(WITH_REGEXP "Build Perl-compatible regex support." ON) -option(WITH_UI "Build GTK-2 UI support." ON) +option(WITH_UI "Build GTK-3 UI support." ON) option(WITH_SSL "Build SSL support." ON) option(WITH_MYSQL "Build MySQL support." ON) option(WITH_SQLITE "Build Sqlite support." ON) diff --git a/README.md b/README.md index 70c16b3f..3965608b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Users of other Linux/FreeBSD distributions should build Neko from source. See be Neko can be built using CMake (version 3.x is recommended) and one of the C compilers listed as follows: - * Windows: Visual Studio 2010 / 2013 / 2015 / 2017 + * Windows: Visual Studio 2010 / 2013 / 2015 / 2017 * Mac: XCode (with its "Command line tools") * Linux: gcc (can be obtained by installing the "build-essential" Debian/Ubuntu package) @@ -41,7 +41,7 @@ Neko needs to link with various third-party libraries, which are summarized as f | MariaDB / MySQL (Connector/C) | all | libmariadb-client-lgpl-dev-compat (or libmysqlclient-dev) | | SQLite | all | libsqlite3-dev | | mbed TLS | all | libmbedtls-dev | -| GTK+2 | Linux | libgtk2.0-dev | +| GTK+3 | Linux | libgtk-3-dev | On Windows, CMake will automatically download and build the libraries in the build folder during the build process. However, you need to install [Perl](http://www.activestate.com/activeperl) manually because OpenSSL needs it for configuration. On Mac/Linux, you should install the libraries manually to your system before building Neko, or use the `STATIC_DEPS` CMake option, which will be explained in [CMake options](#cmake-options). @@ -73,7 +73,7 @@ You may use the CMake GUI and Visual Studio to build it instead. mkdir build cd build -# run cmake specifying the visual studio version you need +# run cmake specifying the visual studio version you need # Visual Studio 12 2013, Visual Studio 14 2015, Visual Studio 15 2017 # you can additionally specify platform via -A switch (x86, x64) cmake -G "Visual Studio 12 2013" .. @@ -99,7 +99,7 @@ cmake "-Doption=value" .. Settings that allow to exclude libraries and their dependencies from the build; available on all platforms. By default all are `ON`: - `WITH_REGEXP` - Build Perl-compatible regex support -- `WITH_UI` - Build GTK-2 UI support +- `WITH_UI` - Build GTK-3 UI support - `WITH_SSL` - Build SSL support - `WITH_MYSQL` - Build MySQL support - `WITH_SQLITE` - Build Sqlite support @@ -113,7 +113,7 @@ It defines the dependencies that should be linked statically. Can be `all`, `non CMake will automatically download and build the specified dependencies into the build folder. If a library is not present in this list, it should be installed manually, and it will be linked dynamically. -All third-party libraries, except GTK+2 (Linux), can be linked statically. We do not support statically linking GTK+2 due to the difficulty of building it and its own dependencies. +All third-party libraries, except GTK+3 (Linux), can be linked statically. We do not support statically linking GTK+3 due to the difficulty of building it and its own dependencies. #### `RELOCATABLE` diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1a66a87d..1c0bdcb5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -190,7 +190,7 @@ stages: - script: | set -ex sudo apt-get update -qqy - sudo apt-get install -qqy ninja-build pkg-config libgtk2.0-dev devscripts git-buildpackage ubuntu-dev-tools dh-make dh-apache2 + sudo apt-get install -qqy ninja-build pkg-config libgtk-3-dev devscripts git-buildpackage ubuntu-dev-tools dh-make dh-apache2 displayName: Install devscripts - script: cmake . -DSTATIC_DEPS=all displayName: CMake diff --git a/cmake/FindGTK2.cmake b/cmake/FindGTK3.cmake similarity index 56% rename from cmake/FindGTK2.cmake rename to cmake/FindGTK3.cmake index e7846928..714f66a7 100644 --- a/cmake/FindGTK2.cmake +++ b/cmake/FindGTK3.cmake @@ -1,64 +1,64 @@ -FILE(TO_CMAKE_PATH "$ENV{GTK2_DIR}" TRY1_DIR) -FILE(TO_CMAKE_PATH "${GTK2_DIR}" TRY2_DIR) +FILE(TO_CMAKE_PATH "$ENV{GTK3_DIR}" TRY1_DIR) +FILE(TO_CMAKE_PATH "${GTK3_DIR}" TRY2_DIR) FILE(GLOB GTK_DIR ${TRY1_DIR} ${TRY2_DIR}) -FIND_PATH(GTK_gtk_2_INCLUDE_DIR gtk/gtk.h +FIND_PATH(GTK_gtk_3_INCLUDE_DIR gtk/gtk.h ENV INCLUDE DOC "Directory containing gtk/gtk.h include file") -FIND_PATH(GTK_gdk_2_INCLUDE_DIR gdk/gdk.h +FIND_PATH(GTK_gdk_3_INCLUDE_DIR gdk/gdk.h ENV INCLUDE DOC "Directory containing gdk/gdk.h include file") -FIND_PATH(GTK_gdkconfig_2_INCLUDE_DIR gdkconfig.h +FIND_PATH(GTK_gdkconfig_3_INCLUDE_DIR gdkconfig.h ENV INCLUDE DOC "Directory containing gdkconfig.h include file") -FIND_LIBRARY(GTK_gdk_pixbuf_2_LIBRARY NAMES gdk_pixbuf-2.0 +FIND_LIBRARY(GTK_gdk_pixbuf_3_LIBRARY NAMES gdk_pixbuf-3.0 PATHS ${GTK_DIR}/lib ${GTK_DIR}/bin ${GTK_DIR}/win32/bin ${GTK_DIR}/lib ${GTK_DIR}/win32/lib /usr/local/lib /usr/lib ENV LIB DOC "gdk_pixbuf library to link with" NO_SYSTEM_ENVIRONMENT_PATH) -FIND_LIBRARY(GTK_gdk_2_LIBRARY NAMES gdk-win32-2.0 gdk-x11-2.0 +FIND_LIBRARY(GTK_gdk_3_LIBRARY NAMES gdk-win32-3.0 gdk-x11-3.0 PATHS ${GTK_DIR}/lib ${GTK_DIR}/bin ${GTK_DIR}/win32/bin ${GTK_DIR}/lib ${GTK_DIR}/win32/lib /usr/lib /usr/local/lib ENV LIB - DOC "gdk2 library to link with" + DOC "gdk3 library to link with" NO_SYSTEM_ENVIRONMENT_PATH) -FIND_LIBRARY(GTK_gtk_2_LIBRARY NAMES gtk-win32-2.0 gtk-x11-2.0 +FIND_LIBRARY(GTK_gtk_3_LIBRARY NAMES gtk-win32-3.0 gtk-x11-3.0 PATHS ${GTK_DIR}/lib ${GTK_DIR}/bin ${GTK_DIR}/win32/bin ${GTK_DIR}/lib ${GTK_DIR}/win32/lib /usr/lib /usr/local/lib ENV LIB - DOC "gtk2 library to link with" + DOC "gtk3 library to link with" NO_SYSTEM_ENVIRONMENT_PATH) -FIND_LIBRARY(GTK_gdk_pixbuf_2_STATIC_LIBRARY NAMES libgdk_pixbuf-2.0.a +FIND_LIBRARY(GTK_gdk_pixbuf_3_STATIC_LIBRARY NAMES libgdk_pixbuf-3.0.a PATHS ${GTK_DIR}/lib ${GTK_DIR}/bin ${GTK_DIR}/win32/bin ${GTK_DIR}/lib ${GTK_DIR}/win32/lib /usr/local/lib /usr/lib ENV LIB DOC "gdk_pixbuf library to link with" NO_SYSTEM_ENVIRONMENT_PATH) -FIND_LIBRARY(GTK_gdk_2_STATIC_LIBRARY NAMES libgdk-x11-2.0.a +FIND_LIBRARY(GTK_gdk_3_STATIC_LIBRARY NAMES libgdk-x11-3.0.a PATHS ${GTK_DIR}/lib ${GTK_DIR}/bin ${GTK_DIR}/win32/bin ${GTK_DIR}/lib ${GTK_DIR}/win32/lib /usr/lib /usr/local/lib ENV LIB - DOC "gdk2 library to link with" + DOC "gdk3 library to link with" NO_SYSTEM_ENVIRONMENT_PATH) -FIND_LIBRARY(GTK_gtk_2_STATIC_LIBRARY NAMES libgtk-x11-2.0.a +FIND_LIBRARY(GTK_gtk_3_STATIC_LIBRARY NAMES libgtk-x11-3.0.a PATHS ${GTK_DIR}/lib ${GTK_DIR}/bin ${GTK_DIR}/win32/bin ${GTK_DIR}/lib ${GTK_DIR}/win32/lib /usr/lib /usr/local/lib ENV LIB - DOC "gtk2 library to link with" + DOC "gtk3 library to link with" NO_SYSTEM_ENVIRONMENT_PATH) -IF (GTK_gtk_2_INCLUDE_DIR AND GTK_gdk_2_INCLUDE_DIR AND GTK_gdkconfig_2_INCLUDE_DIR) - SET(GTK2_INCLUDE_DIR ${GTK_gtk_2_INCLUDE_DIR} ${GTK_gdk_2_INCLUDE_DIR} ${GTK_gdkconfig_2_INCLUDE_DIR}) - list(REMOVE_DUPLICATES GTK2_INCLUDE_DIR) - SET(GTK2_LIBRARIES ${GTK_gdk_pixbuf_2_LIBRARY} ${GTK_gdk_2_LIBRARY} ${GTK_gtk_2_LIBRARY}) - list(REMOVE_DUPLICATES GTK2_LIBRARIES) - SET(GTK2_STATIC_LIBRARIES ${GTK_gdk_pixbuf_2_STATIC_LIBRARY} ${GTK_gdk_2_STATIC_LIBRARY} ${GTK_gtk_2_STATIC_LIBRARY}) - list(REMOVE_DUPLICATES GTK2_STATIC_LIBRARIES) - SET(GTK2_FOUND TRUE) +IF (GTK_gtk_3_INCLUDE_DIR AND GTK_gdk_3_INCLUDE_DIR AND GTK_gdkconfig_3_INCLUDE_DIR) + SET(GTK3_INCLUDE_DIR ${GTK_gtk_3_INCLUDE_DIR} ${GTK_gdk_3_INCLUDE_DIR} ${GTK_gdkconfig_3_INCLUDE_DIR}) + list(REMOVE_DUPLICATES GTK3_INCLUDE_DIR) + SET(GTK3_LIBRARIES ${GTK_gdk_pixbuf_3_LIBRARY} ${GTK_gdk_3_LIBRARY} ${GTK_gtk_3_LIBRARY}) + list(REMOVE_DUPLICATES GTK3_LIBRARIES) + SET(GTK3_STATIC_LIBRARIES ${GTK_gdk_pixbuf_3_STATIC_LIBRARY} ${GTK_gdk_3_STATIC_LIBRARY} ${GTK_gtk_3_STATIC_LIBRARY}) + list(REMOVE_DUPLICATES GTK3_STATIC_LIBRARIES) + SET(GTK3_FOUND TRUE) - message(STATUS "GTK2_INCLUDE_DIR: ${GTK2_INCLUDE_DIR}") - message(STATUS "GTK2_LIBRARIES: ${GTK2_LIBRARIES}") - message(STATUS "GTK2_STATIC_LIBRARIES: ${GTK2_STATIC_LIBRARIES}") -ENDIF () \ No newline at end of file + message(STATUS "GTK3_INCLUDE_DIR: ${GTK3_INCLUDE_DIR}") + message(STATUS "GTK3_LIBRARIES: ${GTK3_LIBRARIES}") + message(STATUS "GTK3_STATIC_LIBRARIES: ${GTK3_STATIC_LIBRARIES}") +ENDIF () diff --git a/extra/azure-pipelines/build-linux.yml b/extra/azure-pipelines/build-linux.yml index 29787193..87cbdb38 100644 --- a/extra/azure-pipelines/build-linux.yml +++ b/extra/azure-pipelines/build-linux.yml @@ -10,10 +10,10 @@ jobs: vmImage: ${{ parameters.vmImage }} variables: ${{ if eq(parameters.staticDeps, 'true') }}: - APT_PACKAGES: cmake ninja-build pkg-config libgtk2.0-dev + APT_PACKAGES: cmake ninja-build pkg-config libgtk-3-dev STATIC_DEPS: all ${{ if eq(parameters.staticDeps, 'false') }}: - APT_PACKAGES: cmake ninja-build pkg-config libgtk2.0-dev libgc-dev libpcre3-dev zlib1g-dev apache2-dev libmysqlclient-dev libsqlite3-dev + APT_PACKAGES: cmake ninja-build pkg-config libgtk-3-dev libgc-dev libpcre3-dev zlib1g-dev apache2-dev libmysqlclient-dev libsqlite3-dev STATIC_DEPS: none steps: - script: | diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt index 72b37ba7..e53b77c8 100644 --- a/libs/ui/CMakeLists.txt +++ b/libs/ui/CMakeLists.txt @@ -11,12 +11,12 @@ if(APPLE) find_library(CARBON_LIBRARY Carbon REQUIRED) target_link_libraries(ui.ndll ${CARBON_LIBRARY}) elseif(UNIX) - pkg_check_modules(GTK2 REQUIRED gtk+-2.0) + pkg_check_modules(GTK3 REQUIRED gtk+-3.0) target_include_directories(ui.ndll PRIVATE - ${GTK2_INCLUDEDIR} - ${GTK2_INCLUDE_DIRS} + ${GTK3_INCLUDEDIR} + ${GTK3_INCLUDE_DIRS} ) - target_link_libraries(ui.ndll ${GTK2_LIBRARIES}) + target_link_libraries(ui.ndll ${GTK3_LIBRARIES}) endif() set_target_properties(ui.ndll diff --git a/libs/ui/ui.c b/libs/ui/ui.c index 334567ea..3d8c298d 100644 --- a/libs/ui/ui.c +++ b/libs/ui/ui.c @@ -48,7 +48,7 @@ enum { pFunc = 'func' };

UI

Core native User Interface support. This API uses native WIN32 API on Windows, - Carbon API on OSX, and GTK2 on Linux. + Carbon API on OSX, and GTK3 on Linux.

**/ @@ -248,7 +248,7 @@ static value ui_sync( value f ) { // however the GTK lock mechanism is a LOT slower than // using a pthread_mutex pthread_mutex_lock(&data.lock); - gtk_timeout_add( 0, onSyncCall, (gpointer)r ); + gdk_threads_add_timeout( 0, onSyncCall, (gpointer)r ); pthread_mutex_unlock(&data.lock); # endif return val_null; From dd371ef4e1f8ae882305a9bc3ac98280da10b350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=2E=20R=C3=B8dseth?= Date: Mon, 27 Mar 2023 19:08:20 +0200 Subject: [PATCH 2/4] Update the Earthfile --- Earthfile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Earthfile b/Earthfile index 77f9f241..b987d351 100644 --- a/Earthfile +++ b/Earthfile @@ -55,7 +55,13 @@ devcontainer-base: cmake \ ninja-build \ pkg-config \ - libgtk2.0-dev \ + libgtk-3-dev \ + libgc-dev \ + libpcre3-dev \ + zlib1g-dev \ + apache2-dev \ + libmysqlclient-dev \ + libsqlite3-dev \ $LINK_DYNAMIC_PACKAGES \ # # Clean up @@ -151,7 +157,13 @@ build-env: git \ ninja-build \ pkg-config \ - libgtk2.0-dev \ + libgtk-3-dev \ + libgc-dev \ + libpcre3-dev \ + zlib1g-dev \ + apache2-dev \ + libmysqlclient-dev \ + libsqlite3-dev \ # # Clean up && apt-get autoremove -y \ From ba62d581de1487d915a793e7ffc199cee576a608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=2E=20R=C3=B8dseth?= Date: Mon, 27 Mar 2023 19:09:29 +0200 Subject: [PATCH 3/4] Add missing line from README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b72885f..b9106af9 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ It defines the dependencies that should be linked statically. Can be `all`, `non CMake will automatically download and build the specified dependencies into the build folder. If a library is not present in this list, it should be installed manually, and it will be linked dynamically. -All third-party libraries, except GTK+3 (Linux) and BoehmGC on Windows, can be linked statically. We do not support statically linking GTK+3 due to the difficulty of building it and its own dependencies. +All third-party libraries, except GTK+3 (Linux) and BoehmGC on Windows, can be linked statically. We do not support statically linking GTK+3 due to the difficulty of building it and its own dependencies. Additionally, we do not support statically linking the BoehmGC library on Windows systems. Finally, on MacOS, APRutil cannot be linked statically as it has been merged with APR 2.0, which is used on MacOS builds. #### `RELOCATABLE` From 98d2e32858d773f341ae46adbeb6615b60050d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=2E=20R=C3=B8dseth?= Date: Mon, 27 Mar 2023 19:20:30 +0200 Subject: [PATCH 4/4] Update the Earthfile --- Earthfile | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Earthfile b/Earthfile index b987d351..0cb79420 100644 --- a/Earthfile +++ b/Earthfile @@ -56,12 +56,6 @@ devcontainer-base: ninja-build \ pkg-config \ libgtk-3-dev \ - libgc-dev \ - libpcre3-dev \ - zlib1g-dev \ - apache2-dev \ - libmysqlclient-dev \ - libsqlite3-dev \ $LINK_DYNAMIC_PACKAGES \ # # Clean up @@ -158,12 +152,6 @@ build-env: ninja-build \ pkg-config \ libgtk-3-dev \ - libgc-dev \ - libpcre3-dev \ - zlib1g-dev \ - apache2-dev \ - libmysqlclient-dev \ - libsqlite3-dev \ # # Clean up && apt-get autoremove -y \