[python3]make python3 support unix (#8055)

* support unix

* Update portfile.cmake

call vcpkg_execute_build_process instead of vcpkg_execute_required_process
This commit is contained in:
Long Huan 2019-09-30 09:58:00 +08:00 committed by Curtis J Bezault
parent 2cf0a50129
commit fe3e544fa5
2 changed files with 149 additions and 37 deletions

View File

@ -1,4 +1,5 @@
Source: python3
Version: 3.7.3
Homepage: https://github.com/python/cpython
Description: The Python programming language as an embeddable library
Description: The Python programming language as an embeddable library
Build-Depends: libffi, openssl

View File

@ -18,41 +18,152 @@ vcpkg_from_github(
HEAD_REF master
)
# 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
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})
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_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()
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}")
vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/PCBuild/pythoncore.vcxproj
PLATFORM ${BUILD_ARCH})
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)
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}.dll DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
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()
# 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)
set(SOURCE_PATH_DEBUG "${TEMP_SOURCE_PATH}-${TARGET_TRIPLET}-debug")
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})
file(REMOVE_RECURSE ${SOURCE_PATH_DEBUG})
file(RENAME "${TEMP_SOURCE_PATH}" ${SOURCE_PATH_DEBUG})
find_program(MAKE make)
if (NOT MAKE)
message(FATAL_ERROR "MAKE not found")
endif()
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})
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}
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}
LOGNAME config-${TARGET_TRIPLET}-rel
)
endif()
message(STATUS "Building ${TARGET_TRIPLET}-rel")
vcpkg_execute_build_process(
COMMAND make -j ${VCPKG_CONCURRENCY}
NO_PARALLEL_COMMAND make
WORKING_DIRECTORY ${SOURCE_PATH_RELEASE}
LOGNAME make-build-${TARGET_TRIPLET}-release
)
message(STATUS "Installing ${TARGET_TRIPLET}-rel")
vcpkg_execute_build_process(
COMMAND make install
WORKING_DIRECTORY ${SOURCE_PATH_RELEASE}
LOGNAME make-install-${TARGET_TRIPLET}-release
)
file(GLOB HEADERS ${OUT_PATH_RELEASE}/include/*)
file(COPY ${HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include)
file(GLOB LIBS ${OUT_PATH_RELEASE}/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(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)
message(STATUS "Installing ${TARGET_TRIPLET}-rel done")
endif()
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})
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
)
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
)
endif()
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
vcpkg_execute_build_process(
COMMAND make -j ${VCPKG_CONCURRENCY}
NO_PARALLEL_COMMAND make
WORKING_DIRECTORY ${SOURCE_PATH_DEBUG}
LOGNAME make-build-${TARGET_TRIPLET}-debug
)
message(STATUS "Installing ${TARGET_TRIPLET}-dbg")
vcpkg_execute_build_process(
COMMAND make install
WORKING_DIRECTORY ${SOURCE_PATH_DEBUG}
LOGNAME make-install-${TARGET_TRIPLET}-debug
)
file(COPY ${OUT_PATH_DEBUG}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}dm.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()
vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/PCBuild/pythoncore.vcxproj
PLATFORM ${BUILD_ARCH})
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)
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}.dll DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.dll DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
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)
vcpkg_copy_pdbs()