Compare commits
91 Commits
concurrent
...
648c2e491e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
648c2e491e | ||
|
|
d5da2e7c7f | ||
|
|
04da5daa41 | ||
|
|
9505669780 | ||
|
|
f72d4bcda4 | ||
|
|
7948028022 | ||
|
|
4307890356 | ||
|
|
7312fa9a36 | ||
|
|
d255224822 | ||
|
|
49507b4a84 | ||
|
|
3092f4f45b | ||
|
|
6e100e19f5 | ||
| 740d38ccce | |||
|
|
33d1abd14c | ||
|
|
14e13fa8c1 | ||
|
|
3f84598ec0 | ||
|
|
1646f1ada7 | ||
|
|
3a4ac8badd | ||
|
|
0ce6afa43c | ||
|
|
5bec25a628 | ||
|
|
7acc2f6b2f | ||
|
|
641633f6f0 | ||
|
|
f98874401f | ||
|
|
58a132a3a5 | ||
| 05b48af153 | |||
|
|
98f77d90cd | ||
|
|
ab16bb3ce0 | ||
|
|
6d83790358 | ||
|
|
05a32ccf1a | ||
| b11ebc8100 | |||
| e6bc9638e7 | |||
| 00321257b4 | |||
| b0c98d4464 | |||
| 410bc42830 | |||
| 2511e96372 | |||
| f1a0a3ec4a | |||
|
|
8e7d7a54c4 | ||
|
|
9544d5ef0d | ||
|
|
4d03ba1210 | ||
|
|
defbe3a4d7 | ||
| 5ef37dc7fd | |||
| a9e6ed0753 | |||
|
|
2913fc284b | ||
|
|
3dd08bf944 | ||
|
|
fcf91a26b6 | ||
| a4b3edb3e1 | |||
| 6be22ac39f | |||
| 37de1ec099 | |||
| 32d060c8ce | |||
| 7065cbd9ee | |||
| c5f70f4e09 | |||
| 234d4e73be | |||
| e1f2c90790 | |||
| 93cf55d323 | |||
| 2ef0ca6946 | |||
| 73bfe03433 | |||
| 2a42d2a341 | |||
| 7f2c82dc69 | |||
| fa0475cac6 | |||
| cfebf8cf23 | |||
| 3965e54e38 | |||
| f033119a8b | |||
| 6b70045914 | |||
| cc580d9385 | |||
| 05607ccf0e | |||
| fec68299c1 | |||
| ccd6a9888f | |||
| c582d8ff46 | |||
| 9834ac177b | |||
| 31f0d88157 | |||
| e76a07a3f3 | |||
| 31a347250f | |||
| 294831df17 | |||
| e77d3a86a9 | |||
| 66010c83eb | |||
| 57a9ccb854 | |||
| 3ba6a7b0e8 | |||
| 8c3349d84a | |||
| dac318c624 | |||
| e08f805525 | |||
| 26742a1fc3 | |||
| 70a7363f76 | |||
| 8405b564a4 | |||
|
|
494b09847e | ||
|
|
f1951ee711 | ||
| c3257c7c50 | |||
|
|
13bafdc7c1 | ||
|
|
f71fbb0068 | ||
|
|
bb635f6c51 | ||
|
|
d8e47afe13 | ||
| dbb84885e3 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
/.svn
|
/.svn
|
||||||
/doc/rtf
|
/doc/rtf
|
||||||
_unsused
|
_unsused
|
||||||
|
CMakeLists.txt.user
|
||||||
208
CMakeLists.txt
208
CMakeLists.txt
@@ -1,46 +1,36 @@
|
|||||||
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 1)
|
set(pip_MAJOR 2)
|
||||||
set(_PIP_MINOR 99)
|
set(pip_MINOR 5)
|
||||||
set(_PIP_REVISION 3)
|
set(pip_REVISION 0)
|
||||||
set(_PIP_SUFFIX _prebeta)
|
set(pip_SUFFIX _beta)
|
||||||
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)
|
||||||
if(NOT DEFINED BUILD_NUMBER)
|
include(SHSTKMacros)
|
||||||
set(BUILD_NUMBER 9999)
|
|
||||||
endif()
|
shstk_begin_project(pip PIP)
|
||||||
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)
|
||||||
|
|
||||||
@@ -66,10 +56,10 @@ macro(pip_module NAME LIBS LABEL INCLUDES MSG)
|
|||||||
set(HS)
|
set(HS)
|
||||||
set(PHS)
|
set(PHS)
|
||||||
set(CRES)
|
set(CRES)
|
||||||
file(GLOB_RECURSE CPPS "lib/${NAME}/*.cpp")
|
file(GLOB_RECURSE CPPS "libs/${NAME}/*.cpp")
|
||||||
file(GLOB_RECURSE HS "lib/${NAME}/*.h")
|
file(GLOB_RECURSE HS "libs/${NAME}/*.h")
|
||||||
file(GLOB_RECURSE PHS "lib/${NAME}/*_p.h")
|
file(GLOB_RECURSE PHS "libs/${NAME}/*_p.h")
|
||||||
file(GLOB_RECURSE RES "lib/${NAME}/*conf.h")
|
file(GLOB_RECURSE RES "libs/${NAME}/*.conf")
|
||||||
list(REMOVE_ITEM HS "${PHS}")
|
list(REMOVE_ITEM HS "${PHS}")
|
||||||
list(APPEND HDRS ${HS})
|
list(APPEND HDRS ${HS})
|
||||||
list(APPEND PHDRS ${PHS})
|
list(APPEND PHDRS ${PHS})
|
||||||
@@ -84,11 +74,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)
|
||||||
|
|
||||||
@@ -101,23 +91,22 @@ macro(pip_module NAME LIBS LABEL INCLUDES MSG)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if (NOT "${RES}" STREQUAL "")
|
if (NOT "x${RES}" STREQUAL "x")
|
||||||
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})
|
||||||
if (NOT "${RES}" STREQUAL "")
|
target_include_directories(${_target} PUBLIC ${PIP_INCLUDES})
|
||||||
|
if (NOT "x${RES}" STREQUAL "x")
|
||||||
add_dependencies(${_target} pip_rc)
|
add_dependencies(${_target} pip_rc)
|
||||||
endif()
|
endif()
|
||||||
if (NOT "${INCLUDES}" STREQUAL "")
|
if (NOT "x${INCLUDES}" STREQUAL "x")
|
||||||
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 "${LIBS}" STREQUAL "")
|
if (NOT "x${LIBS}" STREQUAL "x")
|
||||||
list(APPEND LIBS_STATUS ${LIBS})
|
list(APPEND LIBS_STATUS ${LIBS})
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
@@ -134,63 +123,10 @@ 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
|
||||||
set_version(PIP
|
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_version.h")
|
||||||
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))
|
||||||
@@ -210,18 +146,15 @@ get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
|
|||||||
|
|
||||||
|
|
||||||
# Main lib
|
# Main lib
|
||||||
file(GLOB PIP_FOLDERS LIST_DIRECTORIES TRUE "${CMAKE_CURRENT_SOURCE_DIR}/lib/main/*")
|
file(GLOB PIP_FOLDERS LIST_DIRECTORIES TRUE "${CMAKE_CURRENT_SOURCE_DIR}/libs/main/*")
|
||||||
list(APPEND PIP_FOLDERS "${CMAKE_CURRENT_SOURCE_DIR}/lib/main")
|
list(APPEND PIP_FOLDERS "${CMAKE_CURRENT_SOURCE_DIR}/libs/main")
|
||||||
set(PIP_MAIN_FOLDERS)
|
set(PIP_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
foreach(F ${PIP_FOLDERS})
|
foreach(F ${PIP_FOLDERS})
|
||||||
if (IS_DIRECTORY "${F}")
|
if (IS_DIRECTORY "${F}")
|
||||||
list(APPEND PIP_MAIN_FOLDERS "${F}")
|
list(APPEND PIP_INCLUDES "${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}")
|
||||||
@@ -231,7 +164,7 @@ endif()
|
|||||||
if(PIP_FREERTOS)
|
if(PIP_FREERTOS)
|
||||||
add_definitions(-DPIP_FREERTOS)
|
add_definitions(-DPIP_FREERTOS)
|
||||||
set(ICU OFF)
|
set(ICU OFF)
|
||||||
set(LIB OFF)
|
set(LOCAL ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check Bessel functions
|
# Check Bessel functions
|
||||||
@@ -367,7 +300,6 @@ 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")
|
||||||
@@ -384,6 +316,15 @@ 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)
|
||||||
@@ -462,7 +403,11 @@ 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()
|
||||||
pip_module(opencl "${_opencl_lib}" "PIP OpenCL support" "" " (${OpenCL_VERSION_STRING})")
|
set(_opencl_inc "${OpenCL_INCLUDE_DIRS}")
|
||||||
|
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()
|
||||||
|
|
||||||
|
|
||||||
@@ -479,15 +424,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}/lib/lua/3rd" " (${LUA_VERSION_STRING})")
|
pip_module(lua "LUA" "PIP Lua support" "${LUA_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd" " (${LUA_VERSION_STRING})")
|
||||||
list(APPEND HDR_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/3rd/LuaBridge")
|
list(APPEND HDR_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/libs/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)
|
target_link_libraries(pip_test pip pip_cloud)
|
||||||
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()
|
||||||
@@ -499,16 +444,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)
|
||||||
|
|
||||||
@@ -520,11 +465,10 @@ 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(LIB)
|
if(NOT LOCAL)
|
||||||
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)
|
||||||
@@ -552,8 +496,6 @@ if(LIB)
|
|||||||
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)
|
||||||
@@ -568,6 +510,8 @@ 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)
|
||||||
|
|
||||||
@@ -593,11 +537,9 @@ if(NOT PIP_FREERTOS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# Libraries messages
|
shstk_is_parent_exists(_pe)
|
||||||
if(DEFINED LIBPROJECT)
|
if (_pe)
|
||||||
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()
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -607,12 +549,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}/lib/lua/3rd\"")
|
set(DOXY_EXCLUDE "\"${CMAKE_CURRENT_SOURCE_DIR}/libs/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}\"")
|
||||||
@@ -623,7 +565,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}/lib\"")
|
string(REPLACE ";" " " DOXY_INPUT "\"${CMAKE_CURRENT_SOURCE_DIR}/libs\"")
|
||||||
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)
|
||||||
@@ -632,13 +574,30 @@ 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(LIB)
|
if (NOT LOCAL)
|
||||||
message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
|
message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
|
||||||
else()
|
else()
|
||||||
if(NOT PIP_FREERTOS)
|
if(NOT PIP_FREERTOS)
|
||||||
@@ -657,7 +616,8 @@ endif()
|
|||||||
message("")
|
message("")
|
||||||
message(" Modules:")
|
message(" Modules:")
|
||||||
foreach(_m ${PIP_SRC_MODULES})
|
foreach(_m ${PIP_SRC_MODULES})
|
||||||
message(" ${_m}: ${PIP_MSG_${_m}}")
|
expand_to_length(_m_e "${_m}" ${_max_len})
|
||||||
|
message(" ${_m_e}: ${PIP_MSG_${_m}}")
|
||||||
endforeach()
|
endforeach()
|
||||||
message("")
|
message("")
|
||||||
if (PIP_TESTS_LIST)
|
if (PIP_TESTS_LIST)
|
||||||
|
|||||||
@@ -1,1068 +0,0 @@
|
|||||||
#[[
|
|
||||||
|
|
||||||
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()
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# 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()
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
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})
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#[[
|
#[[
|
||||||
|
|
||||||
Also create imported targets:
|
Create imported targets:
|
||||||
* PIP - main library
|
* PIP - main library
|
||||||
* PIP::USB
|
* PIP::USB
|
||||||
* PIP::Console
|
* PIP::Console
|
||||||
@@ -18,85 +18,59 @@ main library
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
|
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
|
||||||
if(WIN32)
|
include(SHSTKMacros)
|
||||||
find_package(MinGW REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(_PIP_INCDIR "${PIP_DIR}/include/pip")
|
shstk_set_find_dirs(pip)
|
||||||
set(_PIP_LIBDIR "${PIP_DIR}/lib")
|
|
||||||
set(_PIP_BINDIR)
|
|
||||||
set(_PIP_FP_DP)
|
|
||||||
|
|
||||||
if(MINGW_INCLUDE)
|
set(__libs "usb;crypt;console;fftw;compress;io_utils;cloud;lua")
|
||||||
list(APPEND _PIP_INCDIR "${MINGW_INCLUDE}/pip")
|
|
||||||
list(APPEND _PIP_LIBDIR "${MINGW_LIB}")
|
if (BUILDING_pip)
|
||||||
endif()
|
#set(_libs "pip;pip_usb;pip_console;pip_crypt;pip_fftw;pip_compress;pip_opencl;pip_io_utils;pip_cloud;pip_lua")
|
||||||
if(CMAKE_CROSSCOMPILING)
|
#set(_bins "pip_cmg;pip_rc;deploy_tool")
|
||||||
list(APPEND _PIP_INCDIR "${CMAKE_PREFIX_PATH}/include/pip")
|
#get_target_property(_path pip BINARY_DIR)
|
||||||
list(APPEND _PIP_LIBDIR "${CMAKE_PREFIX_PATH}/lib")
|
#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()
|
else()
|
||||||
if(NOT WIN32)
|
find_library(PIP_LIBRARY pip HINTS ${pip_LIBDIR})
|
||||||
list(APPEND _PIP_INCDIR "/usr/include/pip" "/usr/local/include/pip")
|
foreach (_l ${__libs})
|
||||||
list(APPEND _PIP_LIBDIR "/usr/lib" "/usr/local/lib")
|
find_library(PIP_LIBRARY_${_l} pip_${_l} HINTS ${pip_LIBDIR})
|
||||||
endif()
|
endforeach()
|
||||||
if(APPLE)
|
|
||||||
include_directories(/usr/local/include)
|
|
||||||
link_directories(/usr/local/lib)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
list(APPEND _PIP_LIBDIR "$ENV{SMSDK_DIR}/lib")
|
|
||||||
|
if (BUILDING_pip AND (NOT CMAKE_CROSSCOMPILING))
|
||||||
if(MINGW_INCLUDE)
|
set(PIP_CMG "$<TARGET_FILE_DIR:pip_cmg>/$<TARGET_FILE_NAME:pip_cmg>" CACHE STRING "")
|
||||||
list(APPEND _PIP_BINDIR "${MINGW_BIN}")
|
set(PIP_RC "$<TARGET_FILE_DIR:pip_rc>/$<TARGET_FILE_NAME:pip_rc>" CACHE STRING "")
|
||||||
endif()
|
set(PIP_DEPLOY_TOOL "$<TARGET_FILE_DIR:deploy_tool>/$<TARGET_FILE_NAME:deploy_tool>" CACHE STRING "")
|
||||||
if(CMAKE_CROSSCOMPILING)
|
|
||||||
set(_PIP_FP_DP "NO_DEFAULT_PATH")
|
|
||||||
list(APPEND _PIP_BINDIR "/usr/bin" "/usr/local/bin")
|
|
||||||
else()
|
else()
|
||||||
list(APPEND _PIP_BINDIR "${CMAKE_PREFIX_PATH}/bin")
|
find_program(PIP_CMG pip_cmg${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG})
|
||||||
|
find_program(PIP_RC pip_rc${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG})
|
||||||
|
find_program(PIP_DEPLOY_TOOL deploy_tool${pip_BINEXT} HINTS ${pip_BINDIR} ${pip_FIND_PROGRAM_ARG})
|
||||||
endif()
|
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)
|
if (NOT PIP_LIBRARY)
|
||||||
message(FATAL_ERROR "Can`t find PIP library!")
|
if(PIP_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "Can`t find PIP library!")
|
||||||
|
endif()
|
||||||
|
return()
|
||||||
endif()
|
endif()
|
||||||
set(_PIP_LIBRARY_PATH_ "${PIP_LIBRARY}")
|
set(_PIP_LIBRARY_PATH_ "${PIP_LIBRARY}")
|
||||||
set(_PIP_ADD_LIBS_ "")
|
set(_PIP_ADD_LIBS_ "")
|
||||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
if (NOT BUILDING_pip)
|
||||||
find_library(DL_LIBRARY dl)
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||||
list(APPEND PIP_LIBRARY ${DL_LIBRARY})
|
find_library(DL_LIBRARY dl)
|
||||||
if (NOT DEFINED ANDROID_PLATFORM)
|
list(APPEND PIP_LIBRARY ${DL_LIBRARY})
|
||||||
find_library(PTHREAD_LIBRARY pthread)
|
if (NOT DEFINED ANDROID_PLATFORM)
|
||||||
find_library(UTIL_LIBRARY util)
|
find_library(PTHREAD_LIBRARY pthread)
|
||||||
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
|
find_library(UTIL_LIBRARY util)
|
||||||
list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
|
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
|
||||||
|
list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(PIP_LUA_LIBRARY)
|
if(PIP_LIBRARY_lua)
|
||||||
if (NOT LUA_FOUND)
|
if (NOT LUA_FOUND)
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
set(LUA_INCLUDE_DIR ${MINGW_INCLUDE})
|
set(LUA_INCLUDE_DIR ${MINGW_INCLUDE})
|
||||||
@@ -110,62 +84,81 @@ if(PIP_LUA_LIBRARY)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT PIP_VERSION)
|
if (NOT BUILDING_pip)
|
||||||
include(CheckSymbolExists)
|
shstk_find_header(pip PIP "pip_version.h" "${_PIP_LIBRARY_PATH_}")
|
||||||
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(__modules "USB;Crypt;Console;FFTW;Compress;IOUtils;Cloud;Lua")
|
set(__module_usb USB )
|
||||||
set(__module_USB "${PIP_USB_LIBRARY}" )
|
set(__module_console Console )
|
||||||
set(__module_Console "${PIP_CONSOLE_LIBRARY}" )
|
set(__module_crypt Crypt )
|
||||||
set(__module_Crypt "${PIP_CRYPT_LIBRARY}" )
|
set(__module_fftw FFTW )
|
||||||
set(__module_FFTW "${PIP_FFTW_LIBRARY}" )
|
set(__module_compress Compress )
|
||||||
set(__module_Compress "${PIP_COMPRESS_LIBRARY}" )
|
set(__module_opencl OpenCL )
|
||||||
set(__module_OpenCL "${PIP_OPENCL_LIBRARY}" )
|
set(__module_io_utils IOUtils )
|
||||||
set(__module_IOUtils "${PIP_IO_UTILS_LIBRARY}" )
|
set(__module_cloud Cloud )
|
||||||
set(__module_Cloud "${PIP_CLOUD_LIBRARY}" )
|
set(__module_lua Lua )
|
||||||
set(__module_Lua "${PIP_LUA_LIBRARY}" )
|
|
||||||
if((NOT TARGET PIP) AND PIP_LIBRARY)
|
foreach (_l ${__libs})
|
||||||
add_library(PIP UNKNOWN IMPORTED)
|
set( __inc_${_l} "")
|
||||||
set_target_properties(PIP PROPERTIES
|
set(__deps_${_l} "")
|
||||||
IMPORTED_LOCATION "${_PIP_LIBRARY_PATH_}"
|
set(__libs_${_l} "")
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${PIP_INCLUDES}"
|
|
||||||
INTERFACE_LINK_LIBRARIES "${_PIP_ADD_LIBS_}")
|
|
||||||
endif()
|
|
||||||
foreach (_m ${__modules})
|
|
||||||
if((NOT TARGET PIP::${_m}) AND __module_${_m})
|
|
||||||
add_library(PIP::${_m} UNKNOWN IMPORTED)
|
|
||||||
set_target_properties(PIP::${_m} PROPERTIES
|
|
||||||
IMPORTED_LOCATION "${__module_${_m}}"
|
|
||||||
INTERFACE_LINK_LIBRARIES "PIP")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
endforeach()
|
||||||
if(__module_IOUtils AND __module_Crypt)
|
|
||||||
set_target_properties(PIP::IOUtils PROPERTIES INTERFACE_LINK_LIBRARIES "PIP::Crypt")
|
set( __inc_lua "${LUA_INCLUDE_DIR}")
|
||||||
endif()
|
|
||||||
if(__module_Cloud AND __module_IOUtils)
|
set(__deps_io_utils "PIP::Crypt")
|
||||||
set_target_properties(PIP::Cloud PROPERTIES INTERFACE_LINK_LIBRARIES "PIP::IOUtils")
|
set(__deps_cloud "PIP::IOUtils")
|
||||||
endif()
|
|
||||||
if(__module_Lua)
|
set(__libs_lua "${LUA_LIBRARIES}")
|
||||||
set_target_properties(PIP::Lua PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES "PIP;${LUA_LIBRARIES}")
|
|
||||||
|
|
||||||
|
if (BUILDING_pip)
|
||||||
|
|
||||||
|
if (NOT SET_TARGETS_pip)
|
||||||
|
set(SET_TARGETS_pip ON CACHE BOOL "")
|
||||||
|
#message("create aliases")
|
||||||
|
if((NOT TARGET PIP) AND PIP_LIBRARY)
|
||||||
|
#message("alias PIP = pip")
|
||||||
|
add_library(PIP ALIAS pip)
|
||||||
|
endif()
|
||||||
|
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)
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
<?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>
|
|
||||||
@@ -85,7 +85,6 @@ 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()
|
||||||
@@ -96,7 +95,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 PIP_BUILD)
|
if(NOT BUILDING_pip)
|
||||||
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)
|
||||||
|
|||||||
@@ -1,136 +0,0 @@
|
|||||||
# 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.
@@ -1,10 +0,0 @@
|
|||||||
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@
|
|
||||||
@@ -49,6 +49,9 @@ 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;
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "piccloudserver.h"
|
|
||||||
|
|
||||||
|
|
||||||
PICloudServer::PICloudServer() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
/*! \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
|
|
||||||
@@ -1,574 +0,0 @@
|
|||||||
/*! \file pimathmatrix.h
|
|
||||||
* \brief PIMathMatrix
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
PIP - Platform Independent Primitives
|
|
||||||
PIMathMatrix
|
|
||||||
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 PIMATHMATRIX_H
|
|
||||||
#define PIMATHMATRIX_H
|
|
||||||
|
|
||||||
#include "pimathvector.h"
|
|
||||||
#include "pimathcomplex.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline bool _PIMathMatrixNullCompare(const T v) {
|
|
||||||
return (piAbs(v) < T(1E-200));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
inline bool _PIMathMatrixNullCompare<complexf >(const complexf v) {
|
|
||||||
return (abs(v) < float(1E-200));
|
|
||||||
}
|
|
||||||
template<>
|
|
||||||
inline bool _PIMathMatrixNullCompare<complexd >(const complexd v) {
|
|
||||||
return (abs(v) < double(1E-200));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Matrix templated
|
|
||||||
|
|
||||||
#define PIMM_FOR(r, c) for (uint c = 0; c < Cols; ++c) { for (uint r = 0; r < Rows; ++r) {
|
|
||||||
#define PIMM_FOR_WB(r, c) for (uint c = 0; c < Cols; ++c) for (uint r = 0; r < Rows; ++r) // without brakes
|
|
||||||
#define PIMM_FOR_I(r, c) for (uint r = 0; r < Rows; ++r) { for (uint c = 0; c < Cols; ++c) {
|
|
||||||
#define PIMM_FOR_I_WB(r, c) for (uint r = 0; r < Rows; ++r) for (uint c = 0; c < Cols; ++c) // without brakes
|
|
||||||
#define PIMM_FOR_C(v) for (uint v = 0; v < Cols; ++v)
|
|
||||||
#define PIMM_FOR_R(v) for (uint v = 0; v < Rows; ++v)
|
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
template<uint Rows, uint Cols = Rows, typename Type = double>
|
|
||||||
class PIP_EXPORT PIMathMatrixT {
|
|
||||||
typedef PIMathMatrixT<Rows, Cols, Type> _CMatrix;
|
|
||||||
typedef PIMathMatrixT<Cols, Rows, Type> _CMatrixI;
|
|
||||||
typedef PIMathVectorT<Rows, Type> _CMCol;
|
|
||||||
typedef PIMathVectorT<Cols, Type> _CMRow;
|
|
||||||
public:
|
|
||||||
PIMathMatrixT() {resize(Rows, Cols);}
|
|
||||||
PIMathMatrixT(const PIVector<Type> & val) {resize(Rows, Cols); int i = 0; PIMM_FOR_I_WB(r, c) m[r][c] = val[i++];}
|
|
||||||
|
|
||||||
static _CMatrix identity() {_CMatrix tm = _CMatrix(); PIMM_FOR_WB(r, c) tm.m[r][c] = (c == r ? Type(1) : Type(0)); return tm;}
|
|
||||||
static _CMatrix filled(const Type & v) {_CMatrix tm; PIMM_FOR_WB(r, c) tm.m[r][c] = v; return tm;}
|
|
||||||
static _CMatrix rotation(double angle) {return _CMatrix();}
|
|
||||||
static _CMatrix rotationX(double angle) {return _CMatrix();}
|
|
||||||
static _CMatrix rotationY(double angle) {return _CMatrix();}
|
|
||||||
static _CMatrix rotationZ(double angle) {return _CMatrix();}
|
|
||||||
static _CMatrix scaleX(double factor) {return _CMatrix();}
|
|
||||||
static _CMatrix scaleY(double factor) {return _CMatrix();}
|
|
||||||
static _CMatrix scaleZ(double factor) {return _CMatrix();}
|
|
||||||
|
|
||||||
uint cols() const {return Cols;}
|
|
||||||
uint rows() const {return Rows;}
|
|
||||||
_CMCol col(uint index) {_CMCol tv; PIMM_FOR_R(i) tv[i] = m[i][index]; return tv;}
|
|
||||||
_CMRow row(uint index) {_CMRow tv; PIMM_FOR_C(i) tv[i] = m[index][i]; return tv;}
|
|
||||||
_CMatrix & setCol(uint index, const _CMCol & v) {PIMM_FOR_R(i) m[i][index] = v[i]; return *this;}
|
|
||||||
_CMatrix & setRow(uint index, const _CMRow & v) {PIMM_FOR_C(i) m[index][i] = v[i]; return *this;}
|
|
||||||
_CMatrix & swapRows(uint r0, uint r1) {Type t; PIMM_FOR_C(i) {t = m[r0][i]; m[r0][i] = m[r1][i]; m[r1][i] = t;} return *this;}
|
|
||||||
_CMatrix & swapCols(uint c0, uint c1) {Type t; PIMM_FOR_R(i) {t = m[i][c0]; m[i][c0] = m[i][c1]; m[i][c1] = t;} return *this;}
|
|
||||||
_CMatrix & fill(const Type & v) {PIMM_FOR_WB(r, c) m[r][c] = v; return *this;}
|
|
||||||
bool isSquare() const {return cols() == rows();}
|
|
||||||
bool isIdentity() const {PIMM_FOR_WB(r, c) if ((c == r) ? m[r][c] != Type(1) : m[r][c] != Type(0)) return false; return true;}
|
|
||||||
bool isNull() const {PIMM_FOR_WB(r, c) if (m[r][c] != Type(0)) return false; return true;}
|
|
||||||
|
|
||||||
Type & at(uint row, uint col) {return m[row][col];}
|
|
||||||
Type at(uint row, uint col) const {return m[row][col];}
|
|
||||||
Type * operator [](uint row) {return m[row];}
|
|
||||||
const Type * operator [](uint row) const {return m[row];}
|
|
||||||
_CMatrix & operator =(const _CMatrix & sm) {memcpy(m, sm.m, sizeof(Type) * Cols * Rows); return *this;}
|
|
||||||
bool operator ==(const _CMatrix & sm) const {PIMM_FOR_WB(r, c) if (m[r][c] != sm.m[r][c]) return false; return true;}
|
|
||||||
bool operator !=(const _CMatrix & sm) const {return !(*this == sm);}
|
|
||||||
void operator +=(const _CMatrix & sm) {PIMM_FOR_WB(r, c) m[r][c] += sm.m[r][c];}
|
|
||||||
void operator -=(const _CMatrix & sm) {PIMM_FOR_WB(r, c) m[r][c] -= sm.m[r][c];}
|
|
||||||
void operator *=(const Type & v) {PIMM_FOR_WB(r, c) m[r][c] *= v;}
|
|
||||||
void operator /=(const Type & v) {PIMM_FOR_WB(r, c) m[r][c] /= v;}
|
|
||||||
_CMatrix operator -() const {_CMatrix tm; PIMM_FOR_WB(r, c) tm.m[r][c] = -m[r][c]; return tm;}
|
|
||||||
_CMatrix operator +(const _CMatrix & sm) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] += sm.m[r][c]; return tm;}
|
|
||||||
_CMatrix operator -(const _CMatrix & sm) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] -= sm.m[r][c]; return tm;}
|
|
||||||
_CMatrix operator *(const Type & v) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] *= v; return tm;}
|
|
||||||
_CMatrix operator /(const Type & v) const {_CMatrix tm = _CMatrix(*this); PIMM_FOR_WB(r, c) tm.m[r][c] /= v; return tm;}
|
|
||||||
|
|
||||||
Type determinant(bool * ok = 0) const {
|
|
||||||
_CMatrix m(*this);
|
|
||||||
bool k;
|
|
||||||
Type ret = Type(0);
|
|
||||||
m.toUpperTriangular(&k);
|
|
||||||
if (ok) *ok = k;
|
|
||||||
if (!k) return ret;
|
|
||||||
ret = Type(1);
|
|
||||||
for (uint c = 0; c < Cols; ++c)
|
|
||||||
for (uint r = 0; r < Rows; ++r)
|
|
||||||
if (r == c)
|
|
||||||
ret *= m[r][c];
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
_CMatrix & toUpperTriangular(bool * ok = 0) {
|
|
||||||
if (Cols != Rows) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
_CMatrix smat(*this);
|
|
||||||
bool ndet;
|
|
||||||
uint crow;
|
|
||||||
Type mul;
|
|
||||||
for (uint i = 0; i < Cols; ++i) {
|
|
||||||
ndet = true;
|
|
||||||
for (uint j = 0; j < Rows; ++j) if (smat.m[i][j] != 0) ndet = false;
|
|
||||||
if (ndet) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (uint i = 0; i < Cols; ++i) {
|
|
||||||
crow = i;
|
|
||||||
while (smat.m[i][i] == Type(0))
|
|
||||||
smat.swapRows(i, ++crow);
|
|
||||||
for (uint j = i + 1; j < Rows; ++j) {
|
|
||||||
mul = smat.m[i][j] / smat.m[i][i];
|
|
||||||
for (uint k = i; k < Cols; ++k) smat.m[k][j] -= mul * smat.m[k][i];
|
|
||||||
}
|
|
||||||
if (i < Cols - 1) {
|
|
||||||
if (fabs(smat.m[i+1][i+1]) < Type(1E-200)) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ok != 0) *ok = true;
|
|
||||||
memcpy(m, smat.m, sizeof(Type) * Cols * Rows);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
_CMatrix & invert(bool * ok = 0) {
|
|
||||||
if (Cols != Rows) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
_CMatrix mtmp = _CMatrix::identity(), smat(*this);
|
|
||||||
bool ndet;
|
|
||||||
uint crow;
|
|
||||||
Type mul, iddiv;
|
|
||||||
for (uint i = 0; i < Cols; ++i) {
|
|
||||||
ndet = true;
|
|
||||||
for (uint j = 0; j < Rows; ++j) if (smat.m[i][j] != 0) ndet = false;
|
|
||||||
if (ndet) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (uint i = 0; i < Cols; ++i) {
|
|
||||||
crow = i;
|
|
||||||
while (smat.m[i][i] == Type(0)) {
|
|
||||||
++crow;
|
|
||||||
smat.swapRows(i, crow);
|
|
||||||
mtmp.swapRows(i, crow);
|
|
||||||
}
|
|
||||||
for (uint j = i + 1; j < Rows; ++j) {
|
|
||||||
mul = smat.m[i][j] / smat.m[i][i];
|
|
||||||
for (uint k = i; k < Cols; ++k) smat.m[k][j] -= mul * smat.m[k][i];
|
|
||||||
for (uint k = 0; k < Cols; ++k) mtmp.m[k][j] -= mul * mtmp.m[k][i];
|
|
||||||
}
|
|
||||||
if (i < Cols - 1) {
|
|
||||||
if (fabs(smat.m[i+1][i+1]) < Type(1E-200)) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iddiv = smat.m[i][i];
|
|
||||||
for (uint j = i; j < Cols; ++j) smat.m[j][i] /= iddiv;
|
|
||||||
for (uint j = 0; j < Cols; ++j) mtmp.m[j][i] /= iddiv;
|
|
||||||
}
|
|
||||||
for (uint i = Cols - 1; i > 0; --i) {
|
|
||||||
for (uint j = 0; j < i; ++j) {
|
|
||||||
mul = smat.m[i][j];
|
|
||||||
smat.m[i][j] -= mul;
|
|
||||||
for (uint k = 0; k < Cols; ++k) mtmp.m[k][j] -= mtmp.m[k][i] * mul;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ok != 0) *ok = true;
|
|
||||||
memcpy(m, mtmp.m, sizeof(Type) * Cols * Rows);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
_CMatrix inverted(bool * ok = 0) const {_CMatrix tm(*this); tm.invert(ok); return tm;}
|
|
||||||
_CMatrixI transposed() const {_CMatrixI tm; PIMM_FOR_WB(r, c) tm[c][r] = m[r][c]; return tm;}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void resize(uint rows_, uint cols_, const Type & new_value = Type()) {r_ = rows_; c_ = cols_; PIMM_FOR_WB(r, c) m[r][c] = new_value;}
|
|
||||||
int c_, r_;
|
|
||||||
Type m[Rows][Cols];
|
|
||||||
|
|
||||||
};
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
|
|
||||||
template<> inline PIMathMatrixT<2u, 2u> PIMathMatrixT<2u, 2u>::rotation(double angle) {double c = cos(angle), s = sin(angle); PIMathMatrixT<2u, 2u> tm; tm[0][0] = tm[1][1] = c; tm[0][1] = -s; tm[1][0] = s; return tm;}
|
|
||||||
template<> inline PIMathMatrixT<2u, 2u> PIMathMatrixT<2u, 2u>::scaleX(double factor) {PIMathMatrixT<2u, 2u> tm; tm[0][0] = factor; tm[1][1] = 1.; return tm;}
|
|
||||||
template<> inline PIMathMatrixT<2u, 2u> PIMathMatrixT<2u, 2u>::scaleY(double factor) {PIMathMatrixT<2u, 2u> tm; tm[0][0] = 1.; tm[1][1] = factor; return tm;}
|
|
||||||
|
|
||||||
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::rotationX(double angle) {double c = cos(angle), s = sin(angle); PIMathMatrixT<3u, 3u> tm; tm[0][0] = 1.; tm[1][1] = tm[2][2] = c; tm[2][1] = s; tm[1][2] = -s; return tm;}
|
|
||||||
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::rotationY(double angle) {double c = cos(angle), s = sin(angle); PIMathMatrixT<3u, 3u> tm; tm[1][1] = 1.; tm[0][0] = tm[2][2] = c; tm[2][0] = -s; tm[0][2] = s; return tm;}
|
|
||||||
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::rotationZ(double angle) {double c = cos(angle), s = sin(angle); PIMathMatrixT<3u, 3u> tm; tm[2][2] = 1.; tm[0][0] = tm[1][1] = c; tm[1][0] = s; tm[0][1] = -s; return tm;}
|
|
||||||
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::scaleX(double factor) {PIMathMatrixT<3u, 3u> tm; tm[1][1] = tm[2][2] = 1.; tm[0][0] = factor; return tm;}
|
|
||||||
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::scaleY(double factor) {PIMathMatrixT<3u, 3u> tm; tm[0][0] = tm[2][2] = 1.; tm[1][1] = factor; return tm;}
|
|
||||||
template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::scaleZ(double factor) {PIMathMatrixT<3u, 3u> tm; tm[0][0] = tm[1][1] = 1.; tm[2][2] = factor; return tm;}
|
|
||||||
|
|
||||||
#ifdef PIP_STD_IOSTREAM
|
|
||||||
template<uint Rows, uint Cols, typename Type>
|
|
||||||
inline std::ostream & operator <<(std::ostream & s, const PIMathMatrixT<Rows, Cols, Type> & m) {s << "{"; PIMM_FOR_I(r, c) s << m[r][c]; if (c < Cols - 1 || r < Rows - 1) s << ", ";} if (r < Rows - 1) s << std::endl << " ";} s << "}"; return s;}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<uint Rows, uint Cols, typename Type>
|
|
||||||
inline PICout operator <<(PICout s, const PIMathMatrixT<Rows, Cols, Type> & m) {s << "{"; PIMM_FOR_I(r, c) s << m[r][c]; if (c < Cols - 1 || r < Rows - 1) s << ", ";} if (r < Rows - 1) s << PICoutManipulators::NewLine << " ";} s << "}"; return s;}
|
|
||||||
|
|
||||||
/// Multiply matrices {Rows0 x CR} on {CR x Cols1}, result is {Rows0 x Cols1}
|
|
||||||
template<uint CR, uint Rows0, uint Cols1, typename Type>
|
|
||||||
inline PIMathMatrixT<Rows0, Cols1, Type> operator *(const PIMathMatrixT<Rows0, CR, Type> & fm,
|
|
||||||
const PIMathMatrixT<CR, Cols1, Type> & sm) {
|
|
||||||
PIMathMatrixT<Rows0, Cols1, Type> tm;
|
|
||||||
Type t;
|
|
||||||
for (uint j = 0; j < Rows0; ++j) {
|
|
||||||
for (uint i = 0; i < Cols1; ++i) {
|
|
||||||
t = Type(0);
|
|
||||||
for (uint k = 0; k < CR; ++k)
|
|
||||||
t += fm[j][k] * sm[k][i];
|
|
||||||
tm[j][i] = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Multiply matrix {Rows x Cols} on vector {Cols}, result is vector {Rows}
|
|
||||||
template<uint Cols, uint Rows, typename Type>
|
|
||||||
inline PIMathVectorT<Rows, Type> operator *(const PIMathMatrixT<Rows, Cols, Type> & fm,
|
|
||||||
const PIMathVectorT<Cols, Type> & sv) {
|
|
||||||
PIMathVectorT<Rows, Type> tv;
|
|
||||||
Type t;
|
|
||||||
for (uint j = 0; j < Rows; ++j) {
|
|
||||||
t = Type(0);
|
|
||||||
for (uint i = 0; i < Cols; ++i)
|
|
||||||
t += fm[j][i] * sv[i];
|
|
||||||
tv[j] = t;
|
|
||||||
}
|
|
||||||
return tv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Multiply vector {Rows} on matrix {Rows x Cols}, result is vector {Cols}
|
|
||||||
template<uint Cols, uint Rows, typename Type>
|
|
||||||
inline PIMathVectorT<Cols, Type> operator *(const PIMathVectorT<Rows, Type> & sv,
|
|
||||||
const PIMathMatrixT<Rows, Cols, Type> & fm) {
|
|
||||||
PIMathVectorT<Cols, Type> tv;
|
|
||||||
Type t;
|
|
||||||
for (uint j = 0; j < Cols; ++j) {
|
|
||||||
t = Type(0);
|
|
||||||
for (uint i = 0; i < Rows; ++i)
|
|
||||||
t += fm[i][j] * sv[i];
|
|
||||||
tv[j] = t;
|
|
||||||
}
|
|
||||||
return tv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Multiply value(T) on matrix {Rows x Cols}, result is vector {Rows}
|
|
||||||
template<uint Cols, uint Rows, typename Type>
|
|
||||||
inline PIMathMatrixT<Rows, Cols, Type> operator *(const Type & x, const PIMathMatrixT<Rows, Cols, Type> & v) {
|
|
||||||
return v * x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
typedef PIMathMatrixT<2u, 2u, int> PIMathMatrixT22i;
|
|
||||||
typedef PIMathMatrixT<3u, 3u, int> PIMathMatrixT33i;
|
|
||||||
typedef PIMathMatrixT<4u, 4u, int> PIMathMatrixT44i;
|
|
||||||
typedef PIMathMatrixT<2u, 2u, double> PIMathMatrixT22d;
|
|
||||||
typedef PIMathMatrixT<3u, 3u, double> PIMathMatrixT33d;
|
|
||||||
typedef PIMathMatrixT<4u, 4u, double> PIMathMatrixT44d;
|
|
||||||
|
|
||||||
|
|
||||||
template<typename Type>
|
|
||||||
class PIMathMatrix;
|
|
||||||
|
|
||||||
#undef PIMM_FOR
|
|
||||||
#undef PIMM_FOR_WB
|
|
||||||
#undef PIMM_FOR_I
|
|
||||||
#undef PIMM_FOR_I_WB
|
|
||||||
#undef PIMM_FOR_C
|
|
||||||
#undef PIMM_FOR_R
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Matrix
|
|
||||||
|
|
||||||
#define PIMM_FOR(c, r) for (uint c = 0; c < _V2D::cols_; ++c) for (uint r = 0; r < _V2D::rows_; ++r)
|
|
||||||
#define PIMM_FOR_I(c, r) for (uint r = 0; r < _V2D::rows_; ++r) for (uint c = 0; c < _V2D::cols_; ++c)
|
|
||||||
#define PIMM_FOR_A(v) for (uint v = 0; v < _V2D::mat.size(); ++v)
|
|
||||||
#define PIMM_FOR_C(v) for (uint v = 0; v < _V2D::cols_; ++v)
|
|
||||||
#define PIMM_FOR_R(v) for (uint v = 0; v < _V2D::rows_; ++v)
|
|
||||||
|
|
||||||
template<typename Type>
|
|
||||||
class PIP_EXPORT PIMathMatrix : public PIVector2D<Type> {
|
|
||||||
typedef PIVector2D<Type> _V2D;
|
|
||||||
typedef PIMathMatrix<Type> _CMatrix;
|
|
||||||
typedef PIMathVector<Type> _CMCol;
|
|
||||||
public:
|
|
||||||
PIMathMatrix(const uint cols = 0, const uint rows = 0, const Type & f = Type()) {_V2D::resize(rows, cols, f);}
|
|
||||||
PIMathMatrix(const uint cols, const uint rows, const PIVector<Type> & val) {_V2D::resize(rows, cols); int i=0; PIMM_FOR_I(c, r) _V2D::element(r, c) = val[i++];}
|
|
||||||
PIMathMatrix(const PIVector<PIVector<Type> > & val) {if(!val.isEmpty()) {_V2D::resize(val.size(), val[0].size()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val[r][c];}}
|
|
||||||
PIMathMatrix(const PIVector2D<Type> & val) {if(!val.isEmpty()) {_V2D::resize(val.rows(), val.cols()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val.element(r, c);}}
|
|
||||||
|
|
||||||
static _CMatrix identity(const uint cols, const uint rows) {_CMatrix tm(cols, rows); for (uint r = 0; r < rows; ++r) for (uint c = 0; c < cols; ++c) tm.element(r, c) = (c == r ? Type(1) : Type(0)); return tm;}
|
|
||||||
static _CMatrix matrixRow(const PIMathVector<Type> & val) {return _CMatrix(val.size(), 1, val.toVector());}
|
|
||||||
static _CMatrix matrixCol(const PIMathVector<Type> & val) {return _CMatrix(1, val.size(), val.toVector());}
|
|
||||||
|
|
||||||
_CMatrix & setCol(uint index, const _CMCol & v) {PIMM_FOR_R(i) _V2D::element(i, index) = v[i]; return *this;}
|
|
||||||
_CMatrix & setRow(uint index, const _CMCol & v) {PIMM_FOR_C(i) _V2D::element(index, i) = v[i]; return *this;}
|
|
||||||
_CMatrix & swapCols(uint r0, uint r1) {PIMM_FOR_C(i) {piSwap(_V2D::element(i, r0), _V2D::element(i, r1));} return *this;}
|
|
||||||
_CMatrix & swapRows(uint c0, uint c1) {PIMM_FOR_R(i) {piSwap(_V2D::element(c0, i), _V2D::element(c1, i));} return *this;}
|
|
||||||
_CMatrix & fill(const Type & v) {PIMM_FOR_A(i) _V2D::mat[i] = v; return *this;}
|
|
||||||
bool isSquare() const {return _V2D::cols_ == _V2D::rows_;}
|
|
||||||
bool isIdentity() const {PIMM_FOR(c, r) if ((c == r) ? _V2D::element(r, c) != Type(1) : _V2D::element(r, c) != Type(0)) return false; return true;}
|
|
||||||
bool isNull() const {PIMM_FOR_A(i) if (_V2D::mat[i] != Type(0)) return false; return true;}
|
|
||||||
bool isValid() const {return !PIVector2D<Type>::isEmpty();}
|
|
||||||
|
|
||||||
_CMatrix & operator =(const PIVector<PIVector<Type> > & v) {*this = _CMatrix(v); return *this;}
|
|
||||||
bool operator ==(const _CMatrix & sm) const {PIMM_FOR_A(i) if (_V2D::mat[i] != sm.mat[i]) return false; return true;}
|
|
||||||
bool operator !=(const _CMatrix & sm) const {return !(*this == sm);}
|
|
||||||
void operator +=(const _CMatrix & sm) {PIMM_FOR_A(i) _V2D::mat[i] += sm.mat[i];}
|
|
||||||
void operator -=(const _CMatrix & sm) {PIMM_FOR_A(i) _V2D::mat[i] -= sm.mat[i];}
|
|
||||||
void operator *=(const Type & v) {PIMM_FOR_A(i) _V2D::mat[i] *= v;}
|
|
||||||
void operator /=(const Type & v) {PIMM_FOR_A(i) _V2D::mat[i] /= v;}
|
|
||||||
_CMatrix operator -() const {_CMatrix tm(*this); PIMM_FOR_A(i) tm.mat[i] = -_V2D::mat[i]; return tm;}
|
|
||||||
_CMatrix operator +(const _CMatrix & sm) const {_CMatrix tm(*this); PIMM_FOR_A(i) tm.mat[i] += sm.mat[i]; return tm;}
|
|
||||||
_CMatrix operator -(const _CMatrix & sm) const {_CMatrix tm(*this); PIMM_FOR_A(i) tm.mat[i] -= sm.mat[i]; return tm;}
|
|
||||||
_CMatrix operator *(const Type & v) const {_CMatrix tm(*this); PIMM_FOR_A(i) tm.mat[i] *= v; return tm;}
|
|
||||||
_CMatrix operator /(const Type & v) const {_CMatrix tm(*this); PIMM_FOR_A(i) tm.mat[i] /= v; return tm;}
|
|
||||||
|
|
||||||
Type determinant(bool * ok = 0) const {
|
|
||||||
_CMatrix m(*this);
|
|
||||||
bool k;
|
|
||||||
Type ret = Type(0);
|
|
||||||
m.toUpperTriangular(&k);
|
|
||||||
if (ok) *ok = k;
|
|
||||||
if (!k) return ret;
|
|
||||||
ret = Type(1);
|
|
||||||
for (uint c = 0; c < _V2D::cols_; ++c)
|
|
||||||
for (uint r = 0; r < _V2D::rows_; ++r)
|
|
||||||
if (r == c)
|
|
||||||
ret *= m.element(r, c);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
Type trace(bool * ok = 0) const {
|
|
||||||
Type ret = Type(0);
|
|
||||||
if (!isSquare()) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
for (uint i = 0; i < _V2D::cols_; ++i) {
|
|
||||||
ret += _V2D::element(i, i);
|
|
||||||
}
|
|
||||||
if (ok != 0) *ok = true;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
_CMatrix & toUpperTriangular(bool * ok = 0) {
|
|
||||||
if (!isSquare()) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
_CMatrix smat(*this);
|
|
||||||
bool ndet;
|
|
||||||
uint crow;
|
|
||||||
Type mul;
|
|
||||||
for (uint i = 0; i < _V2D::cols_; ++i) {
|
|
||||||
ndet = true;
|
|
||||||
for (uint j = 0; j < _V2D::rows_; ++j) if (smat.element(i, j) != 0) ndet = false;
|
|
||||||
if (ndet) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (uint i = 0; i < _V2D::cols_; ++i) {
|
|
||||||
crow = i;
|
|
||||||
while (smat.element(i, i) == Type(0))
|
|
||||||
smat.swapRows(i, ++crow);
|
|
||||||
for (uint j = i + 1; j < _V2D::rows_; ++j) {
|
|
||||||
mul = smat.element(i, j) / smat.element(i, i);
|
|
||||||
for (uint k = i; k < _V2D::cols_; ++k) smat.element(k, j) -= mul * smat.element(k, i);
|
|
||||||
}
|
|
||||||
if (i < _V2D::cols_ - 1) {
|
|
||||||
if (_PIMathMatrixNullCompare(smat.element(i+1, i+1))) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ok != 0) *ok = true;
|
|
||||||
_V2D::mat.swap(smat.mat);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
_CMatrix & invert(bool * ok = 0, _CMCol * sv = 0) {
|
|
||||||
if (!isSquare()) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
_CMatrix mtmp = _CMatrix::identity(_V2D::cols_, _V2D::rows_), smat(*this);
|
|
||||||
bool ndet;
|
|
||||||
uint crow;
|
|
||||||
Type mul, iddiv;
|
|
||||||
for (uint i = 0; i < _V2D::cols_; ++i) {
|
|
||||||
ndet = true;
|
|
||||||
for (uint j = 0; j < _V2D::rows_; ++j) if (smat.element(i, j) != Type(0)) ndet = false;
|
|
||||||
if (ndet) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (uint i = 0; i < _V2D::cols_; ++i) {
|
|
||||||
crow = i;
|
|
||||||
while (smat.element(i, i) == Type(0)) {
|
|
||||||
++crow;
|
|
||||||
smat.swapRows(i, crow);
|
|
||||||
mtmp.swapRows(i, crow);
|
|
||||||
if (sv != 0) sv->swap(i, crow);
|
|
||||||
}
|
|
||||||
for (uint j = i + 1; j < _V2D::rows_; ++j) {
|
|
||||||
mul = smat.element(i, j) / smat.element(i, i);
|
|
||||||
for (uint k = i; k < _V2D::cols_; ++k) smat.element(k, j) -= mul * smat.element(k, i);
|
|
||||||
for (uint k = 0; k < _V2D::cols_; ++k) mtmp.element(k, j) -= mul * mtmp.element(k, i);
|
|
||||||
if (sv != 0) (*sv)[j] -= mul * (*sv)[i];
|
|
||||||
}
|
|
||||||
if (i < _V2D::cols_ - 1) {
|
|
||||||
if (_PIMathMatrixNullCompare(smat.element(i+1, i+1))) {
|
|
||||||
if (ok != 0) *ok = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iddiv = smat.element(i, i);
|
|
||||||
for (uint j = i; j < _V2D::cols_; ++j) smat.element(j, i) /= iddiv;
|
|
||||||
for (uint j = 0; j < _V2D::cols_; ++j) mtmp.element(j, i) /= iddiv;
|
|
||||||
if (sv != 0) (*sv)[i] /= iddiv;
|
|
||||||
}
|
|
||||||
for (uint i = _V2D::cols_ - 1; i > 0; --i) {
|
|
||||||
for (uint j = 0; j < i; ++j) {
|
|
||||||
mul = smat.element(i, j);
|
|
||||||
smat.element(i, j) -= mul;
|
|
||||||
for (uint k = 0; k < _V2D::cols_; ++k) mtmp.element(k, j) -= mul * mtmp.element(k, i);
|
|
||||||
if (sv != 0) (*sv)[j] -= mul * (*sv)[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ok != 0) *ok = true;
|
|
||||||
PIVector2D<Type>::swap(mtmp);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
_CMatrix inverted(bool * ok = 0) const {_CMatrix tm(*this); tm.invert(ok); return tm;}
|
|
||||||
_CMatrix transposed() const {_CMatrix tm(_V2D::rows_, _V2D::cols_); PIMM_FOR(c, r) tm.element(c, r) = _V2D::element(r, c); return tm;}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef PIP_STD_IOSTREAM
|
|
||||||
template<typename Type>
|
|
||||||
inline std::ostream & operator <<(std::ostream & s, const PIMathMatrix<Type> & m) {s << "{"; for (uint r = 0; r < m.rows(); ++r) { for (uint c = 0; c < m.cols(); ++c) { s << m.element(r, c); if (c < m.cols() - 1 || r < m.rows() - 1) s << ", ";} if (r < m.rows() - 1) s << std::endl << " ";} s << "}"; return s;}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename Type>
|
|
||||||
inline PICout operator <<(PICout s, const PIMathMatrix<Type> & m) {s << "Matrix{"; for (uint r = 0; r < m.rows(); ++r) { for (uint c = 0; c < m.cols(); ++c) { s << m.element(r, c); if (c < m.cols() - 1 || r < m.rows() - 1) s << ", ";} if (r < m.rows() - 1) s << PICoutManipulators::NewLine << " ";} s << "}"; return s;}
|
|
||||||
|
|
||||||
template<typename Type>
|
|
||||||
inline PIByteArray & operator <<(PIByteArray & s, const PIMathMatrix<Type> & v) {s << (const PIVector2D<Type> &)v; return s;}
|
|
||||||
template<typename Type>
|
|
||||||
inline PIByteArray & operator >>(PIByteArray & s, PIMathMatrix<Type> & v) {s >> (PIVector2D<Type> &)v; return s;}
|
|
||||||
|
|
||||||
|
|
||||||
/// Multiply matrices {CR x Rows0} on {Cols1 x CR}, result is {Cols1 x Rows0}
|
|
||||||
template<typename Type>
|
|
||||||
inline PIMathMatrix<Type> operator *(const PIMathMatrix<Type> & fm,
|
|
||||||
const PIMathMatrix<Type> & sm) {
|
|
||||||
uint cr = fm.cols(), rows0 = fm.rows(), cols1 = sm.cols();
|
|
||||||
PIMathMatrix<Type> tm(cols1, rows0);
|
|
||||||
if (fm.cols() != sm.rows()) return tm;
|
|
||||||
Type t;
|
|
||||||
for (uint j = 0; j < rows0; ++j) {
|
|
||||||
for (uint i = 0; i < cols1; ++i) {
|
|
||||||
t = Type(0);
|
|
||||||
for (uint k = 0; k < cr; ++k)
|
|
||||||
t += fm.element(j, k) * sm.element(k, i);
|
|
||||||
tm.element(j, i) = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Multiply matrix {Cols x Rows} on vector {Cols}, result is vector {Rows}
|
|
||||||
template<typename Type>
|
|
||||||
inline PIMathVector<Type> operator *(const PIMathMatrix<Type> & fm,
|
|
||||||
const PIMathVector<Type> & sv) {
|
|
||||||
uint c = fm.cols(), r = fm.rows();
|
|
||||||
PIMathVector<Type> tv(r);
|
|
||||||
if (c != sv.size()) return tv;
|
|
||||||
Type t;
|
|
||||||
for (uint j = 0; j < r; ++j) {
|
|
||||||
t = Type(0);
|
|
||||||
for (uint i = 0; i < c; ++i)
|
|
||||||
t += fm.element(j, i) * sv[i];
|
|
||||||
tv[j] = t;
|
|
||||||
}
|
|
||||||
return tv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Multiply vector {Rows} on matrix {Rows x Cols}, result is vector {Cols}
|
|
||||||
template<typename Type>
|
|
||||||
inline PIMathVector<Type> operator *(const PIMathVector<Type> & sv,
|
|
||||||
const PIMathMatrix<Type> & fm) {
|
|
||||||
uint c = fm.cols(), r = fm.rows();
|
|
||||||
PIMathVector<Type> tv(c);
|
|
||||||
Type t;
|
|
||||||
for (uint j = 0; j < c; ++j) {
|
|
||||||
t = Type(0);
|
|
||||||
for (uint i = 0; i < r; ++i)
|
|
||||||
t += fm.element(i, j) * sv[i];
|
|
||||||
tv[j] = t;
|
|
||||||
}
|
|
||||||
return tv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Multiply value(T) on matrix {Rows x Cols}, result is vector {Rows}
|
|
||||||
template<typename Type>
|
|
||||||
inline PIMathMatrix<Type> operator *(const Type & x, const PIMathMatrix<Type> & v) {
|
|
||||||
return v * x;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef PIMathMatrix<int> PIMathMatrixi;
|
|
||||||
typedef PIMathMatrix<double> PIMathMatrixd;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
PIMathMatrix<complex<T> > hermitian(const PIMathMatrix<complex<T> > & m) {
|
|
||||||
PIMathMatrix<complex<T> > ret(m);
|
|
||||||
for (uint r = 0; r < ret.rows(); ++r) for (uint c = 0; c < ret.cols(); ++c) ret.element(r, c).imag(-(ret.element(r, c).imag()));
|
|
||||||
return ret.transposed();
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef PIMM_FOR
|
|
||||||
#undef PIMM_FOR_I
|
|
||||||
#undef PIMM_FOR_A
|
|
||||||
#undef PIMM_FOR_C
|
|
||||||
#undef PIMM_FOR_R
|
|
||||||
|
|
||||||
#endif // PIMATHMATRIX_H
|
|
||||||
@@ -17,24 +17,33 @@
|
|||||||
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 "piccloudclient.h"
|
#include "picloudclient.h"
|
||||||
|
|
||||||
|
|
||||||
PICloudClient::PICloudClient() {
|
PICloudClient::PICloudClient(const PIString & path, PIIODevice::DeviceMode mode) : PIIODevice(path, mode), eth(PIEthernet::TCP_Client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
81
libs/cloud/picloudserver.cpp
Normal file
81
libs/cloud/picloudserver.cpp
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "picloudserver.h"
|
||||||
|
|
||||||
|
|
||||||
|
PICloudServer::PICloudServer(const PIString & path, PIIODevice::DeviceMode mode) : PIIODevice(path, mode), eth(PIEthernet::TCP_Client) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PICloudServer::~PICloudServer() {
|
||||||
|
stop();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PICloudServer::openDevice() {
|
||||||
|
piCout << "PICloudServer open device" << path();
|
||||||
|
bool op = eth.connect(path(), false);
|
||||||
|
if (op) {
|
||||||
|
CONNECTL(ð, disconnected, [this](bool){opened_ = false;});
|
||||||
|
CONNECTU(ð, threadedReadEvent, this, readed);
|
||||||
|
eth.startThreadedRead();
|
||||||
|
sendStart();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
eth.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PICloudServer::closeDevice() {
|
||||||
|
return eth.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PICloudServer::readDevice(void * read_to, int max_size) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PICloudServer::writeDevice(const void * data, int max_size) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PICloudServer::sendStart() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PICloudServer::Client::Client(PICloudServer * srv) : server(srv) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PICloudServer::Client::openDevice() {
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PICloudServer::readed(uchar *data, int size) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,12 +17,26 @@
|
|||||||
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 "piccloudtcp.h"
|
#include "picloudtcp.h"
|
||||||
#include "picrypt.h"
|
#include "picrypt.h"
|
||||||
|
#include "pichunkstream.h"
|
||||||
|
|
||||||
|
|
||||||
const char hash_def_key[] = "_picrypt_";
|
const char hash_def_key[] = "_picrypt_";
|
||||||
|
|
||||||
|
|
||||||
PICloudTCP::PICloudTCP() {
|
PIByteArray & operator <<(PIByteArray & s, const PICloud::Header & v) {
|
||||||
|
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() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/*! \file piccloudclient.h
|
/*! \file picloudclient.h
|
||||||
* \brief PICloud Client
|
* \brief PICloud Client
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
@@ -20,13 +20,11 @@
|
|||||||
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 PICCLOUDCLIENT_H
|
#ifndef PICLOUDCLIENT_H
|
||||||
#define PICCLOUDCLIENT_H
|
#define PICLOUDCLIENT_H
|
||||||
|
|
||||||
#include "pip_cloud_export.h"
|
#include "pip_cloud_export.h"
|
||||||
#include "piiodevice.h"
|
#include "piethernet.h"
|
||||||
|
|
||||||
class PIEthernet;
|
|
||||||
|
|
||||||
|
|
||||||
class PIP_CLOUD_EXPORT PICloudClient : public PIIODevice
|
class PIP_CLOUD_EXPORT PICloudClient : public PIIODevice
|
||||||
@@ -34,7 +32,7 @@ class PIP_CLOUD_EXPORT PICloudClient : public PIIODevice
|
|||||||
PIIODEVICE(PICloudClient)
|
PIIODEVICE(PICloudClient)
|
||||||
public:
|
public:
|
||||||
//!
|
//!
|
||||||
explicit PICloudClient();
|
explicit PICloudClient(const PIString & path = PIString(), PIIODevice::DeviceMode mode = PIIODevice::ReadWrite);
|
||||||
virtual ~PICloudClient();
|
virtual ~PICloudClient();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -42,7 +40,10 @@ protected:
|
|||||||
bool closeDevice();
|
bool closeDevice();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PIEthernet * eth;
|
int readDevice(void * read_to, int max_size);
|
||||||
|
int writeDevice(const void * data, int max_size);
|
||||||
|
|
||||||
|
PIEthernet eth;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PICCLOUDCLIENT_H
|
#endif // PICLOUDCLIENT_H
|
||||||
@@ -20,8 +20,8 @@
|
|||||||
#ifndef PICLOUDMODULE_H
|
#ifndef PICLOUDMODULE_H
|
||||||
#define PICLOUDMODULE_H
|
#define PICLOUDMODULE_H
|
||||||
|
|
||||||
#include "piccloudtcp.h"
|
#include "picloudtcp.h"
|
||||||
#include "piccloudclient.h"
|
#include "picloudclient.h"
|
||||||
#include "piccloudserver.h"
|
#include "picloudserver.h"
|
||||||
|
|
||||||
#endif // PICLOUDMODULE_H
|
#endif // PICLOUDMODULE_H
|
||||||
65
libs/main/cloud/picloudserver.h
Normal file
65
libs/main/cloud/picloudserver.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/*! \file picloudserver.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 PICLOUDSERVER_H
|
||||||
|
#define PICLOUDSERVER_H
|
||||||
|
|
||||||
|
#include "pip_cloud_export.h"
|
||||||
|
#include "piethernet.h"
|
||||||
|
|
||||||
|
|
||||||
|
class PIP_CLOUD_EXPORT PICloudServer : public PIIODevice
|
||||||
|
{
|
||||||
|
PIIODEVICE(PICloudServer)
|
||||||
|
public:
|
||||||
|
//!
|
||||||
|
explicit PICloudServer(const PIString & path = PIString(), PIIODevice::DeviceMode mode = PIIODevice::ReadWrite);
|
||||||
|
virtual ~PICloudServer();
|
||||||
|
|
||||||
|
class Client : public PIIODevice {
|
||||||
|
PIIODEVICE(PICloudServer::Client)
|
||||||
|
public:
|
||||||
|
Client(PICloudServer * srv = nullptr);
|
||||||
|
protected:
|
||||||
|
bool openDevice();
|
||||||
|
private:
|
||||||
|
PICloudServer * server;
|
||||||
|
};
|
||||||
|
|
||||||
|
EVENT1(newConnection, PICloudServer::Client * , client)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool openDevice();
|
||||||
|
bool closeDevice();
|
||||||
|
int readDevice(void * read_to, int max_size);
|
||||||
|
int writeDevice(const void * data, int max_size);
|
||||||
|
|
||||||
|
private:
|
||||||
|
EVENT_HANDLER2(void, readed, uchar * , data, int, size);
|
||||||
|
void sendStart();
|
||||||
|
|
||||||
|
PIEthernet eth;
|
||||||
|
PIVector<Client> clients;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PICLOUDSERVER_H
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/*! \file piccloudtcp.h
|
/*! \file picloudtcp.h
|
||||||
* \brief PICloud TCP transport
|
* \brief PICloud TCP transport
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
@@ -20,20 +20,45 @@
|
|||||||
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 PICCLOUDTCP_H
|
#ifndef PICLOUDTCP_H
|
||||||
#define PICCLOUDTCP_H
|
#define PICLOUDTCP_H
|
||||||
|
|
||||||
#include "pip_cloud_export.h"
|
#include "pip_cloud_export.h"
|
||||||
#include "pistring.h"
|
#include "pistring.h"
|
||||||
|
|
||||||
class PIP_CLOUD_EXPORT PICloudTCP {
|
|
||||||
public:
|
|
||||||
//!
|
|
||||||
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:
|
||||||
|
TCP();
|
||||||
|
|
||||||
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
|
||||||
@@ -32,6 +32,10 @@
|
|||||||
* \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
|
||||||
@@ -371,4 +375,7 @@
|
|||||||
* \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.
|
||||||
|
|
||||||
* */
|
* */
|
||||||
@@ -42,6 +42,8 @@
|
|||||||
#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
|
||||||
@@ -39,6 +39,11 @@ 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);
|
||||||
@@ -49,6 +54,7 @@ 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() {
|
||||||
@@ -161,7 +167,6 @@ 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];}
|
||||||
@@ -206,7 +206,6 @@ 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) {
|
||||||
@@ -364,6 +363,13 @@ 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;
|
||||||
@@ -44,11 +44,17 @@ 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() {
|
||||||
@@ -161,7 +167,6 @@ 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];}
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
#ifndef PIBASE_H
|
#ifndef PIBASE_H
|
||||||
#define PIBASE_H
|
#define PIBASE_H
|
||||||
|
|
||||||
#include "piversion.h"
|
#include "pip_version.h"
|
||||||
#include "piplatform.h"
|
#include "piplatform.h"
|
||||||
#include "pip_export.h"
|
#include "pip_export.h"
|
||||||
#include "pip_defs.h"
|
#include "pip_defs.h"
|
||||||
@@ -292,13 +292,6 @@ 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 */
|
||||||
@@ -454,20 +447,7 @@ template<> inline float piLetobe(const float & v) {
|
|||||||
return a.f;
|
return a.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEPRECATED inline ushort letobe_s(const ushort & v) {return (v << 8) | (v >> 8);}
|
/// \brief Generic hash function, implements murmur3/32 algorithm
|
||||||
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;
|
||||||
@@ -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(), v.size());
|
memcpy(v.data(), s.data(), sz);
|
||||||
s.remove(0, v.size());
|
s.remove(0, sz);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -80,11 +80,36 @@ 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();
|
||||||
while (!atEnd()) {
|
if (!data_) return;
|
||||||
read();
|
int pos = 0, sz = data_->size_s();
|
||||||
data_map[last_id] = last_data;
|
uint csz = 0, cid = 0;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +136,7 @@ void PIChunkStream::_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint PIChunkStream::readVInt(PIByteArray & s) {
|
uint PIChunkStream::readVInt(PIByteArray & s, uchar * bytes_cnt) {
|
||||||
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;
|
||||||
@@ -122,6 +147,7 @@ uint PIChunkStream::readVInt(PIByteArray & s) {
|
|||||||
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)));
|
||||||
@@ -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
|
//! Read all chunks from stream. This function just index input data
|
||||||
void readAll();
|
void readAll();
|
||||||
|
|
||||||
//! Returns last readed chunk ID
|
//! Returns last readed chunk ID
|
||||||
@@ -100,7 +100,9 @@ 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 {
|
||||||
PIByteArray ba = data_map.value(id);
|
PIPair<int, int> pos = 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;
|
||||||
@@ -109,13 +111,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
void _init();
|
void _init();
|
||||||
|
|
||||||
static uint readVInt(PIByteArray & s);
|
static uint readVInt(PIByteArray & s, uchar * bytes = 0);
|
||||||
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, PIByteArray> data_map;
|
PIMap<int, PIPair<int, int>> 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);
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user