Skip to content

Commit

Permalink
Further restructuring
Browse files Browse the repository at this point in the history
Moved and renamed libidlc files to their own folder
Moved and renamed generator_common files to their own folder
Moved idlc files to their own folder

Signed-off-by: Martijn Reicher <[email protected]>
  • Loading branch information
reicheratwork committed Aug 4, 2023
1 parent 3e1245a commit dca5787
Show file tree
Hide file tree
Showing 25 changed files with 361 additions and 299 deletions.
2 changes: 1 addition & 1 deletion src/core/ddsc/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ if(ENABLE_SHM)
endif()

target_link_libraries(cunit_ddsc PRIVATE
RoundTrip Space TypesArrayKey WriteTypes InstanceHandleTypes RWData CreateWriter DataRepresentationTypes MinXcdrVersion CdrStreamOptimize CdrStreamSkipDefault CdrStreamKeySize CdrStreamKeyExt SerdataData ddsc)
RoundTrip Space TypesArrayKey WriteTypes InstanceHandleTypes RWData CreateWriter DataRepresentationTypes MinXcdrVersion CdrStreamOptimize CdrStreamSkipDefault CdrStreamKeySize CdrStreamKeyExt SerdataData ddsc idl_common)

if(ENABLE_TYPELIB)
target_link_libraries(cunit_ddsc PRIVATE
Expand Down
103 changes: 72 additions & 31 deletions src/tools/idlc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,63 +10,97 @@
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
include(GenerateExportHeader)
configure_file(src/config.h.in config.h)
configure_file(src/idlc/config.h.in config.h)

set(headers
src/plugin.h
include/idlc/plugin.h
${CMAKE_CURRENT_BINARY_DIR}/config.h)
set(sources
src/idlc.c
src/plugin.c
src/options.c)

if(ENABLE_TYPELIB)
list(APPEND headers src/descriptor_type_meta.h)
list(APPEND sources src/descriptor_type_meta.c)
endif()
src/idlc/idlc.c
src/idlc/plugin.c
src/idlc/options.c)

add_executable(idlc ${sources} ${headers})

if(MSVC)
# ignore warnings C6255 and 6263 about _alloca
target_compile_options(idlc PRIVATE /wd6255 /wd6263)
endif()
target_link_libraries(idlc PRIVATE compat idl idlpp libidlc ddsc ${CMAKE_DL_LIBS})
target_link_libraries(idlc PRIVATE compat idl idlpp ddsc idl_common ${CMAKE_DL_LIBS})

target_include_directories(
idlc PRIVATE
include
include/idlc
include/generator_common
${CMAKE_CURRENT_BINARY_DIR}
$<BUILD_INTERFACE:$<TARGET_PROPERTY:ddsc,INTERFACE_INCLUDE_DIRECTORIES>>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../core/ddsi/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../core/cdr/include>)

add_executable(${PROJECT_NAME}::idlc ALIAS idlc)

set(common_hdrs
include/generator_common/common.h
)

set(common_srcs
src/generator_common/common.c
)

if(ENABLE_TYPELIB)
list(APPEND common_hdrs include/generator_common/descriptor_type_meta.h)
list(APPEND common_hdrs src/generator_common/descriptor_type_meta.c)
endif()

add_library(
idl_common SHARED ${common_hdrs} ${common_srcs})

set_target_properties(idl_common PROPERTIES
OUTPUT_NAME "idl_common"
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
C_STANDARD 99)

if(BUILD_TESTING)
set_property(TARGET idl_common PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
else()
set_property(TARGET idl_common PROPERTY C_VISIBILITY_PRESET hidden)
endif()

target_include_directories(
idl_common
PRIVATE
include
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/generator_common>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/generator_common>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../core/ddsi/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../core/cdr/include>")

add_library(${PROJECT_NAME}::idl_common ALIAS idl_common)

generate_export_header(idl_common BASE_NAME IDL_COMMON EXPORT_FILE_NAME include/generator_common/common_export.h)

target_link_libraries(idl_common PRIVATE idl ddsc)

set(
libidlc_hdrs
include/libidlc/idl_defs.h
include/libidlc/generator.h
include/libidlc/libidlc_generator.h
${CMAKE_CURRENT_BINARY_DIR}/config.h)

set(
libidlc_srcs
src/types.h
src/descriptor.h
src/generator.h
src/descriptor.c
src/generator.c
src/types.c)

if(ENABLE_TYPE_DISCOVERY)
list(APPEND libidlc_hdrs include/libidlc/descriptor_type_meta.h)
list(APPEND libidlc_srcs src/descriptor_type_meta.c src/descriptor_type_meta.h)
endif()
src/libidlc/libidlc__types.h
src/libidlc/libidlc__descriptor.h
src/libidlc/libidlc__generator.h
src/libidlc/libidlc__descriptor.c
src/libidlc/libidlc__generator.c
src/libidlc/libidlc__types.c)

add_library(
libidlc SHARED ${libidlc_srcs} ${libidlc_hdrs})

generate_export_header(libidlc BASE_NAME IDLC EXPORT_FILE_NAME include/libidlc/libidlc_export.h)
generate_export_header(libidlc BASE_NAME LIBIDLC EXPORT_FILE_NAME include/libidlc/libidlc_export.h)

set_target_properties(libidlc PROPERTIES
OUTPUT_NAME "cycloneddsidlc"
Expand All @@ -85,24 +119,31 @@ target_include_directories(
PRIVATE
include
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/libidlc>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/generator_common>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/libidlc>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../core/ddsi/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../core/cdr/include>")

target_link_libraries(libidlc PRIVATE idl ddsc)
target_link_libraries(libidlc PRIVATE idl_common idl ddsc)

add_library(${PROJECT_NAME}::libidlc ALIAS libidlc)

install(
TARGETS libidlc
TARGETS libidlc idl_common
EXPORT "${CMAKE_PROJECT_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT lib
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib)

install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
DIRECTORY
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/libidlc>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/generator_common>"
"${CMAKE_CURRENT_SOURCE_DIR}/include/generator_common"
"${CMAKE_CURRENT_SOURCE_DIR}/include/libidlc"
"${CMAKE_CURRENT_SOURCE_DIR}/include/idlc"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/idlc"
COMPONENT dev
FILES_MATCHING PATTERN "*.h")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@
//
// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

#ifndef IDL_DEFS_H
#define IDL_DEFS_H
#ifndef GENERATOR_COMMON_COMMON_H
#define GENERATOR_COMMON_COMMON_H

#include <stdbool.h>
#include "common_export.h"

#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <stdbool.h>

#include "idl/processor.h"

#if defined (__cplusplus)
Expand All @@ -39,7 +47,7 @@ struct idlc_option {
char *help;
};

typedef struct {
struct idlc_generator_config {
char *output_dir; /* path to write completed files */
char* base_dir; /* Path to start reconstruction of dir structure */

Expand All @@ -52,14 +60,21 @@ typedef struct {
Passing a pointer to a generator function is a reasonable way of avoiding the layering problems
this introduces. May be a null pointer */
idl_retcode_t (*generate_typeinfo_typemap) (const idl_pstate_t *pstate, const idl_node_t *node, idl_typeinfo_typemap_t *result);
} idlc_generator_config_t;
};
typedef struct idlc_generator_config idlc_generator_config_t;

typedef const idlc_option_t **(*idlc_generator_options_t)(void);
typedef const idl_builtin_annotation_t **(*idlc_generator_annotations_t)(void);
typedef int(*idlc_generate_t)(const idl_pstate_t *, const idlc_generator_config_t *);

IDL_COMMON_EXPORT int
print_type(char *str, size_t size, const void *ptr, void *user_data);

IDL_COMMON_EXPORT int
print_scoped_name(char *str, size_t size, const void *ptr, void *user_data);

#if defined(__cplusplus)
}
#endif

#endif /* IDL_DEFS_H */
#endif /* GENERATOR_COMMON_COMMON_H */
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(c) 2021 to 2023 ZettaScale Technology and others
// Copyright(c) 2021 to 2022 ZettaScale Technology and others
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -8,13 +8,20 @@
//
// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

#ifndef DESCRIPTOR_TYPE_META_H
#define DESCRIPTOR_TYPE_META_H
#ifndef GENERATOR_COMMON_DESCRIPTOR_TYPE_META_H
#define GENERATOR_COMMON_DESCRIPTOR_TYPE_META_H

#include "common.h"

#include "libidlc/descriptor_type_meta.h"
#include "dds/ddsi/ddsi_xt_typeinfo.h"
#include "dds/ddsi/ddsi_xt_typemap.h"

#include "idl/processor.h"

#if defined (__cplusplus)
extern "C" {
#endif

struct type_meta {
bool finalized;
struct type_meta *admin_next;
Expand All @@ -32,17 +39,33 @@ struct descriptor_type_meta {
struct type_meta *stack;
};

idl_retcode_t
IDL_COMMON_EXPORT idl_retcode_t
get_type_hash (DDS_XTypes_EquivalenceHash hash, const DDS_XTypes_TypeObject *to);

idl_retcode_t
IDL_COMMON_EXPORT idl_retcode_t
print_type_meta_ser (
FILE *fp,
const idl_pstate_t *state,
const idl_node_t *node);

IDL_COMMON_EXPORT idl_retcode_t
generate_type_meta_ser (
const idl_pstate_t *state,
const idl_node_t *node,
idl_typeinfo_typemap_t *result);

IDL_COMMON_EXPORT idl_retcode_t
generate_descriptor_type_meta (
const idl_pstate_t *pstate,
const idl_node_t *node,
struct descriptor_type_meta *dtm);

void
IDL_COMMON_EXPORT void
descriptor_type_meta_fini (
struct descriptor_type_meta *dtm);

#endif /* DESCRIPTOR_TYPE_META_H */
#if defined(__cplusplus)
}
#endif

#endif /* GENERATOR_COMMON_DESCRIPTOR_TYPE_META_H */
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef OPTIONS_H
#define OPTIONS_H

#include "libidlc/idl_defs.h"
#include "common.h"

#define IDLC_NO_MEMORY (-1)
#define IDLC_BAD_OPTION (-2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef PLUGIN_H
#define PLUGIN_H

#include "libidlc/idl_defs.h"
#include "common.h"

typedef struct idlc_generator_plugin idlc_generator_plugin_t;
struct idlc_generator_plugin {
Expand Down
29 changes: 0 additions & 29 deletions src/tools/idlc/include/libidlc/descriptor_type_meta.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
//
// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

#ifndef IDLC_GENERATOR_H
#define IDLC_GENERATOR_H
#ifndef LIBIDLC_LIBIDLC_GENERATOR_H
#define LIBIDLC_LIBIDLC_GENERATOR_H

#include <stdint.h>

#include "idl/processor.h"
#include "idl/tree.h"
#include "idl_defs.h"
#include "libidlc/libidlc_export.h"
#include "libidlc_export.h"
#include "common.h"

#if defined (__cplusplus)
extern "C" {
Expand All @@ -26,20 +25,14 @@ extern "C" {
#define IDLC_GENERATOR_ANNOTATIONS generator_annotations
#define IDLC_GENERATE generate

IDLC_EXPORT idl_retcode_t
LIBIDLC_EXPORT idl_retcode_t
generate(const idl_pstate_t *pstate, const idlc_generator_config_t *config);

IDLC_EXPORT const idlc_option_t**
LIBIDLC_EXPORT const idlc_option_t**
generator_options(void);

IDLC_EXPORT int
print_type(char *str, size_t size, const void *ptr, void *user_data);

IDLC_EXPORT int
print_scoped_name(char *str, size_t size, const void *ptr, void *user_data);

#if defined(__cplusplus)
}
#endif

#endif /* IDLC_GENERATOR_H */
#endif /* LIBIDLC_LIBIDLC_GENERATOR_H */
Loading

0 comments on commit dca5787

Please sign in to comment.