2017-05-20 16:58:30 +08:00
|
|
|
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic AND VCPKG_CRT_LINKAGE STREQUAL static)
|
|
|
|
message(STATUS "Warning: Dynamic library with static CRT is not supported. Building static library.")
|
|
|
|
set(VCPKG_LIBRARY_LINKAGE static)
|
|
|
|
endif()
|
|
|
|
|
2018-01-05 00:55:01 +08:00
|
|
|
set(PYTHON_VERSION_MAJOR 3)
|
2019-03-26 21:09:04 +08:00
|
|
|
set(PYTHON_VERSION_MINOR 7)
|
|
|
|
set(PYTHON_VERSION_PATCH 3)
|
2018-01-05 00:55:01 +08:00
|
|
|
set(PYTHON_VERSION ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH})
|
2017-05-20 05:31:04 +08:00
|
|
|
|
|
|
|
vcpkg_from_github(
|
|
|
|
OUT_SOURCE_PATH TEMP_SOURCE_PATH
|
|
|
|
REPO python/cpython
|
2018-01-05 00:55:01 +08:00
|
|
|
REF v${PYTHON_VERSION}
|
2019-03-26 21:09:04 +08:00
|
|
|
SHA512 023960a2f570fe7178d3901df0c3c33346466906b6d55c73ef7947c19619dbab62efc42c7262a0539bc5e31543b1113eb7a088d4615ad7557a0707bdaca27940
|
2017-05-20 05:31:04 +08:00
|
|
|
HEAD_REF master
|
2018-03-18 19:31:30 +08:00
|
|
|
)
|
|
|
|
|
2020-03-11 03:25:18 +08:00
|
|
|
if("enable-shared" IN_LIST FEATURES)
|
|
|
|
set(_ENABLED_SHARED --enable-shared)
|
|
|
|
else()
|
|
|
|
unset(_ENABLED_SHARED)
|
|
|
|
endif()
|
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
if (VCPKG_TARGET_IS_WINDOWS)
|
2020-03-11 03:25:18 +08:00
|
|
|
if(DEFINED _ENABLED_SHARED)
|
|
|
|
message(WARNING "enable-shared requested, by Windows build already produce a shared library by default")
|
|
|
|
endif()
|
2020-01-17 05:56:28 +08:00
|
|
|
set(SOURCE_PATH "${TEMP_SOURCE_PATH}-Lib-Win")
|
2019-09-30 09:58:00 +08:00
|
|
|
file(REMOVE_RECURSE ${SOURCE_PATH})
|
|
|
|
file(RENAME "${TEMP_SOURCE_PATH}" ${SOURCE_PATH})
|
2020-03-11 03:25:18 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
# 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
|
2020-03-11 03:25:18 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
if (VCPKG_TARGET_ARCHITECTURE MATCHES "x86")
|
|
|
|
set(BUILD_ARCH "Win32")
|
|
|
|
set(OUT_DIR "win32")
|
|
|
|
elseif (VCPKG_TARGET_ARCHITECTURE MATCHES "x64")
|
|
|
|
set(BUILD_ARCH "x64")
|
|
|
|
set(OUT_DIR "amd64")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unsupported architecture: ${VCPKG_TARGET_ARCHITECTURE}")
|
|
|
|
endif()
|
2017-05-20 05:31:04 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
vcpkg_build_msbuild(
|
|
|
|
PROJECT_PATH ${SOURCE_PATH}/PCBuild/pythoncore.vcxproj
|
|
|
|
PLATFORM ${BUILD_ARCH})
|
2018-04-21 08:53:57 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
file(GLOB HEADERS ${SOURCE_PATH}/Include/*.h)
|
2020-03-11 03:25:18 +08:00
|
|
|
file(INSTALL
|
|
|
|
${HEADERS}
|
|
|
|
"${SOURCE_PATH}/PC/pyconfig.h"
|
|
|
|
DESTINATION
|
|
|
|
"${CURRENT_PACKAGES_DIR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
|
|
|
|
)
|
|
|
|
file(INSTALL
|
|
|
|
"${SOURCE_PATH}/Lib"
|
|
|
|
DESTINATION
|
|
|
|
"${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}"
|
|
|
|
)
|
|
|
|
file(INSTALL
|
|
|
|
"${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.lib"
|
|
|
|
DESTINATION
|
|
|
|
"${CURRENT_PACKAGES_DIR}/lib"
|
|
|
|
)
|
2019-11-19 06:04:25 +08:00
|
|
|
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
2020-03-11 03:25:18 +08:00
|
|
|
file(INSTALL "${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.lib" DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
|
2019-11-19 06:04:25 +08:00
|
|
|
endif()
|
2019-02-07 09:21:23 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
|
2020-03-11 03:25:18 +08:00
|
|
|
file(INSTALL "${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.dll" DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
|
2019-11-19 06:04:25 +08:00
|
|
|
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
2020-03-11 03:25:18 +08:00
|
|
|
file(INSTALL "${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.dll" DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
|
2019-11-19 06:04:25 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
|
|
vcpkg_copy_pdbs()
|
2019-09-30 09:58:00 +08:00
|
|
|
endif()
|
|
|
|
# Handle copyright
|
2020-03-11 03:25:18 +08:00
|
|
|
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR} RENAME copyright)
|
2019-11-19 06:04:25 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
elseif (VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX)
|
2019-11-19 06:04:25 +08:00
|
|
|
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
|
|
set(SOURCE_PATH_DEBUG "${TEMP_SOURCE_PATH}-${TARGET_TRIPLET}-debug")
|
|
|
|
endif()
|
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
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})
|
2019-11-19 06:04:25 +08:00
|
|
|
|
|
|
|
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})
|
|
|
|
endif()
|
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
find_program(MAKE make)
|
|
|
|
if (NOT MAKE)
|
|
|
|
message(FATAL_ERROR "MAKE not found")
|
|
|
|
endif()
|
2020-03-11 03:25:18 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
|
|
|
################
|
|
|
|
# Release build
|
|
|
|
################
|
|
|
|
message(STATUS "Configuring ${TARGET_TRIPLET}-rel")
|
|
|
|
set(OUT_PATH_RELEASE ${SOURCE_PATH_RELEASE}/../../make-build-${TARGET_TRIPLET}-release)
|
|
|
|
file(MAKE_DIRECTORY ${OUT_PATH_RELEASE})
|
2020-03-11 03:25:18 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
if(VCPKG_TARGET_IS_OSX)
|
|
|
|
vcpkg_execute_build_process(
|
2020-03-11 03:25:18 +08:00
|
|
|
COMMAND
|
|
|
|
"${SOURCE_PATH_RELEASE}/configure"
|
|
|
|
${_ENABLED_SHARED}
|
|
|
|
--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}
|
|
|
|
LOGNAME config-${TARGET_TRIPLET}-rel
|
2019-09-30 09:58:00 +08:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
vcpkg_execute_build_process(
|
2020-03-11 03:25:18 +08:00
|
|
|
COMMAND
|
|
|
|
"${SOURCE_PATH_RELEASE}/configure"
|
|
|
|
${_ENABLED_SHARED}
|
|
|
|
--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}
|
|
|
|
LOGNAME config-${TARGET_TRIPLET}-rel
|
2019-09-30 09:58:00 +08:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "Building ${TARGET_TRIPLET}-rel")
|
2019-11-19 06:04:25 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
vcpkg_execute_build_process(
|
2020-04-17 02:57:59 +08:00
|
|
|
COMMAND make install -j ${VCPKG_CONCURRENCY}
|
|
|
|
NO_PARALLEL_COMMAND make install
|
2019-09-30 09:58:00 +08:00
|
|
|
WORKING_DIRECTORY ${SOURCE_PATH_RELEASE}
|
|
|
|
LOGNAME make-build-${TARGET_TRIPLET}-release
|
|
|
|
)
|
2020-03-11 03:25:18 +08:00
|
|
|
|
|
|
|
message(STATUS "Installing ${TARGET_TRIPLET}-rel headers...")
|
|
|
|
file(GLOB HEADERS
|
|
|
|
${OUT_PATH_RELEASE}/include/*)
|
|
|
|
file(INSTALL ${HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include
|
|
|
|
PATTERN "*__pycache__*" EXCLUDE
|
|
|
|
)
|
|
|
|
|
|
|
|
message(STATUS "Installing ${TARGET_TRIPLET}-rel lib files...")
|
|
|
|
file(GLOB LIBS
|
|
|
|
${OUT_PATH_RELEASE}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/*)
|
|
|
|
file(INSTALL ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/Lib
|
|
|
|
PATTERN "*.pyc" EXCLUDE
|
|
|
|
PATTERN "*__pycache__*" EXCLUDE
|
|
|
|
)
|
|
|
|
|
|
|
|
message(STATUS "Installing ${TARGET_TRIPLET}-rel share files...")
|
|
|
|
file(GLOB LIBS
|
|
|
|
${OUT_PATH_RELEASE}/lib/pkgconfig/*)
|
|
|
|
file(INSTALL ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}
|
|
|
|
PATTERN "*.pyc" EXCLUDE
|
|
|
|
PATTERN "*__pycache__*" EXCLUDE
|
|
|
|
)
|
|
|
|
|
|
|
|
message(STATUS "Installing ${TARGET_TRIPLET}-rel Python library files...")
|
|
|
|
file(GLOB LIBS
|
|
|
|
${OUT_PATH_RELEASE}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m.*)
|
|
|
|
file(INSTALL ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/lib
|
|
|
|
PATTERN "*.pyc" EXCLUDE
|
|
|
|
PATTERN "*__pycache__*" EXCLUDE
|
|
|
|
)
|
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
message(STATUS "Installing ${TARGET_TRIPLET}-rel done")
|
2019-11-19 06:04:25 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
endif()
|
2017-05-20 05:31:04 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
|
|
################
|
|
|
|
# Debug build
|
|
|
|
################
|
|
|
|
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
|
|
|
|
set(OUT_PATH_DEBUG ${SOURCE_PATH_DEBUG}/../../make-build-${TARGET_TRIPLET}-debug)
|
|
|
|
file(MAKE_DIRECTORY ${OUT_PATH_DEBUG})
|
2019-11-19 06:04:25 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
if(VCPKG_TARGET_IS_OSX)
|
|
|
|
vcpkg_execute_build_process(
|
2020-03-11 03:25:18 +08:00
|
|
|
COMMAND
|
|
|
|
"${SOURCE_PATH_DEBUG}/configure"
|
|
|
|
--with-pydebug
|
|
|
|
${_ENABLED_SHARED}
|
|
|
|
--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
|
2019-09-30 09:58:00 +08:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
vcpkg_execute_build_process(
|
2020-03-11 03:25:18 +08:00
|
|
|
COMMAND
|
|
|
|
"${SOURCE_PATH_DEBUG}/configure"
|
|
|
|
--with-pydebug
|
|
|
|
${_ENABLED_SHARED}
|
|
|
|
--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
|
2019-09-30 09:58:00 +08:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
|
|
|
|
vcpkg_execute_build_process(
|
2020-04-17 02:57:59 +08:00
|
|
|
COMMAND make install -j ${VCPKG_CONCURRENCY}
|
|
|
|
NO_PARALLEL_COMMAND make install
|
2019-09-30 09:58:00 +08:00
|
|
|
WORKING_DIRECTORY ${SOURCE_PATH_DEBUG}
|
|
|
|
LOGNAME make-build-${TARGET_TRIPLET}-debug
|
|
|
|
)
|
2020-03-11 03:25:18 +08:00
|
|
|
|
|
|
|
message(STATUS "Installing ${TARGET_TRIPLET}-dbg Python library files...")
|
|
|
|
file(GLOB LIBS
|
|
|
|
${OUT_PATH_DEBUG}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}dm.*)
|
|
|
|
file(INSTALL ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib
|
|
|
|
PATTERN "*.pyc" EXCLUDE
|
|
|
|
PATTERN "*__pycache__*" EXCLUDE
|
|
|
|
)
|
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
message(STATUS "Installing ${TARGET_TRIPLET}-dbg done")
|
2019-11-19 06:04:25 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
endif()
|
|
|
|
# Handle copyright
|
2020-03-11 03:25:18 +08:00
|
|
|
file(INSTALL ${SOURCE_PATH_RELEASE}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR} RENAME copyright)
|
2019-11-19 06:04:25 +08:00
|
|
|
|
2019-09-30 09:58:00 +08:00
|
|
|
endif()
|