You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "xuxin930 (via GitHub)" <gi...@apache.org> on 2023/08/14 12:48:13 UTC
[GitHub] [nuttx] xuxin930 opened a new pull request, #10224: cmake:new feature on enhance apps header cmake module
xuxin930 opened a new pull request, #10224:
URL: https://github.com/apache/nuttx/pull/10224
## Summary
In the original GNU Make build, we use `Make.defs` to add the global include path,
and the private include path of the application library is written in the `Makefile`.
In Nuttx CMake build, we achieve similar global functionality through this patch.
- `nuttx_export_header` for applications global header file export:
the export path is in the `build-directory/apps/include/target-name`.
all exported header files retain relative paths.
```cmake
# set(INCDIRS foo/include)
# nuttx_export_header(TARGET libfoo INCLUDE_DIRECTORIES ${INCDIRS})
#
# foo/include/ build/apps/include/foo/
# ├── demo/ ├── demo/
# | └── demo.h symbolic link | └── demo.h
# ├── test/ ============> ├── test/
# | └── test.h | └── test.h
# └── foo.h └── foo.h
```
- `nuttx_add_dependencies` is the wrapper to achieve import
add the dependency by nuttx wrapping function, and automatically add its exported include path.
```cmake
nuttx_add_dependencies(TARGET bar TARGET foo)
# In bar CFLAGS add this automatically
# C_INCLUDES= -I build-directory/apps/include/foo
```
## Impact
## Testing
`libtomcrypt` DEPENDSON `libtommath`
- In CMakeLists.txt of `libtommath`
```cmake
nuttx_add_library(libtommath STATIC)
nuttx_export_header(TARGET libtommath INCLUDE_DIRECTORIES ${LIBTOMMATH_DIR})
```
- In CMakeLists.txt of `libtomcrypt`
```cmake
nuttx_add_library(libtomcrypt STATIC)
nuttx_add_dependencies(TARGET libtomcrypt TARGET_DEPS libtommath)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xuxin930 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1294119319
##########
cmake/nuttx_apps_headers.cmake:
##########
@@ -0,0 +1,127 @@
+# ##############################################################################
+# cmake/nuttx_apps_headers.cmake
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership. The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+include(nuttx_parse_function_args)
+
+# export_relative_path_recursively
+#
+# Used to recursively add all header files under the `include_directory` to the
+# `prefix` directory and preserve their relative relationship
+#
+# When the target relative path is repeated and the original path is different
+# throws an exception and abort the build
+function(export_relative_path_recursively prefix include_directory)
+ # recursively find header files under the path
+ file(GLOB_RECURSE FOUND_FILES ${include_directory}/*.h)
+ if(FOUND_FILES)
+ foreach(FOUND_FILE ${FOUND_FILES})
+ if(EXISTS ${FOUND_FILE})
+ # take relative path
+ file(RELATIVE_PATH REL_FILE ${include_directory} ${FOUND_FILE})
+ # check for path conflicts
+ string(REPLACE "/" "_" CHECK_PROP _check_${prefix}_${REL_FILE})
+ get_property(REL_FILE_CHECK GLOBAL PROPERTY ${CHECK_PROP})
+ if(REL_FILE_CHECK AND NOT REL_FILE_CHECK STREQUAL FOUND_FILE)
+ message(
+ FATAL_ERROR
+ "Error: NUTTX_ADD_APPS_HEADER add a duplicate header files ${FOUND_FILE} ${REL_FILE_CHECK}"
+ )
+ endif()
+ set_property(GLOBAL PROPERTY ${CHECK_PROP} ${FOUND_FILE})
+ message(
+ VERBOSE
+ "NUTTX_ADD_APPS_HEADER: REL_FILE found: ${REL_FILE} in ${INCDIR}")
+ # create symbolic lick in the BINAPPS/include directory
+ file(CREATE_LINK ${FOUND_FILE} ${prefix}/${REL_FILE} COPY_ON_ERROR
+ SYMBOLIC)
+ endif()
+ endforeach()
+ endif()
+endfunction()
+
+# ~~~
+# nuttx_export_header
+#
+# Description:
+# Export include directory to apps global include path.
+# `${NUTTX_APPS_BINDIR}/include/${TARGET}`
+# preserve relative paths to all header files.
+#
+# In the original GNU Make build, we use `Make.defs` to add the global include path,
+# and the private include path of the application library is written in the `Makefile`
+# In Nuttx CMake build, we achieve similar global functionality through this function.
+#
+# Usage:
+# nuttx_export_header(TARGET <string> INCLUDE_DIRECTORIES <list>)
+#
+# Parameters:
+# TARGET : target for exporting header directory
+# INCLUDE_DIRECTORIES : directory list to be exported
+#
+# Example:
+# set(INCDIRS foo/include)
+# nuttx_export_header(TARGET libfoo INCLUDE_DIRECTORIES ${INCDIRS})
+#
+# foo/include/ build/apps/include/foo/
+# ├── demo/ ├── demo/
+# | └── demo.h symbolic link | └── demo.h
Review Comment:
Yes, it is better, and more suitable for situations like install header
let me replace it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] acassis commented on pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#issuecomment-1677288273
Hi @xuxin930 please include the Summary in the commit log message
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1302475948
##########
cmake/nuttx_apps_headers.cmake:
##########
@@ -0,0 +1,127 @@
+# ##############################################################################
+# cmake/nuttx_apps_headers.cmake
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership. The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+include(nuttx_parse_function_args)
+
+# export_relative_path_recursively
+#
+# Used to recursively add all header files under the `include_directory` to the
+# `prefix` directory and preserve their relative relationship
+#
+# When the target relative path is repeated and the original path is different
+# throws an exception and abort the build
+function(export_relative_path_recursively prefix include_directory)
+ # recursively find header files under the path
+ file(GLOB_RECURSE FOUND_FILES ${include_directory}/*.h)
+ if(FOUND_FILES)
+ foreach(FOUND_FILE ${FOUND_FILES})
+ if(EXISTS ${FOUND_FILE})
+ # take relative path
+ file(RELATIVE_PATH REL_FILE ${include_directory} ${FOUND_FILE})
+ # check for path conflicts
+ string(REPLACE "/" "_" CHECK_PROP _check_${prefix}_${REL_FILE})
+ get_property(REL_FILE_CHECK GLOBAL PROPERTY ${CHECK_PROP})
+ if(REL_FILE_CHECK AND NOT REL_FILE_CHECK STREQUAL FOUND_FILE)
+ message(
+ FATAL_ERROR
+ "Error: NUTTX_ADD_APPS_HEADER add a duplicate header files ${FOUND_FILE} ${REL_FILE_CHECK}"
+ )
+ endif()
+ set_property(GLOBAL PROPERTY ${CHECK_PROP} ${FOUND_FILE})
+ message(
+ VERBOSE
+ "NUTTX_ADD_APPS_HEADER: REL_FILE found: ${REL_FILE} in ${INCDIR}")
+ # create symbolic lick in the BINAPPS/include directory
+ file(CREATE_LINK ${FOUND_FILE} ${prefix}/${REL_FILE} COPY_ON_ERROR
+ SYMBOLIC)
+ endif()
+ endforeach()
+ endif()
+endfunction()
+
+# ~~~
+# nuttx_export_header
+#
+# Description:
+# Export include directory to apps global include path.
+# `${NUTTX_APPS_BINDIR}/include/${TARGET}`
+# preserve relative paths to all header files.
+#
+# In the original GNU Make build, we use `Make.defs` to add the global include path,
+# and the private include path of the application library is written in the `Makefile`
+# In Nuttx CMake build, we achieve similar global functionality through this function.
+#
+# Usage:
+# nuttx_export_header(TARGET <string> INCLUDE_DIRECTORIES <list>)
+#
+# Parameters:
+# TARGET : target for exporting header directory
+# INCLUDE_DIRECTORIES : directory list to be exported
+#
+# Example:
+# set(INCDIRS foo/include)
+# nuttx_export_header(TARGET libfoo INCLUDE_DIRECTORIES ${INCDIRS})
+#
+# foo/include/ build/apps/include/foo/
+# ├── demo/ ├── demo/
+# | └── demo.h symbolic link | └── demo.h
Review Comment:
why not directly search the origin source code location directly?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1293840178
##########
CMakeLists.txt:
##########
@@ -373,6 +373,8 @@ include(nuttx_add_application)
include(nuttx_add_romfs)
include(nuttx_add_symtab)
include(nuttx_add_module)
+include(nuttx_add_dependencies)
+include(nuttx_apps_headers)
Review Comment:
could we make more general name since apps is replaceable.
##########
cmake/nuttx_apps_headers.cmake:
##########
@@ -0,0 +1,127 @@
+# ##############################################################################
+# cmake/nuttx_apps_headers.cmake
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership. The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+include(nuttx_parse_function_args)
+
+# export_relative_path_recursively
+#
+# Used to recursively add all header files under the `include_directory` to the
+# `prefix` directory and preserve their relative relationship
+#
+# When the target relative path is repeated and the original path is different
+# throws an exception and abort the build
+function(export_relative_path_recursively prefix include_directory)
+ # recursively find header files under the path
+ file(GLOB_RECURSE FOUND_FILES ${include_directory}/*.h)
+ if(FOUND_FILES)
+ foreach(FOUND_FILE ${FOUND_FILES})
+ if(EXISTS ${FOUND_FILE})
+ # take relative path
+ file(RELATIVE_PATH REL_FILE ${include_directory} ${FOUND_FILE})
+ # check for path conflicts
+ string(REPLACE "/" "_" CHECK_PROP _check_${prefix}_${REL_FILE})
+ get_property(REL_FILE_CHECK GLOBAL PROPERTY ${CHECK_PROP})
+ if(REL_FILE_CHECK AND NOT REL_FILE_CHECK STREQUAL FOUND_FILE)
+ message(
+ FATAL_ERROR
+ "Error: NUTTX_ADD_APPS_HEADER add a duplicate header files ${FOUND_FILE} ${REL_FILE_CHECK}"
+ )
+ endif()
+ set_property(GLOBAL PROPERTY ${CHECK_PROP} ${FOUND_FILE})
+ message(
+ VERBOSE
+ "NUTTX_ADD_APPS_HEADER: REL_FILE found: ${REL_FILE} in ${INCDIR}")
+ # create symbolic lick in the BINAPPS/include directory
+ file(CREATE_LINK ${FOUND_FILE} ${prefix}/${REL_FILE} COPY_ON_ERROR
+ SYMBOLIC)
+ endif()
+ endforeach()
+ endif()
+endfunction()
+
+# ~~~
+# nuttx_export_header
+#
+# Description:
+# Export include directory to apps global include path.
+# `${NUTTX_APPS_BINDIR}/include/${TARGET}`
+# preserve relative paths to all header files.
+#
+# In the original GNU Make build, we use `Make.defs` to add the global include path,
+# and the private include path of the application library is written in the `Makefile`
+# In Nuttx CMake build, we achieve similar global functionality through this function.
+#
+# Usage:
+# nuttx_export_header(TARGET <string> INCLUDE_DIRECTORIES <list>)
+#
+# Parameters:
+# TARGET : target for exporting header directory
+# INCLUDE_DIRECTORIES : directory list to be exported
+#
+# Example:
+# set(INCDIRS foo/include)
+# nuttx_export_header(TARGET libfoo INCLUDE_DIRECTORIES ${INCDIRS})
+#
+# foo/include/ build/apps/include/foo/
+# ├── demo/ ├── demo/
+# | └── demo.h symbolic link | └── demo.h
Review Comment:
can we export the origin path instead creating the symbol link?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xuxin930 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1294124613
##########
CMakeLists.txt:
##########
@@ -373,6 +373,8 @@ include(nuttx_add_application)
include(nuttx_add_romfs)
include(nuttx_add_symtab)
include(nuttx_add_module)
+include(nuttx_add_dependencies)
+include(nuttx_apps_headers)
Review Comment:
Yes, @xiaoxiang781216 do you have any suggestion💡
how about `nuttx_include_directories` ? that is nuttx wrapper name for cmake module `include_directories` ,but the meaning is opposite.
or `nuttx_export_header` ? that expresses its function.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1296221615
##########
CMakeLists.txt:
##########
@@ -373,6 +373,8 @@ include(nuttx_add_application)
include(nuttx_add_romfs)
include(nuttx_add_symtab)
include(nuttx_add_module)
+include(nuttx_add_dependencies)
+include(nuttx_apps_headers)
Review Comment:
nuttx_export_header
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xuxin930 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1294124613
##########
CMakeLists.txt:
##########
@@ -373,6 +373,8 @@ include(nuttx_add_application)
include(nuttx_add_romfs)
include(nuttx_add_symtab)
include(nuttx_add_module)
+include(nuttx_add_dependencies)
+include(nuttx_apps_headers)
Review Comment:
Yes, do you have any suggestion💡
how about `nuttx_include_directories` ? that is nuttx wrapper name for cmake module `include_directories`.
or `nuttx_export_header` ? that expresses its function.
##########
CMakeLists.txt:
##########
@@ -373,6 +373,8 @@ include(nuttx_add_application)
include(nuttx_add_romfs)
include(nuttx_add_symtab)
include(nuttx_add_module)
+include(nuttx_add_dependencies)
+include(nuttx_apps_headers)
Review Comment:
Yes, do you have any suggestion💡
how about `nuttx_include_directories` ? that is nuttx wrapper name for cmake module `include_directories`.
or `nuttx_export_header` ? that expresses its function.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1296221615
##########
CMakeLists.txt:
##########
@@ -373,6 +373,8 @@ include(nuttx_add_application)
include(nuttx_add_romfs)
include(nuttx_add_symtab)
include(nuttx_add_module)
+include(nuttx_add_dependencies)
+include(nuttx_apps_headers)
Review Comment:
change to nuttx_export_header
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xuxin930 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1302444349
##########
cmake/nuttx_apps_headers.cmake:
##########
@@ -0,0 +1,127 @@
+# ##############################################################################
+# cmake/nuttx_apps_headers.cmake
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership. The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+include(nuttx_parse_function_args)
+
+# export_relative_path_recursively
+#
+# Used to recursively add all header files under the `include_directory` to the
+# `prefix` directory and preserve their relative relationship
+#
+# When the target relative path is repeated and the original path is different
+# throws an exception and abort the build
+function(export_relative_path_recursively prefix include_directory)
+ # recursively find header files under the path
+ file(GLOB_RECURSE FOUND_FILES ${include_directory}/*.h)
+ if(FOUND_FILES)
+ foreach(FOUND_FILE ${FOUND_FILES})
+ if(EXISTS ${FOUND_FILE})
+ # take relative path
+ file(RELATIVE_PATH REL_FILE ${include_directory} ${FOUND_FILE})
+ # check for path conflicts
+ string(REPLACE "/" "_" CHECK_PROP _check_${prefix}_${REL_FILE})
+ get_property(REL_FILE_CHECK GLOBAL PROPERTY ${CHECK_PROP})
+ if(REL_FILE_CHECK AND NOT REL_FILE_CHECK STREQUAL FOUND_FILE)
+ message(
+ FATAL_ERROR
+ "Error: NUTTX_ADD_APPS_HEADER add a duplicate header files ${FOUND_FILE} ${REL_FILE_CHECK}"
+ )
+ endif()
+ set_property(GLOBAL PROPERTY ${CHECK_PROP} ${FOUND_FILE})
+ message(
+ VERBOSE
+ "NUTTX_ADD_APPS_HEADER: REL_FILE found: ${REL_FILE} in ${INCDIR}")
+ # create symbolic lick in the BINAPPS/include directory
+ file(CREATE_LINK ${FOUND_FILE} ${prefix}/${REL_FILE} COPY_ON_ERROR
+ SYMBOLIC)
+ endif()
+ endforeach()
+ endif()
+endfunction()
+
+# ~~~
+# nuttx_export_header
+#
+# Description:
+# Export include directory to apps global include path.
+# `${NUTTX_APPS_BINDIR}/include/${TARGET}`
+# preserve relative paths to all header files.
+#
+# In the original GNU Make build, we use `Make.defs` to add the global include path,
+# and the private include path of the application library is written in the `Makefile`
+# In Nuttx CMake build, we achieve similar global functionality through this function.
+#
+# Usage:
+# nuttx_export_header(TARGET <string> INCLUDE_DIRECTORIES <list>)
+#
+# Parameters:
+# TARGET : target for exporting header directory
+# INCLUDE_DIRECTORIES : directory list to be exported
+#
+# Example:
+# set(INCDIRS foo/include)
+# nuttx_export_header(TARGET libfoo INCLUDE_DIRECTORIES ${INCDIRS})
+#
+# foo/include/ build/apps/include/foo/
+# ├── demo/ ├── demo/
+# | └── demo.h symbolic link | └── demo.h
Review Comment:
> can we export the origin path instead creating the symbol link?
hi @xiaoxiang781216
`copy` will cause incremental compilation problems, when developers modify header files will not take effect.
I plan to switch back to symbolic link.
for the requirement of exporting header files, I will create an cmake install target to achieve.
How do you think ? @xiaoxiang781216
##########
cmake/nuttx_apps_headers.cmake:
##########
@@ -0,0 +1,127 @@
+# ##############################################################################
+# cmake/nuttx_apps_headers.cmake
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership. The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+include(nuttx_parse_function_args)
+
+# export_relative_path_recursively
+#
+# Used to recursively add all header files under the `include_directory` to the
+# `prefix` directory and preserve their relative relationship
+#
+# When the target relative path is repeated and the original path is different
+# throws an exception and abort the build
+function(export_relative_path_recursively prefix include_directory)
+ # recursively find header files under the path
+ file(GLOB_RECURSE FOUND_FILES ${include_directory}/*.h)
+ if(FOUND_FILES)
+ foreach(FOUND_FILE ${FOUND_FILES})
+ if(EXISTS ${FOUND_FILE})
+ # take relative path
+ file(RELATIVE_PATH REL_FILE ${include_directory} ${FOUND_FILE})
+ # check for path conflicts
+ string(REPLACE "/" "_" CHECK_PROP _check_${prefix}_${REL_FILE})
+ get_property(REL_FILE_CHECK GLOBAL PROPERTY ${CHECK_PROP})
+ if(REL_FILE_CHECK AND NOT REL_FILE_CHECK STREQUAL FOUND_FILE)
+ message(
+ FATAL_ERROR
+ "Error: NUTTX_ADD_APPS_HEADER add a duplicate header files ${FOUND_FILE} ${REL_FILE_CHECK}"
+ )
+ endif()
+ set_property(GLOBAL PROPERTY ${CHECK_PROP} ${FOUND_FILE})
+ message(
+ VERBOSE
+ "NUTTX_ADD_APPS_HEADER: REL_FILE found: ${REL_FILE} in ${INCDIR}")
+ # create symbolic lick in the BINAPPS/include directory
+ file(CREATE_LINK ${FOUND_FILE} ${prefix}/${REL_FILE} COPY_ON_ERROR
+ SYMBOLIC)
+ endif()
+ endforeach()
+ endif()
+endfunction()
+
+# ~~~
+# nuttx_export_header
+#
+# Description:
+# Export include directory to apps global include path.
+# `${NUTTX_APPS_BINDIR}/include/${TARGET}`
+# preserve relative paths to all header files.
+#
+# In the original GNU Make build, we use `Make.defs` to add the global include path,
+# and the private include path of the application library is written in the `Makefile`
+# In Nuttx CMake build, we achieve similar global functionality through this function.
+#
+# Usage:
+# nuttx_export_header(TARGET <string> INCLUDE_DIRECTORIES <list>)
+#
+# Parameters:
+# TARGET : target for exporting header directory
+# INCLUDE_DIRECTORIES : directory list to be exported
+#
+# Example:
+# set(INCDIRS foo/include)
+# nuttx_export_header(TARGET libfoo INCLUDE_DIRECTORIES ${INCDIRS})
+#
+# foo/include/ build/apps/include/foo/
+# ├── demo/ ├── demo/
+# | └── demo.h symbolic link | └── demo.h
Review Comment:
> can we export the origin path instead creating the symbol link?
hi @xiaoxiang781216
`copy` will cause incremental compilation problems, when developers modify header files will not take effect.
I plan to switch back to symbolic link.
for the requirement of exporting header files, I will create an cmake install target to achieve.
How do you think ? @xiaoxiang781216
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xuxin930 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1294574605
##########
cmake/nuttx_add_dependencies.cmake:
##########
@@ -0,0 +1,63 @@
+# ##############################################################################
+# cmake/nuttx_add_dependencies.cmake
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership. The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+include(nuttx_parse_function_args)
+
+# ~~~
+# nuttx_add_dependencies
+#
+# Description:
+# Wrapper of cmake add_dependencies.
+# At the same time, It also allows adding the header file path
+# exported by the dependent library under NUTTX_APPS_BINDIR/include
+#
+# Usage:
+# nuttx_add_dependencies( TARGET <string> TARGET_DEPS <list>)
+#
+# Parameters:
+# TARGET : target needs to add dependencie
+# TARGET_DEPS : targets which depends on
+# ~~~
+
+function(nuttx_add_dependencies)
+
+ # parse arguments into variables
+
+ nuttx_parse_function_args(
+ FUNC
+ nuttx_add_dependencies
+ ONE_VALUE
+ TARGET
+ MULTI_VALUE
+ TARGET_DEPS
+ REQUIRED
+ TARGET
+ TARGET_DEPS
Review Comment:
> TARGET_DEPS -> DEPENDS
Done🙏
##########
cmake/nuttx_add_dependencies.cmake:
##########
@@ -0,0 +1,63 @@
+# ##############################################################################
+# cmake/nuttx_add_dependencies.cmake
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership. The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+include(nuttx_parse_function_args)
+
+# ~~~
+# nuttx_add_dependencies
+#
+# Description:
+# Wrapper of cmake add_dependencies.
+# At the same time, It also allows adding the header file path
+# exported by the dependent library under NUTTX_APPS_BINDIR/include
+#
+# Usage:
+# nuttx_add_dependencies( TARGET <string> TARGET_DEPS <list>)
+#
+# Parameters:
+# TARGET : target needs to add dependencie
+# TARGET_DEPS : targets which depends on
+# ~~~
+
+function(nuttx_add_dependencies)
+
+ # parse arguments into variables
+
+ nuttx_parse_function_args(
+ FUNC
+ nuttx_add_dependencies
+ ONE_VALUE
+ TARGET
+ MULTI_VALUE
+ TARGET_DEPS
+ REQUIRED
+ TARGET
+ TARGET_DEPS
Review Comment:
> TARGET_DEPS -> DEPENDS
Done🙏
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xuxin930 commented on pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#issuecomment-1678323348
> > Hi @xuxin930 please include the Summary in the commit log message
>
> I think it is not necessary because you already put it in the cmake file itself, but a better suggestion should be create a CMake instruction documentation to help people to use NuttX specific CMake rules
Hi @acassis , thank you for your suggestion. I also think it is better to provide documentation for developers. I will create a action to track this task.
at present, there are still many applications in cmake build that have not been migrated. and also some features that need to be refined.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 merged pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #10224:
URL: https://github.com/apache/nuttx/pull/10224
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xuxin930 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1296599901
##########
CMakeLists.txt:
##########
@@ -373,6 +373,8 @@ include(nuttx_add_application)
include(nuttx_add_romfs)
include(nuttx_add_symtab)
include(nuttx_add_module)
+include(nuttx_add_dependencies)
+include(nuttx_apps_headers)
Review Comment:
> > change to nuttx_export_header
>
> this has been changed in patchset2. do you mean squash these two commits? do we need to keep the discussion and revison?
Done 🙏
##########
CMakeLists.txt:
##########
@@ -373,6 +373,8 @@ include(nuttx_add_application)
include(nuttx_add_romfs)
include(nuttx_add_symtab)
include(nuttx_add_module)
+include(nuttx_add_dependencies)
+include(nuttx_apps_headers)
Review Comment:
> > change to nuttx_export_header
>
> this has been changed in patchset2. do you mean squash these two commits? do we need to keep the discussion and revison?
Done 🙏
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] anchao commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1293436529
##########
cmake/nuttx_add_dependencies.cmake:
##########
@@ -0,0 +1,63 @@
+# ##############################################################################
+# cmake/nuttx_add_dependencies.cmake
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership. The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+include(nuttx_parse_function_args)
+
+# ~~~
+# nuttx_add_dependencies
+#
+# Description:
+# Wrapper of cmake add_dependencies.
+# At the same time, It also allows adding the header file path
+# exported by the dependent library under NUTTX_APPS_BINDIR/include
+#
+# Usage:
+# nuttx_add_dependencies( TARGET <string> TARGET_DEPS <list>)
+#
+# Parameters:
+# TARGET : target needs to add dependencie
+# TARGET_DEPS : targets which depends on
+# ~~~
+
+function(nuttx_add_dependencies)
+
+ # parse arguments into variables
+
+ nuttx_parse_function_args(
+ FUNC
+ nuttx_add_dependencies
+ ONE_VALUE
+ TARGET
+ MULTI_VALUE
+ TARGET_DEPS
+ REQUIRED
+ TARGET
+ TARGET_DEPS
Review Comment:
TARGET_DEPS -> DEPENDS
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xuxin930 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1296592323
##########
CMakeLists.txt:
##########
@@ -373,6 +373,8 @@ include(nuttx_add_application)
include(nuttx_add_romfs)
include(nuttx_add_symtab)
include(nuttx_add_module)
+include(nuttx_add_dependencies)
+include(nuttx_apps_headers)
Review Comment:
> change to nuttx_export_header
this has been changed in patchset2.
do you mean squash these two commits? do we need to keep the discussion and revison?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xuxin930 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1302999473
##########
cmake/nuttx_apps_headers.cmake:
##########
@@ -0,0 +1,127 @@
+# ##############################################################################
+# cmake/nuttx_apps_headers.cmake
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership. The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+include(nuttx_parse_function_args)
+
+# export_relative_path_recursively
+#
+# Used to recursively add all header files under the `include_directory` to the
+# `prefix` directory and preserve their relative relationship
+#
+# When the target relative path is repeated and the original path is different
+# throws an exception and abort the build
+function(export_relative_path_recursively prefix include_directory)
+ # recursively find header files under the path
+ file(GLOB_RECURSE FOUND_FILES ${include_directory}/*.h)
+ if(FOUND_FILES)
+ foreach(FOUND_FILE ${FOUND_FILES})
+ if(EXISTS ${FOUND_FILE})
+ # take relative path
+ file(RELATIVE_PATH REL_FILE ${include_directory} ${FOUND_FILE})
+ # check for path conflicts
+ string(REPLACE "/" "_" CHECK_PROP _check_${prefix}_${REL_FILE})
+ get_property(REL_FILE_CHECK GLOBAL PROPERTY ${CHECK_PROP})
+ if(REL_FILE_CHECK AND NOT REL_FILE_CHECK STREQUAL FOUND_FILE)
+ message(
+ FATAL_ERROR
+ "Error: NUTTX_ADD_APPS_HEADER add a duplicate header files ${FOUND_FILE} ${REL_FILE_CHECK}"
+ )
+ endif()
+ set_property(GLOBAL PROPERTY ${CHECK_PROP} ${FOUND_FILE})
+ message(
+ VERBOSE
+ "NUTTX_ADD_APPS_HEADER: REL_FILE found: ${REL_FILE} in ${INCDIR}")
+ # create symbolic lick in the BINAPPS/include directory
+ file(CREATE_LINK ${FOUND_FILE} ${prefix}/${REL_FILE} COPY_ON_ERROR
+ SYMBOLIC)
+ endif()
+ endforeach()
+ endif()
+endfunction()
+
+# ~~~
+# nuttx_export_header
+#
+# Description:
+# Export include directory to apps global include path.
+# `${NUTTX_APPS_BINDIR}/include/${TARGET}`
+# preserve relative paths to all header files.
+#
+# In the original GNU Make build, we use `Make.defs` to add the global include path,
+# and the private include path of the application library is written in the `Makefile`
+# In Nuttx CMake build, we achieve similar global functionality through this function.
+#
+# Usage:
+# nuttx_export_header(TARGET <string> INCLUDE_DIRECTORIES <list>)
+#
+# Parameters:
+# TARGET : target for exporting header directory
+# INCLUDE_DIRECTORIES : directory list to be exported
+#
+# Example:
+# set(INCDIRS foo/include)
+# nuttx_export_header(TARGET libfoo INCLUDE_DIRECTORIES ${INCDIRS})
+#
+# foo/include/ build/apps/include/foo/
+# ├── demo/ ├── demo/
+# | └── demo.h symbolic link | └── demo.h
Review Comment:
> why not directly search the origin source code location directly?
OK, origin header for compile, install target for export.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] acassis commented on pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#issuecomment-1677804968
> Hi @xuxin930 please include the Summary in the commit log message
I think it is not necessary because you already put it in the cmake file itself, but a better suggestion should be create a CMake instruction documentation to help people to use NuttX specific CMake rules
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xuxin930 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1294577894
##########
CMakeLists.txt:
##########
@@ -373,6 +373,8 @@ include(nuttx_add_application)
include(nuttx_add_romfs)
include(nuttx_add_symtab)
include(nuttx_add_module)
+include(nuttx_add_dependencies)
+include(nuttx_apps_headers)
Review Comment:
> could we make more general name since apps is replaceable.
Done, changed module name to `nuttx_export_header.cmake`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xuxin930 commented on a diff in pull request #10224: cmake:new feature on enhance apps header cmake module
Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on code in PR #10224:
URL: https://github.com/apache/nuttx/pull/10224#discussion_r1294577438
##########
cmake/nuttx_apps_headers.cmake:
##########
@@ -0,0 +1,127 @@
+# ##############################################################################
+# cmake/nuttx_apps_headers.cmake
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership. The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+include(nuttx_parse_function_args)
+
+# export_relative_path_recursively
+#
+# Used to recursively add all header files under the `include_directory` to the
+# `prefix` directory and preserve their relative relationship
+#
+# When the target relative path is repeated and the original path is different
+# throws an exception and abort the build
+function(export_relative_path_recursively prefix include_directory)
+ # recursively find header files under the path
+ file(GLOB_RECURSE FOUND_FILES ${include_directory}/*.h)
+ if(FOUND_FILES)
+ foreach(FOUND_FILE ${FOUND_FILES})
+ if(EXISTS ${FOUND_FILE})
+ # take relative path
+ file(RELATIVE_PATH REL_FILE ${include_directory} ${FOUND_FILE})
+ # check for path conflicts
+ string(REPLACE "/" "_" CHECK_PROP _check_${prefix}_${REL_FILE})
+ get_property(REL_FILE_CHECK GLOBAL PROPERTY ${CHECK_PROP})
+ if(REL_FILE_CHECK AND NOT REL_FILE_CHECK STREQUAL FOUND_FILE)
+ message(
+ FATAL_ERROR
+ "Error: NUTTX_ADD_APPS_HEADER add a duplicate header files ${FOUND_FILE} ${REL_FILE_CHECK}"
+ )
+ endif()
+ set_property(GLOBAL PROPERTY ${CHECK_PROP} ${FOUND_FILE})
+ message(
+ VERBOSE
+ "NUTTX_ADD_APPS_HEADER: REL_FILE found: ${REL_FILE} in ${INCDIR}")
+ # create symbolic lick in the BINAPPS/include directory
+ file(CREATE_LINK ${FOUND_FILE} ${prefix}/${REL_FILE} COPY_ON_ERROR
+ SYMBOLIC)
+ endif()
+ endforeach()
+ endif()
+endfunction()
+
+# ~~~
+# nuttx_export_header
+#
+# Description:
+# Export include directory to apps global include path.
+# `${NUTTX_APPS_BINDIR}/include/${TARGET}`
+# preserve relative paths to all header files.
+#
+# In the original GNU Make build, we use `Make.defs` to add the global include path,
+# and the private include path of the application library is written in the `Makefile`
+# In Nuttx CMake build, we achieve similar global functionality through this function.
+#
+# Usage:
+# nuttx_export_header(TARGET <string> INCLUDE_DIRECTORIES <list>)
+#
+# Parameters:
+# TARGET : target for exporting header directory
+# INCLUDE_DIRECTORIES : directory list to be exported
+#
+# Example:
+# set(INCDIRS foo/include)
+# nuttx_export_header(TARGET libfoo INCLUDE_DIRECTORIES ${INCDIRS})
+#
+# foo/include/ build/apps/include/foo/
+# ├── demo/ ├── demo/
+# | └── demo.h symbolic link | └── demo.h
Review Comment:
> can we export the origin path instead creating the symbol link?
Done🙏
##########
cmake/nuttx_apps_headers.cmake:
##########
@@ -0,0 +1,127 @@
+# ##############################################################################
+# cmake/nuttx_apps_headers.cmake
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership. The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+include(nuttx_parse_function_args)
+
+# export_relative_path_recursively
+#
+# Used to recursively add all header files under the `include_directory` to the
+# `prefix` directory and preserve their relative relationship
+#
+# When the target relative path is repeated and the original path is different
+# throws an exception and abort the build
+function(export_relative_path_recursively prefix include_directory)
+ # recursively find header files under the path
+ file(GLOB_RECURSE FOUND_FILES ${include_directory}/*.h)
+ if(FOUND_FILES)
+ foreach(FOUND_FILE ${FOUND_FILES})
+ if(EXISTS ${FOUND_FILE})
+ # take relative path
+ file(RELATIVE_PATH REL_FILE ${include_directory} ${FOUND_FILE})
+ # check for path conflicts
+ string(REPLACE "/" "_" CHECK_PROP _check_${prefix}_${REL_FILE})
+ get_property(REL_FILE_CHECK GLOBAL PROPERTY ${CHECK_PROP})
+ if(REL_FILE_CHECK AND NOT REL_FILE_CHECK STREQUAL FOUND_FILE)
+ message(
+ FATAL_ERROR
+ "Error: NUTTX_ADD_APPS_HEADER add a duplicate header files ${FOUND_FILE} ${REL_FILE_CHECK}"
+ )
+ endif()
+ set_property(GLOBAL PROPERTY ${CHECK_PROP} ${FOUND_FILE})
+ message(
+ VERBOSE
+ "NUTTX_ADD_APPS_HEADER: REL_FILE found: ${REL_FILE} in ${INCDIR}")
+ # create symbolic lick in the BINAPPS/include directory
+ file(CREATE_LINK ${FOUND_FILE} ${prefix}/${REL_FILE} COPY_ON_ERROR
+ SYMBOLIC)
+ endif()
+ endforeach()
+ endif()
+endfunction()
+
+# ~~~
+# nuttx_export_header
+#
+# Description:
+# Export include directory to apps global include path.
+# `${NUTTX_APPS_BINDIR}/include/${TARGET}`
+# preserve relative paths to all header files.
+#
+# In the original GNU Make build, we use `Make.defs` to add the global include path,
+# and the private include path of the application library is written in the `Makefile`
+# In Nuttx CMake build, we achieve similar global functionality through this function.
+#
+# Usage:
+# nuttx_export_header(TARGET <string> INCLUDE_DIRECTORIES <list>)
+#
+# Parameters:
+# TARGET : target for exporting header directory
+# INCLUDE_DIRECTORIES : directory list to be exported
+#
+# Example:
+# set(INCDIRS foo/include)
+# nuttx_export_header(TARGET libfoo INCLUDE_DIRECTORIES ${INCDIRS})
+#
+# foo/include/ build/apps/include/foo/
+# ├── demo/ ├── demo/
+# | └── demo.h symbolic link | └── demo.h
Review Comment:
> can we export the origin path instead creating the symbol link?
Done🙏
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org