From 3ac1a5af2aca35dd89e01a7c5405ff6c79fe0fdc Mon Sep 17 00:00:00 2001 From: Jean-Jacques Lafay Date: Tue, 17 Jun 2025 16:28:28 +0200 Subject: [PATCH 1/2] Improve use through installed package When an idl has been installed, users of the corresponding package should be able to find the generated headers (or the idl if imported) just by depending on xxx_idl_[host|enclave]. --- cmake/FindRPCGenerator.cmake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cmake/FindRPCGenerator.cmake b/cmake/FindRPCGenerator.cmake index 296b3171..b867b20f 100644 --- a/cmake/FindRPCGenerator.cmake +++ b/cmake/FindRPCGenerator.cmake @@ -133,6 +133,18 @@ function( else() message("target ${dep}_generate does not exist so skipped") endif() + # when installed (used through a package) idl dependencies can be found through their *_host (or *_enclave) targets: + # we know that /${param_install_dir}/interfaces/include is in the target's include directories, and + # that the idls themselves are in /${param_install_dir} + if(TARGET ${dep}_host) + get_target_property(include_dirs ${dep}_host INTERFACE_INCLUDE_DIRECTORIES) + foreach(include_dir ${include_dirs}) + if(${include_dir} MATCHES "/interfaces/include$") + string(REPLACE "/interfaces/include" "" idl_dir ${include_dir}) + set(PATHS_PARAMS ${PATHS_PARAMS} --path ${idl_dir}) + endif() + endforeach() + endif() endforeach() if(NOT ${namespace} STREQUAL "") @@ -402,6 +414,7 @@ function( endif() if(params_install_dir) + # install the files when creating a package install(DIRECTORY "$" DESTINATION ${params_install_dir}/interfaces/include) install(DIRECTORY "$" @@ -409,5 +422,9 @@ function( install(DIRECTORY "$" DESTINATION ${params_install_dir}/interfaces/check_sums) install(FILES "$" DESTINATION ${params_install_dir}/${idl_relative_dir}) + # make sure the files can be found when used through a package + target_include_directories(${name}_idl_host INTERFACE $) + target_include_directories(${name}_idl_enclave + INTERFACE $) endif() endfunction() From d0c9fbf1a8e9b4bd9341ff713b375c2de30c0fb4 Mon Sep 17 00:00:00 2001 From: Rui Almeida Date: Mon, 9 Jun 2025 14:57:46 +0100 Subject: [PATCH 2/2] Change assigned_value from int to int64_t to prevent overflow This would happen in a pattern where an (int-based) enum is given a my_enum::MAX value set to MAX_INT. --- generator/src/json_schema/generator.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generator/src/json_schema/generator.cpp b/generator/src/json_schema/generator.cpp index fa5641e8..27c6c9df 100644 --- a/generator/src/json_schema/generator.cpp +++ b/generator/src/json_schema/generator.cpp @@ -2,6 +2,7 @@ #include "cpp_parser.h" // Your parser API header #include "json_schema/generator.h" #include "json_schema/writer.h" +#include #include #include #include @@ -335,7 +336,7 @@ namespace json_schema_generator writer.write_string_property("type", "integer"); writer.write_key("enum"); writer.open_array(); - int next_value = 0; + int64_t next_value = 0; std::vector value_descriptions; using underlying = std::underlying_type::type; const entity_type ALL_POSSIBLE_MEMBERS @@ -348,7 +349,7 @@ namespace json_schema_generator std::string enum_value_name = clean_type_name(element_ptr->get_name()); if (!enum_value_name.empty() && enum_value_name.find_first_of("{}[]() \t\n\r") == std::string::npos) { - int assigned_value = next_value; + int64_t assigned_value = next_value; const function_entity* value_entity = dynamic_cast(element_ptr.get()); if (value_entity) { @@ -357,7 +358,7 @@ namespace json_schema_generator { try { - assigned_value = std::stoi(explicit_value_str); + assigned_value = std::stoll(explicit_value_str); } catch (const std::exception& e) {