From 8af9571a074211cecc876ce6a2c69d1db763dde5 Mon Sep 17 00:00:00 2001 From: ggainant Date: Thu, 2 Jan 2020 15:14:39 -0600 Subject: [PATCH 1/6] [glib] Add static build support on windows + Fix compilation issues with Xcode 11.3 (catalina) --- ports/glib/CMakeLists.txt | 27 +++- ports/glib/CONTROL | 4 +- .../fix-static-extern-vars-on-windows.patch | 15 +++ ...fix-static-remove-dllmain-on-windows.patch | 116 ++++++++++++++++++ ports/glib/portfile.cmake | 7 +- 5 files changed, 159 insertions(+), 10 deletions(-) create mode 100644 ports/glib/fix-static-extern-vars-on-windows.patch create mode 100644 ports/glib/fix-static-remove-dllmain-on-windows.patch diff --git a/ports/glib/CMakeLists.txt b/ports/glib/CMakeLists.txt index 4da1a80a134ad8..79bb94de3646e6 100644 --- a/ports/glib/CMakeLists.txt +++ b/ports/glib/CMakeLists.txt @@ -40,7 +40,8 @@ if(APPLE) find_library(COREFOUNDATION_LIBRARY CoreFoundation) find_library(FOUNDATION_LIBRARY Foundation) find_library(CORESERVICES_LIBRARY CoreServices) - link_libraries(${CORESERVICES_LIBRARY} ${COREFOUNDATION_LIBRARY} ${FOUNDATION_LIBRARY}) + find_library(APPKIT_LIBRARY AppKit) + link_libraries(${CORESERVICES_LIBRARY} ${COREFOUNDATION_LIBRARY} ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY}) endif() if(WIN32 OR APPLE) @@ -82,6 +83,20 @@ else() set(LDFLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${CMAKE_STATIC_LINKER_FLAGS_${UPPER_CONFIG}} -L${LIB_DIR}") endif() + if(APPLE) + set(LDFLAGS "${LDFLAGS} ${LIBINTL_LIBRARY} -framework Foundation -framework AppKit") + + if ("$ENV{CPATH}" STREQUAL "") + execute_process( + COMMAND xcrun --show-sdk-path + OUTPUT_VARIABLE xc_sdk_path + ) + string(STRIP "${xc_sdk_path}" xc_sdk_path) + set(ENV{CPATH} "${xc_sdk_path}/usr/include") + message(STATUS "set CPATH=$ENV{CPATH}") + endif() + endif() + string(STRIP "${CXXFLAGS}" CXXFLAGS) string(STRIP "${CFLAGS}" CFLAGS) string(STRIP "${LDFLAGS}" LDFLAGS) @@ -101,8 +116,14 @@ else() if (NOT HAVE_SELINUX) file(READ "${CMAKE_BINARY_DIR}/config/config.h" CONFIG_H) - string(REPLACE "#define HAVE_SELINUX 1" - "#undef HAVE_SELINUX" CONFIG_H "${CONFIG_H}") + string(REPLACE "#define HAVE_SELINUX 1" "#undef HAVE_SELINUX" CONFIG_H "${CONFIG_H}") + file(WRITE "${CMAKE_BINARY_DIR}/config/config.h" "${CONFIG_H}") + endif() + + if(APPLE) + file(READ "${CMAKE_BINARY_DIR}/config/config.h" CONFIG_H) + string(REPLACE "#define HAVE_DTRACE 1" "#undef HAVE_DTRACE" CONFIG_H "${CONFIG_H}") + string(REPLACE "/* #undef HAVE_COCOA */" "#define HAVE_COCOA 1" CONFIG_H "${CONFIG_H}") file(WRITE "${CMAKE_BINARY_DIR}/config/config.h" "${CONFIG_H}") endif() diff --git a/ports/glib/CONTROL b/ports/glib/CONTROL index cdf5441fe60cfe..0bae418ae7c769 100644 --- a/ports/glib/CONTROL +++ b/ports/glib/CONTROL @@ -1,8 +1,8 @@ Source: glib -Version: 2.52.3-14-5 +Version: 2.52.3-14-6 Homepage: https://developer.gnome.org/glib/ Description: Portable, general-purpose utility library. Build-Depends: zlib, pcre, libffi, gettext, libiconv Feature: selinux -Description: Build with selinux support. \ No newline at end of file +Description: Build with selinux support. diff --git a/ports/glib/fix-static-extern-vars-on-windows.patch b/ports/glib/fix-static-extern-vars-on-windows.patch new file mode 100644 index 00000000000000..3170e3c2754236 --- /dev/null +++ b/ports/glib/fix-static-extern-vars-on-windows.patch @@ -0,0 +1,15 @@ +diff --git a/glib/glibconfig.h.win32 b/glib/glibconfig.h.win32 +index b75a86f..4c4367a 100644 +--- a/glib/glibconfig.h.win32 ++++ b/glib/glibconfig.h.win32 +@@ -167,6 +167,10 @@ typedef unsigned __int64 guintptr; + #define G_OS_WIN32 + #define G_PLATFORM_WIN32 + ++#ifndef DLL_EXPORT ++#undef GLIB_STATIC_COMPILATION ++#define GLIB_STATIC_COMPILATION 1 ++#endif + + #if !defined (_MSC_VER) || (_MSC_VER >= 1800) + #define G_VA_COPY va_copy diff --git a/ports/glib/fix-static-remove-dllmain-on-windows.patch b/ports/glib/fix-static-remove-dllmain-on-windows.patch new file mode 100644 index 00000000000000..adb79c96409c1e --- /dev/null +++ b/ports/glib/fix-static-remove-dllmain-on-windows.patch @@ -0,0 +1,116 @@ +diff --git a/glib/glib-init.c b/glib/glib-init.c +index 30a9654..e3af9e6 100644 +--- a/glib/glib-init.c ++++ b/glib/glib-init.c +@@ -275,11 +275,9 @@ glib_init (void) + + #if defined (G_OS_WIN32) + +-BOOL WINAPI DllMain (HINSTANCE hinstDLL, +- DWORD fdwReason, +- LPVOID lpvReserved); ++HMODULE glib_dll = NULL; + +-HMODULE glib_dll; ++#if defined (DLL_EXPORT) + + BOOL WINAPI + DllMain (HINSTANCE hinstDLL, +@@ -290,11 +288,6 @@ DllMain (HINSTANCE hinstDLL, + { + case DLL_PROCESS_ATTACH: + glib_dll = hinstDLL; +- g_clock_win32_init (); +-#ifdef THREADS_WIN32 +- g_thread_win32_init (); +-#endif +- glib_init (); + break; + + case DLL_THREAD_DETACH: +@@ -318,7 +311,10 @@ DllMain (HINSTANCE hinstDLL, + return TRUE; + } + +-#elif defined (G_HAS_CONSTRUCTORS) ++#endif /* DLL_EXPORT */ ++#endif /* G_OS_WIN32 */ ++ ++#if defined (G_HAS_CONSTRUCTORS) + + #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA + #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(glib_init_ctor) +@@ -328,9 +324,18 @@ G_DEFINE_CONSTRUCTOR(glib_init_ctor) + static void + glib_init_ctor (void) + { ++#if defined (G_OS_WIN32) ++ g_clock_win32_init (); ++#endif /* G_OS_WIN32 */ ++ ++#ifdef THREADS_WIN32 ++ g_thread_win32_init (); ++#endif /* THREADS_WIN32 */ ++ + glib_init (); + } + + #else + # error Your platform/compiler is missing constructor support + #endif ++ +diff --git a/gobject/gtype.c b/gobject/gtype.c +index f381a78..046169e 100644 +--- a/gobject/gtype.c ++++ b/gobject/gtype.c +@@ -4451,32 +4451,7 @@ gobject_init (void) + _g_signal_init (); + } + +-#if defined (G_OS_WIN32) +- +-BOOL WINAPI DllMain (HINSTANCE hinstDLL, +- DWORD fdwReason, +- LPVOID lpvReserved); +- +-BOOL WINAPI +-DllMain (HINSTANCE hinstDLL, +- DWORD fdwReason, +- LPVOID lpvReserved) +-{ +- switch (fdwReason) +- { +- case DLL_PROCESS_ATTACH: +- gobject_init (); +- break; +- +- default: +- /* do nothing */ +- ; +- } +- +- return TRUE; +-} +- +-#elif defined (G_HAS_CONSTRUCTORS) ++#if defined (G_HAS_CONSTRUCTORS) + #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA + #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(gobject_init_ctor) + #endif +@@ -4488,6 +4463,16 @@ gobject_init_ctor (void) + gobject_init (); + } + ++#elif defined (G_OS_WIN32) && defined (DLL_EXPORT) ++ ++BOOL WINAPI DllMain ( ++ HINSTANCE hinstDLL, ++ DWORD fdwReason, ++ LPVOID lpvReserved) ++{ ++ return TRUE; ++} ++ + #else + # error Your platform/compiler is missing constructor support + #endif diff --git a/ports/glib/portfile.cmake b/ports/glib/portfile.cmake index 7823debc9e15f3..8eccad9b885ecf 100644 --- a/ports/glib/portfile.cmake +++ b/ports/glib/portfile.cmake @@ -1,11 +1,6 @@ # Glib uses winapi functions not available in WindowsStore vcpkg_fail_port_install(ON_TARGET "UWP") -# Glib relies on DllMain on Windows -if (VCPKG_TARGET_IS_WINDOWS) - vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) -endif() - set(GLIB_VERSION 2.52.3) vcpkg_download_distfile(ARCHIVE URLS "https://ftp.gnome.org/pub/gnome/sources/glib/2.52/glib-${GLIB_VERSION}.tar.xz" @@ -20,6 +15,8 @@ vcpkg_extract_source_archive_ex( use-libiconv-on-windows.patch arm64-defines.patch fix-arm-builds.patch + fix-static-remove-dllmain-on-windows.patch + fix-static-extern-vars-on-windows.patch ) file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) From 49731f810c86b7224acd776785950050dce0c4c3 Mon Sep 17 00:00:00 2001 From: ggainant Date: Wed, 8 Jan 2020 12:27:27 -0600 Subject: [PATCH 2/6] [cairo] Add Quartz support on macos platform + Fix build issues on macos --- ports/cairo/CMakeLists.txt | 11 +++++++++++ ports/cairo/CONTROL | 4 ++-- ports/cairo/cairo-features.h | 35 +++++++++++++++-------------------- ports/cairo/portfile.cmake | 12 +++++++++--- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/ports/cairo/CMakeLists.txt b/ports/cairo/CMakeLists.txt index eea64b96c5614a..44364f49cc2efc 100644 --- a/ports/cairo/CMakeLists.txt +++ b/ports/cairo/CMakeLists.txt @@ -142,6 +142,13 @@ file(GLOB SOURCES "cairo-ft-font.c" ) +# OSX +file(GLOB PLATFORM_SOURCES_OSX +"cairo-quartz-font.c" +"cairo-quartz-image-surface.c" +"cairo-quartz-surface.c" +) + # win32 file(GLOB PLATFORM_SOURCES_WIN32 "win32/cairo-win32-debug.c" @@ -154,6 +161,10 @@ file(GLOB PLATFORM_SOURCES_WIN32 "win32/cairo-win32-font.c" ) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + list(APPEND SOURCES ${PLATFORM_SOURCES_OSX}) +endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") list(APPEND SOURCES ${PLATFORM_SOURCES_WIN32}) endif() diff --git a/ports/cairo/CONTROL b/ports/cairo/CONTROL index e9d49423563172..b8487d64771a9a 100644 --- a/ports/cairo/CONTROL +++ b/ports/cairo/CONTROL @@ -1,8 +1,8 @@ Source: cairo -Version: 1.16.0-2 +Version: 1.16.0-3 Homepage: https://cairographics.org Description: Cairo is a 2D graphics library with support for multiple output devices. Currently supported output targets include the X Window System (via both Xlib and XCB), Quartz, Win32, image buffers, PostScript, PDF, and SVG file output. Experimental backends include OpenGL, BeOS, OS/2, and DirectFB. Build-Depends: zlib, libpng, pixman, glib, freetype, fontconfig Feature: x11 -Description: build with x11 support \ No newline at end of file +Description: build with x11 support diff --git a/ports/cairo/cairo-features.h b/ports/cairo/cairo-features.h index e3eb31c139ce85..82dc77c62e4f83 100644 --- a/ports/cairo/cairo-features.h +++ b/ports/cairo/cairo-features.h @@ -1,38 +1,33 @@ #ifndef CAIRO_FEATURES_H #define CAIRO_FEATURES_H -/* Chosen from the various possible defines in "../build/Makefile.win32.features.h"" - guided by "../build/Makefile.win32.features". Modify at your own risk. -*/ -/* Always for Win32 */ -#ifdef _WIN32 -#define CAIRO_HAS_WIN32_SURFACE 1 -#define CAIRO_HAS_WIN32_FONT 1 -#endif - -/* Require libpng */ #define CAIRO_HAS_PNG_FUNCTIONS 1 #define CAIRO_HAS_PS_SURFACE 1 #define CAIRO_HAS_PDF_SURFACE 1 - -// Likely available #define CAIRO_HAS_SCRIPT_SURFACE 1 #define CAIRO_HAS_SVG_SURFACE 1 - -/* Always available */ #define CAIRO_HAS_IMAGE_SURFACE 1 #define CAIRO_HAS_MIME_SURFACE 1 #define CAIRO_HAS_RECORDING_SURFACE 1 #define CAIRO_HAS_OBSERVER_SURFACE 1 #define CAIRO_HAS_USER_FONT 1 - -/* Require GObject */ #define CAIRO_HAS_GOBJECT_FUNCTIONS 1 - -/* Require FreeType */ #define CAIRO_HAS_FT_FONT 1 - -/* Require FontConfig */ #define CAIRO_HAS_FC_FONT 1 +#ifdef _WIN32 +#define CAIRO_HAS_WIN32_SURFACE 1 +#define CAIRO_HAS_WIN32_FONT 1 +#endif + +#ifdef __APPLE__ +#define CAIRO_HAS_QUARTZ_FONT 1 +#define CAIRO_HAS_QUARTZ_SURFACE 1 +#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1 +#define CAIRO_HAS_XCB_SHM_FUNCTIONS 1 +#define CAIRO_HAS_XCB_SURFACE 1 +#define CAIRO_HAS_XLIB_SURFACE 1 +#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1 +#endif + #endif diff --git a/ports/cairo/portfile.cmake b/ports/cairo/portfile.cmake index f5b1f35f8e7fd3..269ade33a8d09d 100644 --- a/ports/cairo/portfile.cmake +++ b/ports/cairo/portfile.cmake @@ -1,4 +1,3 @@ -include(vcpkg_common_functions) set(CAIRO_VERSION 1.16.0) vcpkg_download_distfile(ARCHIVE @@ -41,6 +40,8 @@ vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-cairo TARGET_PATH share/u # Copy the appropriate header files. foreach(FILE +"${SOURCE_PATH}/cairo-version.h" +"${SOURCE_PATH}/util/cairo-gobject/cairo-gobject.h" "${SOURCE_PATH}/src/cairo.h" "${SOURCE_PATH}/src/cairo-deprecated.h" "${SOURCE_PATH}/src/cairo-features.h" @@ -48,9 +49,14 @@ foreach(FILE "${SOURCE_PATH}/src/cairo-ps.h" "${SOURCE_PATH}/src/cairo-script.h" "${SOURCE_PATH}/src/cairo-svg.h" -"${SOURCE_PATH}/cairo-version.h" +"${SOURCE_PATH}/src/cairo-tee.h" +"${SOURCE_PATH}/src/cairo-xcb.h" +"${SOURCE_PATH}/src/cairo-xlib.h" +"${SOURCE_PATH}/src/cairo-xlib-xrender.h" +"${SOURCE_PATH}/src/cairo-xml.h" "${SOURCE_PATH}/src/cairo-win32.h" -"${SOURCE_PATH}/util/cairo-gobject/cairo-gobject.h" +"${SOURCE_PATH}/src/cairo-quartz.h" +"${SOURCE_PATH}/src/cairo-quartz-image.h" "${SOURCE_PATH}/src/cairo-ft.h") file(COPY ${FILE} DESTINATION ${CURRENT_PACKAGES_DIR}/include) file(COPY ${FILE} DESTINATION ${CURRENT_PACKAGES_DIR}/include/cairo) From c1b9a589aac4ea97abc69c157d460b801535038a Mon Sep 17 00:00:00 2001 From: ggainant Date: Wed, 8 Jan 2020 13:53:18 -0600 Subject: [PATCH 3/6] [fltk] Update to FLTK 1.4 + add cairo extension --- ports/fltk/CONTROL | 6 ++- ports/fltk/add-link-libraries.patch | 6 +-- ports/fltk/find-lib-cairo.patch | 60 +++++++++++++++++++++++++++++ ports/fltk/find-lib-png.patch | 49 +++++++++++++++++++++++ ports/fltk/findlibsfix.patch | 51 ------------------------ ports/fltk/portfile.cmake | 52 +++++++++++++++---------- 6 files changed, 148 insertions(+), 76 deletions(-) create mode 100644 ports/fltk/find-lib-cairo.patch create mode 100644 ports/fltk/find-lib-png.patch delete mode 100644 ports/fltk/findlibsfix.patch diff --git a/ports/fltk/CONTROL b/ports/fltk/CONTROL index a029a5e85b8dc1..9522622ec395e5 100644 --- a/ports/fltk/CONTROL +++ b/ports/fltk/CONTROL @@ -1,5 +1,9 @@ Source: fltk -Version: 1.3.5-1 +Version: 1.4-2 Homepage: https://www.fltk.org/ Description: FLTK (pronounced fulltick) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. FLTK provides modern GUI functionality without the bloat and supports 3D graphics via OpenGL and its built-in GLUT emulation. Build-Depends: zlib, libpng, libjpeg-turbo + +Feature: cairo +Description: build with cairo support +Build-Depends: cairo diff --git a/ports/fltk/add-link-libraries.patch b/ports/fltk/add-link-libraries.patch index 547c9717ca22c3..e6a5bbd6833cea 100644 --- a/ports/fltk/add-link-libraries.patch +++ b/ports/fltk/add-link-libraries.patch @@ -1,13 +1,13 @@ diff --git a/CMake/macros.cmake b/CMake/macros.cmake -index 4def62d..27b4901 100644 +index e54d984..09e515f 100644 --- a/CMake/macros.cmake +++ b/CMake/macros.cmake -@@ -67,6 +67,8 @@ macro(FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES) +@@ -97,6 +97,8 @@ macro(FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES) COMPILE_DEFINITIONS "FL_DLL" ) endif (${LIBTYPE} STREQUAL "SHARED") + -+ target_link_libraries(${LIBRARY_NAME} gdi32 gdiplus user32 advapi32 ole32 shell32 comdlg32) ++ target_link_libraries(${LIBRARY_NAME} gdi32 gdiplus user32 advapi32 ole32 shell32 comdlg32) endif (MSVC) install(TARGETS ${LIBRARY_NAME} diff --git a/ports/fltk/find-lib-cairo.patch b/ports/fltk/find-lib-cairo.patch new file mode 100644 index 00000000000000..a3073f34b96ed3 --- /dev/null +++ b/ports/fltk/find-lib-cairo.patch @@ -0,0 +1,60 @@ +diff --git a/CMake/options.cmake b/CMake/options.cmake +index 3784314..ae0b48f 100644 +--- a/CMake/options.cmake ++++ b/CMake/options.cmake +@@ -157,37 +157,33 @@ if(OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION) + endif(OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION) + + ####################################################################### +-include(FindPkgConfig) + + option(OPTION_CAIRO "use lib Cairo" OFF) + option(OPTION_CAIROEXT + "use FLTK code instrumentation for Cairo extended use" OFF + ) + +-if ((OPTION_CAIRO OR OPTION_CAIROEXT) AND LIB_CAIRO) +- pkg_search_module(PKG_CAIRO cairo) +-endif ((OPTION_CAIRO OR OPTION_CAIROEXT) AND LIB_CAIRO) +- +-if (PKG_CAIRO_FOUND) ++if (OPTION_CAIRO OR OPTION_CAIROEXT) ++ # find_library(LIB_CAIRO cairo) in resources.cmake ++ if (NOT LIB_CAIRO) ++ message(STATUS "*** Cairo was requested but not found - please install Cairo ...") ++ message(STATUS "*** or disable options OPTION_CAIRO and OPTION_CAIRO_EXT") ++ message(FATAL_ERROR "*** Terminating: missing Cairo libs or headers") ++ endif (NOT LIB_CAIRO) + set (FLTK_HAVE_CAIRO 1) + add_subdirectory(cairo) +- list(APPEND FLTK_LDLIBS -lcairo -lpixman-1) +- include_directories(${PKG_CAIRO_INCLUDE_DIRS}) +- string(REPLACE ";" " " CAIROFLAGS "${PKG_CAIRO_CFLAGS}") +- ++# list(APPEND FLTK_LDLIBS -lcairo -lpixman-1) ++# include_directories(${PKG_CAIRO_INCLUDE_DIRS}) ++# string(REPLACE ";" " " CAIROFLAGS "${PKG_CAIRO_CFLAGS}") + if (LIB_CAIRO AND OPTION_CAIROEXT) +- set(FLTK_USE_CAIRO 1) +- set(FLTK_CAIRO_FOUND TRUE) +- else () +- set(FLTK_CAIRO_FOUND FALSE) +- endif (LIB_CAIRO AND OPTION_CAIROEXT) +-else () +- if (OPTION_CAIRO OR OPTION_CAIROEXT) +- message(STATUS "*** Cairo was requested but not found - please check your cairo installation") +- message(STATUS "*** or disable options OPTION_CAIRO and OPTION_CAIRO_EXT.") +- message(FATAL_ERROR "*** Terminating: missing Cairo libs or headers.") +- endif (OPTION_CAIRO OR OPTION_CAIROEXT) +-endif (PKG_CAIRO_FOUND) ++ set(FLTK_USE_CAIRO 1) ++ set(FLTK_CAIRO_FOUND TRUE) ++ else() ++ set(FLTK_CAIRO_FOUND FALSE) ++ endif() ++else() ++ set(FLTK_CAIRO_FOUND FALSE) ++endif (OPTION_CAIRO OR OPTION_CAIROEXT) + + ####################################################################### + option(OPTION_USE_NANOSVG "support SVG images" ON) diff --git a/ports/fltk/find-lib-png.patch b/ports/fltk/find-lib-png.patch new file mode 100644 index 00000000000000..801bf929ee6a0f --- /dev/null +++ b/ports/fltk/find-lib-png.patch @@ -0,0 +1,49 @@ +diff --git a/CMake/resources.cmake b/CMake/resources.cmake +index 3676d3b..3e9cc1d 100644 +--- a/CMake/resources.cmake ++++ b/CMake/resources.cmake +@@ -63,15 +63,25 @@ endmacro (fl_find_header) + fl_find_header (HAVE_ALSA_ASOUNDLIB_H alsa/asoundlib.h) + fl_find_header (HAVE_DLFCN_H dlfcn.h) + fl_find_header (HAVE_GL_GLU_H GL/glu.h) +-fl_find_header (HAVE_LIBPNG_PNG_H libpng/png.h) ++#fl_find_header (HAVE_LIBPNG_PNG_H libpng/png.h) + fl_find_header (HAVE_LOCALE_H locale.h) + fl_find_header (HAVE_OPENGL_GLU_H OpenGL/glu.h) +-fl_find_header (HAVE_PNG_H png.h) ++#fl_find_header (HAVE_PNG_H png.h) + fl_find_header (HAVE_STDIO_H stdio.h) + fl_find_header (HAVE_STRINGS_H strings.h) + fl_find_header (HAVE_SYS_SELECT_H sys/select.h) + fl_find_header (HAVE_SYS_STDTYPES_H sys/stdtypes.h) + ++find_package(PNG REQUIRED) ++if(PNG_FOUND) ++ set(LIB_png ${PNG_LIBRARIES}) ++ set(HAVE_PNG_H ${PNG_FOUND}) ++endif() ++find_package(ZLIB REQUIRED) ++if(ZLIB_FOUND) ++ set(LIB_zlib ${ZLIB_LIBRARIES}) ++endif() ++ + if (USE_FIND_FILE) + fl_find_header (HAVE_X11_XREGION_H "X11/Xregion.h") + fl_find_header (HAVE_XDBE_H "X11/extensions/Xdbe.h") +@@ -184,12 +194,13 @@ find_library(LIB_freetype freetype) + find_library(LIB_GL GL) + find_library(LIB_MesaGL MesaGL) + find_library(LIB_jpeg jpeg) +-find_library(LIB_png png) +-find_library(LIB_zlib z) ++#find_library(LIB_png png) ++#find_library(LIB_zlib z) + + mark_as_advanced(LIB_CAIRO LIB_dl LIB_fontconfig LIB_freetype) + mark_as_advanced(LIB_GL LIB_MesaGL) +-mark_as_advanced(LIB_jpeg LIB_png LIB_zlib) ++#mark_as_advanced(LIB_jpeg LIB_png LIB_zlib) ++mark_as_advanced(LIB_jpeg) + + ####################################################################### + # functions diff --git a/ports/fltk/findlibsfix.patch b/ports/fltk/findlibsfix.patch deleted file mode 100644 index 6c2a7158a23acf..00000000000000 --- a/ports/fltk/findlibsfix.patch +++ /dev/null @@ -1,51 +0,0 @@ -diff --git a/CMake/resources.cmake b/CMake/resources.cmake -index 37c0c08..b1f52d1 100644 ---- a/CMake/resources.cmake -+++ b/CMake/resources.cmake -@@ -26,10 +26,10 @@ find_file(HAVE_DLFCN_H dlfcn.h) - find_file(HAVE_FREETYPE_H freetype.h PATH_SUFFIXES freetype2 freetype2/freetype) - find_file(HAVE_GL_GL_H GL/gl.h) - find_file(HAVE_GL_GLU_H GL/glu.h) --find_file(HAVE_LIBPNG_PNG_H libpng/png.h) -+#find_file(HAVE_LIBPNG_PNG_H libpng/png.h) - find_file(HAVE_LOCALE_H locale.h) - find_file(HAVE_OPENGL_GLU_H OpenGL/glu.h) --find_file(HAVE_PNG_H png.h) -+#find_file(HAVE_PNG_H png.h) - find_file(HAVE_PTHREAD_H pthread.h) - find_file(HAVE_STDIO_H stdio.h) - find_file(HAVE_STRINGS_H strings.h) -@@ -38,6 +38,17 @@ find_file(HAVE_SYS_STDTYPES_H sys/stdtypes.h) - find_file(HAVE_X11_XREGION_H X11/Xregion.h) - find_path(HAVE_XDBE_H Xdbe.h PATH_SUFFIXES X11/extensions extensions) - -+find_package(PNG REQUIRED) -+if(PNG_FOUND) -+ set(LIB_png ${PNG_LIBRARIES}) -+ set(HAVE_PNG_H ${PNG_FOUND}) -+ -+endif() -+find_package(ZLIB REQUIRED) -+if(ZLIB_FOUND) -+ set(LIB_zlib ${ZLIB_LIBRARIES}) -+endif() -+ - if (MSVC) - message(STATUS "Note: The following three headers should all be found!") - message(STATUS "HAVE_GL_GL_H = '${HAVE_GL_GL_H}'") -@@ -92,12 +103,12 @@ find_library(LIB_freetype freetype) - find_library(LIB_GL GL) - find_library(LIB_MesaGL MesaGL) - find_library(LIB_jpeg jpeg) --find_library(LIB_png png) --find_library(LIB_zlib z) -+#find_library(LIB_png png) -+#find_library(LIB_zlib z) - - mark_as_advanced(LIB_CAIRO LIB_dl LIB_fontconfig LIB_freetype) - mark_as_advanced(LIB_GL LIB_MesaGL) --mark_as_advanced(LIB_jpeg LIB_png LIB_zlib) -+mark_as_advanced(LIB_jpeg) - - ####################################################################### - # functions diff --git a/ports/fltk/portfile.cmake b/ports/fltk/portfile.cmake index bc385385714610..055ecd29de46af 100644 --- a/ports/fltk/portfile.cmake +++ b/ports/fltk/portfile.cmake @@ -1,23 +1,19 @@ -include(vcpkg_common_functions) - -vcpkg_download_distfile(ARCHIVE - URLS "https://fltk.org/pub/fltk/1.3.5/fltk-1.3.5-source.tar.gz" - FILENAME "fltk-1.3.5.tar.gz" - SHA512 db7ea7c5f3489195a48216037b9371a50f1119ae7692d66f71b6711e5ccf78814670581bae015e408dee15c4bba921728309372c1cffc90113cdc092e8540821 -) - -vcpkg_extract_source_archive_ex( - OUT_SOURCE_PATH SOURCE_PATH - ARCHIVE ${ARCHIVE} - PATCHES - findlibsfix.patch +vcpkg_from_github(ARCHIVE + OUT_SOURCE_PATH SOURCE_PATH + REPO fltk/fltk + REF ee9ada967806dae72aa1b9ddad7b95b94f4dd2a3 # Nov 9, 2019 + SHA512 2e3c5bb06adcb0eaaaa9eb2d193353b0e792b1cc215686a79ab56486b11f7ea1aa7457fd51eb0bf65463536115b32cf02efc4ef83959842e9a9c17e122407afe + HEAD_REF master + PATCHES + find-lib-cairo.patch + find-lib-png.patch add-link-libraries.patch ) if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - set(BUILD_SHARED ON) + set(OPTION_BUILD_SHARED "-DOPTION_BUILD_SHARED_LIBS=ON") else() - set(BUILD_SHARED OFF) + set(OPTION_BUILD_SHARED "-DOPTION_BUILD_SHARED_LIBS=OFF") endif() if (VCPKG_TARGET_ARCHITECTURE MATCHES "arm" OR VCPKG_TARGET_ARCHITECTURE MATCHES "arm64") @@ -26,6 +22,10 @@ else() set(OPTION_USE_GL "-DOPTION_USE_GL=ON") endif() +if ("cairo" IN_LIST FEATURES) + set(OPTION_USE_CAIRO "-DOPTION_CAIRO=ON") +endif() + vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA @@ -36,7 +36,8 @@ vcpkg_configure_cmake( -DOPTION_USE_SYSTEM_ZLIB=ON -DOPTION_USE_SYSTEM_LIBPNG=ON -DOPTION_USE_SYSTEM_LIBJPEG=ON - -DOPTION_BUILD_SHARED_LIBS=${BUILD_SHARED} + ${OPTION_BUILD_SHARED} + ${OPTION_USE_CAIRO} ${OPTION_USE_GL} ) @@ -46,14 +47,23 @@ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/CMAKE ${CURRENT_PACKAGES_DIR}/debug/CMAKE ${CURRENT_PACKAGES_DIR}/debug/include + ${CURRENT_PACKAGES_DIR}/debug/share ) -file(COPY ${CURRENT_PACKAGES_DIR}/bin/fluid.exe DESTINATION ${CURRENT_PACKAGES_DIR}/tools/fltk) -file(REMOVE ${CURRENT_PACKAGES_DIR}/bin/fluid.exe) -file(REMOVE ${CURRENT_PACKAGES_DIR}/bin/fltk-config) +if (VCPKG_TARGET_IS_WINDOWS) + set(FLUID_TARGET fluid.exe) +elseif (VCPKG_TARGET_IS_OSX) + set(FLUID_TARGET fluid.app) +endif() + +if (FLUID_TARGET) + file(COPY ${CURRENT_PACKAGES_DIR}/bin/${FLUID_TARGET} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/fltk) + file(REMOVE ${CURRENT_PACKAGES_DIR}/bin/${FLUID_TARGET}) + file(REMOVE ${CURRENT_PACKAGES_DIR}/bin/fltk-config) -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/fluid.exe) -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/fltk-config) + file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/${FLUID_TARGET}) + file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/fltk-config) +endif() vcpkg_copy_pdbs() From e16e9fc0913cdc82d7c9e7e06286719330b99d06 Mon Sep 17 00:00:00 2001 From: ggainant Date: Wed, 8 Jan 2020 14:01:08 -0600 Subject: [PATCH 4/6] [fluid/fltk] Patch FLUID tool allowing relative positioning on top of non-window parent --- ports/fltk/fluid-group-relative.patch | 71 +++++++++++++++++++++++++++ ports/fltk/portfile.cmake | 1 + 2 files changed, 72 insertions(+) create mode 100644 ports/fltk/fluid-group-relative.patch diff --git a/ports/fltk/fluid-group-relative.patch b/ports/fltk/fluid-group-relative.patch new file mode 100644 index 00000000000000..7dbe64e283096b --- /dev/null +++ b/ports/fltk/fluid-group-relative.patch @@ -0,0 +1,71 @@ +diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx +index 655aa72..0cf83ba 100644 +--- a/fluid/Fl_Widget_Type.cxx ++++ b/fluid/Fl_Widget_Type.cxx +@@ -46,6 +46,8 @@ extern const char* i18n_include; + extern const char* i18n_function; + extern const char* i18n_file; + extern const char* i18n_set; ++extern int varused_test, varused; ++extern bool fl_curr_write_once; + + int Fl_Widget_Type::default_size = FL_NORMAL_SIZE; + +@@ -2093,8 +2095,6 @@ const char *Fl_Type::callback_name() { + return unique_id(this, "cb", name(), label()); + } + +-extern int varused_test, varused; +- + void Fl_Widget_Type::write_code1() { + const char* t = subclassname(this); + const char *c = array_name(this); +@@ -2153,6 +2153,16 @@ void Fl_Widget_Type::write_code1() { + } + } + ++ if(fl_curr_write_once) { ++ write_c("%s#ifndef fl_curr_x\n", indent()); ++ write_c("%s#define fl_curr_x() 0\n", indent()); ++ write_c("%s#endif\n", indent()); ++ write_c("%s#ifndef fl_curr_y\n", indent()); ++ write_c("%s#define fl_curr_y() 0\n", indent()); ++ write_c("%s#endif\n", indent()); ++ fl_curr_write_once = false; ++ } ++ + write_c("%s{ ", indent()); + write_comment_inline_c(); + if (varused) write_c("%s* o = ", t); +@@ -2163,9 +2173,9 @@ void Fl_Widget_Type::write_code1() { + if (!strstr(t, "Window")) + write_c("new %s(0, 0, %d, %d", t, o->w(), o->h()); + else +- write_c("new %s(%d, %d", t, o->w(), o->h()); ++ write_c("new %s(fl_curr_x()+%d, fl_curr_y()+%d", t, o->w(), o->h()); + } else { +- write_c("new %s(%d, %d, %d, %d", t, o->x(), o->y(), o->w(), o->h()); ++ write_c("new %s(fl_curr_x()+%d, fl_curr_y()+%d, %d, %d", t, o->x(), o->y(), o->w(), o->h()); + } + if (label() && *label()) { + write_c(", "); +diff --git a/fluid/code.cxx b/fluid/code.cxx +index 50e5d70..8dd1f82 100644 +--- a/fluid/code.cxx ++++ b/fluid/code.cxx +@@ -149,6 +149,7 @@ int write_declare(const char *format, ...) { + // anything, but set a variable if it looks like the variable "o" is used: + int varused_test; + int varused; ++bool fl_curr_write_once; + + // write an array of C characters (adds a null): + void write_cstring(const char *s, int length) { +@@ -364,6 +365,7 @@ int write_code(const char *s, const char *t) { + indentation = 0; + current_class = 0L; + current_widget_class = 0L; ++ fl_curr_write_once = true; + if (!s) code_file = stdout; + else { + FILE *f = fl_fopen(s, filemode); diff --git a/ports/fltk/portfile.cmake b/ports/fltk/portfile.cmake index 055ecd29de46af..912d309771bcb5 100644 --- a/ports/fltk/portfile.cmake +++ b/ports/fltk/portfile.cmake @@ -8,6 +8,7 @@ vcpkg_from_github(ARCHIVE find-lib-cairo.patch find-lib-png.patch add-link-libraries.patch + fluid-group-relative.patch ) if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) From 04fe29b8da30a8aa99e9a9f9e1f8a94c871f2315 Mon Sep 17 00:00:00 2001 From: ggainant Date: Thu, 21 Nov 2019 19:48:23 -0600 Subject: [PATCH 5/6] [libyaml] Preserve strdup() on Mac OSX --- ports/libyaml/portfile.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ports/libyaml/portfile.cmake b/ports/libyaml/portfile.cmake index 3d7f12d7e56a8c..0d79bf5261bf8f 100644 --- a/ports/libyaml/portfile.cmake +++ b/ports/libyaml/portfile.cmake @@ -1,4 +1,6 @@ -include(vcpkg_common_functions) +if (VCPKG_TARGET_IS_WINDOWS) + set(PATCH_fix_posix_name "fix-POSIX_name.patch") +endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH @@ -6,8 +8,8 @@ vcpkg_from_github( REF 0.2.2 SHA512 455494591014a97c4371a1f372ad09f0d6e487e4f1d3419c98e9cd2f16d43a0cf9a0787d7250bebee8b8d400df4626f5acd81e90139e54fa574a66ec84964c06 HEAD_REF master - PATCHES - fix-POSIX_name.patch + PATCHES + "${PATCH_fix_posix_name}" ) vcpkg_configure_cmake( From b7f17b85ef4ea92b46ff6e0f47afeeda42f3265c Mon Sep 17 00:00:00 2001 From: ggainant Date: Thu, 12 Dec 2019 17:34:34 -0600 Subject: [PATCH 6/6] [python3] Restore support of windows static build + Remove Py_DEBUG in debug build config altering PyModule_Create() symbol + Remove conflicting link time (LT) optimizations in Windows profile --- ports/python3/0001-Static-library.patch | 51 ++++ ports/python3/0002-Static-CRT.patch | 15 ++ .../0003-Fix-header-for-static-linkage.patch | 13 + ...-Remove-linktime-global-optimization.patch | 31 +++ ports/python3/CONTROL | 4 +- ports/python3/portfile.cmake | 237 ++++++++++++------ 6 files changed, 266 insertions(+), 85 deletions(-) create mode 100644 ports/python3/0001-Static-library.patch create mode 100644 ports/python3/0002-Static-CRT.patch create mode 100644 ports/python3/0003-Fix-header-for-static-linkage.patch create mode 100644 ports/python3/0004-Remove-linktime-global-optimization.patch diff --git a/ports/python3/0001-Static-library.patch b/ports/python3/0001-Static-library.patch new file mode 100644 index 00000000000000..1609497c227d50 --- /dev/null +++ b/ports/python3/0001-Static-library.patch @@ -0,0 +1,51 @@ +diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj +index a56fb7a..e8c01e5 100644 +--- a/PCbuild/pythoncore.vcxproj ++++ b/PCbuild/pythoncore.vcxproj +@@ -41,7 +41,7 @@ + + + +- DynamicLibrary ++ StaticLibrary + false + + +@@ -70,12 +70,36 @@ + /Zm200 %(AdditionalOptions) + $(PySourcePath)Python;%(AdditionalIncludeDirectories) + $(zlibDir);%(AdditionalIncludeDirectories) +- _USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions) ++ _USRDLL;Py_BUILD_CORE;Py_NO_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions) + _Py_HAVE_ZLIB;%(PreprocessorDefinitions) + + + version.lib;shlwapi.lib;ws2_32.lib;%(AdditionalDependencies) + ++ ++ MachineX86 ++ ++ ++ MachineX86 ++ ++ ++ MachineX86 ++ ++ ++ MachineX86 ++ ++ ++ MachineX64 ++ ++ ++ MachineX64 ++ ++ ++ MachineX64 ++ ++ ++ MachineX64 ++ + + + diff --git a/ports/python3/0002-Static-CRT.patch b/ports/python3/0002-Static-CRT.patch new file mode 100644 index 00000000000000..dcad9d32a9a590 --- /dev/null +++ b/ports/python3/0002-Static-CRT.patch @@ -0,0 +1,15 @@ +diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj +index e8c01e5..326df66 100644 +--- a/PCbuild/pythoncore.vcxproj ++++ b/PCbuild/pythoncore.vcxproj +@@ -72,6 +72,10 @@ + $(zlibDir);%(AdditionalIncludeDirectories) + _USRDLL;Py_BUILD_CORE;Py_NO_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions) + _Py_HAVE_ZLIB;%(PreprocessorDefinitions) ++ MultiThreadedDebug ++ MultiThreadedDebug ++ MultiThreaded ++ MultiThreaded + + + version.lib;shlwapi.lib;ws2_32.lib;%(AdditionalDependencies) diff --git a/ports/python3/0003-Fix-header-for-static-linkage.patch b/ports/python3/0003-Fix-header-for-static-linkage.patch new file mode 100644 index 00000000000000..3752abeaeb2941 --- /dev/null +++ b/ports/python3/0003-Fix-header-for-static-linkage.patch @@ -0,0 +1,13 @@ +diff --git a/PC/pyconfig.h b/PC/pyconfig.h +index 46fc84e..ca6f5bf 100644 +--- a/PC/pyconfig.h ++++ b/PC/pyconfig.h +@@ -254,6 +254,8 @@ typedef int pid_t; + + /* For Windows the Python core is in a DLL by default. Test + Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ ++#undef Py_NO_ENABLE_SHARED ++#define Py_NO_ENABLE_SHARED // GG: patched from vcpkg to force static build! + #if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) + # define Py_ENABLE_SHARED 1 /* standard symbol for shared library */ + # define MS_COREDLL /* deprecated old symbol */ diff --git a/ports/python3/0004-Remove-linktime-global-optimization.patch b/ports/python3/0004-Remove-linktime-global-optimization.patch new file mode 100644 index 00000000000000..42bc5661a09311 --- /dev/null +++ b/ports/python3/0004-Remove-linktime-global-optimization.patch @@ -0,0 +1,31 @@ +diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj +index 326df66..d091906 100644 +--- a/PCbuild/pythoncore.vcxproj ++++ b/PCbuild/pythoncore.vcxproj +@@ -76,6 +76,10 @@ + MultiThreadedDebug + MultiThreaded + MultiThreaded ++ false ++ false ++ false ++ false + + + version.lib;shlwapi.lib;ws2_32.lib;%(AdditionalDependencies) +@@ -91,6 +95,7 @@ + + + MachineX86 ++ false + + + MachineX64 +@@ -103,6 +108,7 @@ + + + MachineX64 ++ false + + + diff --git a/ports/python3/CONTROL b/ports/python3/CONTROL index da8409fd996743..6dbcba9f73257f 100644 --- a/ports/python3/CONTROL +++ b/ports/python3/CONTROL @@ -1,5 +1,5 @@ Source: python3 -Version: 3.7.3 +Version: 3.7.3-1 Homepage: https://github.com/python/cpython Description: The Python programming language as an embeddable library -Build-Depends: libffi, openssl \ No newline at end of file +Build-Depends: libffi, openssl diff --git a/ports/python3/portfile.cmake b/ports/python3/portfile.cmake index 3a22d25b7f5e69..ce406674ec971c 100644 --- a/ports/python3/portfile.cmake +++ b/ports/python3/portfile.cmake @@ -3,28 +3,37 @@ if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic AND VCPKG_CRT_LINKAGE STREQUAL static set(VCPKG_LIBRARY_LINKAGE static) endif() + set(PYTHON_VERSION_MAJOR 3) set(PYTHON_VERSION_MINOR 7) set(PYTHON_VERSION_PATCH 3) set(PYTHON_VERSION ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}) +set(PYTHON_SHA512 "023960a2f570fe7178d3901df0c3c33346466906b6d55c73ef7947c19619dbab62efc42c7262a0539bc5e31543b1113eb7a088d4615ad7557a0707bdaca27940") + -include(vcpkg_common_functions) +function (vcpkg_build_msbuild_type PROJECT_PATH PLATFORM BUILD_TYPE) + set(VCPKG_BUILD_TYPE_backup ${VCPKG_BUILD_TYPE}) + set(VCPKG_BUILD_TYPE ${BUILD_TYPE}) + vcpkg_build_msbuild( + PROJECT_PATH ${PROJECT_PATH} + PLATFORM ${PLATFORM} + ) + set(VCPKG_BUILD_TYPE ${VCPKG_BUILD_TYPE_backup}) +endfunction() -vcpkg_from_github( - OUT_SOURCE_PATH TEMP_SOURCE_PATH - REPO python/cpython - REF v${PYTHON_VERSION} - SHA512 023960a2f570fe7178d3901df0c3c33346466906b6d55c73ef7947c19619dbab62efc42c7262a0539bc5e31543b1113eb7a088d4615ad7557a0707bdaca27940 - HEAD_REF master -) if (VCPKG_TARGET_IS_WINDOWS) - set(SOURCE_PATH "${TEMP_SOURCE_PATH}-Lib-${VCPKG_LIBRARY_LINKAGE}-crt-${VCPKG_CRT_LINKAGE}") - file(REMOVE_RECURSE ${SOURCE_PATH}) - file(RENAME "${TEMP_SOURCE_PATH}" ${SOURCE_PATH}) - - # We need per-triplet directories because we need to patch the project files differently based on the linkage - # Because the patches patch the same file, they have to be applied in the correct order + + if (VCPKG_LIBRARY_LINKAGE STREQUAL static) + if (NOT VCPKG_CRT_LINKAGE STREQUAL static) + message(FATAL_ERROR "CRT must be static! Patched build requires LIB AND CRT to be static.") + endif() + + set(SOURCE_STATIC_PATCH_0001 "0001-Static-library.patch") + set(SOURCE_STATIC_PATCH_0002 "0002-Static-CRT.patch") + set(SOURCE_STATIC_PATCH_0003 "0003-Fix-header-for-static-linkage.patch") + set(SOURCE_STATIC_PATCH_0004 "0004-Remove-linktime-global-optimization.patch") + endif() if (VCPKG_TARGET_ARCHITECTURE MATCHES "x86") set(BUILD_ARCH "Win32") @@ -36,74 +45,123 @@ if (VCPKG_TARGET_IS_WINDOWS) message(FATAL_ERROR "Unsupported architecture: ${VCPKG_TARGET_ARCHITECTURE}") endif() - vcpkg_build_msbuild( - PROJECT_PATH ${SOURCE_PATH}/PCBuild/pythoncore.vcxproj - PLATFORM ${BUILD_ARCH}) + ################ + # Release build + ################ - file(GLOB HEADERS ${SOURCE_PATH}/Include/*.h) - file(COPY ${HEADERS} ${SOURCE_PATH}/PC/pyconfig.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - file(COPY ${SOURCE_PATH}/Lib DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}) - file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + vcpkg_from_github( + OUT_SOURCE_PATH DL_SOURCE_PATH + REPO python/cpython + REF "v${PYTHON_VERSION}" + SHA512 "${PYTHON_SHA512}" + HEAD_REF master + PATCHES + "${SOURCE_STATIC_PATCH_0001}" + "${SOURCE_STATIC_PATCH_0002}" + "${SOURCE_STATIC_PATCH_0003}" + "${SOURCE_STATIC_PATCH_0004}" + ) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) - endif() + set(SOURCE_PATH "${DL_SOURCE_PATH}-${TARGET_TRIPLET}-rel") + file(REMOVE_RECURSE ${SOURCE_PATH}) + file(RENAME ${DL_SOURCE_PATH} ${SOURCE_PATH}) - if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.dll DESTINATION ${CURRENT_PACKAGES_DIR}/bin) + message(STATUS "Building ${TARGET_TRIPLET}-rel") - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.dll DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) - endif() + vcpkg_build_msbuild_type( + ${SOURCE_PATH}/PCBuild/pythoncore.vcxproj + ${BUILD_ARCH} + "release" + ) - endif() + file(GLOB HEADERS ${SOURCE_PATH}/Include/*.h) + file(COPY ${HEADERS} ${SOURCE_PATH}/PC/pyconfig.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) + file(COPY ${SOURCE_PATH}/Lib DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}) + file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_copy_pdbs() + if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.dll DESTINATION ${CURRENT_PACKAGES_DIR}/bin) + endif() endif() - # Handle copyright - file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}) - file(RENAME ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/LICENSE ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/copyright) -elseif (VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX) + ################ + # Debug build + ################ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - set(SOURCE_PATH_DEBUG "${TEMP_SOURCE_PATH}-${TARGET_TRIPLET}-debug") - endif() + vcpkg_from_github( + OUT_SOURCE_PATH DL_SOURCE_PATH + REPO python/cpython + REF "v${PYTHON_VERSION}" + SHA512 "${PYTHON_SHA512}" + HEAD_REF master + PATCHES + "${SOURCE_STATIC_PATCH_0001}" + "${SOURCE_STATIC_PATCH_0002}" + "${SOURCE_STATIC_PATCH_0003}" + "${SOURCE_STATIC_PATCH_0004}" + ) - set(SOURCE_PATH_RELEASE "${TEMP_SOURCE_PATH}-${TARGET_TRIPLET}-release") - file(REMOVE_RECURSE ${SOURCE_PATH_RELEASE}) - file(GLOB FILES ${TEMP_SOURCE_PATH}/*) - file(COPY ${FILES} DESTINATION ${SOURCE_PATH_RELEASE}) + set(SOURCE_PATH "${DL_SOURCE_PATH}-${TARGET_TRIPLET}-dbg") + file(REMOVE_RECURSE ${SOURCE_PATH}) + file(RENAME ${DL_SOURCE_PATH} ${SOURCE_PATH}) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(REMOVE_RECURSE ${SOURCE_PATH_DEBUG}) - file(RENAME "${TEMP_SOURCE_PATH}" ${SOURCE_PATH_DEBUG}) + message(STATUS "Building ${TARGET_TRIPLET}-dbg") + + vcpkg_build_msbuild_type( + ${SOURCE_PATH}/PCBuild/pythoncore.vcxproj + ${BUILD_ARCH} + "debug" + ) + + file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + + if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.dll DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + endif() + + vcpkg_copy_pdbs() endif() +else() # MACOS + Linux + find_program(MAKE make) if (NOT MAKE) message(FATAL_ERROR "MAKE not found") endif() + ################ + # Release build + ################ + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - ################ - # Release build - ################ + vcpkg_from_github( + OUT_SOURCE_PATH DL_SOURCE_PATH + REPO python/cpython + REF "v${PYTHON_VERSION}" + SHA512 "${PYTHON_SHA512}" + HEAD_REF master + ) + + set(SOURCE_PATH "${DL_SOURCE_PATH}-${TARGET_TRIPLET}-rel") + file(REMOVE_RECURSE ${SOURCE_PATH}) + file(RENAME ${DL_SOURCE_PATH} ${SOURCE_PATH}) + message(STATUS "Configuring ${TARGET_TRIPLET}-rel") - set(OUT_PATH_RELEASE ${SOURCE_PATH_RELEASE}/../../make-build-${TARGET_TRIPLET}-release) - file(MAKE_DIRECTORY ${OUT_PATH_RELEASE}) + set(OUT_PATH ${SOURCE_PATH}/../../make-build-${TARGET_TRIPLET}-rel) + file(MAKE_DIRECTORY ${OUT_PATH}) if(VCPKG_TARGET_IS_OSX) vcpkg_execute_build_process( - COMMAND "${SOURCE_PATH_RELEASE}/configure" --prefix=${OUT_PATH_RELEASE} --with-openssl=${CURRENT_INSTALLED_DIR} "CPPFLAGS=-I${CURRENT_INSTALLED_DIR}/include -framework CoreFoundation" "LDFLAGS=-L${CURRENT_INSTALLED_DIR}/lib" "LIBS=-liconv" - WORKING_DIRECTORY ${SOURCE_PATH_RELEASE} + COMMAND "${SOURCE_PATH}/configure" --prefix=${OUT_PATH} --with-openssl=${CURRENT_INSTALLED_DIR} "CPPFLAGS=-I${CURRENT_INSTALLED_DIR}/include -framework CoreFoundation" "LDFLAGS=-L${CURRENT_INSTALLED_DIR}/lib" "LIBS=-liconv" + WORKING_DIRECTORY ${SOURCE_PATH} LOGNAME config-${TARGET_TRIPLET}-rel ) else() vcpkg_execute_build_process( - COMMAND "${SOURCE_PATH_RELEASE}/configure" --prefix=${OUT_PATH_RELEASE} --with-openssl=${CURRENT_INSTALLED_DIR} "CPPFLAGS=-I${CURRENT_INSTALLED_DIR}/include" "LDFLAGS=-L${CURRENT_INSTALLED_DIR}/lib" - WORKING_DIRECTORY ${SOURCE_PATH_RELEASE} + COMMAND "${SOURCE_PATH}/configure" --prefix=${OUT_PATH} --with-openssl=${CURRENT_INSTALLED_DIR} "CPPFLAGS=-I${CURRENT_INSTALLED_DIR}/include" "LDFLAGS=-L${CURRENT_INSTALLED_DIR}/lib" + WORKING_DIRECTORY ${SOURCE_PATH} LOGNAME config-${TARGET_TRIPLET}-rel ) endif() @@ -113,47 +171,59 @@ elseif (VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX) vcpkg_execute_build_process( COMMAND make -j ${VCPKG_CONCURRENCY} NO_PARALLEL_COMMAND make - WORKING_DIRECTORY ${SOURCE_PATH_RELEASE} - LOGNAME make-build-${TARGET_TRIPLET}-release + WORKING_DIRECTORY ${SOURCE_PATH} + LOGNAME make-build-${TARGET_TRIPLET}-rel ) message(STATUS "Installing ${TARGET_TRIPLET}-rel") vcpkg_execute_build_process( COMMAND make install - WORKING_DIRECTORY ${SOURCE_PATH_RELEASE} - LOGNAME make-install-${TARGET_TRIPLET}-release + WORKING_DIRECTORY ${SOURCE_PATH} + LOGNAME make-install-${TARGET_TRIPLET}-rel ) - file(GLOB HEADERS ${OUT_PATH_RELEASE}/include/*) + file(GLOB HEADERS ${OUT_PATH}/include/*) file(COPY ${HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include) - file(GLOB LIBS ${OUT_PATH_RELEASE}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/*) + file(GLOB LIBS ${OUT_PATH}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/*) file(COPY ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/Lib) - file(GLOB LIBS ${OUT_PATH_RELEASE}/lib/pkgconfig/*) + file(GLOB LIBS ${OUT_PATH}/lib/pkgconfig/*) file(COPY ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}) - file(COPY ${OUT_PATH_RELEASE}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m.a DESTINATION ${CURRENT_PACKAGES_DIR}/lib) + file(COPY ${OUT_PATH}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m.a DESTINATION ${CURRENT_PACKAGES_DIR}/lib) message(STATUS "Installing ${TARGET_TRIPLET}-rel done") - endif() + ################ + # Debug build + ################ + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - ################ - # Debug build - ################ + vcpkg_from_github( + OUT_SOURCE_PATH DL_SOURCE_PATH + REPO python/cpython + REF "v${PYTHON_VERSION}" + SHA512 "${PYTHON_SHA512}" + HEAD_REF master + ) + + set(SOURCE_PATH "${DL_SOURCE_PATH}-${TARGET_TRIPLET}-dbg") + file(REMOVE_RECURSE ${SOURCE_PATH}) + file(RENAME ${DL_SOURCE_PATH} ${SOURCE_PATH}) + message(STATUS "Configuring ${TARGET_TRIPLET}-dbg") - set(OUT_PATH_DEBUG ${SOURCE_PATH_DEBUG}/../../make-build-${TARGET_TRIPLET}-debug) - file(MAKE_DIRECTORY ${OUT_PATH_DEBUG}) + set(OUT_PATH ${SOURCE_PATH}/../../make-build-${TARGET_TRIPLET}-dbg) + file(MAKE_DIRECTORY ${OUT_PATH}) if(VCPKG_TARGET_IS_OSX) vcpkg_execute_build_process( - COMMAND "${SOURCE_PATH_DEBUG}/configure" --with-pydebug --prefix=${OUT_PATH_DEBUG} --with-openssl=${CURRENT_INSTALLED_DIR}/debug "CPPFLAGS=-I${CURRENT_INSTALLED_DIR}/include -framework CoreFoundation" "LDFLAGS=-L${CURRENT_INSTALLED_DIR}/debug/lib" "LIBS=-liconv" - WORKING_DIRECTORY ${SOURCE_PATH_DEBUG} - LOGNAME config-${TARGET_TRIPLET}-debug + COMMAND "${SOURCE_PATH}/configure" --prefix=${OUT_PATH} --with-openssl=${CURRENT_INSTALLED_DIR}/debug "CPPFLAGS=-I${CURRENT_INSTALLED_DIR}/include -framework CoreFoundation" "LDFLAGS=-L${CURRENT_INSTALLED_DIR}/debug/lib" "LIBS=-liconv" + WORKING_DIRECTORY ${SOURCE_PATH} + LOGNAME config-${TARGET_TRIPLET}-dbg ) else() vcpkg_execute_build_process( - COMMAND "${SOURCE_PATH_DEBUG}/configure" --with-pydebug --prefix=${OUT_PATH_DEBUG} --with-openssl=${CURRENT_INSTALLED_DIR}/debug "CPPFLAGS=-I${CURRENT_INSTALLED_DIR}/include" "LDFLAGS=-L${CURRENT_INSTALLED_DIR}/debug/lib" - WORKING_DIRECTORY ${SOURCE_PATH_DEBUG} - LOGNAME config-${TARGET_TRIPLET}-debug + COMMAND "${SOURCE_PATH}/configure" --prefix=${OUT_PATH} --with-openssl=${CURRENT_INSTALLED_DIR}/debug "CPPFLAGS=-I${CURRENT_INSTALLED_DIR}/include" "LDFLAGS=-L${CURRENT_INSTALLED_DIR}/debug/lib" + WORKING_DIRECTORY ${SOURCE_PATH} + LOGNAME config-${TARGET_TRIPLET}-dbg ) endif() @@ -161,23 +231,24 @@ elseif (VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX) vcpkg_execute_build_process( COMMAND make -j ${VCPKG_CONCURRENCY} NO_PARALLEL_COMMAND make - WORKING_DIRECTORY ${SOURCE_PATH_DEBUG} - LOGNAME make-build-${TARGET_TRIPLET}-debug + WORKING_DIRECTORY ${SOURCE_PATH} + LOGNAME make-build-${TARGET_TRIPLET}-dbg ) message(STATUS "Installing ${TARGET_TRIPLET}-dbg") vcpkg_execute_build_process( COMMAND make install - WORKING_DIRECTORY ${SOURCE_PATH_DEBUG} - LOGNAME make-install-${TARGET_TRIPLET}-debug + WORKING_DIRECTORY ${SOURCE_PATH} + LOGNAME make-install-${TARGET_TRIPLET}-dbg ) - file(COPY ${OUT_PATH_DEBUG}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}dm.a DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + file(COPY ${OUT_PATH}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m.a DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) message(STATUS "Installing ${TARGET_TRIPLET}-dbg done") - endif() - # Handle copyright - file(COPY ${SOURCE_PATH_RELEASE}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}) - file(RENAME ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/LICENSE ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/copyright) endif() + +# Handle copyright +file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/LICENSE ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/copyright) +