Commit 791a988c authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Build the Python wrapper on Linux.

parent 5e57f294
......@@ -27,53 +27,24 @@ else()
set(EP_linphone_GIT_TAG "eca15bf8c07daa2391ddda055ca6d08bc443c51d")
endif()
set(EP_linphone_CMAKE_OPTIONS )
set(EP_linphone_LINKING_TYPE "-DENABLE_STATIC=NO")
set(EP_linphone_DEPENDENCIES EP_bellesip EP_ortp EP_ms2 EP_xml2)
if(ENABLE_VIDEO)
list(APPEND EP_linphone_CMAKE_OPTIONS "-DENABLE_VIDEO=YES")
else()
list(APPEND EP_linphone_CMAKE_OPTIONS "-DENABLE_VIDEO=NO")
endif()
if(ENABLE_TUNNEL)
list(APPEND EP_linphone_CMAKE_OPTIONS "-DENABLE_TUNNEL=YES")
else()
list(APPEND EP_linphone_CMAKE_OPTIONS "-DENABLE_TUNNEL=NO")
endif()
if(ENABLE_UNIT_TESTS)
list(APPEND EP_linphone_CMAKE_OPTIONS "-DENABLE_UNIT_TESTS=YES")
else()
list(APPEND EP_linphone_CMAKE_OPTIONS "-DENABLE_UNIT_TESTS=NO")
endif()
if(MSVC)
# Use temporary CMake build scripts for Windows. TODO: Port fully to CMake.
set(EP_linphone_DEPENDENCIES EP_bellesip EP_ortp EP_ms2 EP_xml2)
set(EP_linphone_EXTRA_LDFLAGS "/SAFESEH:NO")
else()
set(EP_linphone_BUILD_METHOD "autotools")
set(EP_linphone_USE_AUTOGEN "yes")
set(EP_linphone_CROSS_COMPILATION_OPTIONS
"--prefix=${CMAKE_INSTALL_PREFIX}"
"--host=${LINPHONE_BUILDER_HOST}"
)
set(EP_linphone_CONFIGURE_OPTIONS
"--disable-strict"
"--enable-bellesip"
"--enable-external-ortp"
"--enable-external-mediastreamer"
)
set(EP_linphone_LINKING_TYPE "--disable-static" "--enable-shared")
set(EP_linphone_DEPENDENCIES EP_bellesip EP_ortp EP_ms2 EP_xml2)
if(${ENABLE_SPEEX})
list(APPEND EP_linphone_CONFIGURE_OPTIONS "--enable-speex")
else(${ENABLE_SPEEX})
list(APPEND EP_linphone_CONFIGURE_OPTIONS "--disable-speex")
endif(${ENABLE_SPEEX})
if(${ENABLE_VIDEO})
list(APPEND EP_linphone_CONFIGURE_OPTIONS "--enable-video")
else(${ENABLE_VIDEO})
list(APPEND EP_linphone_CONFIGURE_OPTIONS "--disable-video")
endif(${ENABLE_VIDEO})
if(${ENABLE_ZRTP})
list(APPEND EP_linphone_CONFIGURE_OPTIONS "--enable-zrtp")
else(${ENABLE_ZRTP})
list(APPEND EP_linphone_CONFIGURE_OPTIONS "--disable-zrtp")
endif(${ENABLE_ZRTP})
if(${ENABLE_TUNNEL})
list(APPEND EP_linphone_CONFIGURE_OPTIONS "--enable-tunnel")
list(APPEND EP_linphone_DEPENDENCIES EP_tunnel)
else(${ENABLE_TUNNEL})
list(APPEND EP_linphone_CONFIGURE_OPTIONS "--disable-tunnel")
endif(${ENABLE_TUNNEL})
if(${ENABLE_UNIT_TESTS})
list(APPEND EP_linphone_DEPENDENCIES EP_cunit)
else(${ENABLE_UNIT_TESTS})
list(APPEND EP_linphone_CONFIGURE_OPTIONS "--disable-tests")
endif(${ENABLE_UNIT_TESTS})
endif()
......@@ -24,109 +24,52 @@ set(EP_ms2_GIT_REPOSITORY "git://git.linphone.org/mediastreamer2.git")
if(LINPHONE_BUILDER_LATEST)
set(EP_ms2_GIT_TAG "master")
else()
set(EP_ms2_GIT_TAG "974f7ae2c810a4662d4c1b6a644ee9d0be31e894")
set(EP_ms2_GIT_TAG "4b28ead656e4da10579425d435adbf9d985da755")
endif()
if(MSVC)
set(EP_ms2_CMAKE_OPTIONS )
set(EP_ms2_LINKING_TYPE "-DENABLE_STATIC=NO")
set(EP_ms2_DEPENDENCIES EP_ortp)
if(ENABLE_GSM)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_GSM=YES")
list(APPEND EP_ms2_DEPENDENCIES EP_gsm)
else()
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_GSM=NO")
endif()
if(ENABLE_OPUS)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_OPUS=YES")
list(APPEND EP_ms2_DEPENDENCIES EP_opus)
else()
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_OPUS=NO")
endif()
if(ENABLE_SPEEX)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_SPEEX=YES")
list(APPEND EP_ms2_DEPENDENCIES EP_speex)
else()
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_SPEEX=NO")
endif()
if(ENABLE_VIDEO)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_VIDEO=YES")
if(ENABLE_FFMPEG)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_FFMPEG=YES")
list(APPEND EP_ms2_DEPENDENCIES EP_ffmpeg)
else()
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_FFMPEG=NO")
endif()
if(ENABLE_VPX)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_VPX=YES")
list(APPEND EP_ms2_DEPENDENCIES EP_vpx)
else()
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_VPX=NO")
endif()
else()
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_VIDEO=NO")
endif()
set(EP_ms2_EXTRA_LDFLAGS "/SAFESEH:NO")
set(EP_ms2_CMAKE_OPTIONS )
set(EP_ms2_LINKING_TYPE "-DENABLE_STATIC=NO")
set(EP_ms2_DEPENDENCIES EP_ortp)
if(ENABLE_GSM)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_GSM=YES")
list(APPEND EP_ms2_DEPENDENCIES EP_gsm)
else()
set(EP_ms2_BUILD_METHOD "autotools")
set(EP_ms2_USE_AUTOGEN "yes")
set(EP_ms2_CONFIG_H_FILE mediastreamer-config.h)
set(EP_ms2_CROSS_COMPILATION_OPTIONS
"--prefix=${CMAKE_INSTALL_PREFIX}"
"--host=${LINPHONE_BUILDER_HOST}"
)
set(EP_ms2_CONFIGURE_OPTIONS
"--disable-strict"
"--enable-external-ortp"
"--disable-theora"
)
set(EP_ms2_LINKING_TYPE "--disable-static" "--enable-shared")
set(EP_ms2_DEPENDENCIES EP_ortp)
if(ENABLE_GSM)
list(APPEND EP_ms2_CONFIGURE_OPTIONS "--with-gsm=${CMAKE_INSTALL_PREFIX}")
list(APPEND EP_ms2_DEPENDENCIES EP_gsm)
else()
list(APPEND EP_ms2_CONFIGURE_OPTIONS "--disable-gsm")
endif()
if(ENABLE_OPUS)
list(APPEND EP_ms2_DEPENDENCIES EP_opus)
else()
list(APPEND EP_ms2_CONFIGURE_OPTIONS "--disable-opus")
endif()
if(ENABLE_SPEEX)
list(APPEND EP_ms2_DEPENDENCIES EP_speex)
else()
list(APPEND EP_ms2_CONFIGURE_OPTIONS "--disable-speex")
endif()
if(ENABLE_VIDEO)
list(APPEND EP_ms2_CONFIGURE_OPTIONS "--enable-video")
else()
list(APPEND EP_ms2_CONFIGURE_OPTIONS "--disable-video")
endif()
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_GSM=NO")
endif()
if(ENABLE_OPUS)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_OPUS=YES")
list(APPEND EP_ms2_DEPENDENCIES EP_opus)
else()
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_OPUS=NO")
endif()
if(ENABLE_SPEEX)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_SPEEX=YES")
list(APPEND EP_ms2_DEPENDENCIES EP_speex)
else()
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_SPEEX=NO")
endif()
if(ENABLE_VIDEO)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_VIDEO=YES")
if(ENABLE_FFMPEG)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_FFMPEG=YES")
list(APPEND EP_ms2_DEPENDENCIES EP_ffmpeg)
else()
list(APPEND EP_ms2_CONFIGURE_OPTIONS "--disable-ffmpeg")
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_FFMPEG=NO")
endif()
if(ENABLE_VPX)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_VPX=YES")
list(APPEND EP_ms2_DEPENDENCIES EP_vpx)
else()
list(APPEND EP_ms2_CONFIGURE_OPTIONS "--disable-vp8")
endif()
if("${BUILD_V4L}" STREQUAL "yes")
list(APPEND EP_ms2_DEPENDENCIES EP_v4l)
endif()
if(ENABLE_UNIT_TESTS)
list(APPEND EP_ms2_DEPENDENCIES EP_cunit)
else()
list(APPEND EP_ms2_CONFIGURE_OPTIONS "--disable-tests")
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_VPX=NO")
endif()
else()
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_VIDEO=NO")
endif()
if(ENABLE_UNIT_TESTS)
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_UNIT_TESTS=YES")
else()
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_UNIT_TESTS=NO")
endif()
if(MSVC)
set(EP_ms2_EXTRA_LDFLAGS "/SAFESEH:NO")
endif()
......@@ -24,51 +24,24 @@ set(EP_ortp_GIT_REPOSITORY "git://git.linphone.org/ortp.git")
if(LINPHONE_BUILDER_LATEST)
set(EP_ortp_GIT_TAG "master")
else()
set(EP_ortp_GIT_TAG "b7c9040fec9d3ac7383dff4a3022bbc6d62335d2")
set(EP_ortp_GIT_TAG "49fc68957126d1126be1eb0fcaaa6153480e93e4")
endif()
set(EP_ortp_CMAKE_OPTIONS )
set(EP_ortp_LINKING_TYPE "-DENABLE_STATIC=0")
set(EP_ortp_DEPENDENCIES )
if(ENABLE_SRTP)
list(APPEND EP_ortp_CMAKE_OPTIONS "-DENABLE_SRTP=1")
list(APPEND EP_ortp_DEPENDENCIES EP_srtp)
else()
list(APPEND EP_ortp_CMAKE_OPTIONS "-DENABLE_SRTP=0")
endif()
if(ENABLE_ZRTP)
list(APPEND EP_ortp_CMAKE_OPTIONS "-DENABLE_ZRTP=1")
list(APPEND EP_ortp_DEPENDENCIES EP_bzrtp)
else()
list(APPEND EP_ortp_CMAKE_OPTIONS "-DENABLE_ZRTP=0")
endif()
if(MSVC)
set(EP_ortp_CMAKE_OPTIONS )
set(EP_ortp_LINKING_TYPE "-DENABLE_STATIC=0")
set(EP_ortp_DEPENDENCIES )
if(ENABLE_SRTP)
list(APPEND EP_ortp_CMAKE_OPTIONS "-DENABLE_SRTP=1")
list(APPEND EP_ortp_DEPENDENCIES EP_srtp)
else()
list(APPEND EP_ortp_CMAKE_OPTIONS "-DENABLE_SRTP=0")
endif()
if(ENABLE_ZRTP)
list(APPEND EP_ortp_CMAKE_OPTIONS "-DENABLE_ZRTP=1")
list(APPEND EP_ortp_DEPENDENCIES EP_bzrtp)
else()
list(APPEND EP_ortp_CMAKE_OPTIONS "-DENABLE_ZRTP=0")
endif()
set(EP_ortp_EXTRA_LDFLAGS "/SAFESEH:NO")
else()
set(EP_ortp_BUILD_METHOD "autotools")
set(EP_ortp_USE_AUTOGEN "yes")
set(EP_ortp_CONFIG_H_FILE ortp-config.h)
set(EP_ortp_CROSS_COMPILATION_OPTIONS
"--prefix=${CMAKE_INSTALL_PREFIX}"
"--host=${LINPHONE_BUILDER_HOST}"
)
set(EP_ortp_CONFIGURE_OPTIONS
"--disable-strict"
)
set(EP_ortp_LINKING_TYPE "--disable-static" "--enable-shared")
set(EP_ortp_DEPENDENCIES )
if(ENABLE_SRTP)
list(APPEND EP_ortp_CONFIGURE_OPTIONS "--with-srtp=${CMAKE_INSTALL_PREFIX}")
list(APPEND EP_ortp_DEPENDENCIES EP_srtp)
else()
list(APPEND EP_ortp_CONFIGURE_OPTIONS "--with-srtp=none")
endif()
if(ENABLE_ZRTP)
list(APPEND EP_ortp_DEPENDENCIES EP_bzrtp)
list(APPEND EP_ortp_CONFIGURE_OPTIONS "--enable-zrtp")
else()
list(APPEND EP_ortp_CONFIGURE_OPTIONS "--disable-zrtp")
endif()
endif()
......@@ -37,6 +37,8 @@ set(EP_xml2_CONFIGURE_OPTIONS
"--with-reader"
"--with-writer"
"--with-sax1"
"--without-lzma"
"--without-zlib"
"--enable-rebuild-docs=no"
)
set(EP_xml2_LINKING_TYPE "--disable-static" "--enable-shared")
......
......@@ -62,6 +62,7 @@ if (UNIX)
set(LINPHONE_BUILDER_LDFLAGS "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} -arch ${CMAKE_OSX_ARCHITECTURES}")
else()
set(BUILD_V4L "yes")
set(LINPHONE_BUILDER_LDFLAGS "-Wl,-Bsymbolic -fPIC")
endif()
endif()
if(WIN32)
......@@ -85,24 +86,19 @@ set(EP_bzrtp_LINKING_TYPE "-DENABLE_STATIC=YES")
# cunit
set(EP_cunit_LINKING_TYPE "-DENABLE_STATIC=YES")
# ffmpeg
set(EP_ffmpeg_LINKING_TYPE "--disable-static" "--enable-shared")
# gsm
set(EP_gsm_LINKING_TYPE "-DENABLE_STATIC=YES")
# linphone
if(MSVC)
set(EP_linphone_LINKING_TYPE "-DENABLE_STATIC=YES")
list(APPEND EP_linphone_CMAKE_OPTIONS "-DENABLE_RELATIVE_PREFIX=YES")
else()
set(EP_linphone_LINKING_TYPE "--enable-static" "--disable-shared")
endif()
set(EP_linphone_LINKING_TYPE "-DENABLE_STATIC=YES")
list(APPEND EP_linphone_CMAKE_OPTIONS "-DENABLE_RELATIVE_PREFIX=YES")
# ms2
if(MSVC)
set(EP_ms2_LINKING_TYPE "-DENABLE_STATIC=YES")
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_RELATIVE_PREFIX=YES")
else()
set(EP_ms2_LINKING_TYPE "--enable-static" "--disable-shared")
endif()
set(EP_ms2_LINKING_TYPE "-DENABLE_STATIC=YES")
list(APPEND EP_ms2_CMAKE_OPTIONS "-DENABLE_RELATIVE_PREFIX=YES")
# opus
if(NOT MSVC)
......@@ -111,11 +107,7 @@ if(NOT MSVC)
endif()
# ortp
if(MSVC)
set(EP_ortp_LINKING_TYPE "-DENABLE_STATIC=YES")
else()
set(EP_ortp_LINKING_TYPE "--enable-static" "--disable-shared")
endif()
set(EP_ortp_LINKING_TYPE "-DENABLE_STATIC=YES")
# polarssl
set(EP_polarssl_LINKING_TYPE "-DUSE_SHARED_POLARSSL_LIBRARY=NO")
......
......@@ -23,6 +23,12 @@
cmake_minimum_required(VERSION 2.8.12)
project(PYLINPHONE C) # Dummy project
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PLATFORM_ARCH_NAME "x86_64")
else()
set(PLATFORM_ARCH_NAME "i386")
endif()
find_package(PythonInterp REQUIRED)
find_package(Git)
......@@ -76,14 +82,19 @@ add_custom_target(pylinphone_source
)
# Generate setup.py file that will be used to generate the package
set(_BUILDS )
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
list(APPEND _BUILDS "debug")
endif()
if(WIN32)
list(APPEND LINPHONE_CPPFLAGS "-DWIN32")
list(APPEND LINPHONE_LIBRARIES gcc mingwex)
file(GLOB LINPHONE_DYNAMIC_LIBRARIES "${CMAKE_INSTALL_PREFIX}/bin/*.dll")
list(APPEND _BUILDS "exe" "msi" "zip" "wheel")
endif()
set(_BUILDS "exe" "msi" "zip" "wheel")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
list(PREPEND _BUILDS "debug")
if(UNIX AND NOT APPLE)
file(GLOB LINPHONE_DYNAMIC_LIBRARIES "${CMAKE_INSTALL_PREFIX}/lib/*.so*")
list(APPEND _BUILDS "zip" "wheel")
endif()
foreach(_BUILD ${_BUILDS})
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_${_BUILD}/linphone/linphone")
......@@ -108,15 +119,9 @@ foreach(_BUILD ${_BUILDS})
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/setup.py.cmake" "${CMAKE_CURRENT_BINARY_DIR}/build_${_BUILD}/linphone/setup.py")
endforeach()
if(MSVC)
if(NOT "${MSVC_VERSION}" STREQUAL "9")
set(ENV{VS90COMNTOOLS} "$ENV{VS${MSVC_VERSION}0COMNTOOLS}")
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
add_custom_target(pylinphone_debug ALL
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/setup.py" "build" "--debug"
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/build_debug/linphone/setup.py" "build" "--debug"
DEPENDS pylinphone_source
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_debug/linphone"
)
......@@ -124,6 +129,8 @@ else()
add_custom_target(pylinphone_debug ALL DEPENDS pylinphone_source)
endif()
if(WIN32)
# Generate the installer
set(EXE_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/build_exe/linphone/dist/linphone-${LINPHONE_GIT_REVISION}.win32-py${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.exe")
add_custom_target(pylinphone_exe ALL
......@@ -160,4 +167,28 @@ add_custom_target(pylinphone_wheel ALL
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone"
)
install(FILES ${WHEEL_FILENAME} DESTINATION ".")
endif()
if(UNIX)
# Generate the zip
set(ZIP_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/build_zip/linphone/dist/linphone-${LINPHONE_GIT_REVISION}.linux-${PLATFORM_ARCH_NAME}.zip")
add_custom_target(pylinphone_zip ALL
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/build_zip/linphone/setup.py" "bdist" "--format=zip"
DEPENDS pylinphone_debug
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_zip/linphone"
)
install(FILES ${ZIP_FILENAME} DESTINATION "." RENAME "linphone-${LINPHONE_GIT_REVISION}.linux-${PLATFORM_ARCH_NAME}-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/linphone-${LINPHONE_UNDERSCORE_GIT_REVISION}-cp27-none-linux_${PLATFORM_ARCH_NAME}.whl")
add_custom_target(pylinphone_wheel ALL
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone/setup.py" "bdist_wheel"
DEPENDS pylinphone_zip
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone"
)
install(FILES ${WHEEL_FILENAME} DESTINATION ".")
endif()
......@@ -18,6 +18,7 @@
import os
import string
import sys
from setuptools import setup, Extension
version = "@BUILD_VERSION@"
......@@ -37,7 +38,20 @@ libraries = libraries.split(';')
library_dirs = [os.path.dirname(item) for item in libraries if os.path.dirname(item) != '']
library_dirs = list(set(library_dirs))
libraries = [os.path.basename(item) for item in libraries]
libraries = [string.replace(item, '.lib', '') for item in libraries]
extra_link_args = []
if sys.platform.startswith("win32"):
libraries = [string.replace(item, '.lib', '') for item in libraries]
else:
libraries = [item[3:] for item in libraries]
static_libraries = [item for item in libraries if item.endswith('.a')]
dynamic_libraries = [item for item in libraries if '.so' in item]
static_libraries = [string.replace(item, '.a', '') for item in static_libraries]
dynamic_libraries = [string.replace(item, '.so', '') for item in dynamic_libraries]
extra_link_args.append("-Wl,--start-group")
extra_link_args += ['-l' + item for item in static_libraries]
extra_link_args.append("-Wl,--end-group")
extra_link_args.append("-Wl,-rpath=$ORIGIN")
libraries = dynamic_libraries
data_files = data_files.split(';')
ext = Extension('linphone',
......@@ -45,6 +59,7 @@ ext = Extension('linphone',
include_dirs = include_dirs,
libraries = libraries,
library_dirs = library_dirs,
extra_link_args = extra_link_args,
sources = ['@SOURCE_FILENAME@']
)
setup(name = 'linphone',
......
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