[DEV] uptate new lutin declaration model

This commit is contained in:
Edouard DUPIN 2021-10-25 07:51:00 +02:00
parent 68a25bd37a
commit 09a97ba3c2
8 changed files with 365 additions and 157 deletions

5
.gitignore vendored
View File

@ -1,3 +1,8 @@
__pycache__
.bck
out
target
build
###################################
# folders

208
CMakeLists.txt Normal file
View File

@ -0,0 +1,208 @@
cmake_minimum_required(VERSION 3.20)
if (WIN32)
set(CPACK_GENERATOR "ZIP")
else()
set(CPACK_GENERATOR "TGZ")
endif()
set(CPACK_VERBATIM_VARIABLES YES)
include(CPack)
function(json_get_list OUT_VAR INPUT_JSON VARIABLE)
string(JSON LIST_JSON_ELEMENTS ERROR_VARIABLE ${VARIABLE} GET ${INPUT_JSON} ${VARIABLE})
if (${LIST_JSON_ELEMENTS} EQUAL ${VARIABLE}-NOTFOUND)
set("${OUT_VAR}" PARENT_SCOPE)
retrun()
endif()
#message("LIST_JSON_ELEMENTS : ${LIST_JSON_ELEMENTS}")
string(JSON LENGTH_VALUE LENGTH ${LIST_JSON_ELEMENTS})
#message("LENGTH_VALUE : ${LENGTH_VALUE}")
if (${LENGTH_VALUE} EQUAL 0)
set("${OUT_VAR}" PARENT_SCOPE)
retrun()
endif()
set(OUT_LIST)
MATH(EXPR LENGTH_VALUE "${LENGTH_VALUE}-1")
foreach(IDX RANGE ${LENGTH_VALUE})
string(JSON ELEM GET ${LIST_JSON_ELEMENTS} ${IDX})
#message(" - : ${ELEM}")
list(APPEND OUT_LIST ${ELEM})
endforeach()
#message("OUT_LIST : ${OUT_LIST}")
set("${OUT_VAR}" ${OUT_LIST} PARENT_SCOPE)
endfunction()
function(json_get_element OUT_VAR INPUT_JSON VARIABLE)
string(JSON ELEMENT ERROR_VARIABLE ${VARIABLE} GET ${INPUT_JSON} ${VARIABLE})
if (${ELEMENT} EQUAL ${VARIABLE}-NOTFOUND)
set("${OUT_VAR}" PARENT_SCOPE)
retrun()
endif()
set("${OUT_VAR}" ${ELEMENT} PARENT_SCOPE)
endfunction()
# add the executable
# add_executable(Tutorial tutorial.cxx)
set(LIBRARY_NAME "elog")
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/GLD_${LIBRARY_NAME}.json
)
# Read the JSON file.
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/GLD_${LIBRARY_NAME}.json MY_JSON_STRING)
# Loop through each element of the JSON array (indices 0 though 1).
json_get_element(LIBRARY_TYPE ${MY_JSON_STRING} "type")
json_get_element(LIBRARY_GROUP_ID ${MY_JSON_STRING} "group-id")
json_get_element(LIBRARY_DECRIPTION ${MY_JSON_STRING} "description")
json_get_element(LIBRARY_LICENCE ${MY_JSON_STRING} "licence")
json_get_element(LIBRARY_LICENCE_FILE ${MY_JSON_STRING} "licence-file")
json_get_element(LIBRARY_MAINTAINER ${MY_JSON_STRING} "maintainer")
json_get_element(LIBRARY_AUTHORS ${MY_JSON_STRING} "authors")
json_get_element(LIBRARY_VERSION ${MY_JSON_STRING} "version")
json_get_element(LIBRARY_SOURCES ${MY_JSON_STRING} "sources")
json_get_element(LIBRARY_HEADERS ${MY_JSON_STRING} "headers")
json_get_list(LIBRARY_PATH ${MY_JSON_STRING} "path")
json_get_element(LIBRARY_COMPILATION_VERSION ${MY_JSON_STRING} "compilation-version")
json_get_list(LIBRARY_DEPENDENCY ${MY_JSON_STRING} "dependency")
json_get_element(LIBRARY_PLATFORM ${MY_JSON_STRING} "platform")
json_get_element(LIBRARY_COMPILATION_VERSION_LANGUAGE ${MY_JSON_STRING} "language")
json_get_element(LIBRARY_COMPILATION_VERSION_VALUE ${MY_JSON_STRING} "version")
message("LIBRARY_NAME : ${LIBRARY_NAME}")
message("LIBRARY_TYPE : ${LIBRARY_TYPE}")
message("LIBRARY_GROUP_ID : ${LIBRARY_GROUP_ID}")
message("LIBRARY_DECRIPTION : ${LIBRARY_DECRIPTION}")
message("LIBRARY_LICENCE : ${LIBRARY_LICENCE}")
message("LIBRARY_LICENCE_FILE : ${LIBRARY_LICENCE_FILE}")
message("LIBRARY_MAINTAINER : ${LIBRARY_MAINTAINER}")
message("LIBRARY_AUTHORS : ${LIBRARY_AUTHORS}")
message("LIBRARY_VERSION : ${LIBRARY_VERSION}")
message("LIBRARY_COMPILATION_VERSION : ${LIBRARY_COMPILATION_VERSION_LANGUAGE} : ${LIBRARY_COMPILATION_VERSION_VALUE}")
#message("LIBRARY_SOURCES: ${LIBRARY_SOURCES}")
#message("LIBRARY_HEADERS: ${LIBRARY_HEADERS}")
message("LIBRARY_PATH: ${LIBRARY_PATH}")
#message("LIBRARY_COMPILATION_VERSION: ${LIBRARY_COMPILATION_VERSION}")
message("LIBRARY_DEPENDENCY: ${LIBRARY_DEPENDENCY}")
#message("LIBRARY_PLATFORM: ${LIBRARY_PLATFORM}")
json_get_list(SOURCES_LIST ${LIBRARY_SOURCES} "list")
message("SOURCES_LIST: ${SOURCES_LIST}")
json_get_list(EXPORT_HEADER_LIST ${LIBRARY_HEADERS} "list")
json_get_element(EXPORT_HEADER_LIST_PATH ${LIBRARY_HEADERS} "destination-path")
message("EXPORT_HEADER_LIST: ${EXPORT_HEADER_LIST}")
message("EXPORT_HEADER_LIST_PATH: ${EXPORT_HEADER_LIST_PATH}")
string(JSON LIBRARY_PLOP ERROR_VARIABLE "qsdfqsdfqsdf" GET ${MY_JSON_STRING} "qsdfqsdfqsdf")
#string(JSON LIBRARY_MEMBERS MEMBER ${MY_JSON_STRING} )
#message("LIBRARY_MEMBERS : ${LIBRARY_MEMBERS}")
message("LIBRARY_PLOP : ${LIBRARY_PLOP}")
string(REPLACE "-" "_" LIBRARY_NAME222 ${LIBRARY_NAME})
set(LIBRARY_NAME222 ${LIBRARY_NAME})
project(${LIBRARY_NAME222} VERSION ${LIBRARY_VERSION})
set(${LIBRARY_NAME222} PROPERTIES CPACK_PACKAGE_VERSION ${LIBRARY_VERSION})
add_library(${LIBRARY_NAME222}_OBJ OBJECT ${SOURCES_LIST})
# shared libraries need PIC
set_property(TARGET ${LIBRARY_NAME222}_OBJ PROPERTY POSITION_INDEPENDENT_CODE 1)
#set_target_properties(${LIBRARY_NAME222} PROPERTIES PUBLIC_HEADER ${EXPORT_HEADER_LIST})
target_include_directories(${LIBRARY_NAME222}_OBJ PUBLIC
${LIBRARY_PATH}
)
list(APPEND CMAKE_MODULE_PATH "/home/heero/dev/perso/framework/atria-soft/generated_package/etk-core-1.5.3-/cmake/etk-core/")
find_package("etk-core" REQUIRED)
add_library(${LIBRARY_NAME222}_dynamic SHARED $<TARGET_OBJECTS:${LIBRARY_NAME222}_OBJ>)
add_library(${LIBRARY_NAME222}_static STATIC $<TARGET_OBJECTS:${LIBRARY_NAME222}_OBJ>)
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
if (NOT WIN32)
set_target_properties(${LIBRARY_NAME222}_static PROPERTIES OUTPUT_NAME ${LIBRARY_NAME222})
endif()
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES VERSION ${LIBRARY_VERSION})
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES SOVERSION ${LIBRARY_VERSION})
set_target_properties(${LIBRARY_NAME222}_dynamic PROPERTIES DESCRIPTION ${LIBRARY_DECRIPTION})
# install dynamic & static library
install(TARGETS ${LIBRARY_NAME222}_dynamic EXPORT ${LIBRARY_NAME222}Targets
RUNTIME DESTINATION lib
)
install(TARGETS ${LIBRARY_NAME222}_static
RUNTIME DESTINATION lib)
#install(TARGETS ${LIBRARY_NAME222} EXPORT ${LIBRARY_NAME222}Targets
# LIBRARY DESTINATION lib
# ARCHIVE DESTINATION lib
# RUNTIME DESTINATION bin
# INCLUDES DESTINATION include
#)
# install exported headers
# this copy all the headers in a single folder:
#install(FILES ${EXPORT_HEADER_LIST} DESTINATION include)
# this keep the basic path for each folders:
set(BASE "${PROJECT_SOURCE_DIR}/install")
foreach(ITEM ${EXPORT_HEADER_LIST})
get_filename_component(ITEM_PATH ${ITEM} PATH)
string(REPLACE ${BASE} "" ITEM_PATH ${ITEM_PATH})
install(FILES ${ITEM}
DESTINATION "include/${ITEM_PATH}"
COMPONENT Devel)
endforeach()
#include(CMakePackageConfigHelpers)
#set(CONFIG_PACKAGE_LOCATION cmake/${LIBRARY_NAME222})
#install(EXPORT ${LIBRARY_NAME222}Targets
# FILE
# ${LIBRARY_NAME222}Targets.cmake
# NAMESPACE
# ${LIBRARY_NAME222}::
# DESTINATION
# ${CONFIG_PACKAGE_LOCATION}
#)
#message("CMAKE_INSTALL_LIBDIR===${CMAKE_INSTALL_LIBDIR}")
#include(CMakePackageConfigHelpers)
#configure_package_config_file(cmake/${LIBRARY_NAME222}Config.cmake.in
# "${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}Config.cmake"
# INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION}
# NO_SET_AND_CHECK_MACRO
# NO_CHECK_REQUIRED_COMPONENTS_MACRO)
#write_basic_package_version_file(
# "${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}ConfigVersion.cmake"
# VERSION ${LIBRARY_VERSION}
# COMPATIBILITY SameMajorVersion)
#install(
# FILES
# "${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}Config.cmake"
# "${PROJECT_BINARY_DIR}/${LIBRARY_NAME222}ConfigVersion.cmake"
# DESTINATION ${CONFIG_PACKAGE_LOCATION}
# COMPONENT Devel)

25
GLD_elog-sample.json Normal file
View File

@ -0,0 +1,25 @@
{
"type":"BINARY",
"sub-type":"SAMPLE",
"group-id":"com.atria-soft",
"description":"elog sample",
"license":"MPL-2",
"license-file":"file://LICENCE",
"maintainer":"file://authors.txt",
"author":"file://authors.txt",
"version":"file://version.txt",
"code-quality":"MEDIUM",
"source": {
"list":[
"sample/debug.cpp",
"sample/main.cpp"
]
},
"path":[
"."
],
"dependency": [
"elog"
]
}

102
GLD_elog.json Normal file
View File

@ -0,0 +1,102 @@
{
"type":"LIBRARY",
"group-id":"com.atria-soft",
"description":"Ewol Logger",
"license":"MPL-2",
"license-file":"file://LICENCE",
"maintainer":"file://authors.txt",
"author":"file://authors.txt",
"version":"file://version.txt",
"code-quality":"MEDIUM",
"source": {
"list":[
"elog/debug.cpp",
"elog/log.cpp",
"elog/elog.cpp"
]
},
"header": {
"list": [
"elog/log.hpp",
"elog/elog.hpp"
]
},
"path":[
"."
],
"compilation-version": [
{
"language": "c++",
"version": 2017
},{
"language": "c",
"version": 1999
}
],
"dependency": [
"etk-core",
{
"name": "ethread-tools",
"optional": true,
"export": true,
"flag": {
"language": "c++",
"value": "-DELOG_BUILD_ETHREAD"
}
}
],
"target": {
"IOs": {
"source": {
"list":[
"elog/logIOs.m"
]
}
}
},
"arch": {},
"mode": {
"*": {
"target": {
"*": {
"arch": {
"*": {},
"X86": {},
"AMD64": {},
"ARM-v9": {},
"ARM64": {}
}
},
"Linux": {},
"MacOs": {},
"Windows": {},
"Android": {},
"MinGw": {},
"IOs": {}
},
"arch": {}
},
"release": {
},
"debug": {
"target": {
"!Windows&!MacOs&!IOs": {
"flag": {
"language": "link",
"value": [ "-ldl", "-rdynamic" ],
"export": true
}
},
"!Windows": {
"flag": {
"language": "link",
"value": ["-ldl"],
"export": true
}
}
}
}
}
}

25
GLD_test-debug.json Normal file
View File

@ -0,0 +1,25 @@
{
"type":"LIBRARY",
"group-id":"com.atria-soft",
"description":"basic debug log for test",
"license":"MPL-2",
"license-file":"file://LICENCE",
"maintainer":"file://authors.txt",
"author":"file://authors.txt",
"version":"file://version.txt",
"code-quality":"MEDIUM",
"source": [
"test-debug/debug.cpp"
],
"header": [
"test-debug/debug.hpp"
],
"path":[
"."
],
"dependency": [
"etk-core"
]
}

View File

@ -1,43 +0,0 @@
#!/usr/bin/python
import realog.debug as debug
import lutin.tools as tools
def get_type():
return "BINARY"
def get_sub_type():
return "SAMPLE"
def get_desc():
return "elog sample"
def get_licence():
return "MPL-2"
def get_compagny_type():
return "com"
def get_compagny_name():
return "atria-soft"
def get_maintainer():
return "authors.txt"
def get_version():
return "version.txt"
def configure(target, my_module):
my_module.add_extra_flags()
# add the file to compile:
my_module.add_src_file([
'sample/debug.cpp',
'sample/main.cpp'
])
# build in C++ mode
my_module.compile_version("c++", 2011)
my_module.add_depend(['elog', 'cxx'])
my_module.add_path('sample')
return True

View File

@ -1,75 +0,0 @@
#!/usr/bin/python
import realog.debug as debug
import lutin.tools as tools
def get_type():
return "LIBRARY"
def get_desc():
return "Ewol log basic interface"
def get_licence():
return "MPL-2"
def get_compagny_type():
return "com"
def get_compagny_name():
return "atria-soft"
def get_maintainer():
return "authors.txt"
def get_version():
return "version.txt"
def configure(target, my_module):
my_module.add_extra_flags()
# add the file to compile:
my_module.add_src_file([
'elog/debug.cpp',
'elog/log.cpp',
'elog/elog.cpp'
])
if "IOs" in target.get_type():
my_module.add_src_file('elog/logIOs.m')
my_module.add_header_file([
'elog/log.hpp',
'elog/elog.hpp'
])
if target.get_mode() == "debug":
# Bor backtrace display :
if "Windows" not in target.get_type() \
and "MacOs" not in target.get_type() \
and "IOs" not in target.get_type():
# TODO : check if it is really needed ...
my_module.add_flag('link', [
'-ldl',
'-rdynamic'],
export=True)
elif "Windows" not in target.get_type():
my_module.add_flag('link', [
'-ldl'],
export=True)
# build in C++ mode
my_module.compile_version("c++", 2011)
my_module.compile_version("c", 1999)
# add dependency of the generic C++ library:
my_module.add_optionnal_depend('etk-core')
my_module.add_optionnal_depend('ethread-tools', ["c++", "-DELOG_BUILD_ETHREAD"])
if "Windows" in target.get_type():
pass
elif "Android" in target.get_type():
my_module.add_depend("SDK")
pass
else:
my_module.add_depend("pthread")
my_module.add_path(".")
return True

View File

@ -1,39 +0,0 @@
#!/usr/bin/python
import realog.debug as debug
import lutin.tools as tools
import realog.debug as debug
def get_type():
return "LIBRARY"
def get_sub_type():
return "TEST"
def get_desc():
return "basic debug log for test"
def get_licence():
return "MPL-2"
def get_compagny_type():
return "com"
def get_compagny_name():
return "atria-soft"
def get_maintainer():
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
def configure(target, my_module):
my_module.add_src_file([
'test-debug/debug.cpp'
])
my_module.add_header_file([
'test-debug/debug.hpp'
])
my_module.add_depend('etk-core')
my_module.add_path(".")
return True