Commit 161e055c authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Build linphone python installer.

parent a0ed770c
......@@ -89,6 +89,7 @@ set(EP_cunit_LINKING_TYPE "-DENABLE_STATIC=YES")
set(EP_gsm_LINKING_TYPE "-DENABLE_STATIC=YES")
# linphone
set(EP_linphone_GIT_TAG "dev_python")
if(MSVC)
set(EP_linphone_LINKING_TYPE "-DENABLE_STATIC=YES")
else()
......@@ -118,6 +119,9 @@ endif()
# polarssl
set(EP_polarssl_LINKING_TYPE "-DUSE_SHARED_POLARSSL_LIBRARY=NO")
# speex
set(EP_speex_LINKING_TYPE "-DENABLE_STATIC=YES")
# srtp
set(EP_srtp_LINKING_TYPE "-DENABLE_STATIC=YES")
......@@ -129,3 +133,15 @@ set(EP_vpx_LINKING_TYPE "--enable-static" "--disable-shared" "--enable-pic")
# xml2
set(EP_xml2_LINKING_TYPE "--enable-static" "--disable-shared" "--with-pic")
# Python module
linphone_builder_expand_external_project_vars()
ExternalProject_Add(TARGET_pylinphone
DEPENDS TARGET_linphone
DOWNLOAD_COMMAND ""
PATCH_COMMAND "${CMAKE_COMMAND}" "-E" "copy_directory" "${CMAKE_CURRENT_LIST_DIR}/python" "<SOURCE_DIR>"
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS ${LINPHONE_BUILDER_EP_ARGS}
INSTALL_COMMAND ""
)
############################################################################
# CMakeLists.txt
# 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.
#
############################################################################
cmake_minimum_required(VERSION 2.8.12)
project(PYLINPHONE C) # Dummy project
find_package(PythonInterp REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_PREFIX_PATH}/share/cmake/Modules)
find_package(Linphone REQUIRED)
message("LINPHONE_LIBRARIES: ${LINPHONE_LIBRARIES}")
message("LINPHONE_INCLUDE_DIRS: ${LINPHONE_INCLUDE_DIRS}")
set(LINPHONE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../EP_linphone")
# Find the doxygen XML directory
file(GLOB XML_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/linphone-*/xml")
# Generate the API in XML format from the doxygen XML files
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/api.xml"
DEPENDS ${XML_FILES}
COMMAND ${PYTHON_EXECUTABLE} "${LINPHONE_SOURCE_DIR}/tools/genapixml.py" "--pretty" "--outputfile" "${CMAKE_CURRENT_BINARY_DIR}/api.xml" "${XML_DIR}"
)
# Generate the Python wrapper source code for the API in XML format
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/linphone.c"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/api.xml"
COMMAND ${PYTHON_EXECUTABLE} "${LINPHONE_SOURCE_DIR}/tools/python/apixml2python.py" "--outputfile" "${CMAKE_CURRENT_BINARY_DIR}/linphone.c" "${CMAKE_CURRENT_BINARY_DIR}/api.xml"
WORKING_DIRECTORY "${LINPHONE_SOURCE_DIR}/tools/python"
)
# Generate setup.py file that will be used to generate the package
if(WIN32)
list(APPEND LINPHONE_CPPFLAGS "-DWIN32")
list(APPEND LINPHONE_LIBRARIES gcc mingwex)
file(GLOB LINPHONE_DYNAMIC_LIBRARIES "${CMAKE_INSTALL_PREFIX}/bin/*.dll")
endif()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/linphone")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/linphone/__init__.py" "import linphone")
file(COPY ${LINPHONE_DYNAMIC_LIBRARIES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/linphone")
file(COPY "${CMAKE_INSTALL_PREFIX}/share/images" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/linphone/share/")
file(COPY "${CMAKE_INSTALL_PREFIX}/share/linphone" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/linphone/share/")
file(COPY "${CMAKE_INSTALL_PREFIX}/share/sounds" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/linphone/share/")
file(GLOB_RECURSE LINPHONE_DATA_FILES RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/linphone" "${CMAKE_CURRENT_BINARY_DIR}/linphone/*")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/setup.py.cmake" "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
# Generate the installer
#set(ENV{VS90COMNTOOLS} "$ENV{VS110COMNTOOLS}")
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/linphone.exe"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linphone.c"
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/setup.py" "bdist_wininst"
)
add_custom_target(custom_pylinphone ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linphone.exe")
#!/usr/bin/python
# Copyright (C) 2014 Belledonne Communications SARL
#
# 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.
import os
import string
from distutils.core import setup, Extension
macros = "@LINPHONE_CPPFLAGS@"
include_dirs = "@LINPHONE_INCLUDE_DIRS@"
libraries = "@LINPHONE_LIBRARIES@"
data_files = "@LINPHONE_DATA_FILES@"
define_macros = []
macros = macros.split(';')
for macro in macros:
if macro.startswith('-D'):
macro = macro[2:]
define_macros.append((macro, None))
include_dirs = list(set(include_dirs.split(';')))
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]
data_files = data_files.split(';')
ext = Extension('linphone',
define_macros = define_macros,
include_dirs = include_dirs,
libraries = libraries,
library_dirs = library_dirs,
sources = ['linphone.c']
)
setup(name = 'linphone',
version = '1.0',
description = 'Linphone package for Python',
author = "Belledonne Communications",
url = "http://www.linphone.org/",
packages = ['linphone'],
ext_package = 'linphone',
ext_modules = [ext],
package_data = {'linphone': data_files}
)
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