From 77dc5a8e3e30d9fcdc2ad7ac929d505e63cc56dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 24 Oct 2019 20:32:04 +0900 Subject: [PATCH] [nnfw-api] Remove header install by copy (#8376) Divide nnfw api directory to src and include, and install public headers Rename nnapi directory and install public header Signed-off-by: Hyeongseok Oh --- infra/nnfw/CMakeLists.txt | 5 ----- packaging/nnfw.spec | 4 ---- runtimes/CMakeLists.txt | 12 +----------- runtimes/libs/nnapi/v1.1/CMakeLists.txt | 2 +- runtimes/libs/nnapi/v1.2/CMakeLists.txt | 2 +- runtimes/logging/CMakeLists.txt | 6 +++++- runtimes/neurun/CMakeLists.txt | 4 ++++ runtimes/neurun/api/CMakeLists.txt | 14 +++++++++++--- runtimes/{ => neurun/api}/include/nnfw.h | 0 runtimes/{ => neurun/api}/include/nnfw_dev.h | 0 runtimes/neurun/api/{ => src}/CustomKernel.cc | 0 runtimes/neurun/api/{ => src}/CustomKernel.h | 0 runtimes/neurun/api/{ => src}/CustomKernelRegistry.cc | 0 runtimes/neurun/api/{ => src}/CustomKernelRegistry.h | 0 runtimes/neurun/api/{ => src}/nnfw_api.cc | 0 runtimes/neurun/api/{ => src}/nnfw_api_internal.cc | 0 runtimes/neurun/api/{ => src}/nnfw_api_internal.h | 0 runtimes/neurun/core/CMakeLists.txt | 2 +- runtimes/neurun/frontend/nnapi/CMakeLists.txt | 2 +- runtimes/nnapi-header/CMakeLists.txt | 8 ++++++++ runtimes/{ => nnapi-header}/include/NeuralNetworks.h | 0 runtimes/{ => nnapi-header}/include/NeuralNetworksEx.h | 0 .../{ => nnapi-header}/include/NeuralNetworksExtensions.h | 0 runtimes/pure_arm_compute/CMakeLists.txt | 2 +- tests/custom_op/apps/CMakeLists.txt | 2 +- tests/custom_op/kernels/CMakeLists.txt | 2 +- 26 files changed, 36 insertions(+), 31 deletions(-) rename runtimes/{ => neurun/api}/include/nnfw.h (100%) rename runtimes/{ => neurun/api}/include/nnfw_dev.h (100%) rename runtimes/neurun/api/{ => src}/CustomKernel.cc (100%) rename runtimes/neurun/api/{ => src}/CustomKernel.h (100%) rename runtimes/neurun/api/{ => src}/CustomKernelRegistry.cc (100%) rename runtimes/neurun/api/{ => src}/CustomKernelRegistry.h (100%) rename runtimes/neurun/api/{ => src}/nnfw_api.cc (100%) rename runtimes/neurun/api/{ => src}/nnfw_api_internal.cc (100%) rename runtimes/neurun/api/{ => src}/nnfw_api_internal.h (100%) create mode 100644 runtimes/nnapi-header/CMakeLists.txt rename runtimes/{ => nnapi-header}/include/NeuralNetworks.h (100%) rename runtimes/{ => nnapi-header}/include/NeuralNetworksEx.h (100%) rename runtimes/{ => nnapi-header}/include/NeuralNetworksExtensions.h (100%) diff --git a/infra/nnfw/CMakeLists.txt b/infra/nnfw/CMakeLists.txt index 15dd62f..d606597 100644 --- a/infra/nnfw/CMakeLists.txt +++ b/infra/nnfw/CMakeLists.txt @@ -93,12 +93,7 @@ endif(ENABLE_COVERAGE) nnas_include(AddSubdirectories) -add_library(nnfw-header INTERFACE) -target_include_directories(nnfw-header INTERFACE ${NNAS_PROJECT_SOURCE_DIR}/runtimes/include) - add_subdirectory(${NNAS_PROJECT_SOURCE_DIR}/compute compute) -add_subdirectory(${NNAS_PROJECT_SOURCE_DIR}/runtimes/contrib contrib) -add_subdirectory(${NNAS_PROJECT_SOURCE_DIR}/runtimes/libs libs) add_subdirectory(${NNAS_PROJECT_SOURCE_DIR}/runtimes runtimes) add_subdirectory(${NNAS_PROJECT_SOURCE_DIR}/tests tests) add_subdirectory(${NNAS_PROJECT_SOURCE_DIR}/tools tools) diff --git a/packaging/nnfw.spec b/packaging/nnfw.spec index efd1b7d..1553700 100644 --- a/packaging/nnfw.spec +++ b/packaging/nnfw.spec @@ -89,10 +89,6 @@ cp -v Makefile.template Makefile %ifarch arm armv7l aarch64 %{build_options} make install -# copy header's for devel -mkdir -p %{buildroot}%{_includedir} -cp -rf runtimes/include/* %{buildroot}%{_includedir} - %ifarch aarch64 mv %{buildroot}%{_prefix}/lib %{buildroot}%{_libdir} %endif diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index a303040..5ea6cda 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -1,11 +1 @@ -if(BUILD_NEURUN) - add_subdirectory(neurun) -endif(BUILD_NEURUN) - -if(BUILD_PURE_ARM_COMPUTE) - add_subdirectory(pure_arm_compute) -endif() - -if(BUILD_LOGGING) - add_subdirectory(logging) -endif(BUILD_LOGGING) +add_subdirectories() diff --git a/runtimes/libs/nnapi/v1.1/CMakeLists.txt b/runtimes/libs/nnapi/v1.1/CMakeLists.txt index 1bc158f..dc018c6 100644 --- a/runtimes/libs/nnapi/v1.1/CMakeLists.txt +++ b/runtimes/libs/nnapi/v1.1/CMakeLists.txt @@ -1,4 +1,4 @@ add_library(nnfw_lib_nnapi_1_1 INTERFACE) target_include_directories(nnfw_lib_nnapi_1_1 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) -target_link_libraries(nnfw_lib_nnapi_1_1 INTERFACE nnfw-header) +target_link_libraries(nnfw_lib_nnapi_1_1 INTERFACE nnfw-nnapi-header) diff --git a/runtimes/libs/nnapi/v1.2/CMakeLists.txt b/runtimes/libs/nnapi/v1.2/CMakeLists.txt index 9aef6f1..21ec301 100644 --- a/runtimes/libs/nnapi/v1.2/CMakeLists.txt +++ b/runtimes/libs/nnapi/v1.2/CMakeLists.txt @@ -1,4 +1,4 @@ add_library(nnfw_lib_nnapi_1_2 INTERFACE) target_include_directories(nnfw_lib_nnapi_1_2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) -target_link_libraries(nnfw_lib_nnapi_1_2 INTERFACE nnfw-header) +target_link_libraries(nnfw_lib_nnapi_1_2 INTERFACE nnfw-nnapi-header) diff --git a/runtimes/logging/CMakeLists.txt b/runtimes/logging/CMakeLists.txt index 48c06e6..b200bf8 100644 --- a/runtimes/logging/CMakeLists.txt +++ b/runtimes/logging/CMakeLists.txt @@ -1,3 +1,7 @@ +if(NOT BUILD_LOGGING) + return() +endif(NOT BUILD_LOGGING) + file(GLOB_RECURSE NNAPI_LOGGING_SRCS "src/*.cc") nnas_find_package(Boost REQUIRED) @@ -5,4 +9,4 @@ nnas_find_package(Boost REQUIRED) add_library(neuralnetworks SHARED ${NNAPI_LOGGING_SRCS}) target_include_directories(neuralnetworks PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories(neuralnetworks PRIVATE ${Boost_INCLUDE_DIRS}) -target_link_libraries(neuralnetworks PUBLIC nnfw-header) +target_link_libraries(neuralnetworks PUBLIC nnfw-nnapi-header) diff --git a/runtimes/neurun/CMakeLists.txt b/runtimes/neurun/CMakeLists.txt index c4754f8..4b3def5 100644 --- a/runtimes/neurun/CMakeLists.txt +++ b/runtimes/neurun/CMakeLists.txt @@ -1,3 +1,7 @@ +if(NOT BUILD_NEURUN) + return() +endif(NOT BUILD_NEURUN) + # Add cpu # TODO Remove this variable as adding include dirs is done with target_link_libraries diff --git a/runtimes/neurun/api/CMakeLists.txt b/runtimes/neurun/api/CMakeLists.txt index 4ded7ad..97758fd 100644 --- a/runtimes/neurun/api/CMakeLists.txt +++ b/runtimes/neurun/api/CMakeLists.txt @@ -3,9 +3,17 @@ file(GLOB_RECURSE API_SRC "*.cc") set(NEURUN_DEV nnfw-dev) add_library(${NEURUN_DEV} SHARED ${API_SRC}) -target_link_libraries(${NEURUN_DEV} PUBLIC nnfw-header) -target_link_libraries(${NEURUN_DEV} PUBLIC neurun_core) # TODO Link PRIVATE neurun_core +# Public headers to publish +set(NNFW_API_HEADERS include/nnfw.h include/nnfw_dev.h) + +target_link_libraries(${NEURUN_DEV} PUBLIC nnfw-nnapi-header) +target_link_libraries(${NEURUN_DEV} PRIVATE neurun_core) target_link_libraries(${NEURUN_DEV} PRIVATE jsoncpp tflite_loader circle_loader ${LIB_PTHREAD}) target_link_libraries(${NEURUN_DEV} PRIVATE nnfw_common) target_link_libraries(${NEURUN_DEV} PRIVATE nnfw_coverage) -install(TARGETS ${NEURUN_DEV} DESTINATION lib) +target_include_directories(${NEURUN_DEV} PUBLIC include) +set_target_properties(${NEURUN_DEV} PROPERTIES PUBLIC_HEADER "${NNFW_API_HEADERS}") + +install(TARGETS ${NEURUN_DEV} + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include) diff --git a/runtimes/include/nnfw.h b/runtimes/neurun/api/include/nnfw.h similarity index 100% rename from runtimes/include/nnfw.h rename to runtimes/neurun/api/include/nnfw.h diff --git a/runtimes/include/nnfw_dev.h b/runtimes/neurun/api/include/nnfw_dev.h similarity index 100% rename from runtimes/include/nnfw_dev.h rename to runtimes/neurun/api/include/nnfw_dev.h diff --git a/runtimes/neurun/api/CustomKernel.cc b/runtimes/neurun/api/src/CustomKernel.cc similarity index 100% rename from runtimes/neurun/api/CustomKernel.cc rename to runtimes/neurun/api/src/CustomKernel.cc diff --git a/runtimes/neurun/api/CustomKernel.h b/runtimes/neurun/api/src/CustomKernel.h similarity index 100% rename from runtimes/neurun/api/CustomKernel.h rename to runtimes/neurun/api/src/CustomKernel.h diff --git a/runtimes/neurun/api/CustomKernelRegistry.cc b/runtimes/neurun/api/src/CustomKernelRegistry.cc similarity index 100% rename from runtimes/neurun/api/CustomKernelRegistry.cc rename to runtimes/neurun/api/src/CustomKernelRegistry.cc diff --git a/runtimes/neurun/api/CustomKernelRegistry.h b/runtimes/neurun/api/src/CustomKernelRegistry.h similarity index 100% rename from runtimes/neurun/api/CustomKernelRegistry.h rename to runtimes/neurun/api/src/CustomKernelRegistry.h diff --git a/runtimes/neurun/api/nnfw_api.cc b/runtimes/neurun/api/src/nnfw_api.cc similarity index 100% rename from runtimes/neurun/api/nnfw_api.cc rename to runtimes/neurun/api/src/nnfw_api.cc diff --git a/runtimes/neurun/api/nnfw_api_internal.cc b/runtimes/neurun/api/src/nnfw_api_internal.cc similarity index 100% rename from runtimes/neurun/api/nnfw_api_internal.cc rename to runtimes/neurun/api/src/nnfw_api_internal.cc diff --git a/runtimes/neurun/api/nnfw_api_internal.h b/runtimes/neurun/api/src/nnfw_api_internal.h similarity index 100% rename from runtimes/neurun/api/nnfw_api_internal.h rename to runtimes/neurun/api/src/nnfw_api_internal.h diff --git a/runtimes/neurun/core/CMakeLists.txt b/runtimes/neurun/core/CMakeLists.txt index d5449a9..63b8cf9 100644 --- a/runtimes/neurun/core/CMakeLists.txt +++ b/runtimes/neurun/core/CMakeLists.txt @@ -15,4 +15,4 @@ if(ENVVAR_NEURUN_CONFIG) target_compile_definitions(neurun_core PRIVATE ENVVAR_FOR_DEFAULT_CONFIG) endif(ENVVAR_NEURUN_CONFIG) -target_link_libraries(neurun_core PUBLIC nnfw-header) # To be removed later +target_link_libraries(neurun_core PUBLIC nnfw-nnapi-header) # To be removed later diff --git a/runtimes/neurun/frontend/nnapi/CMakeLists.txt b/runtimes/neurun/frontend/nnapi/CMakeLists.txt index 2a98d76..39c276d 100644 --- a/runtimes/neurun/frontend/nnapi/CMakeLists.txt +++ b/runtimes/neurun/frontend/nnapi/CMakeLists.txt @@ -5,7 +5,7 @@ list(REMOVE_ITEM SOURCES_FRONTEND ${TESTS_FRONTEND}) set(LIB_NEURUN neurun) add_library(${LIB_NEURUN} SHARED ${SOURCES_FRONTEND}) -target_link_libraries(${LIB_NEURUN} PUBLIC nnfw-header) +target_link_libraries(${LIB_NEURUN} PUBLIC nnfw-nnapi-header) target_link_libraries(${LIB_NEURUN} PUBLIC neurun_core) # TODO Link PRIVATE neurun_core target_link_libraries(${LIB_NEURUN} PRIVATE nnfw_common) target_link_libraries(${LIB_NEURUN} PRIVATE nnfw_coverage) diff --git a/runtimes/nnapi-header/CMakeLists.txt b/runtimes/nnapi-header/CMakeLists.txt new file mode 100644 index 0000000..21d0e1c --- /dev/null +++ b/runtimes/nnapi-header/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(nnfw-nnapi-header INTERFACE) +target_include_directories(nnfw-nnapi-header INTERFACE include) + +set(NNFW_NNAPI_HEADERS ${CMAKE_CURRENT_LIST_DIR}/include/NeuralNetworks.h + ${CMAKE_CURRENT_LIST_DIR}/include/NeuralNetworksEx.h + ${CMAKE_CURRENT_LIST_DIR}/include/NeuralNetworksExtensions.h) + +install(FILES ${NNFW_NNAPI_HEADERS} DESTINATION include) diff --git a/runtimes/include/NeuralNetworks.h b/runtimes/nnapi-header/include/NeuralNetworks.h similarity index 100% rename from runtimes/include/NeuralNetworks.h rename to runtimes/nnapi-header/include/NeuralNetworks.h diff --git a/runtimes/include/NeuralNetworksEx.h b/runtimes/nnapi-header/include/NeuralNetworksEx.h similarity index 100% rename from runtimes/include/NeuralNetworksEx.h rename to runtimes/nnapi-header/include/NeuralNetworksEx.h diff --git a/runtimes/include/NeuralNetworksExtensions.h b/runtimes/nnapi-header/include/NeuralNetworksExtensions.h similarity index 100% rename from runtimes/include/NeuralNetworksExtensions.h rename to runtimes/nnapi-header/include/NeuralNetworksExtensions.h diff --git a/runtimes/pure_arm_compute/CMakeLists.txt b/runtimes/pure_arm_compute/CMakeLists.txt index 47117bb..f9cdfcb 100644 --- a/runtimes/pure_arm_compute/CMakeLists.txt +++ b/runtimes/pure_arm_compute/CMakeLists.txt @@ -13,7 +13,7 @@ target_include_directories(nnapi_pure_arm_compute PUBLIC src) if(BUILD_TFLITE_BENCHMARK_MODEL) target_compile_definitions(nnapi_pure_arm_compute PUBLIC "TFLITE_PROFILING_ENABLED") endif() -target_link_libraries(nnapi_pure_arm_compute nnfw-header) +target_link_libraries(nnapi_pure_arm_compute nnfw-nnapi-header) target_link_libraries(nnapi_pure_arm_compute arm_compute arm_compute_ex) target_link_libraries(nnapi_pure_arm_compute nnfw_lib_cpp14 nnfw_lib_misc nnfw_lib_profiling) diff --git a/tests/custom_op/apps/CMakeLists.txt b/tests/custom_op/apps/CMakeLists.txt index ccaebf1..c7c266e 100644 --- a/tests/custom_op/apps/CMakeLists.txt +++ b/tests/custom_op/apps/CMakeLists.txt @@ -13,7 +13,7 @@ function(add_nnfw_custom_op_app NAME) ) add_executable(${NAME} ${PARSED_ARGS_SOURCES}) target_link_libraries(${NAME} PRIVATE ${PARSED_ARGS_KERNELS}) - target_link_libraries(${NAME} PRIVATE nnfw-header nnfw-dev) + target_link_libraries(${NAME} PRIVATE nnfw-nnapi-header nnfw-dev) target_link_libraries(${NAME} PRIVATE dl ${LIB_PTHREAD}) endfunction() diff --git a/tests/custom_op/kernels/CMakeLists.txt b/tests/custom_op/kernels/CMakeLists.txt index 1d292f3..1906e78 100644 --- a/tests/custom_op/kernels/CMakeLists.txt +++ b/tests/custom_op/kernels/CMakeLists.txt @@ -2,7 +2,7 @@ nnfw_find_package(FlatBuffers REQUIRED) function(add_nnfw_kernel NAME) add_library(${NAME} STATIC ${ARGN}) - target_link_libraries(${NAME} PRIVATE nnfw-header nnfw-dev) + target_link_libraries(${NAME} PRIVATE nnfw-nnapi-header nnfw-dev) target_link_libraries(${NAME} PRIVATE flatbuffers) endfunction() -- 2.7.4