Commit 4e21bf64 authored by Ghislain MARY's avatar Ghislain MARY

Simplify installation of Python packages.

parent 95505eef
......@@ -225,7 +225,7 @@ macro(linphone_builder_expand_external_project_vars)
list(APPEND LINPHONE_BUILDER_EP_ARGS -D${_varname}:${_vartype}=${${_varname}})
list(APPEND LINPHONE_BUILDER_EP_VARNAMES ${_varname})
endforeach()
endmacro(linphone_builder_expand_external_project_vars)
endmacro()
list(APPEND LINPHONE_BUILDER_EP_VARS
CMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH
......@@ -270,19 +270,23 @@ list(APPEND LINPHONE_BUILDER_EP_VARS
CMAKE_SKIP_RPATH:BOOL
CMAKE_SKIP_BUILD_RPATH:BOOL
CMAKE_VERBOSE_MAKEFILE:BOOL
CMAKE_SYSTEM_NAME:STRING
CMAKE_SYSTEM_VERSION:STRING
MSVC_C_ARCHITECTURE_ID:STRING
MSVC_CXX_ARCHITECTURE_ID:STRING
MSVC_VERSION:STRING
)
if(CMAKE_CROSSCOMPILING)
list(APEND LINPHONE_BUILDER_EP_VARS
CMAKE_SYSTEM_NAME:STRING
CMAKE_SYSTEM_VERSION:STRING
)
endif()
if(APPLE)
list(APPEND LINPHONE_BUILDER_EP_VARS
CMAKE_MACOSX_RPATH:BOOL
CMAKE_OSX_ARCHITECTURES:STRING
CMAKE_OSX_DEPLOYMENT_TARGET:STRING
)
endif(APPLE)
endif()
if(CMAKE_TOOLCHAIN_FILE)
list(APPEND LINPHONE_BUILDER_EP_VARS CMAKE_TOOLCHAIN_FILE:PATH)
endif()
......
......@@ -159,6 +159,7 @@ ExternalProject_Add(TARGET_pylinphone
DOWNLOAD_COMMAND ""
PATCH_COMMAND "${CMAKE_COMMAND}" "-E" "copy_directory" "${CMAKE_CURRENT_LIST_DIR}/python" "<SOURCE_DIR>"
"COMMAND" "${CMAKE_COMMAND}" "-E" "copy" "${CMAKE_CURRENT_LIST_DIR}/../cmake/FindXML2.cmake" "<SOURCE_DIR>"
INSTALL_COMMAND ""
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS ${LINPHONE_BUILDER_EP_ARGS} -DPACKAGE_NAME=${PACKAGE_NAME} -DENABLE_FFMPEG:BOOL=${ENABLE_FFMPEG} -DENABLE_OPENH264:BOOL=${ENABLE_OPENH264} -DENABLE_WASAPI:BOOL=${ENABLE_WASAPI}
)
......@@ -23,12 +23,6 @@
cmake_minimum_required(VERSION 2.8.12)
project(PYLINPHONE C CXX) # Dummy project
if(APPLE)
set(PLATFORM_ARCH_NAME "${CMAKE_OSX_ARCHITECTURES}")
else()
set(PLATFORM_ARCH_NAME "${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()
set(Python_ADDITIONAL_VERSIONS 2.7)
find_package(PythonInterp REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)
......@@ -170,91 +164,65 @@ foreach(PACKAGE_TO_BUILD ${PACKAGES_TO_BUILD})
endif()
endforeach()
if(WIN32)
set(PLATFORM_TAG "win32")
else()
if(CMAKE_CROSSCOMPILING)
string(TOLOWER "${CMAKE_SYSTEM_NAME}" PLATFORM_OS)
else()
if(APPLE)
set(PLATFORM_OS "macosx")
else()
set(PLATFORM_OS "linux")
endif()
endif()
set(PLATFORM_TAG "${PLATFORM_OS}-${CMAKE_SYSTEM_PROCESSOR}")
endif()
set(PYLINPHONE_INSTALL_DEPS )
if(WIN32)
# Generate the installer
set(EXE_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/build_exe/linphone/dist/${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}.win32.exe")
add_custom_command(OUTPUT "${EXE_FILENAME}"
add_custom_target(pylinphone_exe ALL
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/build_exe/linphone/setup.py" "bdist_wininst"
DEPENDS pylinphone
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_exe/linphone"
)
add_custom_target(pylinphone_exe ALL DEPENDS "${EXE_FILENAME}")
install(FILES ${EXE_FILENAME} DESTINATION "." RENAME "${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}.win32-py${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.exe")
list(APPEND PYLINPHONE_INSTALL_DEPS pylinphone_exe)
# Generate the msi
set(MSI_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/build_msi/linphone/dist/${PACKAGE_NAME}-${LINPHONE_VERSION}.win32.msi")
add_custom_command(OUTPUT "${MSI_FILENAME}"
add_custom_target(pylinphone_msi ALL
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/build_msi/linphone/setup.py" "bdist_msi"
DEPENDS pylinphone
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_msi/linphone"
)
add_custom_target(pylinphone_msi ALL DEPENDS "${MSI_FILENAME}")
install(FILES ${MSI_FILENAME} DESTINATION "." RENAME "${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}.win32-py${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.msi")
# Generate the zip
set(ZIP_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/build_zip/linphone/dist/${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}.win32.zip")
add_custom_command(OUTPUT "${ZIP_FILENAME}"
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/build_zip/linphone/setup.py" "bdist" "--format=zip"
DEPENDS pylinphone
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_zip/linphone"
)
add_custom_target(pylinphone_zip ALL DEPENDS "${ZIP_FILENAME}")
install(FILES ${ZIP_FILENAME} DESTINATION "." RENAME "${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}.win32-py${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.zip")
# Generate the wheel package
string(REPLACE "-" "_" LINPHONE_UNDERSCORE_GIT_REVISION ${LINPHONE_GIT_REVISION})
set(WHEEL_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone/dist/${PACKAGE_NAME}-${LINPHONE_UNDERSCORE_GIT_REVISION}-py2-none-any.whl")
add_custom_command(OUTPUT "${WHEEL_FILENAME}"
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone/setup.py" "bdist_wheel"
DEPENDS pylinphone
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone"
)
add_custom_target(pylinphone_wheel ALL DEPENDS "${WHEEL_FILENAME}")
install(FILES ${WHEEL_FILENAME} DESTINATION "." RENAME "${PACKAGE_NAME}-${LINPHONE_UNDERSCORE_GIT_REVISION}-cp27-none-win32.whl")
list(APPEND PYLINPHONE_INSTALL_DEPS pylinphone_msi)
endif()
if(UNIX)
if(CMAKE_CROSSCOMPILING)
string(TOLOWER "${CMAKE_SYSTEM_NAME}" PLATFORM_OS)
set(PLATFORM_TAG "${PLATFORM_OS}-${CMAKE_SYSTEM_PROCESSOR}")
set(UNDERSCORE_PLATFORM_TAG "any")
else()
if(APPLE)
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "x86_64")
endif()
set(PLATFORM_OS "macosx-${CMAKE_OSX_DEPLOYMENT_TARGET}")
else()
set(PLATFORM_OS "linux")
endif()
string(REPLACE "-" "_" UNDERSCORE_PLATFORM_OS ${PLATFORM_OS})
string(REPLACE "." "_" UNDERSCORE_PLATFORM_OS ${UNDERSCORE_PLATFORM_OS})
set(PLATFORM_TAG "${PLATFORM_OS}-${PLATFORM_ARCH_NAME}")
set(UNDERSCORE_PLATFORM_TAG "${UNDERSCORE_PLATFORM_OS}_${PLATFORM_ARCH_NAME}")
endif()
# Generate the zip
set(ZIP_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/build_zip/linphone/dist/${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}.${PLATFORM_OS}-${PLATFORM_ARCH_NAME}.zip")
add_custom_command(OUTPUT "${ZIP_FILENAME}"
add_custom_target(pylinphone_zip ALL
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/build_zip/linphone/setup.py" "bdist" "--format=zip"
DEPENDS pylinphone
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_zip/linphone"
)
add_custom_target(pylinphone_zip ALL DEPENDS "${ZIP_FILENAME}")
install(FILES ${ZIP_FILENAME} DESTINATION "." RENAME "${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}.${PLATFORM_TAG}-py${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.zip")
list(APPEND PYLINPHONE_INSTALL_DEPS pylinphone_zip)
# Generate the wheel package
string(REPLACE "-" "_" LINPHONE_UNDERSCORE_GIT_REVISION ${LINPHONE_GIT_REVISION})
set(WHEEL_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone/dist/${PACKAGE_NAME}-${LINPHONE_UNDERSCORE_GIT_REVISION}-py2-none-any.whl")
add_custom_command(OUTPUT "${WHEEL_FILENAME}"
add_custom_target(pylinphone_wheel
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone/setup.py" "bdist_wheel"
DEPENDS pylinphone
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone"
)
add_custom_target(pylinphone_wheel ALL DEPENDS "${WHEEL_FILENAME}")
install(FILES ${WHEEL_FILENAME} DESTINATION "." RENAME "${PACKAGE_NAME}-${LINPHONE_UNDERSCORE_GIT_REVISION}-cp27-none-${UNDERSCORE_PLATFORM_TAG}.whl")
list(APPEND PYLINPHONE_INSTALL_DEPS pylinphone_wheel)
endif()
add_custom_target(pylinphone_install ALL
COMMAND "${CMAKE_COMMAND}" "-DPACKAGE_NAME=${PACKAGE_NAME}" "-DLINPHONE_GIT_REVISION=${LINPHONE_GIT_REVISION}"
"-DPLATFORM_TAG=${PLATFORM_TAG}" "-DPYTHON_VERSION=${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
"-DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" "-DINSTALL_DIR=${CMAKE_INSTALL_PREFIX}"
"-P" "${CMAKE_CURRENT_SOURCE_DIR}/install.cmake"
DEPENDS ${PYLINPHONE_INSTALL_DEPS}
)
############################################################################
# install.cmake
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
file(GLOB EXE_FILEPATH "${BINARY_DIR}/build_exe/linphone/dist/${PACKAGE_NAME}-*.exe")
file(GLOB MSI_FILEPATH "${BINARY_DIR}/build_msi/linphone/dist/${PACKAGE_NAME}-*.msi")
file(GLOB ZIP_FILEPATH "${BINARY_DIR}/build_zip/linphone/dist/${PACKAGE_NAME}-*.zip")
file(GLOB WHL_FILEPATH "${BINARY_DIR}/build_wheel/linphone/dist/${PACKAGE_NAME}-*.whl")
string(REPLACE "." "" PYTHON_VERSION_NO_DOT "${PYTHON_VERSION}")
string(REPLACE "-" "_" PLATFORM_TAG_UNDERSCORED "${PLATFORM_TAG}")
if(EXE_FILEPATH)
get_filename_component(EXE_FILENAME "${EXE_FILEPATH}" NAME)
file(COPY "${EXE_FILEPATH}" DESTINATION "${INSTALL_DIR}")
file(RENAME "${INSTALL_DIR}/${EXE_FILENAME}" "${INSTALL_DIR}/${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}.${PLATFORM_TAG}-py${PYTHON_VERSION}.exe")
endif()
if(MSI_FILEPATH)
get_filename_component(MSI_FILENAME "${MSI_FILEPATH}" NAME)
file(COPY "${MSI_FILEPATH}" DESTINATION "${INSTALL_DIR}")
file(RENAME "${INSTALL_DIR}/${MSI_FILENAME}" "${INSTALL_DIR}/${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}.${PLATFORM_TAG}-py${PYTHON_VERSION}.msi")
endif()
if(ZIP_FILEPATH)
get_filename_component(ZIP_FILENAME "${ZIP_FILEPATH}" NAME)
file(COPY "${ZIP_FILEPATH}" DESTINATION "${INSTALL_DIR}")
file(RENAME "${INSTALL_DIR}/${ZIP_FILENAME}" "${INSTALL_DIR}/${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}.${PLATFORM_TAG}-py${PYTHON_VERSION}.zip")
endif()
if(WHL_FILEPATH)
get_filename_component(WHL_FILENAME "${WHL_FILEPATH}" NAME)
file(COPY "${WHL_FILEPATH}" DESTINATION "${INSTALL_DIR}")
file(RENAME "${INSTALL_DIR}/${WHL_FILENAME}" "${INSTALL_DIR}/${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}-py${PYTHON_VERSION_NO_DOT}-none-${PLATFORM_TAG_UNDERSCORED}.whl")
endif()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment