From c1f4d5c248e7b4578cd378606e808ad414fe368a Mon Sep 17 00:00:00 2001 From: Shylock Hg <33566796+Shylock-Hg@users.noreply.github.com> Date: Thu, 26 Aug 2021 17:52:57 +0800 Subject: [PATCH 1/3] Draft the module system for outside use. --- docs/rfcs/0001-module-system.md | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 docs/rfcs/0001-module-system.md diff --git a/docs/rfcs/0001-module-system.md b/docs/rfcs/0001-module-system.md new file mode 100644 index 00000000000..3c306a4eb52 --- /dev/null +++ b/docs/rfcs/0001-module-system.md @@ -0,0 +1,47 @@ +# Summary + +Provide the modular build system to abstract the component of objects for outside project. + +# Motivation + +Some outside project will use some components directly, such as cpp client will reference the `common` and `interface` code. And useful to `UDF` and `extension` system etc. developing in future. + +User could only build used modules instead of build the whole project or build many objects directly. + +# Usage explanation + +For the module user, just try these steps: + +1. Include the nebula project, build the module you need, such as `cmake --build --target module_common` will build the module contains all objects in common source folder. +2. Find the nebula as package. +3. Include the reference headers, link with used objects. And the object will add prefix `nebula_` to name, so user need link to `nebula_base_obj` instead of `base_obj`. + +# Design explanation + +The module is a target which depends the whole objects belong to itself. +And define a macro to simplify add object to module: + +```cmake +macro(nebula_add_module_library name type module) + nebula_add_library(${name} ${type} ${ARGN}) + export( + TARGETS ${name} + NAMESPACE "nebula_" + APPEND + FILE ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}-config.cmake + ) + add_dependencies(${module} ${name}) +endmacro() +``` + +# Rationale and alternatives + +# Drawbacks + +# Prior art + +# Unresolved questions + +# Future possibilities + +Maybe could use in inner too. Replace link to objects to avoid write so many objects. And make the relationship between build components more clear. From 6503e0c7f603e18e631371376481d29001a4e394 Mon Sep 17 00:00:00 2001 From: Shylock Hg <33566796+Shylock-Hg@users.noreply.github.com> Date: Fri, 27 Aug 2021 14:20:21 +0800 Subject: [PATCH 2/3] Try object directly. --- docs/rfcs/0001-expose-object.md | 43 ++++++++++++++++++++++++++++++ docs/rfcs/0001-module-system.md | 47 --------------------------------- 2 files changed, 43 insertions(+), 47 deletions(-) create mode 100644 docs/rfcs/0001-expose-object.md delete mode 100644 docs/rfcs/0001-module-system.md diff --git a/docs/rfcs/0001-expose-object.md b/docs/rfcs/0001-expose-object.md new file mode 100644 index 00000000000..716ca623fb1 --- /dev/null +++ b/docs/rfcs/0001-expose-object.md @@ -0,0 +1,43 @@ +# Summary + +Provide the build facility to expose objects of nebula for outside project. + +# Motivation + +Some outside project will use some components of nebula directly, such as cpp client will reference the `common` and `interface` code. And also useful to `UDF` and `extension` system etc. developing in future. + +# Usage explanation + +For the module user, just try these steps: + +1. Include the nebula project, build the objects you need, such as `cmake --build --target base_obj` will build the object contains all code in `base` source folder. +2. Find the nebula as package. +3. Include the reference headers, link with used objects. And the object will add prefix `nebula_` to name when exposed to outside, so user need link to `nebula_base_obj` instead of `base_obj`. + +# Design explanation + +There is a cmake macro to simplify expose object: + +```cmake +macro(nebula_add_export_library name type) + nebula_add_library(${name} ${type} ${ARGN}) + export( + TARGETS ${name} + NAMESPACE "nebula_" + APPEND + FILE ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}-config.cmake + ) +endmacro() +``` + +# Rationale and alternatives + +# Drawbacks + +# Prior art + +# Unresolved questions + +# Future possibilities + +Maybe we should provide shared library too. And the shared library could reduce the size of test binaries. diff --git a/docs/rfcs/0001-module-system.md b/docs/rfcs/0001-module-system.md deleted file mode 100644 index 3c306a4eb52..00000000000 --- a/docs/rfcs/0001-module-system.md +++ /dev/null @@ -1,47 +0,0 @@ -# Summary - -Provide the modular build system to abstract the component of objects for outside project. - -# Motivation - -Some outside project will use some components directly, such as cpp client will reference the `common` and `interface` code. And useful to `UDF` and `extension` system etc. developing in future. - -User could only build used modules instead of build the whole project or build many objects directly. - -# Usage explanation - -For the module user, just try these steps: - -1. Include the nebula project, build the module you need, such as `cmake --build --target module_common` will build the module contains all objects in common source folder. -2. Find the nebula as package. -3. Include the reference headers, link with used objects. And the object will add prefix `nebula_` to name, so user need link to `nebula_base_obj` instead of `base_obj`. - -# Design explanation - -The module is a target which depends the whole objects belong to itself. -And define a macro to simplify add object to module: - -```cmake -macro(nebula_add_module_library name type module) - nebula_add_library(${name} ${type} ${ARGN}) - export( - TARGETS ${name} - NAMESPACE "nebula_" - APPEND - FILE ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}-config.cmake - ) - add_dependencies(${module} ${name}) -endmacro() -``` - -# Rationale and alternatives - -# Drawbacks - -# Prior art - -# Unresolved questions - -# Future possibilities - -Maybe could use in inner too. Replace link to objects to avoid write so many objects. And make the relationship between build components more clear. From 1c78570ecfd0053adbdb6c0f2b04bc449f5d5b1e Mon Sep 17 00:00:00 2001 From: Shylock Hg <33566796+Shylock-Hg@users.noreply.github.com> Date: Fri, 24 Sep 2021 17:00:24 +0800 Subject: [PATCH 3/3] Fix some typo. --- docs/rfcs/0001-expose-object.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/rfcs/0001-expose-object.md b/docs/rfcs/0001-expose-object.md index 716ca623fb1..30554e05cbc 100644 --- a/docs/rfcs/0001-expose-object.md +++ b/docs/rfcs/0001-expose-object.md @@ -4,19 +4,19 @@ Provide the build facility to expose objects of nebula for outside project. # Motivation -Some outside project will use some components of nebula directly, such as cpp client will reference the `common` and `interface` code. And also useful to `UDF` and `extension` system etc. developing in future. +Some outside projects will use some components of nebula directly, such as CPP client will reference the `common` and `interface` code. And also useful to `UDF` and `extension` systems etc. developing in future. # Usage explanation For the module user, just try these steps: -1. Include the nebula project, build the objects you need, such as `cmake --build --target base_obj` will build the object contains all code in `base` source folder. +1. Include the nebula project, build the objects you need, such as `cmake --build --target base_obj` which will build the object containing all code in `base` source folder. 2. Find the nebula as package. -3. Include the reference headers, link with used objects. And the object will add prefix `nebula_` to name when exposed to outside, so user need link to `nebula_base_obj` instead of `base_obj`. +3. Include the reference headers, link with used objects. A prefix `nebula_` will be added to the object's name when exposed to outside, so user should link to `nebula_base_obj` instead of `base_obj`. # Design explanation -There is a cmake macro to simplify expose object: +There is a cmake macro to simplify exposing object: ```cmake macro(nebula_add_export_library name type)