Commit 79684bad authored by François Grisez's avatar François Grisez

C++ wrapper: build scripts reworking

parent efeab2d4
set(GENERATED_SOURCES
src/account_creator.cc
src/address.cc
src/auth_info.cc
src/buffer.cc
src/call.cc
src/call_log.cc
src/call_params.cc
src/call_stats.cc
src/chat_message.cc
src/chat_room.cc
src/conference.cc
src/conference_params.cc
src/config.cc
src/content.cc
src/core.cc
src/core_v_table.cc
src/error_info.cc
src/event.cc
src/factory.cc
src/friend.cc
src/friend_list.cc
src/nat_policy.cc
src/payload_type.cc
src/player.cc
src/presence_activity.cc
src/presence_model.cc
src/presence_note.cc
src/presence_person.cc
src/presence_service.cc
src/proxy_config.cc
src/sip_transports.cc
src/tunnel.cc
src/tunnel_config.cc
src/vcard.cc
src/video_policy.cc
src/xml_rpc_request.cc
src/xml_rpc_session.cc
)
set(SOURCES
${GENERATED_SOURCES}
object.cc
)
set(GENERATED_HEADERS
${CMAKE_CURRENT_BINARY_DIR}/include/account_creator.hh
${CMAKE_CURRENT_BINARY_DIR}/include/account_creator_listener.hh
${CMAKE_CURRENT_BINARY_DIR}/include/address.hh
${CMAKE_CURRENT_BINARY_DIR}/include/auth_info.hh
${CMAKE_CURRENT_BINARY_DIR}/include/buffer.hh
${CMAKE_CURRENT_BINARY_DIR}/include/call.hh
${CMAKE_CURRENT_BINARY_DIR}/include/call_log.hh
${CMAKE_CURRENT_BINARY_DIR}/include/call_params.hh
${CMAKE_CURRENT_BINARY_DIR}/include/call_stats.hh
${CMAKE_CURRENT_BINARY_DIR}/include/chat_message.hh
${CMAKE_CURRENT_BINARY_DIR}/include/chat_message_listener.hh
${CMAKE_CURRENT_BINARY_DIR}/include/chat_room.hh
${CMAKE_CURRENT_BINARY_DIR}/include/conference.hh
${CMAKE_CURRENT_BINARY_DIR}/include/conference_params.hh
${CMAKE_CURRENT_BINARY_DIR}/include/config.hh
${CMAKE_CURRENT_BINARY_DIR}/include/content.hh
${CMAKE_CURRENT_BINARY_DIR}/include/core.hh
${CMAKE_CURRENT_BINARY_DIR}/include/core_listener.hh
${CMAKE_CURRENT_BINARY_DIR}/include/core_v_table.hh
${CMAKE_CURRENT_BINARY_DIR}/include/enums.hh
${CMAKE_CURRENT_BINARY_DIR}/include/error_info.hh
${CMAKE_CURRENT_BINARY_DIR}/include/event.hh
${CMAKE_CURRENT_BINARY_DIR}/include/factory.hh
${CMAKE_CURRENT_BINARY_DIR}/include/friend.hh
${CMAKE_CURRENT_BINARY_DIR}/include/friend_list.hh
${CMAKE_CURRENT_BINARY_DIR}/include/friend_list_listener.hh
${CMAKE_CURRENT_BINARY_DIR}/include/linphone.hh
${CMAKE_CURRENT_BINARY_DIR}/include/nat_policy.hh
${CMAKE_CURRENT_BINARY_DIR}/include/payload_type.hh
${CMAKE_CURRENT_BINARY_DIR}/include/player.hh
${CMAKE_CURRENT_BINARY_DIR}/include/presence_activity.hh
${CMAKE_CURRENT_BINARY_DIR}/include/presence_model.hh
${CMAKE_CURRENT_BINARY_DIR}/include/presence_note.hh
${CMAKE_CURRENT_BINARY_DIR}/include/presence_person.hh
${CMAKE_CURRENT_BINARY_DIR}/include/presence_service.hh
${CMAKE_CURRENT_BINARY_DIR}/include/proxy_config.hh
${CMAKE_CURRENT_BINARY_DIR}/include/sip_transports.hh
${CMAKE_CURRENT_BINARY_DIR}/include/tunnel_config.hh
${CMAKE_CURRENT_BINARY_DIR}/include/tunnel.hh
${CMAKE_CURRENT_BINARY_DIR}/include/vcard.hh
${CMAKE_CURRENT_BINARY_DIR}/include/video_policy.hh
${CMAKE_CURRENT_BINARY_DIR}/include/xml_rpc_request.hh
${CMAKE_CURRENT_BINARY_DIR}/include/xml_rpc_request_listener.hh
${CMAKE_CURRENT_BINARY_DIR}/include/xml_rpc_session.hh
)
set(HEADERS
${GENERATED_HEADERS}
object.hh
)
configure_file(c_make_lists.mustache.in c_make_lists.mustache @ONLY)
configure_file(object.cc src/object.cc COPYONLY)
configure_file(object.hh include/object.hh COPYONLY)
add_custom_command(OUTPUT ${GENERATED_SOURCES} ${GENERATED_HEADERS}
add_custom_command(OUTPUT CMakeLists.txt include/linphone.hh
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/genheaders.py" "${PROJECT_BINARY_DIR}/coreapi/help/doc/xml"
DEPENDS *.py *.mustache linphone-doc "${PROJECT_BINARY_DIR}/coreapi/help/doc/xml/index.xml"
)
add_compile_options(-Wall -Wextra -Wno-deprecated-declarations -Wno-unused-parameter -Werror --std=c++11)
add_definitions(-DWRAPPER_BUILD)
add_library(linphone++ SHARED ${SOURCES})
target_link_libraries(linphone++ PRIVATE linphone)
target_include_directories(linphone++
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${PROJECT_SOURCE_DIR}
)
set_target_properties(linphone++
PROPERTIES SOVERSION ${LINPHONE_SO_VERSION}
)
install(TARGETS linphone++
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/linphone++
DEPENDS *.py *.mustache linphone-doc
"${PROJECT_BINARY_DIR}/coreapi/help/doc/xml/index.xml"
"${CMAKE_CURRENT_BINARY_DIR}/c_make_lists.mustache"
)
add_custom_target(make_cpp_wrapper ALL ${CMAKE_COMMAND} -E make_directory build/
COMMAND ${CMAKE_COMMAND} -E chdir build/ ${CMAKE_COMMAND} .. -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
COMMAND ${CMAKE_COMMAND} --build build/
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.txt
${CMAKE_CURRENT_BINARY_DIR}/include/linphone.hh
)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/build --target install)")
cmake_minimum_required(VERSION 3.0)
include(GNUInstallDirs)
set(GENERATED_SOURCES
{{#classes}}
src/{{{source}}}
{{/classes}}
)
set(SOURCES
${GENERATED_SOURCES}
src/object.cc
)
set(GENERATED_HEADERS
{{#classes}}
${CMAKE_CURRENT_SOURCE_DIR}/include/{{{header}}}
{{/classes}}
)
set(HEADERS
${GENERATED_HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/include/object.hh
)
add_library(linphone++ SHARED ${SOURCES})
target_link_libraries(linphone++ PRIVATE @PROJECT_BINARY_DIR@/coreapi/liblinphone.so.@LINPHONE_SO_VERSION@)
target_include_directories(linphone++
PUBLIC include
PRIVATE @PROJECT_SOURCE_DIR@/include
)
set_target_properties(linphone++
PROPERTIES SOVERSION @LINPHONE_SO_VERSION@
)
install(TARGETS linphone++
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/linphone++
)
......@@ -611,6 +611,11 @@ class ClassImpl(object):
namespace = parsedClass.find_first_ancestor_by_type(AbsApi.Namespace)
self.namespace = namespace.name.concatenate(fullName=True) if namespace is not None else None
class CMakeLists(object):
def __init__(self):
self.classes = []
self.interfaces = []
def main():
argparser = argparse.ArgumentParser(description='Generate source files for the C++ wrapper')
......@@ -631,26 +636,6 @@ def main():
parser = AbsApi.CParser(project)
parser.parse_all()
translator = CppTranslator()
#translator.ignore += ['linphone_tunnel_get_http_proxy',
#'linphone_core_can_we_add_call',
#'linphone_core_get_default_proxy',
#'linphone_core_add_listener',
#'linphone_core_remove_listener',
#'linphone_core_get_current_callbacks',
#'linphone_proxy_config_normalize_number',
#'linphone_proxy_config_set_file_transfer_server',
#'linphone_proxy_config_get_file_transfer_server',
#'linphone_factory_create_core',
#'linphone_factory_create_core_with_config',
#'linphone_buffer_get_content',
#'linphone_chat_room_send_chat_message',
#'linphone_config_read_relative_file',
#'linphone_core_new_with_config',
#'LinphoneImEncryptionEngine',
#'LinphoneImEncryptionEngineCbs',
#'LinphoneImNotifPolicy',
#'LpConfig']
renderer = pystache.Renderer()
header = EnumsHeader(translator)
......@@ -664,13 +649,23 @@ def main():
f.write(renderer.render(header))
mainHeader = MainHeader()
cmakelists = CMakeLists()
for _class in parser.classesIndex.values() + parser.interfacesIndex.values():
if _class is not None:
try:
header = ClassHeader(_class, translator, ignore=['LinphoneBuffer'])
impl = ClassImpl(_class, header._class)
mainHeader.add_include(_class.name.to_snake_case() + '.hh')
headerName = _class.name.to_snake_case() + '.hh'
sourceName = _class.name.to_snake_case() + '.cc'
mainHeader.add_include(headerName)
if type(_class) is AbsApi.Class:
cmakelists.classes.append({'header': headerName, 'source': sourceName})
else:
cmakelists.interfaces.append({'header': headerName})
with open(args.outputdir + '/include/' + header.filename, mode='w') as f:
f.write(renderer.render(header))
......@@ -683,6 +678,9 @@ def main():
with open(args.outputdir + '/include/linphone.hh', mode='w') as f:
f.write(renderer.render(mainHeader))
with open(args.outputdir + '/CMakeLists.txt', mode='w') as f:
f.write(renderer.render(cmakelists))
if __name__ == '__main__':
......
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