xo-gc xo-cmake: simplify idl -> *.*pp codegen
This commit is contained in:
parent
9c33fa5d9f
commit
ff5186ed55
3 changed files with 9 additions and 74 deletions
|
|
@ -1677,9 +1677,6 @@ function(xo_add_genfacet)
|
|||
TARGET # Name for this generation target
|
||||
FACET # facet name
|
||||
INPUT # Input .json5 file
|
||||
OUTPUT_HPP_DIR # Directory for .hpp files
|
||||
OUTPUT_IMPL_SUBDIR # Subdirectory name for impl headers
|
||||
OUTPUT_CPP_DIR # Directory for .cpp files
|
||||
)
|
||||
set(multiValueArgs "")
|
||||
|
||||
|
|
@ -1693,41 +1690,18 @@ function(xo_add_genfacet)
|
|||
if(NOT DEFINED GF_FACET)
|
||||
message(FATAL_ERROR "xo_add_genfacet: FACET is required")
|
||||
endif()
|
||||
if(NOT DEFINED GF_OUTPUT_HPP_DIR)
|
||||
message(FATAL_ERROR "xo_add_genfacet: OUTPUT_HPP_DIR is required")
|
||||
endif()
|
||||
if(NOT DEFINED GF_OUTPUT_IMPL_SUBDIR)
|
||||
message(FATAL_ERROR "xo_add_genfacet: OUTPUT_IMPL_SUBDIR is required")
|
||||
endif()
|
||||
find_program(GENFACET_EXECUTABLE NAMES genfacet
|
||||
HINTS ${CMAKE_SOURCE_DIR}/xo-facet/codegen
|
||||
DOC "path to xo genfacet code generator"
|
||||
REQUIRED)
|
||||
message(STATUS "GENFACET_EXECUTABLE=${GENFACET_EXECUTABLE}")
|
||||
|
||||
set(generatedFiles
|
||||
${GF_OUTPUT_HPP_DIR}/${GF_FACET}.hpp
|
||||
${GF_OUTPUT_HPP_DIR}/${GF_OUTPUT_IMPL_SUBDIR}/A${GF_FACET}.hpp
|
||||
${GF_OUTPUT_HPP_DIR}/${GF_OUTPUT_IMPL_SUBDIR}/I${GF_FACET}_Any.hpp
|
||||
${GF_OUTPUT_HPP_DIR}/${GF_OUTPUT_IMPL_SUBDIR}/I${GF_FACET}_Xfer.hpp
|
||||
${GF_OUTPUT_HPP_DIR}/${GF_OUTPUT_IMPL_SUBDIR}/R${GF_FACET}.hpp)
|
||||
|
||||
set(_output_cpp_args "")
|
||||
if(DEFINED GF_OUTPUT_CPP_DIR)
|
||||
list(APPEND generatedFiles ${GF_OUTPUT_CPP_DIR}/I${GF_FACET}_Any.cpp)
|
||||
set(_output_cpp_args --output-cpp ${GF_OUTPUT_CPP_DIR})
|
||||
endif()
|
||||
|
||||
#message(STATUS "generatedFiles=${generatedFiles}")
|
||||
|
||||
# Build the genfacet command
|
||||
add_custom_command(
|
||||
OUTPUT ${generatedFiles}
|
||||
COMMAND ${GENFACET_EXECUTABLE}
|
||||
--input ${GF_INPUT}
|
||||
--output-hpp ${GF_OUTPUT_HPP_DIR}
|
||||
--output-impl-hpp ${GF_OUTPUT_IMPL_SUBDIR}
|
||||
${_output_cpp_args}
|
||||
OUTPUT ${GF_INPUT}.out
|
||||
COMMAND ${GENFACET_EXECUTABLE} --input ${GF_INPUT}
|
||||
DEPENDS ${GF_INPUT}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Generating facet source files from ${GF_INPUT}"
|
||||
|
|
@ -1735,7 +1709,7 @@ function(xo_add_genfacet)
|
|||
)
|
||||
|
||||
# Create a target for this generation
|
||||
add_custom_target(${GF_TARGET} DEPENDS ${generatedFiles})
|
||||
add_custom_target(${GF_TARGET} DEPENDS ${GF_INPUT})
|
||||
|
||||
set_property(DIRECTORY APPEND PROPERTY XO_GENFACET_TARGETS ${GF_TARGET})
|
||||
endfunction()
|
||||
|
|
@ -1770,12 +1744,6 @@ function(xo_add_genfacetimpl)
|
|||
if(NOT DEFINED GF_INPUT)
|
||||
message(FATAL_ERROR "xo_add_genfacetimpl: INPUT is required")
|
||||
endif()
|
||||
if(NOT DEFINED GF_OUTPUT_HPP_DIR)
|
||||
message(FATAL_ERROR "xo_add_genfacetimpl: OUTPUT_HPP_DIR is required")
|
||||
endif()
|
||||
if(NOT DEFINED GF_OUTPUT_IMPL_SUBDIR)
|
||||
message(FATAL_ERROR "xo_add_genfacetimpl: OUTPUT_IMPL_SUBDIR is required")
|
||||
endif()
|
||||
if(NOT DEFINED GF_FACET_DIR)
|
||||
if (NOT DEFINED GF_FACET_PKG)
|
||||
message(FATAL_ERROR "xo_add_genfacetimpl: FACET_PKG or FACET_DIR required")
|
||||
|
|
@ -1791,26 +1759,12 @@ function(xo_add_genfacetimpl)
|
|||
REQUIRED)
|
||||
message(STATUS "GENFACET_EXECUTABLE=${GENFACET_EXECUTABLE}")
|
||||
|
||||
set(generatedFiles
|
||||
${GF_OUTPUT_HPP_DIR}/${GF_OUTPUT_IMPL_SUBDIR}/I${GF_FACET}_D${GF_REPR}.hpp)
|
||||
|
||||
set(_output_cpp_args "")
|
||||
if(DEFINED GF_OUTPUT_CPP_DIR)
|
||||
list(APPEND generatedFiles ${GF_OUTPUT_CPP_DIR}/I${GF_FACET}_D${GF_REPR}.cpp)
|
||||
set(_output_cpp_args --output-cpp ${GF_OUTPUT_CPP_DIR})
|
||||
endif()
|
||||
|
||||
# Build the genfacet command.
|
||||
# But careful: can't have the same generated files in two different rules,
|
||||
# so need to remove overlaps here
|
||||
add_custom_command(
|
||||
OUTPUT ${generatedFiles}
|
||||
COMMAND ${GENFACET_EXECUTABLE}
|
||||
--input ${GF_INPUT}
|
||||
--facet-dir ${GF_FACET_DIR}
|
||||
--output-hpp ${GF_OUTPUT_HPP_DIR}
|
||||
--output-impl-hpp ${GF_OUTPUT_IMPL_SUBDIR}
|
||||
${_output_cpp_args}
|
||||
OUTPUT ${GF_INPUT}.out
|
||||
COMMAND ${GENFACET_EXECUTABLE} --input ${GF_INPUT} --facet-dir ${GF_FACET_DIR}
|
||||
DEPENDS ${GF_INPUT}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Generating facet source files from ${GF_INPUT}"
|
||||
|
|
@ -1818,7 +1772,7 @@ function(xo_add_genfacetimpl)
|
|||
)
|
||||
|
||||
# Create a target for this generation
|
||||
add_custom_target(${GF_TARGET} DEPENDS ${generatedFiles})
|
||||
add_custom_target(${GF_TARGET} DEPENDS ${GF_INPUT})
|
||||
|
||||
set_property(DIRECTORY APPEND PROPERTY XO_GENFACET_TARGETS ${GF_TARGET})
|
||||
endfunction()
|
||||
|
|
|
|||
|
|
@ -455,38 +455,21 @@ def main():
|
|||
parser.add_argument('--input', required=True, help='input IDL JSON5 file')
|
||||
# --facet-dir: only with mode=implementation
|
||||
parser.add_argument('--facet-dir', required=False, help='base dir for facet json')
|
||||
parser.add_argument('--output-cpp', required=False, help='.cpp output directory')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
idl_fname = args.input
|
||||
idl = load_idl(idl_fname)
|
||||
|
||||
# output_hpp_dir: prefer IDL, fall back to CLI
|
||||
if 'output_hpp_dir' in idl:
|
||||
output_hpp_dir = Path(idl['output_hpp_dir'])
|
||||
elif args.output_hpp:
|
||||
output_hpp_dir = Path(args.output_hpp)
|
||||
else:
|
||||
parser.error("--output-hpp required when .json5 lacks output_hpp_dir")
|
||||
output_hpp_dir = Path(idl['output_hpp_dir'])
|
||||
output_hpp_dir.mkdir(parents=False, exist_ok=True)
|
||||
|
||||
# output_impl_hpp_subdir: prefer IDL, fall back to CLI
|
||||
if 'output_impl_subdir' in idl:
|
||||
output_impl_hpp_subdir = Path(idl['output_impl_subdir'])
|
||||
elif args.output_impl_hpp:
|
||||
output_impl_hpp_subdir = Path(args.output_impl_hpp)
|
||||
else:
|
||||
parser.error("--output-impl-hpp required when .json5 lacks output_impl_subdir")
|
||||
output_impl_hpp_subdir = Path(idl['output_impl_subdir'])
|
||||
output_impl_hpp_dir = output_hpp_dir / output_impl_hpp_subdir
|
||||
output_impl_hpp_dir.mkdir(parents=False, exist_ok=True)
|
||||
|
||||
if 'output_cpp_dir' in idl:
|
||||
output_cpp_dir = Path(idl['output_cpp_dir'])
|
||||
elif args.output_cpp:
|
||||
output_cpp_dir = Path(args.output_cpp)
|
||||
else:
|
||||
parser.error("--output-cpp required when .json5 lacks output_cpp_dir")
|
||||
output_cpp_dir = Path(idl['output_cpp_dir'])
|
||||
output_cpp_dir.mkdir(parents=False, exist_ok=True)
|
||||
|
||||
# setup jinja2
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ xo_add_genfacet(
|
|||
TARGET xo-gc-facet-gcobject
|
||||
FACET GCObject
|
||||
INPUT idl/GCObject.json5
|
||||
OUTPUT_HPP_DIR include/xo/gc
|
||||
OUTPUT_IMPL_SUBDIR detail
|
||||
)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue