10 Commits

Author SHA1 Message Date
9e5a5970a3 Improved PIBlockingDeque constructors
- resolve creation from constant (see test construct_from_constant_is_max_size_eq_capacity)
- add tests for constructors
2020-08-11 12:30:28 +03:00
46d93c6c9f Improved PIBlockingDeque behaviour and unit tests for put, offer, take methods
- Methods put, offer, take begins working with move and copy semantics
- Mocking queue condition variables with GMock in Unit tests
- Rewrite part of unit tests
2020-08-07 19:12:09 +03:00
662a2fc464 Refactor PIBlockingDequeue 2020-08-07 10:10:05 +03:00
194389ef6d Refactor templates & submit doc 2020-08-06 13:23:49 +03:00
3cfdda7365 PIThreadPoolExecutor & PIBlockingDequeue improvements
- add support move & copy semantic
- introduce submit method for executor with future result
2020-08-05 22:59:33 +03:00
3ec1ecfb5b refactor concurrent module code 2020-08-04 16:39:08 +03:00
be51728570 Merge remote-tracking branch 'origin/master' into concurrent 2020-08-03 17:48:36 +03:00
41e54e5859 Merge pip2 2020-08-03 17:47:19 +03:00
badaa01deb Merge remote-tracking branch 'origin/master' into concurrent
# Conflicts:
#	lib/main/thread/pithreadpoolexecutor.cpp
#	lib/main/thread/pithreadpoolexecutor.h
#	tests/concurrent/ExecutorIntegrationTest.cpp
#	tests/concurrent/ExecutorUnitTest.cpp
#	tests/concurrent/testutil.h
2020-08-03 10:18:52 +03:00
8efd2cf447 Rewrite executor to template & come back executor unit tests 2020-07-17 18:36:28 +03:00
281 changed files with 4507 additions and 8399 deletions

1
.gitignore vendored
View File

@@ -2,4 +2,3 @@
/.svn /.svn
/doc/rtf /doc/rtf
_unsused _unsused
CMakeLists.txt.user*

View File

@@ -1,36 +1,46 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(pip) project(pip)
set(pip_MAJOR 2) set(_PIP_MAJOR 1)
set(pip_MINOR 9) set(_PIP_MINOR 99)
set(pip_REVISION 1) set(_PIP_REVISION 3)
set(pip_SUFFIX ) set(_PIP_SUFFIX _prebeta)
set(pip_COMPANY SHS) set(_PIP_COMPANY SHS)
set(pip_DOMAIN org.SHS) set(_PIP_DOMAIN org.SHS)
if ("x${CMAKE_MODULE_PATH}" STREQUAL "x") if ("x${CMAKE_MODULE_PATH}" STREQUAL "x")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
endif() endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(PIP_BUILD 1)
include(CheckFunctionExists) include(CheckFunctionExists)
include(GenerateExportHeader)
include(DeployMacros)
include(PIPMacros) include(PIPMacros)
include(SHSTKMacros) if(NOT DEFINED BUILD_NUMBER)
set(BUILD_NUMBER 9999)
shstk_begin_project(pip PIP) endif()
if("x${BUILD_NUMBER}" STREQUAL "x")
set(BUILD_NUMBER 0)
endif()
set(_ICU_DEFAULT OFF) set(_ICU_DEFAULT OFF)
if((NOT DEFINED WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT DEFINED APPLE)) if((NOT DEFINED WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT DEFINED APPLE))
set(_ICU_DEFAULT ON) set(_ICU_DEFAULT ON)
endif() endif()
set(PIP_DLL_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING "")
# Options # Options
option(ICU "ICU support for convert codepages" ${_ICU_DEFAULT}) option(ICU "ICU support for convert codepages" ${_ICU_DEFAULT})
option(STD_IOSTREAM "Building with std iostream operators support" OFF) option(STD_IOSTREAM "Building with std iostream operators support" OFF)
option(INTROSPECTION "Build with introspection" OFF) option(INTROSPECTION "Build with introspection" OFF)
option(LIB "System install" ON)
option(STATIC_LIB OFF)
option(TESTS "Build tests and perform their before install step" OFF) option(TESTS "Build tests and perform their before install step" OFF)
set(PIP_UTILS 1) set(PIP_UTILS 1)
if(LIBPROJECT)
set(PIP_UTILS ${UTILS})
endif()
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
@@ -56,13 +66,11 @@ macro(pip_module NAME LIBS LABEL INCLUDES MSG)
set(HS) set(HS)
set(PHS) set(PHS)
set(CRES) set(CRES)
file(GLOB_RECURSE CPPS "libs/${NAME}/*.cpp") file(GLOB_RECURSE CPPS "lib/${NAME}/*.cpp")
file(GLOB_RECURSE HS "libs/${NAME}/*.h") file(GLOB_RECURSE HS "lib/${NAME}/*.h")
file(GLOB_RECURSE PHS "libs/${NAME}/*_p.h") file(GLOB_RECURSE PHS "lib/${NAME}/*_p.h")
file(GLOB_RECURSE RES "libs/${NAME}/*.conf") file(GLOB_RECURSE RES "lib/${NAME}/*conf.h")
if (NOT "x${PHS}" STREQUAL "x") list(REMOVE_ITEM HS "${PHS}")
list(REMOVE_ITEM HS ${PHS})
endif()
list(APPEND HDRS ${HS}) list(APPEND HDRS ${HS})
list(APPEND PHDRS ${PHS}) list(APPEND PHDRS ${PHS})
@@ -76,11 +84,11 @@ macro(pip_module NAME LIBS LABEL INCLUDES MSG)
string(TOUPPER "${_target}" DEF_NAME) string(TOUPPER "${_target}" DEF_NAME)
set(PIP_MSG_${NAME} "yes${MSG}") set(PIP_MSG_${NAME} "yes${MSG}")
import_version(${_target} pip) import_version(${_target} PIP)
set_deploy_property(${_target} ${pip_LIB_TYPE} set_deploy_property(${_target} ${PIP_LIB_TYPE}
LABEL "${LABEL}" LABEL "${LABEL}"
FULLNAME "${pip_DOMAIN}.${_target}" FULLNAME "${_PIP_DOMAIN}.${_target}"
COMPANY "${pip_COMPANY}" COMPANY "${_PIP_COMPANY}"
INFO "Platform-Independent Primitives") INFO "Platform-Independent Primitives")
make_rc(${_target} _RC) make_rc(${_target} _RC)
@@ -93,22 +101,23 @@ macro(pip_module NAME LIBS LABEL INCLUDES MSG)
endif() endif()
endforeach() endforeach()
if (NOT "x${RES}" STREQUAL "x") if (NOT "${RES}" STREQUAL "")
pip_resources(CRES "${RES}") pip_resources(CRES "${RES}")
endif() endif()
add_definitions(-D${DEF_NAME}) add_definitions(-D${DEF_NAME})
add_library(${_target} ${pip_LIB_TYPE} ${CPPS} ${CRES} ${_RC}) add_library(${_target} ${PIP_LIB_TYPE} ${CPPS} ${CRES} ${_RC})
target_include_directories(${_target} PUBLIC ${PIP_INCLUDES}) if (NOT "${RES}" STREQUAL "")
if (NOT "x${RES}" STREQUAL "x")
add_dependencies(${_target} pip_rc) add_dependencies(${_target} pip_rc)
endif() endif()
if (NOT "x${INCLUDES}" STREQUAL "x") if (NOT "${INCLUDES}" STREQUAL "")
target_include_directories(${_target} PRIVATE ${INCLUDES}) target_include_directories(${_target} PRIVATE ${INCLUDES})
endif() endif()
generate_export_header(${_target})
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/${_target}_export.h")
list(APPEND PIP_EXPORTS "${DEF_NAME}_EXPORT") list(APPEND PIP_EXPORTS "${DEF_NAME}_EXPORT")
target_link_libraries(${_target} ${LINK_LIBS}) target_link_libraries(${_target} ${LINK_LIBS})
list(APPEND PIP_MODULES ${_target}) list(APPEND PIP_MODULES ${_target})
if (NOT "x${LIBS}" STREQUAL "x") if (NOT "${LIBS}" STREQUAL "")
list(APPEND LIBS_STATUS ${LIBS}) list(APPEND LIBS_STATUS ${LIBS})
endif() endif()
endmacro() endmacro()
@@ -125,10 +134,63 @@ if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
set(STATIC_LIB ON) set(STATIC_LIB ON)
endif() endif()
if(STATIC_LIB)
set(PIP_LIB_TYPE STATIC)
set(PIP_LIB_TYPE_MSG "Static")
add_definitions(-DPIP_STATIC_DEFINE)
else()
set(PIP_LIB_TYPE SHARED)
set(PIP_LIB_TYPE_MSG "Shared")
endif()
# Version # Version
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_version.h") set_version(PIP
MAJOR "${_PIP_MAJOR}"
MINOR "${_PIP_MINOR}"
REVISION "${_PIP_REVISION}"
BUILD "${BUILD_NUMBER}"
SUFFIX "${_PIP_SUFFIX}"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/piversion.h")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h")
file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h")
endif()
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/piversion.h")
if(MINGW)
find_package(MinGW REQUIRED)
list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB})
else()
if(APPLE)
if(CMAKE_CROSSCOMPILING)
set(CMAKE_INSTALL_NAME_DIR "@rpath")
else()
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
endif()
set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/lib;@loader_path/../lib")
set(CMAKE_MACOSX_RPATH 1)
else()
set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib")
endif()
endif()
if(LIB)
if(WIN32)
if(MINGW)
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
endif()
else()
if (DEFINED ANDROID_PLATFORM)
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
else()
if(CMAKE_CROSSCOMPILING)
set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX})
else()
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local)
endif()
endif()
endif()
endif()
if (NOT DEFINED PIP_CMG) if (NOT DEFINED PIP_CMG)
if (CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM)) if (CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM))
@@ -148,15 +210,18 @@ get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
# Main lib # Main lib
file(GLOB PIP_FOLDERS LIST_DIRECTORIES TRUE "${CMAKE_CURRENT_SOURCE_DIR}/libs/main/*") file(GLOB PIP_FOLDERS LIST_DIRECTORIES TRUE "${CMAKE_CURRENT_SOURCE_DIR}/lib/main/*")
list(APPEND PIP_FOLDERS "${CMAKE_CURRENT_SOURCE_DIR}/libs/main") list(APPEND PIP_FOLDERS "${CMAKE_CURRENT_SOURCE_DIR}/lib/main")
set(PIP_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}") set(PIP_MAIN_FOLDERS)
foreach(F ${PIP_FOLDERS}) foreach(F ${PIP_FOLDERS})
if (IS_DIRECTORY "${F}") if (IS_DIRECTORY "${F}")
list(APPEND PIP_INCLUDES "${F}") list(APPEND PIP_MAIN_FOLDERS "${F}")
#include_directories("${F}") include_directories("${F}")
endif() endif()
endforeach(F) endforeach(F)
if (DEFINED LIBPROJECT)
set(PIP_MAIN_FOLDERS "${PIP_MAIN_FOLDERS}" PARENT_SCOPE)
endif()
if (TESTS) if (TESTS)
set(PIP_ROOT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") set(PIP_ROOT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
@@ -166,7 +231,7 @@ endif()
if(PIP_FREERTOS) if(PIP_FREERTOS)
add_definitions(-DPIP_FREERTOS) add_definitions(-DPIP_FREERTOS)
set(ICU OFF) set(ICU OFF)
set(LOCAL ON) set(LIB OFF)
endif() endif()
# Check Bessel functions # Check Bessel functions
@@ -302,6 +367,7 @@ else()
pip_find_lib(${LIB_}) pip_find_lib(${LIB_})
endforeach() endforeach()
endif() endif()
import_version(pip PIP)
if(WIN32) if(WIN32)
add_definitions(-DPSAPI_VERSION=1) add_definitions(-DPSAPI_VERSION=1)
if(${C_COMPILER} STREQUAL "cl.exe") if(${C_COMPILER} STREQUAL "cl.exe")
@@ -318,15 +384,6 @@ set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
pip_module(main "${LIBS_MAIN}" "PIP main library" "" "") pip_module(main "${LIBS_MAIN}" "PIP main library" "" "")
generate_export_header(pip)
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
foreach(_m ${PIP_SRC_MODULES})
set_target_properties(pip PROPERTIES DEFINE_SYMBOL pip_${_m}_EXPORTS)
generate_export_header(pip BASE_NAME "pip_${_m}")
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_${_m}_export.h")
endforeach()
set_target_properties(pip PROPERTIES DEFINE_SYMBOL pip_EXPORTS)
if (NOT CROSSTOOLS) if (NOT CROSSTOOLS)
if (NOT PIP_FREERTOS) if (NOT PIP_FREERTOS)
@@ -405,11 +462,7 @@ if (NOT CROSSTOOLS)
if(${CMAKE_VERSION} VERSION_LESS "3.7.0") if(${CMAKE_VERSION} VERSION_LESS "3.7.0")
target_link_libraries(_opencl_lib OpenCL) target_link_libraries(_opencl_lib OpenCL)
endif() endif()
set(_opencl_inc "${OpenCL_INCLUDE_DIRS}") pip_module(opencl "${_opencl_lib}" "PIP OpenCL support" "" " (${OpenCL_VERSION_STRING})")
if(APPLE)
set(_opencl_inc "${OpenCL_INCLUDE_DIRS}/Headers")
endif()
pip_module(opencl "${_opencl_lib}" "PIP OpenCL support" "${_opencl_inc}" " (${OpenCL_VERSION_STRING})")
endif() endif()
@@ -426,15 +479,15 @@ if (NOT CROSSTOOLS)
endif() endif()
find_package(Lua QUIET) find_package(Lua QUIET)
if (LUA_FOUND) if (LUA_FOUND)
pip_module(lua "LUA" "PIP Lua support" "${LUA_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd" " (${LUA_VERSION_STRING})") pip_module(lua "LUA" "PIP Lua support" "${LUA_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/3rd" " (${LUA_VERSION_STRING})")
list(APPEND HDR_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd/LuaBridge") list(APPEND HDR_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/3rd/LuaBridge")
endif() endif()
# Test program # Test program
if(PIP_UTILS) if(PIP_UTILS)
add_executable(pip_test "main.cpp") add_executable(pip_test "main.cpp")
target_link_libraries(pip_test pip pip_cloud) target_link_libraries(pip_test pip)
if (LUA_FOUND) if (LUA_FOUND)
target_link_libraries(pip_test pip_lua ${LUA_LIBRARIES}) target_link_libraries(pip_test pip_lua ${LUA_LIBRARIES})
endif() endif()
@@ -446,16 +499,16 @@ if (NOT CROSSTOOLS)
set(PIP_MSG_compress "yes") set(PIP_MSG_compress "yes")
set(PIP_MODULES pip) set(PIP_MODULES pip)
add_definitions(-DPIP_CRYPT) add_definitions(-DPIP_CRYPT)
add_library(pip_crypt ${pip_LIB_TYPE} ${CPP_LIB_CRYPT}) add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT})
target_link_libraries(pip_crypt pip) target_link_libraries(pip_crypt pip)
list(APPEND PIP_MODULES pip_crypt) list(APPEND PIP_MODULES pip_crypt)
set(IO_UTILS_LIBS pip) set(IO_UTILS_LIBS pip)
add_library(pip_io_utils ${pip_LIB_TYPE} ${CPP_LIB_IO_UTILS}) add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS})
list(APPEND IO_UTILS_LIBS pip_crypt) list(APPEND IO_UTILS_LIBS pip_crypt)
target_link_libraries(pip_io_utils ${IO_UTILS_LIBS}) target_link_libraries(pip_io_utils ${IO_UTILS_LIBS})
list(APPEND PIP_MODULES pip_io_utils) list(APPEND PIP_MODULES pip_io_utils)
add_definitions(-DPIP_COMPRESS) add_definitions(-DPIP_COMPRESS)
add_library(pip_compress ${pip_LIB_TYPE} ${CPP_LIB_COMPRESS}) add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS})
target_link_libraries(pip_compress pip) target_link_libraries(pip_compress pip)
list(APPEND PIP_MODULES pip_compress) list(APPEND PIP_MODULES pip_compress)
@@ -467,10 +520,11 @@ target_compile_definitions(pip PRIVATE "PICODE_DEFINES=\"${PIP_EXPORTS_STR}\"")
# Install # Install
# Check if system or local install will be used (to system install use "-DLIB=" argument of cmake) # Check if system or local install will be used (to system install use "-DLIB=" argument of cmake)
if(NOT LOCAL) if(LIB)
if(WIN32) if(WIN32)
if(MINGW) if(MINGW)
if (NOT CROSSTOOLS) if (NOT CROSSTOOLS)
install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip)
install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip) install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip)
if(HDR_DIRS) if(HDR_DIRS)
install(DIRECTORY ${HDR_DIRS} DESTINATION ${MINGW_INCLUDE}/pip) install(DIRECTORY ${HDR_DIRS} DESTINATION ${MINGW_INCLUDE}/pip)
@@ -498,6 +552,8 @@ if(NOT LOCAL)
endif() endif()
install(TARGETS ${PIP_MODULES} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) install(TARGETS ${PIP_MODULES} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif() endif()
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore")
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
else() else()
if(NOT PIP_FREERTOS) if(NOT PIP_FREERTOS)
if(WIN32) if(WIN32)
@@ -512,8 +568,6 @@ else()
endif() endif()
endif() endif()
endif() endif()
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in")
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
if(NOT PIP_FREERTOS) if(NOT PIP_FREERTOS)
@@ -539,9 +593,11 @@ if(NOT PIP_FREERTOS)
endif() endif()
shstk_is_parent_exists(_pe) # Libraries messages
if (_pe) if(DEFINED LIBPROJECT)
set(PIP_MODULES ${PIP_MODULES} PARENT_SCOPE) set(PIP_MODULES ${PIP_MODULES} PARENT_SCOPE)
list(APPEND _ALL_TARGETS ${PIP_MODULES})
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
endif() endif()
# #
@@ -551,12 +607,12 @@ if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
include(PIPDocumentation) include(PIPDocumentation)
find_package(Doxygen) find_package(Doxygen)
if(DOXYGEN_FOUND) if(DOXYGEN_FOUND)
set(DOXY_PROJECT_NUMBER "${pip_VERSION}") set(DOXY_PROJECT_NUMBER "${PIP_VERSION}")
set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${pip_VERSION}\"") set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"")
set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${pip_VERSION}\"") set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"")
set(DOXY_EXAMPLE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/examples\"") set(DOXY_EXAMPLE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/examples\"")
set(DOXY_IMAGE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/images\"") set(DOXY_IMAGE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/doc/images\"")
set(DOXY_EXCLUDE "\"${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd\"") set(DOXY_EXCLUDE "\"${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/3rd\"")
if(DOXYGEN_DOT_EXECUTABLE) if(DOXYGEN_DOT_EXECUTABLE)
string(REPLACE "\\" "" _DOT_PATH "${DOXYGEN_DOT_PATH}") string(REPLACE "\\" "" _DOT_PATH "${DOXYGEN_DOT_PATH}")
set(DOXY_DOT_PATH "\"${_DOT_PATH}\"") set(DOXY_DOT_PATH "\"${_DOT_PATH}\"")
@@ -567,7 +623,7 @@ if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
foreach(F ${PIP_MAIN_FOLDERS}) foreach(F ${PIP_MAIN_FOLDERS})
list(APPEND DOXY_INPUT "\"${F}\"") list(APPEND DOXY_INPUT "\"${F}\"")
endforeach(F) endforeach(F)
string(REPLACE ";" " " DOXY_INPUT "\"${CMAKE_CURRENT_SOURCE_DIR}/libs\"") string(REPLACE ";" " " DOXY_INPUT "\"${CMAKE_CURRENT_SOURCE_DIR}/lib\"")
string(REPLACE ";" " " DOXY_INCLUDE_PATH "${DOXY_INPUT}") string(REPLACE ";" " " DOXY_INCLUDE_PATH "${DOXY_INPUT}")
string(REPLACE ";" " " DOXY_DEFINES "${PIP_EXPORTS};DOXYGEN;PIOBJECT;PIOBJECT_SUBCLASS") string(REPLACE ";" " " DOXY_DEFINES "${PIP_EXPORTS};DOXYGEN;PIOBJECT;PIOBJECT_SUBCLASS")
add_documentation(doc doc/Doxyfile.in) add_documentation(doc doc/Doxyfile.in)
@@ -576,30 +632,13 @@ if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
endif() endif()
set(_max_len 0)
foreach(_m ${PIP_SRC_MODULES})
string(LENGTH "${_m}" _clen)
if (_clen GREATER _max_len)
set(_max_len ${_clen})
endif()
endforeach()
macro(expand_to_length _out _str _len)
set(${_out} "${_str}")
while(TRUE)
string(LENGTH "${${_out}}" _clen)
if (_clen GREATER_EQUAL ${_len})
break()
endif()
string(APPEND ${_out} " ")
endwhile()
endmacro()
list(REMOVE_ITEM LIBS_STATUS ${PIP_MODULES}) list(REMOVE_ITEM LIBS_STATUS ${PIP_MODULES})
message("----------PIP----------") message("----------PIP----------")
message(" Version: ${pip_VERSION} ") message(" Version: ${PIP_VERSION} ")
message(" Linkage: ${pip_LIB_TYPE_MSG}") message(" Linkage: ${PIP_LIB_TYPE_MSG}")
message(" Type : ${pip_BUILD_TYPE}") message(" Type : ${PIP_BUILD_TYPE}")
if (NOT LOCAL) if(LIB)
message(" Install: \"${CMAKE_INSTALL_PREFIX}\"") message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
else() else()
if(NOT PIP_FREERTOS) if(NOT PIP_FREERTOS)
@@ -618,8 +657,7 @@ endif()
message("") message("")
message(" Modules:") message(" Modules:")
foreach(_m ${PIP_SRC_MODULES}) foreach(_m ${PIP_SRC_MODULES})
expand_to_length(_m_e "${_m}" ${_max_len}) message(" ${_m}: ${PIP_MSG_${_m}}")
message(" ${_m_e}: ${PIP_MSG_${_m}}")
endforeach() endforeach()
message("") message("")
if (PIP_TESTS_LIST) if (PIP_TESTS_LIST)

1068
cmake/DeployMacros.cmake Normal file
View File

@@ -0,0 +1,1068 @@
#[[
Important! You should include this file
in your top-level CMakeLists.txt
set_version(<target> [MAJOR <value>] [MINOR <value>] [REVISION <value>] [SUFFIX <value>] [BUILD <value>] [OUTPUT <file>])
Set target version, optionally creates file
Create variable <target>_VERSION with full version name
If OUTPUT then generate header <file> with
version macros - <target>_VERSION_<NAME>
Also create macro <target>_VERSION_NAME with full string version
Attention: macro <target>_VERSION is byte-packed integer version!
set_lang(<target> <lang> [<lang> [...] ])
Set target translations, e.g. "ru" "fr"
import_version(<target> <source_target>)
Copy all version components and languages from <source_target>
import_deploy_properties(<target> <source_target>)
Copy all deploy properties from <source_target>
set_deploy_property(<target> [SHARED | STATIC] NAME <value> [NAME <value> [...] ])
Set target deploy property, where NAME one of:
* LABEL - application icon name
* FULLNAME - package name in format "*.*.*"
* COMPANY - company name
* ICON - icon file path
* INFO - additional info
Specify SHARED or STATIC if your target is library
You can setup several properties in one command
make_rc(<target> <rc_out_file>)
Generate Windows *.rc file from deploy properties
and return file path to <rc_out_file>
On other platforms this variable set to empty
You should set version and deploy properties
before call this macro, see
"set_version()" and "set_deploy_property()"
deploy_target(<target> [DEPLOY_DIR <dir>]
[DESTINATION <dir>]
[RESOURCES <dir|file> [<dir|file> ...] ]
[PLUGINS <dir|file> [<dir|file> ...] ]
[FILES <dir|file> [<dir|file> ...] ]
[LIBS <dir|file> [<dir|file> ...] ]
[OPTIONS <flag> ...]
[VERBOSE]
[DMG_NO_ZIP]
[DEB_USR_DIR] [DEB_ADD_SERVICE])
Create make target "deploy_<target>", depends on target "deploy".
On this target create release package, containing all dependencies:
* .zip on Windows
* .deb on Linux
* .dmg[.zip] on MacOS
* .apk/.aab on Android
If not defined DMG_NO_ZIP then *.dmg.zip will be created on MacOS.
You should set version and deploy properties
before call this macro, see
"set_version()" and "set_deploy_property()".
Example:
deploy_target(my_app DESTINATION packages)
DEPLOY_DIR - dir where you install
* executable on Windows, Linux
* <T>.app directory with executable on MacOS
DESTINATION - dir where macro place package
RESOURCES, PLUGINS and FILES - list of directories and files, copied to:
| | Windows | Linux | Linux (DEB_USR_DIR) | MacOS |
|-----------|---------|-------------------------|---------------------------|---------------------|
| RESOURCES | root | /opt/COMPANY/target | /usr/share/COMPANY/target | Contents/Resources |
| PLUGINS | root | /opt/COMPANY/target | /usr/lib/COMPANY/target | Contents/PlugIns |
| FILES | root | /opt/COMPANY/target | /usr/bin | Contents/MacOS |
| LIBS | root | /opt/COMPANY/target/lib | /usr/lib | Contents/Frameworks |
Relative paths are taken from DEPLOY_DIR
Also check library dependencies from PLUGINS and FILES
Important! RESOURCES, PLUGINS, FILES and LIBS lists check
at cmake-time, so if entry ends with "/" it treat
as directory, else - file
This macro using "deploy_tool" from PIP,
so make sure it can be executed from shell
OPTIONS allow you to pass custom flags to "deploy_tool"
You can see flags by launch "deploy_tool" without arguments
Using CMAKE_LDD, CMAKE_OTOOL or CMAKE_OBJDUMP variable,
depends on target platform
DEPLOY_ADD_LIBPATH variable used as additional
library search path
If DEB_ADD_SERVICE then <T>-service.deb package will be created.
This package use contents of CMAKE_CURRENT_SOURCE_DIR/debian-service directory:
* CMAKE_CURRENT_SOURCE_DIR/debian-service/DEBIAN/
* CMAKE_CURRENT_SOURCE_DIR/debian-service/*.service
.service file placed in /opt/COMPANY/target, you should copy it to system with script
You can use "postinst,postrm,preinst,prerm,config" files to configure service
]]
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
if (POLICY CMP0057)
cmake_policy(SET CMP0057 NEW) # Support if() IN_LIST
endif()
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
endif()
set(__prop_names "LABEL;FULLNAME;COMPANY;ICON;INFO")
list(APPEND __prop_names "ANDROID_TARGET_SDK;ANDROID_STORE_FILE;ANDROID_STORE_PASSWORD;ANDROID_KEY_PASSWORD;ANDROID_KEY_ALIAS;ANDROID_NEW_LOADER")
set(__version_names "MAJOR;MINOR;REVISION;BUILD;SUFFIX")
include(TargetArch)
if (NOT MY_ARCH)
target_architecture(MY_ARCH)
endif()
if (NOT _dep_exists)
set(_dep_exists 1)
add_custom_target(deploy COMMENT "Deploy")
endif()
set(_modules_dir "${CMAKE_ROOT}/Modules")
if (LIBPROJECT)
set(_modules_dir ${PIP_CMAKE_MODULE_PATH})
endif()
set(_dt_delim "::")
macro(set_version _T)
set(_VERSION_ 1) # macro version
set(_name)
set(_is_name 1)
set(_is_out 0)
set(_out)
foreach(_i ${ARGN})
if (_is_out)
set(_is_out 0)
set(_out "${_i}")
elseif ("x${_i}" STREQUAL "xOUTPUT")
set(_is_out 1)
elseif(_is_name)
set(_is_name 0)
if (_i IN_LIST __version_names)
else()
message(FATAL_ERROR "Invalid version component \"${_i}\"!")
endif()
set(_name ${_i})
else()
set(_is_name 1)
set(${_T}_VERSION_${_name} ${_i})
endif()
endforeach()
set(${_T}_VERSION_FULLSUFFIX "${${_T}_VERSION_SUFFIX}")
if (NOT ("x${${_T}_VERSION_FULLSUFFIX}" STREQUAL "x"))
if(NOT ("${${_T}_VERSION_FULLSUFFIX}" MATCHES "_.*"))
set(${_T}_VERSION_FULLSUFFIX "_${${_T}_VERSION_FULLSUFFIX}")
endif()
endif()
if ("x${${_T}_VERSION_MAJOR}" STREQUAL "x")
set(${_T}_VERSION_MAJOR "0")
endif()
if ("x${${_T}_VERSION_MINOR}" STREQUAL "x")
set(${_T}_VERSION_MINOR "0")
endif()
if ("x${${_T}_VERSION_REVISION}" STREQUAL "x")
set(${_T}_VERSION_REVISION "0")
endif()
if ("x${${_T}_VERSION_BUILD}" STREQUAL "x")
set(${_T}_VERSION_BUILD "0")
endif()
set(${_T}_VERSION "${${_T}_VERSION_MAJOR}.${${_T}_VERSION_MINOR}.${${_T}_VERSION_REVISION}${${_T}_VERSION_FULLSUFFIX}")
set(_${_T}_VERSION_WB "${${_T}_VERSION}-${${_T}_VERSION_BUILD}")
if (_out)
set(_${_T}_VERSION_CHANGED 0)
if ((NOT _${_T}_CACHED_VERSION) OR (NOT ("x${_${_T}_CACHED_VERSION}" STREQUAL "x${_${_T}_VERSION_WB}")))
set(_${_T}_CACHED_VERSION "${_${_T}_VERSION_WB}" CACHE STRING "" FORCE)
set(_${_T}_VERSION_CHANGED 1)
endif()
if ((NOT _${_T}_CACHED_VERSION_VER) OR (NOT ("x${_${_T}_CACHED_VERSION_VER}" STREQUAL "x${_VERSION_}")))
set(_${_T}_CACHED_VERSION_VER "${_VERSION_}" CACHE STRING "" FORCE)
set(_${_T}_VERSION_CHANGED 1)
endif()
if ((NOT EXISTS "${_out}") OR _${_T}_VERSION_CHANGED)
get_filename_component(_def "${_out}" NAME)
string(MAKE_C_IDENTIFIER "${_T}_${_def}" _def)
string(TOUPPER "${_def}" _def)
string(TOUPPER "${_T}" _TN)
string(TIMESTAMP _cur_date "%d.%m.%Y %H:%M")
file(WRITE "${_out}"
"// This file generated by CMake set_version() version ${_VERSION_}
#ifndef ${_def}
#define ${_def}
// Project
#define ${_TN}_VERSION_MAJOR ${${_T}_VERSION_MAJOR}
#define ${_TN}_VERSION_MINOR ${${_T}_VERSION_MINOR}
#define ${_TN}_VERSION_REVISION ${${_T}_VERSION_REVISION}
#define ${_TN}_VERSION_BUILD ${${_T}_VERSION_BUILD}
#define ${_TN}_VERSION_SUFFIX \"${${_T}_VERSION_SUFFIX}\"
#define ${_TN}_VERSION_NAME \"${${_T}_VERSION}\"
#define ${_TN}_VERSION ((${_TN}_VERSION_MAJOR << 16) | (${_TN}_VERSION_MINOR << 8) | ${_TN}_VERSION_REVISION)
// Tools
#define ${_TN}_CMAKE_VERSION \"${CMAKE_VERSION}\"
#define ${_TN}_CXX_COMPILER \"${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}\"
#define ${_TN}_BUILD_DATE \"${_cur_date}\"
#define ${_TN}_ARCH \"${MY_ARCH}\"
#endif // ${_def}
")
endif()
endif()
endmacro()
macro(set_lang _T)
set(${_T}_LANG)
foreach(_i ${ARGN})
list(APPEND ${_T}_LANG "${_i}")
endforeach()
endmacro()
macro(import_version _T _F)
set(_names "${__version_names};FULLSUFFIX")
foreach(_i ${_names})
set(${_T}_VERSION_${_i} "${${_F}_VERSION_${_i}}")
endforeach()
set(${_T}_VERSION "${${_F}_VERSION}")
set(${_T}_LANG "${${_F}_LANG}")
endmacro()
macro(import_deploy_properties _T _F)
foreach(_i ${__prop_names})
set(${_T}_${_i} "${${_F}_${_i}}")
endforeach()
endmacro()
macro(set_deploy_property _T)
set(_name)
set(_is_name 1)
foreach(_i ${ARGN})
if (("x${_i}" STREQUAL "xSHARED") OR ("x${_i}" STREQUAL "xSTATIC"))
set(${_T}_TYPE "${_i}")
elseif(_is_name)
set(_is_name 0)
if (_i IN_LIST __prop_names)
else()
message(FATAL_ERROR "Invalid property name \"${_i}\"!")
endif()
set(_name ${_i})
else()
set(_is_name 1)
set(${_T}_${_name} ${_i})
endif()
endforeach()
endmacro()
macro(make_rc _T _out)
if (WIN32)
if ("x${${_T}_VERSION_MAJOR}" STREQUAL "x")
message(FATAL_ERROR "Version for \"${_T}\" not set, use set_version()!")
endif()
string(REPLACE "\"" "\"\"" WINDOWS_RC_FULLNAME "${${_T}_FULLNAME}")
string(REPLACE "\"" "\"\"" WINDOWS_RC_VERSION "${${_T}_VERSION}" )
string(REPLACE "\"" "\"\"" WINDOWS_RC_LABEL "${${_T}_LABEL}" )
string(REPLACE "\"" "\"\"" WINDOWS_RC_COMPANY "${${_T}_COMPANY}" )
string(REPLACE "\"" "\"\"" WINDOWS_RC_INFO "${${_T}_INFO}" )
if (("x${${_T}_TYPE}" STREQUAL "x") OR ("x${${_T}_TYPE}" STREQUAL "xEXECUTABLE"))
set(WINDOWS_RC_FILETYPE "0x1L")
set(_rc_prefix "")
set(_rc_ext "exe")
elseif ("x${${_T}_TYPE}" STREQUAL "xSHARED")
set(WINDOWS_RC_FILETYPE "0x2L")
set(_rc_prefix "lib")
set(_rc_ext "dll")
elseif ("x${${_T}_TYPE}" STREQUAL "xSTATIC")
set(WINDOWS_RC_FILETYPE "0x7L")
set(_rc_prefix "lib")
set(_rc_ext "a")
endif()
set(_rc_version "${${_T}_VERSION_MAJOR},${${_T}_VERSION_MINOR},${${_T}_VERSION_REVISION},${${_T}_VERSION_BUILD}")
set(_icon)
if (NOT ("x${${_T}_ICON}" STREQUAL "x"))
get_filename_component(WINDOWS_RC_ICON "${${_T}_ICON}" REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(_icon "1 ICON \"${WINDOWS_RC_ICON}\"")
endif()
set(_rc_file "${CMAKE_CURRENT_BINARY_DIR}/${_T}_winres.rc")
file(WRITE "${_rc_file}"
"# if defined(UNDER_CE)
# include <winbase.h>
# else
# include <winver.h>
# endif
#pragma code_page(65001)
${_icon}
VS_VERSION_INFO VERSIONINFO
FILEVERSION ${_rc_version}
PRODUCTVERSION ${_rc_version}
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
FILETYPE ${WINDOWS_RC_FILETYPE}
FILESUBTYPE 0x0L
BEGIN
BLOCK \"StringFileInfo\"
BEGIN
BLOCK \"041904B0\"
BEGIN
VALUE \"Comments\", \"\\0\"
VALUE \"CompanyName\", \"${WINDOWS_RC_COMPANY}\\0\"
VALUE \"FileDescription\", \"${WINDOWS_RC_INFO}\\0\"
VALUE \"FileVersion\", \"${WINDOWS_RC_VERSION}\\0\"
VALUE \"InternalName\", \"${WINDOWS_RC_FULLNAME}\\0\"
VALUE \"LegalTrademarks\", \"\\0\"
VALUE \"LegalCopyright\", \"${WINDOWS_RC_COMPANY}\\0\"
VALUE \"OriginalFilename\", \"${_rc_prefix}${_T}.${_rc_ext}\\0\"
VALUE \"ProductName\", \"${WINDOWS_RC_LABEL}\\0\"
VALUE \"ProductVersion\", \"${WINDOWS_RC_VERSION}\\0\"
END
END
BLOCK \"VarFileInfo\"
BEGIN
VALUE \"Translation\", 0x0419, 0x04B0, 0x0409, 0x04B0
END
END
")
set(${_out} ${_rc_file})
else()
set(${_out})
endif()
endmacro()
# Help macros begin
macro(__add_file_or_dir _DIR_VAR _FILE_VAR _PATH _RELPATH)
set(_p)
set(_abs 0)
if (IS_ABSOLUTE "${_PATH}")
set(_abs 1)
endif()
if ("${_PATH}" MATCHES "^\$<")
set(_abs 1)
endif()
if (_abs)
set(_p "${_PATH}")
else()
set(_p "${_RELPATH}/${_PATH}")
endif()
if ("${_p}" MATCHES ".*/$")
string(LENGTH "${_p}" __sl)
math(EXPR __sl ${__sl}-1)
string(SUBSTRING "${_p}" 0 ${__sl} _p)
list(APPEND ${_DIR_VAR} "${_p}")
else()
list(APPEND ${_FILE_VAR} "${_p}")
endif()
endmacro()
set(__win_host 0)
set(__mac_host 0)
if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xWindows")
set(__win_host 1)
endif()
if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xDarwin")
set(__mac_host 1)
endif()
macro(__make_win_path _in_path _out_var _is_dir _out_dir)
set(_add "")
if (${_is_dir})
set(_add "/")
endif()
file(TO_NATIVE_PATH "${_in_path}" ${_out_var})
string(REPLACE "//" "/" ${_out_var} "${${_out_var}}${_add}")
if (NOT "x${_out_dir}" STREQUAL "x")
string(LENGTH "${${_out_var}}" __sl)
math(EXPR __sl ${__sl}-1)
string(SUBSTRING "${${_out_var}}" 0 ${__sl} __substr)
get_filename_component(${_out_dir} "${__substr}" NAME)
#message("dirname src=\"${${_out_var}}\", len=${__sl} \"${__substr}\" = \"${${_out_dir}}\"")
endif()
string(REPLACE "/" "\\" ${_out_var} "${${_out_var}}")
endmacro()
macro(__make_dir _cmd _dest)
if (__win_host)
__make_win_path("${_dest}" __d 1 "")
set(${_cmd} ${${_cmd}} COMMAND if not exist "\"${__d}\"" mkdir "\"${__d}\"")
else()
set(${_cmd} ${${_cmd}} COMMAND mkdir ${_VERB} -p "${_dest}")
endif()
endmacro()
macro(__make_copy _cmd _dirs _files _dest)
if (${_dirs} OR ${_files})
__make_dir(${_cmd} "${_dest}")
endif()
if (__win_host)
__make_win_path("${_dest}" _wdest 1 "")
foreach(_d ${${_dirs}})
__make_win_path("${_d}" _wsrc 1 _dirname)
__make_dir(${_cmd} "${_dest}/${_dirname}")
set(${_cmd} ${${_cmd}} COMMAND xcopy /y /r /e "${_wsrc}*" "\"${_wdest}${_dirname}\\\"" ${_WVERB})
endforeach()
foreach(_f ${${_files}})
__make_win_path("${_f}" _wsrc 0 "")
set(${_cmd} ${${_cmd}} COMMAND xcopy /y /r "\"${_wsrc}\"" "\"${_wdest}\"" ${_WVERB})
endforeach()
else()
foreach(_d ${${_dirs}})
set(${_cmd} ${${_cmd}} COMMAND cp ${_VERB} -rf "${_d}" "${_dest}/")
endforeach()
foreach(_f ${${_files}})
set(${_cmd} ${${_cmd}} COMMAND cp ${_VERB} -f "${_f}" "${_dest}/")
endforeach()
endif()
endmacro()
macro(__gather_deps _T _search_path_var _dep_libs_var _dep_libs_cs_var _added_)
get_target_property(_LL${_T} ${_T} LINK_LIBRARIES)
foreach (_L${_T} ${_LL${_T}})
if (TARGET ${_L${_T}})
get_target_property(_II${_T} ${_L${_T}} IMPORTED)
if (NOT _II${_T})
#message("depend on ${_L${_T}}")
get_target_property(_LT${_T} ${_L${_T}} TYPE)
if (("x${_LT${_T}}" STREQUAL "xSHARED_LIBRARY") OR ("x${_LT${_T}}" STREQUAL "xSTATIC_LIBRARY"))
if (NOT _L${_T} IN_LIST ${_added_})
list(APPEND ${_added_} ${_L${_T}})
__gather_deps(${_L${_T}} ${_search_path_var} ${_dep_libs_var} ${_dep_libs_cs_var} ${_added_})
if ("x${_LT${_T}}" STREQUAL "xSHARED_LIBRARY")
if (NOT DEFINED ANDROID_PLATFORM)
set(${_search_path_var} "${${_search_path_var}}${_dt_delim}$<TARGET_FILE_DIR:${_L${_T}}>")
endif()
set(${_dep_libs_cs_var} "${${_dep_libs_cs_var}}${_dt_delim}$<TARGET_FILE_DIR:${_L${_T}}>/$<TARGET_FILE_NAME:${_L${_T}}>")
set(${_dep_libs_var} "${${_dep_libs_var}}" "$<TARGET_FILE_DIR:${_L${_T}}>/$<TARGET_FILE_NAME:${_L${_T}}>")
endif()
endif()
endif()
endif()
endif()
endforeach()
endmacro()
set(__macos_privacy_text "Application request permission")
set(__macos_privacies
"<key>NFCReaderUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSAppleMusicUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSCalendarsUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSCameraUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSContactsUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSFaceIDUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSHealthShareUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSHealthUpdateUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSHomeKitUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSMicrophoneUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSMotionUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSRemindersUsageDescription</key>
<string>${__macos_privacy_text}</string>
<key>NSVideoSubscriberAccountUsageDescription</key>
<string>${__macos_privacy_text}</string>"
)
set(__gradle_lang_start
" defaultConfig {
resConfigs ")
set(__gradle_sign
" signingConfigs {
debug {
storeFile file(DEBUG_STORE_FILE)
}
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyPassword RELEASE_KEY_PASSWORD
keyAlias RELEASE_KEY_ALIAS
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
}
}")
# Help macros end
macro(deploy_target _T)
set(_DESTINATION "${CMAKE_INSTALL_PREFIX}")
set(_DEPLOY_DIR "${CMAKE_INSTALL_PREFIX}")
set(_RES_DIRS)
set(_RES_FILES)
set(_PLUG_DIRS)
set(_PLUG_FILES)
set(_FILE_DIRS)
set(_FILE_FILES)
set(_LIBS_DIRS)
set(_LIBS_FILES)
set(_VERB)
set(_WVERB 1> NUL)
set(_OPTIONS)
set(_ZIP_DMG 1)
set(_DEB_OPT 1)
set(_DEB_SERVICE 0)
set(_cur_arg)
set(__args "DESTINATION;DEPLOY_DIR;RESOURCES;PLUGINS;FILES;LIBS;OPTIONS;VERBOSE;DMG_NO_ZIP;DEB_USR_DIR;DEB_ADD_SERVICE")
foreach(_i ${ARGN})
if (_i IN_LIST __args)
set(_cur_arg "${_i}")
if ("${_cur_arg}" STREQUAL "VERBOSE")
set(_VERB -v)
set(_WVERB)
elseif("${_cur_arg}" STREQUAL "DMG_NO_ZIP")
set(_ZIP_DMG 0)
elseif("${_cur_arg}" STREQUAL "DEB_USR_DIR")
set(_DEB_OPT 0)
elseif("${_cur_arg}" STREQUAL "DEB_ADD_SERVICE")
set(_DEB_SERVICE 1)
endif()
elseif ("${_cur_arg}" STREQUAL "DESTINATION")
set(_cur_arg)
set(_DESTINATION "${_i}/")
elseif ("${_cur_arg}" STREQUAL "DEPLOY_DIR")
set(_cur_arg)
set(_DEPLOY_DIR "${_i}/")
elseif ("${_cur_arg}" STREQUAL "RESOURCES")
__add_file_or_dir(_RES_DIRS _RES_FILES "${_i}" "${_DEPLOY_DIR}")
elseif ("${_cur_arg}" STREQUAL "PLUGINS")
__add_file_or_dir(_PLUG_DIRS _PLUG_FILES "${_i}" "${_DEPLOY_DIR}")
elseif ("${_cur_arg}" STREQUAL "FILES")
__add_file_or_dir(_FILE_DIRS _FILE_FILES "${_i}" "${_DEPLOY_DIR}")
elseif ("${_cur_arg}" STREQUAL "LIBS")
__add_file_or_dir(_LIBS_DIRS _LIBS_FILES "${_i}" "${_DEPLOY_DIR}")
elseif ("${_cur_arg}" STREQUAL "OPTIONS")
list(APPEND _OPTIONS "${_i}")
endif()
#message("-i = ${_i}")
endforeach()
get_filename_component(_ICON_NAME "${${_T}_ICON}" NAME)
get_filename_component(_ICON_FN "${${_T}_ICON}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(_TV "${_T}_${${_T}_VERSION}")
set(_DEP_LIBPATH)
set(_DEP_LIBS_CS)
set(_DEP_LIBS)
set(_add_search_path)
set(_added_)
set(_ADD_DEPS ${_PLUG_DIRS} ${_PLUG_FILES} ${_FILE_DIRS} ${_FILE_FILES} ${_LIBS_DIRS} ${_LIBS_FILES})
__gather_deps(${_T} _add_search_path _DEP_LIBS _DEP_LIBS_CS _added_)
foreach (_L ${DEPLOY_ADD_LIBPATH})
set(_add_search_path "${_add_search_path}${_dt_delim}${_L}")
endforeach()
#message("app depend ${_T} libpath ${_add_search_path}")
set(_CMD_)
set(_deployed)
if ("x${CMAKE_SYSTEM_NAME}" STREQUAL "xLinux")
set(_os_id "")
set(_os_ver "")
set(_paths "/usr/lib" "/etc")
if (CMAKE_CROSSCOMPILING)
set(_paths "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/../etc")
endif()
find_file(_release_file NAMES os-release lsb-release PATHS ${_paths} NO_DEFAULT_PATH)
if (NOT "x${_release_file}" STREQUAL "x")
file(STRINGS "${_release_file}" _lines)
foreach(_l ${_lines})
if ("${_l}" MATCHES "VERSION_ID=.*")
string(SUBSTRING "${_l}" 11 -1 _os_ver)
string(REPLACE "\"" "" _os_ver "${_os_ver}")
#message("VERSION_ID ${_os_ver}")
elseif ("${_l}" MATCHES "ID=.*")
string(SUBSTRING "${_l}" 3 -1 _os_id)
string(REPLACE "\"" "" _os_id "${_os_id}")
#message("ID ${_os_id}")
endif()
endforeach()
endif()
set(_build "${${_T}_VERSION_BUILD}")
if (NOT "x${_build}" STREQUAL "x")
set(_build "-${_build}")
endif()
string(TOLOWER "${_os_id}${_os_ver}" _TARGET_OS)
if ("x${_TARGET_OS}" STREQUAL "x")
set(_TARGET_OS "linux")
endif()
string(REPLACE "_" "-" _DEBNAME "${_T}")
string(REPLACE "_" "-" _DEBVERSION "${${_T}_VERSION}${_build}+${_TARGET_OS}")
string(TOLOWER "${_DEBNAME}" _DEBNAME)
set(_DEB_ARCH)
if("_${MY_ARCH}" STREQUAL "_arm64")
set(_DEB_ARCH "arm64")
elseif("_${MY_ARCH}" STREQUAL "_armv7")
set(_DEB_ARCH "armhf")
elseif("_${MY_ARCH}" STREQUAL "_i386")
set(_DEB_ARCH "i386")
elseif("_${MY_ARCH}" STREQUAL "_x86_64")
set(_DEB_ARCH "amd64")
elseif("_${MY_ARCH}" STREQUAL "_ppc")
set(_DEB_ARCH "PowerPC")
elseif("_${MY_ARCH}" STREQUAL "_ppc64")
set(_DEB_ARCH "PPC64")
elseif("_${MY_ARCH}" STREQUAL "_ia64")
set(_DEB_ARCH "ia64")
endif()
set(_DEB "${_TV}_deb_${_DEB_ARCH}")
set(_AGD "${_DEPLOY_DIR}/${_DEB}")
set(_C_echof ">" "${_AGD}/DEBIAN/control")
set(_C_echo ">>" "${_AGD}/DEBIAN/control")
set(_D_echof ">" "${_AGD}/usr/share/applications/${_DEBNAME}.desktop")
set(_D_echo ">>" "${_AGD}/usr/share/applications/${_DEBNAME}.desktop")
set(_bin_path "${_AGD}/usr/bin")
set(_lib_path "${_AGD}/usr/lib")
set(_pli_path "${_AGD}/usr/lib/${${_T}_COMPANY}/${_T}")
set(_res_path "${_AGD}/usr/share/${${_T}_COMPANY}/${_T}")
set(_ico_path "${_AGD}/usr/share/pixmaps")
set(_app_bin_path "/usr/bin")
set(_app_ico_path "/usr/share/pixmaps")
if(_DEB_OPT)
set(_bin_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
set(_lib_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}/lib")
set(_pli_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
set(_res_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
set(_ico_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}/pixmaps")
set(_app_bin_path "/opt/${${_T}_COMPANY}/${_T}")
set(_app_ico_path "/opt/${${_T}_COMPANY}/${_T}/pixmaps")
endif()
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_bin_path}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_lib_path}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_pli_path}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_res_path}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_ico_path}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_AGD}/usr/share/applications")
__make_copy(_CMD_ _FILE_DIRS _FILE_FILES ${_bin_path})
__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES ${_pli_path})
__make_copy(_CMD_ _RES_DIRS _RES_FILES ${_res_path})
__make_copy(_CMD_ _LIBS_DIRS _LIBS_FILES ${_lib_path})
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_DEPLOY_DIR}/${_T}" "${_bin_path}/")
if (_DEP_LIBS)
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_DEP_LIBS}" "${_lib_path}/")
endif()
if (_ICON_NAME)
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_ICON_FN}" "${_ico_path}/")
endif()
if(_DEB_OPT)
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_AGD}/usr/bin")
set(_CMD_ ${_CMD_} COMMAND ln -srf ${_VERB} "${_bin_path}/${_T}" "${_AGD}/usr/bin/${_T}")
endif()
file(GLOB _files "${CMAKE_CURRENT_SOURCE_DIR}/debian/DEBIAN/*")
foreach (_f ${_files})
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_f}" "${_AGD}/DEBIAN/")
endforeach()
file(GLOB _files "${_AGD}/DEBIAN/p*inst" "${_AGD}/DEBIAN/p*rm" "${_AGD}/DEBIAN/config")
foreach (_f ${_files})
set(_CMD_ ${_CMD_} COMMAND chmod 0755 ${_VERB} "${_f}")
endforeach()
if (NOT CMAKE_LDD)
find_program(CMAKE_LDD ldd)
endif()
set(_dt_opts -l "${CMAKE_LDD}")
if (CMAKE_CROSSCOMPILING)
set(_dt_searchdirs "${CMAKE_PREFIX_PATH}/lib")
if (NOT "x${CMAKE_LIBRARY_ARCHITECTURE}" STREQUAL "x")
set(_dt_searchdirs "${_dt_searchdirs}${_dt_delim}${CMAKE_PREFIX_PATH}/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
set(_dt_searchdirs "${_dt_searchdirs}${_dt_delim}${CMAKE_PREFIX_PATH}/../lib/${CMAKE_LIBRARY_ARCHITECTURE}")
endif()
set(_dt_opts -L "${CMAKE_READELF}" --dpkg-workdir "${CMAKE_DPKG_WORKDIR}" -s "${_dt_searchdirs}")
endif()
set(_deb_name "${_TV}_${_TARGET_OS}_${_DEB_ARCH}.deb")
#message("VER = \"${_DEBVERSION}\"")
#message("DEB = \"${_deb_name}\"")
list(APPEND _CMD_ COMMAND echo "Package: ${_DEBNAME}" ${_C_echof})
list(APPEND _CMD_ COMMAND echo "Version: ${_DEBVERSION}" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Architecture: ${_DEB_ARCH}" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Maintainer: ${${_T}_COMPANY} <>" ${_C_echo})
list(APPEND _CMD_ COMMAND ${PIP_DEPLOY_TOOL} ${_OPTIONS} --prefix "Depends: " --dependencies ${_dt_opts} -a "${_DEP_LIBS_CS}" -o "${_lib_path}" ${_DEPLOY_DIR}/${_T} ${_ADD_DEPS} ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Conflicts:" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Replaces:" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Section: misc" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Priority: optional" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Description: ${${_T}_INFO}" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "[Desktop Entry]" ${_D_echof})
list(APPEND _CMD_ COMMAND echo "Encoding=UTF-8" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Type=Application" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Name=${${_T}_LABEL}" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "GenericName=${${_T}_LABEL}" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Comment=${${_T}_INFO}" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Exec=${_app_bin_path}/${_T}" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Icon=${_app_ico_path}/${_ICON_NAME}" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Terminal=false" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "StartupNotify=true" ${_D_echo})
list(APPEND _CMD_ COMMAND echo "Categories=Utility;" ${_D_echo})
add_custom_target(deploy_${_T}
# gather deb dir
COMMAND rm -rf ${_VERB} "${_AGD}"
COMMAND mkdir ${_VERB} -p "${_AGD}/DEBIAN"
${_CMD_}
# generate deb
COMMAND cd ${_AGD} "&&" md5deep -rl opt usr ">" DEBIAN/md5sums
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
COMMAND dpkg-deb -Z gzip -b ${_AGD} ${_DESTINATION}/${_deb_name}
VERBATIM
COMMENT "Generating ${_deb_name}"
)
set(_deployed "deploy_${_T}")
if (_DEB_SERVICE)
set(_CMD_)
set(_DEB "${_TV}-service_deb_${_DEB_ARCH}")
set(_AGD "${_DEPLOY_DIR}/${_DEB}")
set(_C_echof ">" "${_AGD}/DEBIAN/control")
set(_C_echo ">>" "${_AGD}/DEBIAN/control")
set(_opt_path "${_AGD}/opt/${${_T}_COMPANY}/${_T}")
set(_CMD_ ${_CMD_} COMMAND mkdir ${_VERB} -p "${_opt_path}")
file(GLOB _files "${CMAKE_CURRENT_SOURCE_DIR}/debian-service/*.service")
foreach (_f ${_files})
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_f}" "${_opt_path}/")
endforeach()
set(__deb_dir "${CMAKE_CURRENT_SOURCE_DIR}/debian-service/DEBIAN")
file(GLOB _files "${__deb_dir}/*")
foreach (_f ${_files})
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f "${_f}" "${_AGD}/DEBIAN/")
endforeach()
file(GLOB _files RELATIVE "${__deb_dir}" "${__deb_dir}/p*inst" "${__deb_dir}/p*rm" "${__deb_dir}/config")
foreach (_f ${_files})
set(_CMD_ ${_CMD_} COMMAND chmod 0755 ${_VERB} "${_AGD}/DEBIAN/${_f}")
endforeach()
set(_deb_name "${_TV}-service_${_TARGET_OS}_${_DEB_ARCH}.deb")
#message("VER = \"${_DEBVERSION}\"")
#message("DEB = \"${_deb_name}\"")
list(APPEND _CMD_ COMMAND echo "Package: ${_DEBNAME}-service" ${_C_echof})
list(APPEND _CMD_ COMMAND echo "Version: ${_DEBVERSION}" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Architecture: ${_DEB_ARCH}" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Maintainer: ${${_T}_COMPANY} <>" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Depends: ${_DEBNAME} (>= ${_DEBVERSION})" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Conflicts:" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Replaces:" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Section: misc" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Priority: optional" ${_C_echo})
list(APPEND _CMD_ COMMAND echo "Description: ${${_T}_LABEL} service" ${_C_echo})
add_custom_target(deploy_${_T}-service
# gather deb dir
COMMAND rm -rf ${_VERB} "${_AGD}"
COMMAND mkdir ${_VERB} -p "${_AGD}/DEBIAN"
${_CMD_}
# generate deb
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
COMMAND dpkg-deb -Z gzip -b ${_AGD} ${_DESTINATION}/${_deb_name}
VERBATIM
COMMENT "Generating ${_deb_name}"
)
list(APPEND _deployed "deploy_${_T}-service")
endif()
elseif(WIN32)
if (NOT CMAKE_OBJDUMP)
find_program(CMAKE_OBJDUMP objdump)
endif()
set(_AGD "${_DEPLOY_DIR}/${_TV}_win_${MY_ARCH}/")
if (__win_host)
string(REPLACE "/" "\\" CMAKE_OBJDUMP "${CMAKE_OBJDUMP}")
endif()
set(_var_exe "${_DEPLOY_DIR}/${_T}.exe")
set(_var_empty)
__make_dir(_CMD_ "${_AGD}")
__make_dir(_CMD_ "${_DESTINATION}")
__make_copy(_CMD_ _var_empty _var_exe "${_AGD}")
__make_copy(_CMD_ _RES_DIRS _RES_FILES "${_AGD}")
__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES "${_AGD}")
__make_copy(_CMD_ _FILE_DIRS _FILE_FILES "${_AGD}")
__make_copy(_CMD_ _LIBS_DIRS _LIBS_FILES "${_AGD}")
set(_zip_name "${_TV}_windows_${MY_ARCH}.zip")
add_custom_target(deploy_${_T}
# gather dir
${_CMD_}
COMMAND ${PIP_DEPLOY_TOOL} ${_VERB} ${_OPTIONS} -W "\"${CMAKE_OBJDUMP}\"" -P windows,minimal -S windows -q "\"${Qt5_ROOT}\"" -s "\"${CMAKE_PREFIX_PATH}/bin${_dt_delim}${MINGW_BIN}${_add_search_path}\"" -o ${_AGD} -p ${_AGD} "\"${_AGD}${_T}.exe\"" ${_ADD_DEPS}
# zip
COMMAND cd "\"${_DEPLOY_DIR}\"" "&&" zip -q -r "\"${_DESTINATION}/${_zip_name}\"" "\"${_TV}_win_${MY_ARCH}\""
COMMENT "Generating ${_zip_name}"
)
set(_deployed "deploy_${_T}")
elseif (APPLE)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "${${_T}_FULLNAME}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${${_T}_VERSION}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${${_T}_VERSION}")
set(MACOSX_BUNDLE_ICON_FILE "${_ICON_NAME}")
set(MACOSX_BUNDLE_BUNDLE_NAME "${${_T}_LABEL}")
set(MACOSX_BUNDLE_COPYRIGHT "${${_T}_COMPANY}")
set(MACOSX_BUNDLE_INFO_STRING "${${_T}_INFO}")
set(MACOSX_BUNDLE_BUNDLE_VERSION "6.0")
set(MACOSX_BUNDLE_SIGNATURE "????")
set(MACOSX_BUNDLE_PRIVACIES "${__macos_privacies}")
set_target_properties(${_T} PROPERTIES MACOSX_BUNDLE TRUE)
set_target_properties(${_T} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${_modules_dir}/PIMacOSBundle.plist.in")
set(_AGD "${_DEPLOY_DIR}/${_T}.app")
set(_DMG "${CMAKE_CURRENT_BINARY_DIR}/dmg")
__make_copy(_CMD_ _RES_DIRS _RES_FILES "${_AGD}/Contents/Resources")
__make_copy(_CMD_ _PLUG_DIRS _PLUG_FILES "${_AGD}/Contents/PlugIns")
__make_copy(_CMD_ _FILE_DIRS _FILE_FILES "${_AGD}/Contents/MacOS")
__make_copy(_CMD_ _LIBS_DIRS _LIBS_FILES "${_AGD}/Contents/Frameworks")
if (_ICON_NAME)
set(_CMD_ ${_CMD_} COMMAND cp ${_VERB} -f ${_ICON_FN} ${_AGD}/Contents/Resources)
endif()
if (NOT CMAKE_OTOOL)
set(CMAKE_OTOOL "otool")
endif()
if (NOT CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH "/usr/local")
endif()
set(_dmg_name "${_TV}_macosx_x64.dmg")
set(_cmd_gen_dmg COMMAND genisoimage -quiet -V "${MACOSX_BUNDLE_BUNDLE_NAME}" -D -R -apple -no-pad -o ${_DESTINATION}/${_dmg_name} ${_DMG})
if (__mac_host)
set(_cmd_gen_dmg COMMAND hdiutil create ${_DESTINATION}/${_dmg_name} -ov -volname "${MACOSX_BUNDLE_BUNDLE_NAME}" -fs HFS+ -srcfolder ${_DMG})
endif()
if (_ZIP_DMG)
set(_cmd_gen_dmg ${_cmd_gen_dmg} COMMAND zip -q -r "\"${_DESTINATION}/${_dmg_name}.zip\"" "\"${_DESTINATION}/${_dmg_name}\"")
set(_cmd_gen_dmg ${_cmd_gen_dmg} COMMAND rm "\"${_DESTINATION}/${_dmg_name}\"")
endif()
set(_comment "Generating ${_dmg_name}")
if (_ZIP_DMG)
set(_comment "${_comment}.zip")
endif()
add_custom_target(deploy_${_T}
# gather .app dir
COMMAND mkdir ${_VERB} -p ${_AGD}/Contents/Resources
COMMAND mkdir ${_VERB} -p ${_AGD}/Contents/Frameworks
COMMAND mkdir ${_VERB} -p ${_DESTINATION}
${_CMD_}
COMMAND ${PIP_DEPLOY_TOOL} ${_VERB} ${_OPTIONS} -M "${CMAKE_OTOOL}" -P cocoa,minimal -S mac -q ${Qt5_ROOT} -s "\"${CMAKE_PREFIX_PATH}/lib${_add_search_path}\"" -o ${_AGD}/Contents/Frameworks -p ${_AGD}/Contents/PlugIns ${_AGD}/Contents/MacOS/${_T} ${_ADD_DEPS}
# prepare dmg dir
COMMAND rm -rf ${_DMG}
COMMAND mkdir ${_VERB} -p ${_DMG}
COMMAND cp -r ${_AGD} ${_DMG}
COMMAND ln ${_VERB} -s /Applications ${_DMG}
# generate dmg
${_cmd_gen_dmg}
COMMENT "${_comment}"
)
set(_deployed "deploy_${_T}")
elseif (DEFINED ANDROID_PLATFORM)
set(_res_files)
set(_res_files "${_res_files}\n <qresource prefix=\"/\">")
foreach (_f ${_RES_FILES})
set(_res_files "${_res_files}\n <file>${_f}</file>")
endforeach()
set(_res_files "${_res_files}\n </qresource>")
foreach (_d ${_RES_DIRS})
file(GLOB_RECURSE _df "${_d}/*")
#message("FILES ${_d} = ${_df}")
get_filename_component(_dn "${_d}" NAME)
set(_res_files "${_res_files}\n <qresource prefix=\"${_dn}\">")
foreach (_f ${_df})
get_filename_component(_fn "${_f}" NAME)
set(_res_files "${_res_files}\n <file alias=\"${_fn}\">${_f}</file>")
endforeach()
set(_res_files "${_res_files}\n </qresource>")
endforeach()
set(_res_qrc "${CMAKE_CURRENT_BINARY_DIR}/android_res.qrc")
file(WRITE "${_res_qrc}" "<RCC>${_res_files}\n</RCC>")
set(_AT ${_T}_lib)
set(_ATA ${_AT}_${ANDROID_ABI})
get_target_property(_sources ${_T} SOURCES)
get_target_property(_libs ${_T} LINK_LIBRARIES)
get_target_property(_incs ${_T} INCLUDE_DIRECTORIES)
get_target_property(_defs ${_T} COMPILE_DEFINITIONS)
qt5_add_resources(_res_out "${_res_qrc}")
add_library(${_ATA} SHARED ${_sources} ${_res_out})
target_link_libraries(${_ATA} ${_libs})
target_include_directories(${_ATA} PRIVATE ${_incs})
target_compile_definitions(${_ATA} PRIVATE ${_defs})
set_target_properties(${_T} PROPERTIES EXCLUDE_FROM_ALL 1)
#message("create new target ${_ATA} ${_sources} ${_libs}")
set(_AGD "${_DEPLOY_DIR}/${_T}.android")
__make_dir(_CMD_ "${_AGD}")
set(_file)
set(_dir "${CMAKE_BINARY_DIR}/android-build/libs" "${CMAKE_CURRENT_SOURCE_DIR}/android/res" "${CMAKE_CURRENT_SOURCE_DIR}/android/src")
__make_copy(_CMD_ _dir _file "${_AGD}")
set(_dir)
set(_file "${Qt5_ROOT}/src/android/templates/res/values/libs.xml")
__make_copy(_CMD_ _dir _file "${_AGD}/res/values")
set(_dir "${Qt5_ROOT}/src/3rdparty/gradle/gradle")
set(_file "${Qt5_ROOT}/src/3rdparty/gradle/gradlew"
"${Qt5_ROOT}/src/3rdparty/gradle/gradlew.bat")
__make_copy(_CMD_ _dir _file "${_AGD}")
#message("bindir = ${CMAKE_CURRENT_SOURCE_DIR}")
set(SDK_ROOT "$ENV{ANDROID_SDK_ROOT}")
if("x${SDK_ROOT}" STREQUAL "x")
set(SDK_ROOT "$ENV{ANDROID_HOME}")
endif()
set(__archs "armeabi-v7a" "arm64-v8a" "x86" "x86_64")
set(QT_ANDROID_ARCHITECTURES)
find_library(_lib_ c++_shared)
foreach (_a ${__archs})
set(_aname "${_a}")
if ("${_a}" STREQUAL "armeabi-v7a")
set(_aname "arm")
elseif ("${_a}" STREQUAL "arm64-v8a")
set(_aname "arm64")
endif()
set(_exist 0)
if ("${_a}" STREQUAL "${ANDROID_ABI}")
set(_exist 1)
elseif (EXISTS "${CMAKE_BINARY_DIR}/android-build/libs/${_a}")
set(_exist 1)
endif()
if (_exist)
string(REPLACE "${ANDROID_ABI}" "${_a}" _a_prefix "${CMAKE_PREFIX_PATH}")
string(REPLACE "arch-${ANDROID_ARCH_NAME}" "arch-${_aname}" _a_prefix "${_a_prefix}")
list(APPEND QT_ANDROID_ARCHITECTURES " \"${_a}\" : \"${ANDROID_SYSROOT_${_a}}\"")
string(REPLACE "${ANDROID_SYSROOT_${ANDROID_ABI}}" "${ANDROID_SYSROOT_${_a}}" _lib_${_a} "${_lib_}")
#message("search = ${_a_prefix}/lib")
__make_copy(_CMD_ _empty _lib_${_a} "${_AGD}/libs/${_a}")
set(_CMD_ ${_CMD_} COMMAND ${PIP_DEPLOY_TOOL} ${_VERB} ${_OPTIONS} -W "\"${CMAKE_OBJDUMP}\"" -s "${_a_prefix}/lib${_dt_delim}${Qt5_ROOT}/lib${_add_search_path}" -o "\"${_AGD}/libs/${_a}\"" --ignore "\"c${_dt_delim}m${_dt_delim}z${_dt_delim}dl${_dt_delim}log\"" "\"${_AGD}/libs/${_a}/lib${_AT}_${_a}.so\"" ${_ADD_DEPS})
#message("c++_${_a} -> ${_lib_${_a}}")
endif()
endforeach()
string(REPLACE ";" ",\n" QT_ANDROID_ARCHITECTURES "${QT_ANDROID_ARCHITECTURES}")
set(QT_ANDROID_APPLICATION_BINARY ${_AT})
set(ANDROID_LABEL "${${_T}_LABEL}")
set(ANDROID_ICON "${${_T}_ICON}")
set(ANDROID_VERSION "${${_T}_VERSION}")
set(ANDROID_BUILD "${${_T}_VERSION_BUILD}")
set(ANDROID_PACKAGE "${${_T}_FULLNAME}")
set(ANDROID_TARGET_SDK "${${_T}_ANDROID_TARGET_SDK}")
set(ANDROID_STORE_FILE "${${_T}_ANDROID_STORE_FILE}")
set(ANDROID_STORE_PASSWORD "${${_T}_ANDROID_STORE_PASSWORD}")
set(ANDROID_KEY_PASSWORD "${${_T}_ANDROID_KEY_PASSWORD}")
set(ANDROID_KEY_ALIAS "${${_T}_ANDROID_KEY_ALIAS}")
if (NOT IS_ABSOLUTE "${ANDROID_STORE_FILE}")
set(ANDROID_STORE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/android/${ANDROID_STORE_FILE}")
endif()
if (${_T}_ANDROID_NEW_LOADER)
set(ANDROID_NEW_LOADER "true")
else()
set(ANDROID_NEW_LOADER "false")
endif()
set(__ANDROID_DEBUG_KEYSTORE__ "${_modules_dir}/android_debug.keystore")
set(QT_DIR ${Qt5_ROOT})
set(_out_json "${CMAKE_CURRENT_BINARY_DIR}/${_T}_android_deployment_settings.json")
configure_file("${CMAKE_BINARY_DIR}/android_deployment_settings.json.in" "${_out_json}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/android/AndroidManifest.xml.in" "${_AGD}/AndroidManifest.xml")
configure_file("${_modules_dir}/gradle.properties.in" "${_AGD}/gradle.properties")
set(_depstr)
foreach (_d ${ANDROID_GRADLE_DEPENDENCIES})
set(_depstr "${_depstr}\n ${_d}")
endforeach()
set(__gradle_lang)
foreach (_l ${${_T}_LANG})
if (NOT "x${__gradle_lang}" STREQUAL "x")
set(__gradle_lang "${__gradle_lang}, ")
endif()
set(__gradle_lang "${__gradle_lang}\"${_l}\"")
endforeach()
if ("x${__gradle_lang}" STREQUAL "x")
set(__gradle_lang "\"en\"")
endif()
file(READ "${Qt5_ROOT}/src/android/templates/build.gradle" _file)
string(REPLACE "\ndependencies {" "\ndependencies {${_depstr}" _file "${_file}")
string(REPLACE "\nandroid {" "\nandroid {\n${__gradle_sign}\n${__gradle_lang_start}${__gradle_lang}\n\t}\n" _file "${_file}")
string(REPLACE "['resources']" "['res']" _file "${_file}")
file(WRITE "${_AGD}/build.gradle" "${_file}")
set(_gradle_home)
if (NOT __win_host)
set(_gradle_home "-g" "${CMAKE_BINARY_DIR}")
endif()
set(_CMD_ ${_CMD_} COMMAND "${Qt5_BIN}/androiddeployqt" --aux-mode --android-platform ${ANDROID_PLATFORM} --output "\"${_AGD}\"" --input "\"${_out_json}\"")
set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" assembleDebug)
set(_CMD_ ${_CMD_} COMMAND "${_AGD}/gradlew" ${_gradle_home} --no-daemon -p "\"${_AGD}\"" bundleRelease)
set(_base_name "${_TV}_android_all")
set(_CMD_ ${_CMD_} COMMAND "${CMAKE_COMMAND}" -E copy "${_AGD}/build/outputs/apk/debug/${_T}.android-debug.apk" "${_DESTINATION}/${_base_name}.apk")
if (ANDROID_STORE_FILE)
set(_CMD_ ${_CMD_} COMMAND "${CMAKE_COMMAND}" -E copy "${_AGD}/build/outputs/bundle/release/${_T}.android-release.aab" "${_DESTINATION}/${_base_name}.aab")
endif()
add_custom_target(deploy_${_T}
# gather .app dir
${_CMD_}
COMMENT "Generating ${_base_name}.apk/aab"
)
set(_deployed "deploy_${_T}")
endif()
foreach (_d ${_deployed})
add_dependencies(deploy ${_d})
endforeach()
endmacro()

31
cmake/DownloadGTest.cmake Normal file
View File

@@ -0,0 +1,31 @@
# Download and unpack googletest at configure time
configure_file(GTestCMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()
# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
# The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include")
endif()

24
cmake/FindMinGW.cmake Normal file
View File

@@ -0,0 +1,24 @@
if(${MINGW})
if(NOT DEFINED MINGW_DIR)
get_filename_component(MINGW_BIN ${CMAKE_CXX_COMPILER} PATH)
get_filename_component(MINGW_DIR ${MINGW_BIN} PATH)
find_path(MINGW_INCLUDE
windows.h
PATHS
ENV INCLUDE
${MINGW_DIR}
${MINGW_DIR}/i686-w64-mingw32
${MINGW_DIR}/x86_64-w64-mingw32
PATH_SUFFIXES
include)
#message(STATUS "Find MinGW = ${MINGW_INCLUDE}")
find_library(MINGW_LIB m HINTS ${MINGW_BIN}/../lib ${MINGW_INCLUDE}/../lib)
get_filename_component(MINGW_LIB ${MINGW_LIB} PATH)
if (NOT _MGW_MSG)
set(_MGW_MSG 1 CACHE BOOL "msg_mingw" FORCE)
message(STATUS "Found MinGW binary path = ${MINGW_BIN}")
message(STATUS "Found MinGW include path = ${MINGW_INCLUDE}")
message(STATUS "Found MinGW library path = ${MINGW_LIB}")
endif()
endif()
endif(${MINGW})

View File

@@ -1,6 +1,6 @@
#[[ #[[
Create imported targets: Also create imported targets:
* PIP - main library * PIP - main library
* PIP::USB * PIP::USB
* PIP::Console * PIP::Console
@@ -18,59 +18,85 @@ main library
]] ]]
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
include(SHSTKMacros) if(WIN32)
find_package(MinGW REQUIRED)
shstk_set_find_dirs(pip)
set(__libs "usb;crypt;console;fftw;compress;io_utils;cloud;lua")
if (BUILDING_pip)
#set(_libs "pip;pip_usb;pip_console;pip_crypt;pip_fftw;pip_compress;pip_opencl;pip_io_utils;pip_cloud;pip_lua")
#set(_bins "pip_cmg;pip_rc;deploy_tool")
#get_target_property(_path pip BINARY_DIR)
#get_target_property(_path pip LIBRARY_OUTPUT_NAME)
#message("${_path}")
#set(PIP_LIBRARY "$<TARGET_FILE_DIR:pip>/$<TARGET_FILE_NAME:pip>" CACHE STRING "")
set(PIP_LIBRARY pip CACHE STRING "")
set(PIP_FOUND ON CACHE BOOL "")
else()
find_library(PIP_LIBRARY pip HINTS ${pip_LIBDIR})
foreach (_l ${__libs})
find_library(PIP_LIBRARY_${_l} pip_${_l} HINTS ${pip_LIBDIR})
endforeach()
endif() endif()
if (BUILDING_pip AND (NOT CMAKE_CROSSCOMPILING)) set(_PIP_INCDIR "${PIP_DIR}/include/pip")
set(PIP_CMG "$<TARGET_FILE_DIR:pip_cmg>/$<TARGET_FILE_NAME:pip_cmg>" CACHE STRING "") set(_PIP_LIBDIR "${PIP_DIR}/lib")
set(PIP_RC "$<TARGET_FILE_DIR:pip_rc>/$<TARGET_FILE_NAME:pip_rc>" CACHE STRING "") set(_PIP_BINDIR)
set(PIP_DEPLOY_TOOL "$<TARGET_FILE_DIR:deploy_tool>/$<TARGET_FILE_NAME:deploy_tool>" CACHE STRING "") set(_PIP_FP_DP)
else()
find_program(PIP_CMG pip_cmg${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG}) if(MINGW_INCLUDE)
find_program(PIP_RC pip_rc${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG}) list(APPEND _PIP_INCDIR "${MINGW_INCLUDE}/pip")
find_program(PIP_DEPLOY_TOOL deploy_tool${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG}) list(APPEND _PIP_LIBDIR "${MINGW_LIB}")
endif() endif()
if (NOT PIP_LIBRARY) if(CMAKE_CROSSCOMPILING)
if(PIP_FIND_REQUIRED) list(APPEND _PIP_INCDIR "${CMAKE_PREFIX_PATH}/include/pip")
message(FATAL_ERROR "Can`t find PIP library!") list(APPEND _PIP_LIBDIR "${CMAKE_PREFIX_PATH}/lib")
else()
if(NOT WIN32)
list(APPEND _PIP_INCDIR "/usr/include/pip" "/usr/local/include/pip")
list(APPEND _PIP_LIBDIR "/usr/lib" "/usr/local/lib")
endif() endif()
return() if(APPLE)
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
endif()
endif()
list(APPEND _PIP_LIBDIR "$ENV{SMSDK_DIR}/lib")
if(MINGW_INCLUDE)
list(APPEND _PIP_BINDIR "${MINGW_BIN}")
endif()
if(CMAKE_CROSSCOMPILING)
set(_PIP_FP_DP "NO_DEFAULT_PATH")
list(APPEND _PIP_BINDIR "/usr/bin" "/usr/local/bin")
else()
list(APPEND _PIP_BINDIR "${CMAKE_PREFIX_PATH}/bin")
endif()
list(APPEND _PIP_BINDIR "${PIP_DIR}/bin")
set(_pip_suffix "")
find_library(PIP_LIBRARY pip${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_USB_LIBRARY pip_usb${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_CONSOLE_LIBRARY pip_console${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_CRYPT_LIBRARY pip_crypt${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_FFTW_LIBRARY pip_fftw${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_COMPRESS_LIBRARY pip_compress${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_OPENCL_LIBRARY pip_opencl${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_IO_UTILS_LIBRARY pip_io_utils${_pip_suffix} HINTS ${_PIP_LIBDIR})
find_library(PIP_CLOUD_LIBRARY pip_cloud HINTS${_pip_suffix} ${_PIP_LIBDIR})
find_library(PIP_LUA_LIBRARY pip_lua HINTS${_pip_suffix} ${_PIP_LIBDIR})
find_file(PIP_H_INCLUDE "pip.h" HINTS ${_PIP_INCDIR} $ENV{SMSDK_DIR}/include/pip)
get_filename_component(PIP_INCLUDES ${PIP_H_INCLUDE} PATH)
set(__ext "")
if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xWindows")
set(__ext ".exe")
if (CMAKE_CROSSCOMPILING)
set(_PIP_FP_DP)
endif()
endif()
#message("FIND \"${__ext}\" -> ${_PIP_BINDIR}")
find_program(PIP_CMG pip_cmg${__ext} HINTS ${_PIP_BINDIR} ${_PIP_FP_DP})
find_program(PIP_RC pip_rc${__ext} HINTS ${_PIP_BINDIR} ${_PIP_FP_DP})
find_program(PIP_DEPLOY_TOOL deploy_tool${__ext} HINTS ${_PIP_BINDIR} ${_PIP_FP_DP})
if (NOT PIP_LIBRARY)
message(FATAL_ERROR "Can`t find PIP library!")
endif() endif()
set(_PIP_LIBRARY_PATH_ "${PIP_LIBRARY}") set(_PIP_LIBRARY_PATH_ "${PIP_LIBRARY}")
set(_PIP_ADD_LIBS_ "") set(_PIP_ADD_LIBS_ "")
if (NOT BUILDING_pip) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") find_library(DL_LIBRARY dl)
find_library(DL_LIBRARY dl) list(APPEND PIP_LIBRARY ${DL_LIBRARY})
list(APPEND PIP_LIBRARY ${DL_LIBRARY}) if (NOT DEFINED ANDROID_PLATFORM)
if (NOT DEFINED ANDROID_PLATFORM) find_library(PTHREAD_LIBRARY pthread)
find_library(PTHREAD_LIBRARY pthread) find_library(UTIL_LIBRARY util)
find_library(UTIL_LIBRARY util) set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY}) list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
endif()
endif() endif()
endif() endif()
if(PIP_LIBRARY_lua) if(PIP_LUA_LIBRARY)
if (NOT LUA_FOUND) if (NOT LUA_FOUND)
if(MINGW) if(MINGW)
set(LUA_INCLUDE_DIR ${MINGW_INCLUDE}) set(LUA_INCLUDE_DIR ${MINGW_INCLUDE})
@@ -84,81 +110,62 @@ if(PIP_LIBRARY_lua)
endif() endif()
endif() endif()
if (NOT BUILDING_pip) if(NOT PIP_VERSION)
shstk_find_header(pip PIP "pip_version.h" "${_PIP_LIBRARY_PATH_}") include(CheckSymbolExists)
check_symbol_exists(PIP_VERSION_NAME "${PIP_INCLUDES}/piversion.h" HAVE_PIP_VERSION)
if (HAVE_PIP_VERSION)
file(STRINGS "${PIP_INCLUDES}/piversion.h" _VERSION REGEX "^[ \t]*#define[ \t]+PIP_VERSION_NAME+[ \t]+.*$")
string(REGEX MATCH "\".*\"" _VERSION ${_VERSION})
string(LENGTH ${_VERSION} SL)
math(EXPR SL ${SL}-2)
string(SUBSTRING ${_VERSION} 1 ${SL} _VERSION)
set(PIP_VERSION ${_VERSION} CACHE STRING "VERSION")
if (NOT _PIP_MSG)
set(_PIP_MSG 1 CACHE BOOL "msg_pip" FORCE)
message(STATUS "Found PIP: ${_PIP_LIBRARY_PATH_} (version \"${PIP_VERSION}\")")
endif()
else()
message(FATAL_ERROR "Can`t find PIP version file!")
endif()
endif() endif()
if(PIP_FIND_VERSION VERSION_GREATER PIP_VERSION) if(PIP_FIND_VERSION VERSION_GREATER PIP_VERSION)
message(FATAL_ERROR "PIP version ${PIP_VERSION} is available, but ${PIP_FIND_VERSION} requested!") message(FATAL_ERROR "PIP version ${PIP_VERSION} is available, but ${PIP_FIND_VERSION} requested!")
endif() endif()
set(__module_usb USB ) set(__modules "USB;Crypt;Console;FFTW;Compress;IOUtils;Cloud;Lua")
set(__module_console Console ) set(__module_USB "${PIP_USB_LIBRARY}" )
set(__module_crypt Crypt ) set(__module_Console "${PIP_CONSOLE_LIBRARY}" )
set(__module_fftw FFTW ) set(__module_Crypt "${PIP_CRYPT_LIBRARY}" )
set(__module_compress Compress ) set(__module_FFTW "${PIP_FFTW_LIBRARY}" )
set(__module_opencl OpenCL ) set(__module_Compress "${PIP_COMPRESS_LIBRARY}" )
set(__module_io_utils IOUtils ) set(__module_OpenCL "${PIP_OPENCL_LIBRARY}" )
set(__module_cloud Cloud ) set(__module_IOUtils "${PIP_IO_UTILS_LIBRARY}" )
set(__module_lua Lua ) set(__module_Cloud "${PIP_CLOUD_LIBRARY}" )
set(__module_Lua "${PIP_LUA_LIBRARY}" )
foreach (_l ${__libs}) if((NOT TARGET PIP) AND PIP_LIBRARY)
set( __inc_${_l} "") add_library(PIP UNKNOWN IMPORTED)
set(__deps_${_l} "") set_target_properties(PIP PROPERTIES
set(__libs_${_l} "") IMPORTED_LOCATION "${_PIP_LIBRARY_PATH_}"
endforeach() INTERFACE_INCLUDE_DIRECTORIES "${PIP_INCLUDES}"
INTERFACE_LINK_LIBRARIES "${_PIP_ADD_LIBS_}")
set( __inc_lua "${LUA_INCLUDE_DIR}") endif()
foreach (_m ${__modules})
set(__deps_io_utils "PIP::Crypt") if((NOT TARGET PIP::${_m}) AND __module_${_m})
set(__deps_cloud "PIP::IOUtils") add_library(PIP::${_m} UNKNOWN IMPORTED)
set_target_properties(PIP::${_m} PROPERTIES
set(__libs_lua "${LUA_LIBRARIES}") IMPORTED_LOCATION "${__module_${_m}}"
INTERFACE_LINK_LIBRARIES "PIP")
endif()
if (BUILDING_pip) endforeach()
if(__module_IOUtils AND __module_Crypt)
if (NOT SET_TARGETS_pip) set_target_properties(PIP::IOUtils PROPERTIES INTERFACE_LINK_LIBRARIES "PIP::Crypt")
set(SET_TARGETS_pip ON CACHE BOOL "") endif()
#message("create aliases") if(__module_Cloud AND __module_IOUtils)
if((NOT TARGET PIP) AND PIP_LIBRARY) set_target_properties(PIP::Cloud PROPERTIES INTERFACE_LINK_LIBRARIES "PIP::IOUtils")
#message("alias PIP = pip") endif()
add_library(PIP ALIAS pip) if(__module_Lua)
endif() set_target_properties(PIP::Lua PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES "PIP;${LUA_LIBRARIES}")
foreach (_l ${__libs})
set(_m ${__module_${_l}})
if((NOT TARGET PIP::${_m}) AND TARGET pip_${_l})
#message("alias PIP::${_m} = pip_${_l}")
add_library(PIP::${_m} ALIAS pip_${_l})
endif()
endforeach()
endif()
else()
#message("create interfaces")
if((NOT TARGET PIP) AND PIP_LIBRARY)
add_library(PIP UNKNOWN IMPORTED)
set_target_properties(PIP PROPERTIES
IMPORTED_LOCATION "${_PIP_LIBRARY_PATH_}"
INTERFACE_INCLUDE_DIRECTORIES "${pip_INCLUDES}"
INTERFACE_LINK_LIBRARIES "${_PIP_ADD_LIBS_}")
#message("imported PIP = ${PIP_LIBRARY}")
endif()
foreach (_l ${__libs})
set(_m ${__module_${_l}})
if((NOT TARGET PIP::${_m}) AND PIP_LIBRARY_${_l})
add_library(PIP::${_m} UNKNOWN IMPORTED)
set_target_properties(PIP::${_m} PROPERTIES
IMPORTED_LOCATION "${PIP_LIBRARY_${_l}}"
INTERFACE_INCLUDE_DIRECTORIES "${__inc_${_l}}"
INTERFACE_LINK_LIBRARIES "PIP;${__deps_${_l}};${__libs_${_l}}")
#message("imported PIP::${_m} = ${PIP_LIBRARY_${_l}} ${__deps_${_l}} ${__libs_${_l}} ${__inc_${_l}}")
endif()
endforeach()
endif() endif()
set(PIP_FOUND ON CACHE BOOL "")
include(PIPMacros) include(PIPMacros)

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>${MACOSX_BUNDLE_SIGNATURE}</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>NSSupportsAutomaticTermination</key>
<true/>
<key>NSSupportsSuddenTermination</key>
<true/>
${MACOSX_BUNDLE_PRIVACIES}
</dict>
</plist>

View File

@@ -85,6 +85,7 @@ macro(pip_resources RESULT INPUT)
set(SRC_RC_OUT "${RC_OUT}") set(SRC_RC_OUT "${RC_OUT}")
set(RC_OUT ${CMAKE_CURRENT_BINARY_DIR}/${RC_FILE}) set(RC_OUT ${CMAKE_CURRENT_BINARY_DIR}/${RC_FILE})
set(${RESULT} ${${RESULT}} ${RC_OUT}) set(${RESULT} ${${RESULT}} ${RC_OUT})
set(CCM_FILES)
if(IS_ABSOLUTE "${INPUT}") if(IS_ABSOLUTE "${INPUT}")
set(RC_FILES "${INPUT}") set(RC_FILES "${INPUT}")
else() else()
@@ -95,7 +96,7 @@ macro(pip_resources RESULT INPUT)
set(PIP_DLL_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(PIP_DLL_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif() endif()
set(RC_DEPS ${RC_FILES}) set(RC_DEPS ${RC_FILES})
if(NOT BUILDING_pip) if(NOT PIP_BUILD)
execute_process(COMMAND "${PIP_RC}" -l -i "${RC_FILES}" execute_process(COMMAND "${PIP_RC}" -l -i "${RC_FILES}"
WORKING_DIRECTORY ${PIP_DLL_DIR} WORKING_DIRECTORY ${PIP_DLL_DIR}
OUTPUT_VARIABLE RC_LIST) OUTPUT_VARIABLE RC_LIST)

136
cmake/TargetArch.cmake Normal file
View File

@@ -0,0 +1,136 @@
# Based on the Qt 5 processor detection code, so should be very accurate
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
# Regarding POWER/PowerPC, just as is noted in the Qt source,
# "There are many more known variants/revisions that we do not handle/detect."
set(archdetect_c_code "
#if defined(__aarch64__)
#error cmake_ARCH arm64
#elif defined(__arm__) || defined(__TARGET_ARCH_ARM)
#if defined(__ARM_ARCH_7__) \\
|| defined(__ARM_ARCH_7A__) \\
|| defined(__ARM_ARCH_7R__) \\
|| defined(__ARM_ARCH_7M__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7)
#error cmake_ARCH armv7
#elif defined(__ARM_ARCH_6__) \\
|| defined(__ARM_ARCH_6J__) \\
|| defined(__ARM_ARCH_6T2__) \\
|| defined(__ARM_ARCH_6Z__) \\
|| defined(__ARM_ARCH_6K__) \\
|| defined(__ARM_ARCH_6ZK__) \\
|| defined(__ARM_ARCH_6M__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
#error cmake_ARCH armv6
#elif defined(__ARM_ARCH_5TEJ__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
#error cmake_ARCH armv5
#else
#error cmake_ARCH arm
#endif
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
#error cmake_ARCH i386
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
#error cmake_ARCH x86_64
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
#error cmake_ARCH ia64
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|| defined(_M_MPPC) || defined(_M_PPC)
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
#error cmake_ARCH ppc64
#else
#error cmake_ARCH ppc
#endif
#endif
#error cmake_ARCH unknown
")
# Set ppc_support to TRUE before including this file or ppc and ppc64
# will be treated as invalid architectures since they are no longer supported by Apple
function(target_architecture output_var)
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
# First let's normalize the order of the values
# Note that it's not possible to compile PowerPC applications if you are using
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
# disable it by default
# See this page for more information:
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
set(osx_arch_ppc TRUE)
elseif("${osx_arch}" STREQUAL "i386")
set(osx_arch_i386 TRUE)
elseif("${osx_arch}" STREQUAL "x86_64")
set(osx_arch_x86_64 TRUE)
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
set(osx_arch_ppc64 TRUE)
else()
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
endif()
endforeach()
# Now add all the architectures in our normalized order
if(osx_arch_ppc)
list(APPEND ARCH ppc)
endif()
if(osx_arch_i386)
list(APPEND ARCH i386)
endif()
if(osx_arch_x86_64)
list(APPEND ARCH x86_64)
endif()
if(osx_arch_ppc64)
list(APPEND ARCH ppc64)
endif()
else()
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
enable_language(C)
# Detect the architecture in a rather creative way...
# This compiles a small C program which is a series of ifdefs that selects a
# particular #error preprocessor directive whose message string contains the
# target architecture. The program will always fail to compile (both because
# file is not a valid C program, and obviously because of the presence of the
# #error preprocessor directives... but by exploiting the preprocessor in this
# way, we can detect the correct target architecture even when cross-compiling,
# since the program itself never needs to be run (only the compiler/preprocessor)
try_run(
run_result_unused
compile_result_unused
"${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/arch.c"
COMPILE_OUTPUT_VARIABLE ARCH
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
)
# Parse the architecture name from the compiler output
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
# Get rid of the value marker leaving just the architecture name
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
# If we are compiling with an unknown architecture this variable should
# already be set to "unknown" but in the case that it's empty (i.e. due
# to a typo in the code), then set it to unknown
if (NOT ARCH)
set(ARCH unknown)
endif()
endif()
set(${output_var} "${ARCH}" PARENT_SCOPE)
endfunction()

Binary file not shown.

View File

@@ -0,0 +1,10 @@
androidBuildToolsVersion=
androidCompileSdkVersion=@ANDROID_TARGET_SDK@
android.bundle.enableUncompressedNativeLibs=@ANDROID_NEW_LOADER@
buildDir=build
qt5AndroidDir=@Qt5_ROOT@/src/android/java
DEBUG_STORE_FILE=@__ANDROID_DEBUG_KEYSTORE__@
RELEASE_STORE_FILE=@ANDROID_STORE_FILE@
RELEASE_STORE_PASSWORD=@ANDROID_STORE_PASSWORD@
RELEASE_KEY_PASSWORD=@ANDROID_KEY_PASSWORD@
RELEASE_KEY_ALIAS=@ANDROID_KEY_ALIAS@

View File

@@ -49,9 +49,6 @@ PIVector<char> vec(4u, 'p');
piForeachC (char i, vec) piForeachC (char i, vec)
cout << i << ", "; cout << i << ", ";
// p, p, p, p, // p, p, p, p,
piCout << PIVector<int>({1, 2, 3});
// 1, 2, 3
//! [PIVector::PIVector] //! [PIVector::PIVector]
//! [PIVector::at_c] //! [PIVector::at_c]
PIVector<int> vec; PIVector<int> vec;

View File

@@ -17,33 +17,24 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "picloudclient.h" #include "piccloudclient.h"
PICloudClient::PICloudClient(const PIString & path, PIIODevice::DeviceMode mode) : PIIODevice(path, mode), eth(PIEthernet::TCP_Client) { PICloudClient::PICloudClient() {
} }
PICloudClient::~PICloudClient() { PICloudClient::~PICloudClient() {
stop();
close();
} }
bool PICloudClient::openDevice() { bool PICloudClient::openDevice() {
return false;
} }
bool PICloudClient::closeDevice() { bool PICloudClient::closeDevice() {
return false;
} }
int PICloudClient::readDevice(void * read_to, int max_size) {
return eth.read(read_to, max_size);
}
int PICloudClient::writeDevice(const void * data, int max_size) {
return eth.write(data, max_size);
}

View File

@@ -1,30 +1,25 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
PISpinlock PICloud Server
Ivan Pelipenko peri4ko@yandex.ru Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** \class PISpinlock #include "piccloudserver.h"
* \brief Spinlock
* \details
* \section PISpinlock_sec0 Synopsis PICloudServer::PICloudServer() {
* %PISpinlock provides synchronization blocks between several threads. }
* PISpinlock functionality similar to PIMutex, but working on atomic
* type and \a lock() method wait with 100% CPU load.
* \note
* Use this type instead of PIMutex when less waiting time is more
* important than CPU load!
* */

View File

@@ -17,26 +17,12 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "picloudtcp.h" #include "piccloudtcp.h"
#include "picrypt.h" #include "picrypt.h"
#include "pichunkstream.h"
const char hash_def_key[] = "_picrypt_"; const char hash_def_key[] = "_picrypt_";
PIByteArray & operator <<(PIByteArray & s, const PICloud::Header & v) { PICloudTCP::PICloudTCP() {
s << v.version << v.type << v.sname;
return s;
}
PIByteArray & operator >>(PIByteArray & s, PICloud::Header & v) {
s >> v.version >> v.type >> v.sname;
return s;
}
PICloud::TCP::TCP() {
} }

View File

@@ -1,4 +1,4 @@
/*! \file picloudclient.h /*! \file piccloudclient.h
* \brief PICloud Client * \brief PICloud Client
*/ */
/* /*
@@ -20,11 +20,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICLOUDCLIENT_H #ifndef PICCLOUDCLIENT_H
#define PICLOUDCLIENT_H #define PICCLOUDCLIENT_H
#include "pip_cloud_export.h" #include "pip_cloud_export.h"
#include "piethernet.h" #include "piiodevice.h"
class PIEthernet;
class PIP_CLOUD_EXPORT PICloudClient : public PIIODevice class PIP_CLOUD_EXPORT PICloudClient : public PIIODevice
@@ -32,7 +34,7 @@ class PIP_CLOUD_EXPORT PICloudClient : public PIIODevice
PIIODEVICE(PICloudClient) PIIODEVICE(PICloudClient)
public: public:
//! //!
explicit PICloudClient(const PIString & path = PIString(), PIIODevice::DeviceMode mode = PIIODevice::ReadWrite); explicit PICloudClient();
virtual ~PICloudClient(); virtual ~PICloudClient();
protected: protected:
@@ -40,10 +42,7 @@ protected:
bool closeDevice(); bool closeDevice();
private: private:
int readDevice(void * read_to, int max_size); PIEthernet * eth;
int writeDevice(const void * data, int max_size);
PIEthernet eth;
}; };
#endif // PICLOUDCLIENT_H #endif // PICCLOUDCLIENT_H

View File

@@ -20,8 +20,8 @@
#ifndef PICLOUDMODULE_H #ifndef PICLOUDMODULE_H
#define PICLOUDMODULE_H #define PICLOUDMODULE_H
#include "picloudtcp.h" #include "piccloudtcp.h"
#include "picloudclient.h" #include "piccloudclient.h"
#include "picloudserver.h" #include "piccloudserver.h"
#endif // PICLOUDMODULE_H #endif // PICLOUDMODULE_H

View File

@@ -0,0 +1,40 @@
/*! \file piccloudserver.h
* \brief PICloud Server
*/
/*
PIP - Platform Independent Primitives
PICloud Server
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PICCLOUDSERVER_H
#define PICCLOUDSERVER_H
#include "pip_cloud_export.h"
#include "piiodevice.h"
class PIP_CLOUD_EXPORT PICloudServer {
public:
//!
explicit PICloudServer();
private:
};
#endif // PICCLOUDSERVER_H

View File

@@ -1,4 +1,4 @@
/*! \file picloudtcp.h /*! \file piccloudtcp.h
* \brief PICloud TCP transport * \brief PICloud TCP transport
*/ */
/* /*
@@ -20,45 +20,20 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PICLOUDTCP_H #ifndef PICCLOUDTCP_H
#define PICLOUDTCP_H #define PICCLOUDTCP_H
#include "pip_cloud_export.h" #include "pip_cloud_export.h"
#include "pistring.h" #include "pistring.h"
class PIP_CLOUD_EXPORT PICloudTCP {
namespace PICloud {
enum Version {
Version_1 = 1,
};
enum HeaderType {
Server = 1,
Client = 2,
};
struct PIP_CLOUD_EXPORT Header {
Header() {
version = Version_1;
}
uchar version; // PICloud::Version
uchar type; // PICloud::HeaderType
PIString sname; // server name
};
class PIP_CLOUD_EXPORT TCP {
public: public:
TCP(); //!
PICloudTCP();
private: private:
}; };
} #endif // PICCLOUDTCP_H
PIP_CLOUD_EXPORT PIByteArray & operator <<(PIByteArray & s, const PICloud::Header & v);
PIP_CLOUD_EXPORT PIByteArray & operator >>(PIByteArray & s, PICloud::Header & v);
#endif // PICLOUDTCP_H

View File

@@ -32,10 +32,6 @@
* \brief Contructs vector with size "size" filled elements "value" * \brief Contructs vector with size "size" filled elements "value"
* \details Example: \snippet picontainers.cpp PIVector::PIVector * \details Example: \snippet picontainers.cpp PIVector::PIVector
* \fn PIVector::PIVector(std::initializer_list list);
* \brief Contructs vector from C++11 initializer list
* \details Example: \snippet picontainers.cpp PIVector::PIVector
* \fn const T & PIVector::at(size_t index) const; * \fn const T & PIVector::at(size_t index) const;
* \brief Read-only access to element by index "index" * \brief Read-only access to element by index "index"
* \details Example: \snippet picontainers.cpp PIVector::at_c * \details Example: \snippet picontainers.cpp PIVector::at_c
@@ -375,7 +371,4 @@
* \fn bool PIMapIterator::next() * \fn bool PIMapIterator::next()
* \brief Jump to next entry and return if new position is valid. * \brief Jump to next entry and return if new position is valid.
* \fn void PIMapIterator::reset()
* \brief Reset iterator to initial position.
* */ * */

View File

@@ -42,8 +42,6 @@
#else #else
# include <malloc.h> # include <malloc.h>
#endif #endif
#include <initializer_list>
#include <type_traits>
#include <string.h> #include <string.h>
#include <new> #include <new>
#ifndef PIP_MEMALIGN_BYTES #ifndef PIP_MEMALIGN_BYTES

View File

@@ -39,11 +39,6 @@ public:
alloc(other.pid_size, true); alloc(other.pid_size, true);
newT(pid_data + pid_start, other.pid_data + other.pid_start, pid_size); newT(pid_data + pid_start, other.pid_data + other.pid_start, pid_size);
} }
inline PIDeque(std::initializer_list<T> init_list): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
alloc(init_list.size(), true);
newT(pid_data, init_list.begin(), init_list.size());
}
inline PIDeque(const T * data, size_t size): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) { inline PIDeque(const T * data, size_t size): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T)) PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
alloc(size, true); alloc(size, true);
@@ -54,7 +49,6 @@ public:
resize(pid_size, f); resize(pid_size, f);
} }
inline PIDeque(PIDeque<T> && other): pid_data(other.pid_data), pid_size(other.pid_size), pid_rsize(other.pid_rsize), pid_start(other.pid_start) { inline PIDeque(PIDeque<T> && other): pid_data(other.pid_data), pid_size(other.pid_size), pid_rsize(other.pid_rsize), pid_start(other.pid_start) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
other._reset(); other._reset();
} }
inline virtual ~PIDeque() { inline virtual ~PIDeque() {
@@ -167,6 +161,7 @@ public:
inline bool isEmpty() const {return (pid_size == 0);} inline bool isEmpty() const {return (pid_size == 0);}
inline T & operator [](size_t index) {return pid_data[pid_start + index];} inline T & operator [](size_t index) {return pid_data[pid_start + index];}
inline T & at(size_t index) {return pid_data[pid_start + index];}
inline const T & operator [](size_t index) const {return pid_data[pid_start + index];} inline const T & operator [](size_t index) const {return pid_data[pid_start + index];}
inline const T & at(size_t index) const {return pid_data[pid_start + index];} inline const T & at(size_t index) const {return pid_data[pid_start + index];}
inline T & back() {return pid_data[pid_start + pid_size - 1];} inline T & back() {return pid_data[pid_start + pid_size - 1];}

View File

@@ -206,6 +206,7 @@ public:
return pim_content.back(); return pim_content.back();
} }
const T operator [](const Key & key) const {bool f(false); ssize_t i = _find(key, f); if (f) return pim_content[pim_index[i].index]; return T();} const T operator [](const Key & key) const {bool f(false); ssize_t i = _find(key, f); if (f) return pim_content[pim_index[i].index]; return T();}
T & at(const Key & key) {return (*this)[key];}
const T at(const Key & key) const {return (*this)[key];} const T at(const Key & key) const {return (*this)[key];}
PIMap<Key, T> & operator <<(const PIMap<Key, T> & other) { PIMap<Key, T> & operator <<(const PIMap<Key, T> & other) {
@@ -363,13 +364,6 @@ public:
} }
return false; return false;
} }
inline void reset() {
if (rev) {
pos = m.size_s();
} else {
pos = -1;
}
}
private: private:
const MapType & m; const MapType & m;
ssize_t pos; ssize_t pos;

View File

@@ -44,17 +44,11 @@ public:
alloc(other.piv_size); alloc(other.piv_size);
newT(piv_data, other.piv_data, piv_size); newT(piv_data, other.piv_data, piv_size);
} }
inline PIVector(std::initializer_list<T> init_list): piv_data(0), piv_size(0), piv_rsize(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
alloc(init_list.size());
newT(piv_data, init_list.begin(), init_list.size());
}
inline PIVector(size_t piv_size, const T & f = T()): piv_data(0), piv_size(0), piv_rsize(0) { inline PIVector(size_t piv_size, const T & f = T()): piv_data(0), piv_size(0), piv_rsize(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T)) PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
resize(piv_size, f); resize(piv_size, f);
} }
inline PIVector(PIVector<T> && other): piv_data(other.piv_data), piv_size(other.piv_size), piv_rsize(other.piv_rsize) { inline PIVector(PIVector<T> && other): piv_data(other.piv_data), piv_size(other.piv_size), piv_rsize(other.piv_rsize) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
other._reset(); other._reset();
} }
inline virtual ~PIVector() { inline virtual ~PIVector() {
@@ -167,6 +161,7 @@ public:
inline bool isEmpty() const {return (piv_size == 0);} inline bool isEmpty() const {return (piv_size == 0);}
inline T & operator [](size_t index) {return piv_data[index];} inline T & operator [](size_t index) {return piv_data[index];}
inline T & at(size_t index) {return piv_data[index];}
inline const T & operator [](size_t index) const {return piv_data[index];} inline const T & operator [](size_t index) const {return piv_data[index];}
inline const T & at(size_t index) const {return piv_data[index];} inline const T & at(size_t index) const {return piv_data[index];}
inline T & back() {return piv_data[piv_size - 1];} inline T & back() {return piv_data[piv_size - 1];}

View File

@@ -26,7 +26,7 @@
#ifndef PIBASE_H #ifndef PIBASE_H
#define PIBASE_H #define PIBASE_H
#include "pip_version.h" #include "piversion.h"
#include "piplatform.h" #include "piplatform.h"
#include "pip_export.h" #include "pip_export.h"
#include "pip_defs.h" #include "pip_defs.h"
@@ -94,25 +94,6 @@
//! Macro is defined when PIP can use "rt" library for "PITimer::ThreadRT" timers implementation //! Macro is defined when PIP can use "rt" library for "PITimer::ThreadRT" timers implementation
# define PIP_TIMER_RT # define PIP_TIMER_RT
//! Macro to declare private section, export is optional
# define PRIVATE_DECLARATION(export)
//! Macro to start definition of private section
# define PRIVATE_DEFINITION_START(Class)
//! Macro to end definition of private section
# define PRIVATE_DEFINITION_END(Class)
//! Macro to access private section by pointer
# define PRIVATE
//! Macro to start static initializer
# define STATIC_INITIALIZER_BEGIN
//! Macro to end static initializer
# define STATIC_INITIALIZER_END
#endif #endif
#include <functional> #include <functional>
@@ -236,29 +217,10 @@
#define PRIVATE (__privateinitializer__.p) #define PRIVATE (__privateinitializer__.p)
#define PRIVATEWB __privateinitializer__.p #define PRIVATEWB __privateinitializer__.p
#define NO_COPY_CLASS(name) \ #define NO_COPY_CLASS(name) \
name(const name&) = delete; \ name(const name&) = delete; \
name& operator=(const name&) = delete; name& operator=(const name&) = delete;
#define _PIP_ADD_COUNTER_WS(a, cnt) a##cnt
#define _PIP_ADD_COUNTER_WF(a, cnt) _PIP_ADD_COUNTER_WS(a, cnt)
#define _PIP_ADD_COUNTER(a) _PIP_ADD_COUNTER_WF(a, __COUNTER__)
#define STATIC_INITIALIZER_BEGIN \
class { \
class _Initializer_ { \
public: \
_Initializer_() {
#define STATIC_INITIALIZER_END \
} \
} _initializer_; \
} _PIP_ADD_COUNTER(_pip_initializer_);
#ifdef FREERTOS #ifdef FREERTOS
# define PIP_MIN_MSLEEP 10. # define PIP_MIN_MSLEEP 10.
#else #else
@@ -330,6 +292,13 @@ template<> inline void piSwapBinary(const void *& f, const void *& s) {
} }
} }
template<> inline void piSwap(double & f, double & s) {piSwapBinary<double>(f, s);}
template<> inline void piSwap(ldouble & f, ldouble & s) {piSwapBinary<ldouble>(f, s);}
#ifdef ARCH_BITS_32
template<> inline void piSwap(float & f, float & s) {piSwapBinary<float>(f, s);}
template<> inline void piSwap(llong & f, llong & s) {piSwapBinary<llong>(f, s);}
template<> inline void piSwap(ullong & f, ullong & s) {piSwapBinary<ullong>(f, s);}
#endif
/*! \brief Function for compare two values without "=" by raw content /*! \brief Function for compare two values without "=" by raw content
* \details Example:\n \snippet piincludes.cpp compareBinary */ * \details Example:\n \snippet piincludes.cpp compareBinary */
@@ -485,7 +454,20 @@ template<> inline float piLetobe(const float & v) {
return a.f; return a.f;
} }
/// \brief Generic hash function, implements murmur3/32 algorithm DEPRECATED inline ushort letobe_s(const ushort & v) {return (v << 8) | (v >> 8);}
DEPRECATED inline uint letobe_i(const uint & v) {return (v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | ((v << 24) & 0xFF000000);}
#ifdef DOXYGEN
/// \deprecated \brief Use \a piLetobe() instead of this function
ushort letobe_s(ushort v) {return (v << 8) | (v >> 8);}
/// \deprecated \brief Use \a piLetobe() instead of this function
uint letobe_i(uint v) {return (v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | ((v << 24) & 0xFF000000);}
#endif
/// \brief Generic hash function, impements murmur3/32 algorithm
inline uint piHashData(const uchar * data, uint len, uint seed = 0) { inline uint piHashData(const uchar * data, uint len, uint seed = 0) {
if (!data || len <= 0) return 0u; if (!data || len <= 0) return 0u;
uint h = seed; uint h = seed;

View File

@@ -396,8 +396,8 @@ PIByteArray & operator >>(PIByteArray & s, PIByteArray & v) {
} }
v.resize(sz); v.resize(sz);
if (sz > 0) { if (sz > 0) {
memcpy(v.data(), s.data(), sz); memcpy(v.data(), s.data(), v.size());
s.remove(0, sz); s.remove(0, v.size());
} }
return s; return s;
} }

View File

@@ -80,36 +80,11 @@ int PIChunkStream::read() {
} }
int PIChunkStream::peekVInt(Version version_, PIByteArray * data_, int pos, PIByteArray & hdr, uint & ret) {
switch (version_) {
case Version_1:
memcpy(&ret, data_->data(pos), 4);
return 4;
case Version_2: {
hdr.resize(4);
hdr.fill(uchar(0));
memcpy(hdr.data(), data_->data(pos), piMini(4, data_->size_s() - pos));
uchar hsz = 0;
ret = readVInt(hdr, &hsz);
return hsz;
}
default: break;
}
return 0;
}
void PIChunkStream::readAll() { void PIChunkStream::readAll() {
data_map.clear(); data_map.clear();
if (!data_) return; while (!atEnd()) {
int pos = 0, sz = data_->size_s(); read();
uint csz = 0, cid = 0; data_map[last_id] = last_data;
PIByteArray hdr;
while (pos < sz) {
pos += peekVInt((Version)version_, data_, pos, hdr, cid);
pos += peekVInt((Version)version_, data_, pos, hdr, csz);
data_map[cid] = PIPair<int, int>(pos, csz);
pos += csz;
} }
} }
@@ -136,7 +111,7 @@ void PIChunkStream::_init() {
} }
uint PIChunkStream::readVInt(PIByteArray & s, uchar * bytes_cnt) { uint PIChunkStream::readVInt(PIByteArray & s) {
if (s.isEmpty()) return 0; if (s.isEmpty()) return 0;
uchar bytes[4]; s >> bytes[0]; uchar bytes[4]; s >> bytes[0];
uchar abc = 0; uchar abc = 0;
@@ -147,7 +122,6 @@ uint PIChunkStream::readVInt(PIByteArray & s, uchar * bytes_cnt) {
s >> bytes[abc + 1]; s >> bytes[abc + 1];
} else break; } else break;
} }
if (bytes_cnt) *bytes_cnt = (abc + 1);
uint ret = 0; uint ret = 0;
for (int i = 0; i <= abc; ++i) { for (int i = 0; i <= abc; ++i) {
ret += (bytes[i] << (8 * ((int)abc - i))); ret += (bytes[i] << (8 * ((int)abc - i)));

View File

@@ -79,11 +79,11 @@ public:
//! Returns stream version //! Returns stream version
Version version() const {return (Version)version_;} Version version() const {return (Version)version_;}
//! Read one chunk from stream and returns its ID //! Read one chunk from stream and returns its ID
int read(); int read();
//! Read all chunks from stream. This function just index input data //! Read all chunks from stream
void readAll(); void readAll();
//! Returns last readed chunk ID //! Returns last readed chunk ID
@@ -100,9 +100,7 @@ public:
//! Place value of chunk with id \"id\" into \"v\". You should call \a readAll() before using this function! //! Place value of chunk with id \"id\" into \"v\". You should call \a readAll() before using this function!
template <typename T> template <typename T>
const PIChunkStream & get(int id, T & v) const { const PIChunkStream & get(int id, T & v) const {
PIPair<int, int> pos = data_map.value(id); PIByteArray ba = data_map.value(id);
if (pos.first < 0 || pos.second == 0) return *this;
PIByteArray ba(data_->data(pos.first), pos.second);
if (!ba.isEmpty()) if (!ba.isEmpty())
ba >> v; ba >> v;
return *this; return *this;
@@ -111,14 +109,13 @@ public:
private: private:
void _init(); void _init();
static uint readVInt(PIByteArray & s, uchar * bytes = 0); static uint readVInt(PIByteArray & s);
static void writeVInt(PIByteArray & s, uint val); static void writeVInt(PIByteArray & s, uint val);
static int peekVInt(Version version_, PIByteArray * data_, int pos, PIByteArray & hdr, uint & ret);
int last_id; int last_id;
uchar version_; uchar version_;
PIByteArray * data_, last_data, tmp_data; PIByteArray * data_, last_data, tmp_data;
PIMap<int, PIPair<int, int>> data_map; PIMap<int, PIByteArray> data_map;
template <typename T> friend PIChunkStream & operator <<(PIChunkStream & s, const PIChunkStream::Chunk<T> & c); template <typename T> friend PIChunkStream & operator <<(PIChunkStream & s, const PIChunkStream::Chunk<T> & c);
template <typename T> friend PIChunkStream & operator <<(PIChunkStream & s, const PIChunkStream::ChunkConst<T> & c); template <typename T> friend PIChunkStream & operator <<(PIChunkStream & s, const PIChunkStream::ChunkConst<T> & c);

View File

@@ -44,19 +44,10 @@
# define ADD_NEW_TO_COLLECTION(group, class) # define ADD_NEW_TO_COLLECTION(group, class)
#else #else
# define ADD_TO_COLLECTION(group, object) static PICollection::CollectionAdder __##group##_##__LINE__##_##adder##__(#group, object, false);
# define ADD_TO_COLLECTION(group, object) \ # define ADD_TO_COLLECTION_WITH_NAME(group, object, name) static PICollection::CollectionAdder __##group##_##__LINE__##_##adder##__(#group, object, #name, false);
static PICollection::CollectionAdder _PIP_ADD_COUNTER(_collection_adder_)(#group, object, false); # define ADD_NEW_TO_COLLECTION(group, class) static PICollection::CollectionAdder __##group##_##class##_##adder##__(#group, new class(), true);
# define ADD_NEW_TO_COLLECTION_WITH_NAME(group, class, name) static PICollection::CollectionAdder __##group##_##class##_##adder##__(#group, new class(), #name, true);
# define ADD_TO_COLLECTION_WITH_NAME(group, object, name) \
static PICollection::CollectionAdder _PIP_ADD_COUNTER(_collection_adder_)(#group, object, #name, false);
# define ADD_NEW_TO_COLLECTION(group, class) \
static PICollection::CollectionAdder _PIP_ADD_COUNTER(_collection_adder_)(#group, new class(), true);
# define ADD_NEW_TO_COLLECTION_WITH_NAME(group, class, name) \
static PICollection::CollectionAdder _PIP_ADD_COUNTER(_collection_adder_)(#group, new class(), #name, true);
#endif #endif
class PIP_EXPORT PICollection class PIP_EXPORT PICollection

Some files were not shown because too many files have changed in this diff Show More