feat: Added pyincp to build system
This commit is contained in:
@@ -11,7 +11,10 @@
|
||||
"displayName": "Default Config",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"toolchainFile": "cmake/toolchain.cmake"
|
||||
"toolchainFile": "cmake/toolchain.cmake",
|
||||
"cacheVariables": {
|
||||
"Python3_EXECUTABLE": "/home/didas/src/SAT/incp-test/.venv/bin/python"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
|
||||
@@ -80,6 +80,8 @@ include(FetchContent)
|
||||
#FetchContent_Declare(...)
|
||||
#FetchContent_MakeAvailable(...)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/incp.cmake)
|
||||
|
||||
# == Library linking ==
|
||||
#target_link_libraries(${EXECUTABLE} ...)
|
||||
|
||||
|
||||
82
app/cmake/incp.cmake
Normal file
82
app/cmake/incp.cmake
Normal file
@@ -0,0 +1,82 @@
|
||||
FetchContent_Declare(
|
||||
pyincp
|
||||
GIT_REPOSITORY git@repo.dsi.tecnico.ulisboa.pt:nanosatlab/istsat-2/incp.git
|
||||
GIT_TAG temp/CMake-integration
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(pyincp)
|
||||
|
||||
find_program(ASN1SCC NAMES asn1scc)
|
||||
|
||||
set(INCP_SCHEMA ${CMAKE_CURRENT_LIST_DIR}/../incp/schema.yml) # Can also be a directory or list of files
|
||||
set(INCP_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(ASN1_OUTPUT ${INCP_OUTPUT_DIR}/gen.asn1)
|
||||
|
||||
set(ASN1_OUTPUT ${INCP_OUTPUT_DIR}/gen.asn1)
|
||||
set(ASN1SCC_SOURCES
|
||||
${INCP_OUTPUT_DIR}/gen.c
|
||||
${INCP_OUTPUT_DIR}/asn1crt.c
|
||||
${INCP_OUTPUT_DIR}/asn1crt_encoding.c
|
||||
${INCP_OUTPUT_DIR}/asn1crt_encoding_uper.c
|
||||
)
|
||||
set(ASN1SCC_HEADERS
|
||||
${INCP_OUTPUT_DIR}/gen.h
|
||||
${INCP_OUTPUT_DIR}/asn1crt.h
|
||||
${INCP_OUTPUT_DIR}/asn1crt_encoding.h
|
||||
${INCP_OUTPUT_DIR}/asn1crt_encoding_uper.h
|
||||
)
|
||||
set(WRAPPER_SOURCE ${INCP_OUTPUT_DIR}/gen_wrapper.c)
|
||||
set(WRAPPER_HEADER ${INCP_OUTPUT_DIR}/gen_wrapper.h)
|
||||
set(INCP_SOURCES
|
||||
${ASN1SCC_SOURCES}
|
||||
${WRAPPER_SOURCE}
|
||||
)
|
||||
|
||||
# Generates the ASN1 code
|
||||
add_custom_command(
|
||||
OUTPUT ${ASN1_OUTPUT}
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E env
|
||||
PYTHONPATH=${pyincp_SOURCE_DIR}
|
||||
${INCP_GEN_COMMAND} --asn1 ${INCP_OUTPUT_DIR} ${INCP_SCHEMA}
|
||||
MAIN_DEPENDENCY ${INCP_SCHEMA}
|
||||
COMMENT "INCP: Generating ASN1 definition"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Compiles the ASN1 code to C
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${ASN1SCC_SOURCES}
|
||||
${ASN1SCC_HEADERS}
|
||||
COMMAND
|
||||
${ASN1SCC} -c -uPER --slim --word-size 4 --handle-empty-sequences -if BitStream_AppendByteArray -if BitStream_DecodeConstraintWholeNumber -if BitStream_EncodeConstraintWholeNumber -o ${INCP_OUTPUT_DIR} ${ASN1_OUTPUT}
|
||||
MAIN_DEPENDENCY ${ASN1_OUTPUT}
|
||||
COMMENT "INCP: Compiling ASN1 definition"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Generates the C wrapper
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${WRAPPER_SOURCE}
|
||||
${WRAPPER_HEADER}
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E env
|
||||
PYTHONPATH=${pyincp_SOURCE_DIR}
|
||||
${INCP_GEN_COMMAND} --c ${INCP_OUTPUT_DIR} ${INCP_SCHEMA}
|
||||
MAIN_DEPENDENCY ${INCP_SCHEMA}
|
||||
COMMENT "INCP: Generating C wrapper"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Integrate generated artifacts with the project's build
|
||||
target_sources(${EXECUTABLE} PRIVATE
|
||||
${ASN1SCC_SOURCES}
|
||||
${WRAPPER_SOURCE}
|
||||
)
|
||||
|
||||
target_include_directories(${EXECUTABLE} PRIVATE
|
||||
${INCP_OUTPUT_DIR}
|
||||
)
|
||||
10
app/incp/schema.yml
Normal file
10
app/incp/schema.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
modules:
|
||||
- name: mod_a
|
||||
enums: []
|
||||
variables:
|
||||
- name: var_a
|
||||
doc: Var a
|
||||
type: I32
|
||||
reports: []
|
||||
commands: []
|
||||
events: []
|
||||
Reference in New Issue
Block a user