From a40cb0666c311c187e0d032561fd1611871fa156 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 19 Dec 2017 19:59:46 +0900 Subject: [PATCH] Separate C# generator Change-Id: I3ad683553caad8adc8163b34f39ed73151332323 Signed-off-by: Hwankyu Jhun --- idlc/CMakeLists.txt | 33 +++++++++--------------- idlc/{ => code_block}/copyright.cb | 0 idlc/{ => code_block}/cs_interop.cb | 0 idlc/{ => code_block}/cs_proxy_interop.cb | 0 idlc/{ => code_block}/cs_stub_interop.cb | 0 idlc/{ => cs_gen}/cs_gen_base.cc | 2 +- idlc/{ => cs_gen}/cs_gen_base.h | 6 ++--- idlc/{ => cs_gen}/cs_proxy_gen.cc | 2 +- idlc/{ => cs_gen}/cs_proxy_gen.h | 8 +++--- idlc/{ => cs_gen}/cs_stub_gen.cc | 2 +- idlc/{ => cs_gen}/cs_stub_gen.h | 8 +++--- idlc/generator.cc | 4 +-- idlc/main.cc | 4 +-- packaging/tidl.spec | 2 +- unit_tests/CMakeLists.txt | 22 ++++------------ unit_tests/{ => cs_gen}/cs_proxy_gen_unittest.cc | 2 +- unit_tests/{ => cs_gen}/cs_stub_gen_unittest.cc | 2 +- 17 files changed, 38 insertions(+), 59 deletions(-) rename idlc/{ => code_block}/copyright.cb (100%) rename idlc/{ => code_block}/cs_interop.cb (100%) rename idlc/{ => code_block}/cs_proxy_interop.cb (100%) rename idlc/{ => code_block}/cs_stub_interop.cb (100%) rename idlc/{ => cs_gen}/cs_gen_base.cc (98%) rename idlc/{ => cs_gen}/cs_gen_base.h (91%) rename idlc/{ => cs_gen}/cs_proxy_gen.cc (97%) rename idlc/{ => cs_gen}/cs_proxy_gen.h (87%) rename idlc/{ => cs_gen}/cs_stub_gen.cc (97%) rename idlc/{ => cs_gen}/cs_stub_gen.h (88%) rename unit_tests/{ => cs_gen}/cs_proxy_gen_unittest.cc (98%) rename unit_tests/{ => cs_gen}/cs_stub_gen_unittest.cc (98%) diff --git a/idlc/CMakeLists.txt b/idlc/CMakeLists.txt index 0df400f..7425340 100644 --- a/idlc/CMakeLists.txt +++ b/idlc/CMakeLists.txt @@ -19,22 +19,8 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++11") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") -SET(SOURCES - parser.cc - document.cc - declaration.cc - interface.cc - type.cc - parameter.cc - element.cc - structure.cc - block.cc - generator.cc - cs_gen_base.cc - cs_proxy_gen.cc - cs_stub_gen.cc - main.cc -) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/cs_gen CS_GEN_SOURCES) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) @@ -43,11 +29,16 @@ bison_target(TIDLC ${CMAKE_CURRENT_SOURCE_DIR}/tidlc.yy ${CMAKE_CURRENT_SOURCE_D SET(TILDC_deps ${FLEX_TIDLC_OUTPUTS}) -ADD_EXECUTABLE(tidlc ${BISON_TIDLC_OUTPUTS} ${FLEX_TIDLC_OUTPUTS} ${SOURCES}) +ADD_EXECUTABLE(tidlc + ${BISON_TIDLC_OUTPUTS} + ${FLEX_TIDLC_OUTPUTS} + ${CS_GEN_SOURCES} + ${SOURCES} + ) TARGET_LINK_LIBRARIES(tidlc ${LIBPKGS_LDFLAGS}) INSTALL(TARGETS tidlc DESTINATION bin) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/copyright.cb DESTINATION share/tidl) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cs_interop.cb DESTINATION share/tidl) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cs_proxy_interop.cb DESTINATION share/tidl) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cs_stub_interop.cb DESTINATION share/tidl) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/code_block/copyright.cb DESTINATION share/tidl/code_block) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/code_block/cs_interop.cb DESTINATION share/tidl/code_block) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/code_block/cs_proxy_interop.cb DESTINATION share/tidl/code_block) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/code_block/cs_stub_interop.cb DESTINATION share/tidl/code_block) diff --git a/idlc/copyright.cb b/idlc/code_block/copyright.cb similarity index 100% rename from idlc/copyright.cb rename to idlc/code_block/copyright.cb diff --git a/idlc/cs_interop.cb b/idlc/code_block/cs_interop.cb similarity index 100% rename from idlc/cs_interop.cb rename to idlc/code_block/cs_interop.cb diff --git a/idlc/cs_proxy_interop.cb b/idlc/code_block/cs_proxy_interop.cb similarity index 100% rename from idlc/cs_proxy_interop.cb rename to idlc/code_block/cs_proxy_interop.cb diff --git a/idlc/cs_stub_interop.cb b/idlc/code_block/cs_stub_interop.cb similarity index 100% rename from idlc/cs_stub_interop.cb rename to idlc/code_block/cs_stub_interop.cb diff --git a/idlc/cs_gen_base.cc b/idlc/cs_gen/cs_gen_base.cc similarity index 98% rename from idlc/cs_gen_base.cc rename to idlc/cs_gen/cs_gen_base.cc index f6f3580..724f1e4 100644 --- a/idlc/cs_gen_base.cc +++ b/idlc/cs_gen/cs_gen_base.cc @@ -16,7 +16,7 @@ #include -#include "idlc/cs_gen_base.h" +#include "idlc/cs_gen/cs_gen_base.h" namespace tidl { diff --git a/idlc/cs_gen_base.h b/idlc/cs_gen/cs_gen_base.h similarity index 91% rename from idlc/cs_gen_base.h rename to idlc/cs_gen/cs_gen_base.h index 1391ccd..0e9ffd6 100644 --- a/idlc/cs_gen_base.h +++ b/idlc/cs_gen/cs_gen_base.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef IDLC_CS_GEN_BASE_H_ -#define IDLC_CS_GEN_BASE_H_ +#ifndef IDLC_CS_GEN_CS_GEN_BASE_H_ +#define IDLC_CS_GEN_CS_GEN_BASE_H_ #include #include @@ -44,4 +44,4 @@ class CsGeneratorBase : public Generator { } // namespace tidl -#endif // IDLC_CS_GEN_BASE_H_ +#endif // IDLC_CS_GEN_CS_GEN_BASE_H_ diff --git a/idlc/cs_proxy_gen.cc b/idlc/cs_gen/cs_proxy_gen.cc similarity index 97% rename from idlc/cs_proxy_gen.cc rename to idlc/cs_gen/cs_proxy_gen.cc index 26caaf4..449528b 100644 --- a/idlc/cs_proxy_gen.cc +++ b/idlc/cs_gen/cs_proxy_gen.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "idlc/cs_proxy_gen.h" +#include "idlc/cs_gen/cs_proxy_gen.h" namespace tidl { diff --git a/idlc/cs_proxy_gen.h b/idlc/cs_gen/cs_proxy_gen.h similarity index 87% rename from idlc/cs_proxy_gen.h rename to idlc/cs_gen/cs_proxy_gen.h index 5b6f40a..83dafbd 100644 --- a/idlc/cs_proxy_gen.h +++ b/idlc/cs_gen/cs_proxy_gen.h @@ -14,13 +14,13 @@ * limitations under the License. */ -#ifndef IDLC_CS_PROXY_GEN_H_ -#define IDLC_CS_PROXY_GEN_H_ +#ifndef IDLC_CS_GEN_CS_PROXY_GEN_H_ +#define IDLC_CS_GEN_CS_PROXY_GEN_H_ #include #include -#include "idlc/cs_gen_base.h" +#include "idlc/cs_gen/cs_gen_base.h" namespace tidl { @@ -40,4 +40,4 @@ class CsProxyGen : public CsGeneratorBase { } // namespace tidl -#endif // IDLC_CS_PROXY_GEN_H_ +#endif // IDLC_CS_GEN_CS_PROXY_GEN_H_ diff --git a/idlc/cs_stub_gen.cc b/idlc/cs_gen/cs_stub_gen.cc similarity index 97% rename from idlc/cs_stub_gen.cc rename to idlc/cs_gen/cs_stub_gen.cc index a2fdfd7..afe70ab 100644 --- a/idlc/cs_stub_gen.cc +++ b/idlc/cs_gen/cs_stub_gen.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "idlc/cs_stub_gen.h" +#include "idlc/cs_gen/cs_stub_gen.h" namespace tidl { diff --git a/idlc/cs_stub_gen.h b/idlc/cs_gen/cs_stub_gen.h similarity index 88% rename from idlc/cs_stub_gen.h rename to idlc/cs_gen/cs_stub_gen.h index b0a274f..3dcc5c8 100644 --- a/idlc/cs_stub_gen.h +++ b/idlc/cs_gen/cs_stub_gen.h @@ -14,13 +14,13 @@ * limitations under the License. */ -#ifndef IDLC_STUB_GEN_H_ -#define IDLC_STUB_GEN_H_ +#ifndef IDLC_CS_GEN_STUB_GEN_H_ +#define IDLC_CS_GEN_STUB_GEN_H_ #include #include -#include "idlc/cs_gen_base.h" +#include "idlc/cs_gen/cs_gen_base.h" namespace tidl { @@ -39,4 +39,4 @@ class CsStubGen : public CsGeneratorBase { } // namespace tidl -#endif // IDLC_STUB_GEN_H_ +#endif // IDLC_CS_GEN_STUB_GEN_H_ diff --git a/idlc/generator.cc b/idlc/generator.cc index 7219359..705690f 100644 --- a/idlc/generator.cc +++ b/idlc/generator.cc @@ -40,9 +40,9 @@ void Generator::GenCodeBlock(std::string filename, std::string line; int cnt = 1; - cb_file.open("/usr/share/tidl/" + filename); + cb_file.open("/usr/share/tidl/code_block/" + filename); if (!cb_file.is_open()) { - cb_file.open("../idlc/" + filename); + cb_file.open("../idlc/code_block/" + filename); } if (!cb_file.is_open()) diff --git a/idlc/main.cc b/idlc/main.cc index dd3ebae..eb698c4 100644 --- a/idlc/main.cc +++ b/idlc/main.cc @@ -21,8 +21,8 @@ #include #include "idlc/parser.h" -#include "idlc/cs_proxy_gen.h" -#include "idlc/cs_stub_gen.h" +#include "idlc/cs_gen/cs_proxy_gen.h" +#include "idlc/cs_gen/cs_stub_gen.h" namespace { diff --git a/packaging/tidl.spec b/packaging/tidl.spec index 125df54..c0776ab 100644 --- a/packaging/tidl.spec +++ b/packaging/tidl.spec @@ -59,7 +59,7 @@ rm -rf %{buildroot} %license LICENSE %manifest %{name}.manifest %{_bindir}/tidlc -%{_usr_share_dir}/tidl/*.cb +%{_usr_share_dir}/tidl/* %files tests %manifest %{name}.manifest diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 8751efa..ced432c 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -26,26 +26,12 @@ SET(TIDLC_SOURCES ../idlc/structure.cc ../idlc/block.cc ../idlc/generator.cc - ../idlc/cs_gen_base.cc - ../idlc/cs_proxy_gen.cc - ../idlc/cs_stub_gen.cc ../idlc/parser.cc ) -SET(UNIT_TESTS_SOURCES - document_unittest.cc - block_unittest.cc - type_unittest.cc - element_unittest.cc - declaration_unittest.cc - interface_unittest.cc - structure_unittest.cc - generator_unittest.cc - cs_proxy_gen_unittest.cc - cs_stub_gen_unittest.cc - parser_unittest.cc - main.cc - ) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../idlc/cs_gen CS_GEN_SOURCES) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} UNIT_TESTS_SOURCES) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/cs_gen CS_GEN_UNIT_TESTS_SOURCES) FLEX_TARGET(TIDLC ${CMAKE_CURRENT_SOURCE_DIR}/../idlc/tidlc.ll @@ -60,7 +46,9 @@ ADD_EXECUTABLE(tidl-unit-tests ${BISON_TIDLC_OUTPUTS} ${FLEX_TIDLC_OUTPUTS} ${TIDLC_SOURCES} + ${CS_GEN_SOURCES} ${UNIT_TESTS_SOURCES} + ${CS_GEN_UNIT_TESTS_SOURCES} ) TARGET_LINK_LIBRARIES(tidl-unit-tests ${GTEST_LIBRARIES} pthread) diff --git a/unit_tests/cs_proxy_gen_unittest.cc b/unit_tests/cs_gen/cs_proxy_gen_unittest.cc similarity index 98% rename from unit_tests/cs_proxy_gen_unittest.cc rename to unit_tests/cs_gen/cs_proxy_gen_unittest.cc index fc76852..bef1f70 100644 --- a/unit_tests/cs_proxy_gen_unittest.cc +++ b/unit_tests/cs_gen/cs_proxy_gen_unittest.cc @@ -19,7 +19,7 @@ #include #include "idlc/parser.h" -#include "idlc/cs_proxy_gen.h" +#include "idlc/cs_gen/cs_proxy_gen.h" class CsProxyGenTest : public testing::Test { public: diff --git a/unit_tests/cs_stub_gen_unittest.cc b/unit_tests/cs_gen/cs_stub_gen_unittest.cc similarity index 98% rename from unit_tests/cs_stub_gen_unittest.cc rename to unit_tests/cs_gen/cs_stub_gen_unittest.cc index 9cbb53d..8d4def5 100644 --- a/unit_tests/cs_stub_gen_unittest.cc +++ b/unit_tests/cs_gen/cs_stub_gen_unittest.cc @@ -19,7 +19,7 @@ #include #include "idlc/parser.h" -#include "idlc/cs_stub_gen.h" +#include "idlc/cs_gen/cs_stub_gen.h" class CsStubGenTest : public testing::Test { public: -- 2.7.4