From 969e5730cec9632d9d5a3b73e17d617cec411aae Mon Sep 17 00:00:00 2001 From: Neucrack Date: Sat, 11 May 2024 19:53:01 +0800 Subject: [PATCH] optimzie downloader --- components/3rd_party/asio/CMakeLists.txt | 26 +-- components/3rd_party/asio/component.py | 25 +++ components/3rd_party/brotli/CMakeLists.txt | 29 +--- components/3rd_party/brotli/component.py | 31 ++++ .../3rd_party/cpp-httplib/CMakeLists.txt | 15 -- components/3rd_party/cvi_tpu/CMakeLists.txt | 26 --- components/3rd_party/cvi_tpu/component.py | 35 ++++ components/3rd_party/freetype/CMakeLists.txt | 31 ---- components/3rd_party/freetype/component.py | 31 ++++ components/3rd_party/harfbuzz/CMakeLists.txt | 41 +---- components/3rd_party/harfbuzz/component.py | 62 +++++++ components/3rd_party/ini/CMakeLists.txt | 16 -- components/3rd_party/lvgl/CMakeLists.txt | 27 +-- components/3rd_party/lvgl/component.py | 36 ++++ .../3rd_party/media_server/CMakeLists.txt | 26 +-- .../3rd_party/media_server/component.py | 32 ++++ components/3rd_party/omv/CMakeLists.txt | 46 +---- components/3rd_party/omv/component.py | 34 ++++ components/3rd_party/opencv/CMakeLists.txt | 67 -------- components/3rd_party/opencv/component.py | 124 ++++++++++++++ components/3rd_party/openssl/CMakeLists.txt | 26 --- components/3rd_party/openssl/component.py | 35 ++++ components/3rd_party/pybind11/CMakeLists.txt | 17 -- components/3rd_party/python3/CMakeLists.txt | 64 ------- components/3rd_party/python3/component.py | 80 +++++++++ components/3rd_party/qrcode/CMakeLists.txt | 14 -- components/3rd_party/qrcode/component.py | 35 ++++ components/3rd_party/rlottie/CMakeLists.txt | 15 -- components/3rd_party/rlottie/component.py | 35 ++++ components/3rd_party/sdl/CMakeLists.txt | 31 ---- components/3rd_party/sdl/component.py | 34 ++++ components/3rd_party/sunxi_mpp/CMakeLists.txt | 18 -- components/3rd_party/sunxi_mpp/component.py | 34 ++++ components/3rd_party/websocket/CMakeLists.txt | 26 --- components/3rd_party/websocket/component.py | 34 ++++ components/basic/CMakeLists.txt | 16 -- components/comm/CMakeLists.txt | 16 -- components/maixcam_lib/CMakeLists.txt | 42 ----- components/maixcam_lib/component.py | 29 ++++ components/network/CMakeLists.txt | 16 -- components/nn/CMakeLists.txt | 16 -- components/peripheral/CMakeLists.txt | 16 -- components/vision/CMakeLists.txt | 18 +- dl/README.md | 35 +++- docs/doc/dev/quick_start.md | 2 +- examples/hello_world/main/CMakeLists.txt | 2 +- test/test_examples/test_cases.sh | 3 +- tools/cmake/build.py | 157 +++++++++++++++++- tools/cmake/compile.cmake | 89 ++++++---- tools/{ => cmake}/file_downloader.py | 5 +- 50 files changed, 991 insertions(+), 729 deletions(-) create mode 100644 components/3rd_party/asio/component.py create mode 100644 components/3rd_party/brotli/component.py create mode 100644 components/3rd_party/cvi_tpu/component.py create mode 100644 components/3rd_party/freetype/component.py create mode 100644 components/3rd_party/harfbuzz/component.py create mode 100644 components/3rd_party/lvgl/component.py create mode 100644 components/3rd_party/media_server/component.py create mode 100644 components/3rd_party/omv/component.py create mode 100644 components/3rd_party/opencv/component.py create mode 100644 components/3rd_party/openssl/component.py create mode 100644 components/3rd_party/python3/component.py create mode 100644 components/3rd_party/qrcode/component.py create mode 100644 components/3rd_party/rlottie/component.py create mode 100644 components/3rd_party/sdl/component.py create mode 100644 components/3rd_party/sunxi_mpp/component.py create mode 100644 components/3rd_party/websocket/component.py create mode 100644 components/maixcam_lib/component.py rename tools/{ => cmake}/file_downloader.py (98%) diff --git a/components/3rd_party/asio/CMakeLists.txt b/components/3rd_party/asio/CMakeLists.txt index f9419c4f..2d6104ae 100644 --- a/components/3rd_party/asio/CMakeLists.txt +++ b/components/3rd_party/asio/CMakeLists.txt @@ -1,13 +1,4 @@ -list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': 'https://phoenixnap.dl.sourceforge.net/project/asio/asio/1.28.0%20%28Stable%29/asio-1.28.0.tar.gz', - 'urls':[], - 'sites': ['https://sourceforge.net/projects/asio/files/asio/1.28.0%20%28Stable%29/'], - 'sha256sum': 'e854a53cc6fe599bdf830e3c607f1d22fe74eee892f64c81d3ca997a80ddca97', - 'filename': 'asio-1.28.0.tar.gz', - 'path': 'asio', - 'check_files': ['asio-1.28.0'] -}" -) + set(asio_root "${DL_EXTRACTED_PATH}/asio/asio-1.28.0") list(APPEND ADD_INCLUDE "${asio_root}/include") # append_srcs_dir(ADD_SRCS "${asio_root}/src") @@ -65,21 +56,6 @@ list(APPEND ADD_DEFINITIONS -DASIO_STANDALONE=1) # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib register_component() diff --git a/components/3rd_party/asio/component.py b/components/3rd_party/asio/component.py new file mode 100644 index 00000000..2666fb43 --- /dev/null +++ b/components/3rd_party/asio/component.py @@ -0,0 +1,25 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + url = "https://phoenixnap.dl.sourceforge.net/project/asio/asio/1.28.0%20%28Stable%29/asio-1.28.0.tar.gz" + sha256sum = "e854a53cc6fe599bdf830e3c607f1d22fe74eee892f64c81d3ca997a80ddca97" + filename = "asio-1.28.0.tar.gz" + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': ['https://sourceforge.net/projects/asio/files/asio/1.28.0%20%28Stable%29/'], + 'sha256sum': sha256sum, + 'filename': filename, + 'path': 'asio', + 'check_files': [ + 'asio-1.28.0' + ] + } + ] + + diff --git a/components/3rd_party/brotli/CMakeLists.txt b/components/3rd_party/brotli/CMakeLists.txt index c928c91d..d8d6ca05 100644 --- a/components/3rd_party/brotli/CMakeLists.txt +++ b/components/3rd_party/brotli/CMakeLists.txt @@ -66,21 +66,6 @@ # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## set(version_str "${CONFIG_BROTLI_VERSION_MAJOR}.${CONFIG_BROTLI_VERSION_MINOR}.${CONFIG_BROTLI_VERSION_PATCH}") @@ -100,25 +85,15 @@ set_property(SOURCE ${include_dir} PROPERTY GENERATED 1) set_property(SOURCE ${h_path} PROPERTY GENERATED 1) set_property(SOURCE ${lib_file} PROPERTY GENERATED 1) -set(brotli_url "https://master.dl.sourceforge.net/project/brotli.mirror/v${version_str}/v${version_str}.tar.gz?viasf=1") -set(brotli_filename "brotli-${version_str}.tar.gz") set(brotli_unzip_path "${DL_EXTRACTED_PATH}/brotli_srcs") set(brotli_src_path "${brotli_unzip_path}/google-brotli-${version_str}") if(version_str EQUAL "1.1.0") - set(brotli_file_sha256sum "10973f4b4199eafa1d5735ef661ddb2ec2f97319ee9fd1824d4aabe08cff5265") set(brotli_src_path "${brotli_unzip_path}/google-brotli-ed738e8") else() message(FATAL_ERROR "No brotli version ${version_str} support, please edit to add brotli support for this version") endif() -list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${brotli_url}', - 'urls': [], - 'sha256sum': '${brotli_file_sha256sum}', - 'filename': '${brotli_filename}', - 'path': 'brotli_srcs', - 'check_files': ['google-brotli-${version_str}'] - }" -) + + if(PLATFORM_M2DOCK) set(brotli_toolchain_file ${CMAKE_CURRENT_LIST_DIR}/toolchain_m2dock.cmake) elseif(PLATFORM_MAIXCAM) diff --git a/components/3rd_party/brotli/component.py b/components/3rd_party/brotli/component.py new file mode 100644 index 00000000..5f19987a --- /dev/null +++ b/components/3rd_party/brotli/component.py @@ -0,0 +1,31 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + version = f"{confs['CONFIG_BROTLI_VERSION_MAJOR']}.{confs['CONFIG_BROTLI_VERSION_MINOR']}.{confs['CONFIG_BROTLI_VERSION_PATCH']}" + url = f"https://master.dl.sourceforge.net/project/brotli.mirror/v{version}/v{version}.tar.gz?viasf=1" + if version == "1.1.0": + sha256sum = "10973f4b4199eafa1d5735ef661ddb2ec2f97319ee9fd1824d4aabe08cff5265" + else: + raise Exception(f"version {version} not support") + filename = f"brotli-{version}.tar.gz" + path = "brotli_srcs" + check_file = f'google-brotli-{version}' + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': [], + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ] + } + ] + + diff --git a/components/3rd_party/cpp-httplib/CMakeLists.txt b/components/3rd_party/cpp-httplib/CMakeLists.txt index 7d3b92d5..c7427456 100644 --- a/components/3rd_party/cpp-httplib/CMakeLists.txt +++ b/components/3rd_party/cpp-httplib/CMakeLists.txt @@ -66,21 +66,6 @@ register_component() # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib # register_component() diff --git a/components/3rd_party/cvi_tpu/CMakeLists.txt b/components/3rd_party/cvi_tpu/CMakeLists.txt index ba85a142..cfcbcc49 100644 --- a/components/3rd_party/cvi_tpu/CMakeLists.txt +++ b/components/3rd_party/cvi_tpu/CMakeLists.txt @@ -18,16 +18,6 @@ if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/cvi_tpu_lib) endif() elseif(PLATFORM_MAIXCAM AND NOT CONFIG_COMPONENTS_COMPILE_FROM_SOURCE) if(CONFIG_TOOLCHAIN_PATH MATCHES "musl" OR CONFIG_TOOLCHAIN_PATH MATCHES "glibc") - list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': 'https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/cvi_tpu_lib_v4.1.0-23-gb920beb.tar.xz', - 'urls': [], - 'sites': ['https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0'], - 'sha256sum': '8177ce35a05565a4fdc6cf1ac6bef0dc18809a31fff332321e17d01d2b85421a', - 'filename': 'cvi_tpu_lib_v4.1.0-23-gb920beb.tar.xz', - 'path': 'cvi_tpu', - 'check_files': ['cvi_tpu_lib_v4.1.0-23-gb920beb'] - }" - ) set(cvi_tpu_lib_dir "${DL_EXTRACTED_PATH}/cvi_tpu/cvi_tpu_lib_v4.1.0-23-gb920beb") set(harfbuzz_include_dir "${cvi_tpu_lib_dir}/include") set_property(SOURCE ${harfbuzz_include_dir} PROPERTY GENERATED 1) @@ -118,22 +108,6 @@ register_component() # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib # register_component() diff --git a/components/3rd_party/cvi_tpu/component.py b/components/3rd_party/cvi_tpu/component.py new file mode 100644 index 00000000..24168811 --- /dev/null +++ b/components/3rd_party/cvi_tpu/component.py @@ -0,0 +1,35 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + if (not confs.get("PLATFORM_MAIXCAM", None)) or confs.get("CONFIG_COMPONENTS_COMPILE_FROM_SOURCE", None): + return [] + if "musl" not in confs["CONFIG_TOOLCHAIN_PATH"] and "glibc" not in confs["CONFIG_TOOLCHAIN_PATH"]: + return [] + version = f"{confs['CONFIG_BROTLI_VERSION_MAJOR']}.{confs['CONFIG_BROTLI_VERSION_MINOR']}.{confs['CONFIG_BROTLI_VERSION_PATCH']}" + url = "https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/cvi_tpu_lib_v4.1.0-23-gb920beb.tar.xz" + sha256sum = "8177ce35a05565a4fdc6cf1ac6bef0dc18809a31fff332321e17d01d2b85421a" + filename = "cvi_tpu_lib_v4.1.0-23-gb920beb.tar.xz" + path = "cvi_tpu" + check_file = 'cvi_tpu_lib_v4.1.0-23-gb920beb' + sites = [ + 'https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0' + ] + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ] + } + ] + + diff --git a/components/3rd_party/freetype/CMakeLists.txt b/components/3rd_party/freetype/CMakeLists.txt index df491143..6573f1b9 100644 --- a/components/3rd_party/freetype/CMakeLists.txt +++ b/components/3rd_party/freetype/CMakeLists.txt @@ -66,23 +66,6 @@ list(APPEND ADD_REQUIREMENTS brotli) # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - - set(freetype_version_str "${CONFIG_FREETYPE_VERSION_MAJOR}.${CONFIG_FREETYPE_VERSION_MINOR}.${CONFIG_FREETYPE_VERSION_PATCH}") # write build python version to CMAKE_BINARY_DIR/config/python_version.txt @@ -104,22 +87,8 @@ set_property(SOURCE ${freetype_include_dir} PROPERTY GENERATED 1) set_property(SOURCE ${freetype_h_path} PROPERTY GENERATED 1) set_property(SOURCE ${freetype_lib_file} PROPERTY GENERATED 1) -set(freetype_url "https://phoenixnap.dl.sourceforge.net/project/freetype/freetype2/${freetype_version_str}/freetype-${freetype_version_str}.tar.xz") -set(freetype_filename "freetype-${freetype_version_str}.tar.xz") set(freetype_unzip_path "${DL_EXTRACTED_PATH}/freetype_srcs") set(freetype_src_path "${freetype_unzip_path}/freetype-${freetype_version_str}") -if(freetype_version_str EQUAL "2.13.2") - set(freetype_file_sha256sum "12991c4e55c506dd7f9b765933e62fd2be2e06d421505d7950a132e4f1bb484d") -endif() -list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${freetype_url}', - 'urls': [], - 'sha256sum': '${freetype_file_sha256sum}', - 'filename': '${freetype_filename}', - 'path': 'freetype_srcs', - 'check_files': ['freetype-${freetype_version_str}'] - }" -) if(PLATFORM_M2DOCK) set(freetype_toolchain_file ${CMAKE_CURRENT_LIST_DIR}/toolchain_m2dock.cmake) elseif(PLATFORM_MAIXCAM) diff --git a/components/3rd_party/freetype/component.py b/components/3rd_party/freetype/component.py new file mode 100644 index 00000000..3072e788 --- /dev/null +++ b/components/3rd_party/freetype/component.py @@ -0,0 +1,31 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + version = f"{confs['CONFIG_FREETYPE_VERSION_MAJOR']}.{confs['CONFIG_FREETYPE_VERSION_MINOR']}.{confs['CONFIG_FREETYPE_VERSION_PATCH']}" + url = f"https://phoenixnap.dl.sourceforge.net/project/freetype/freetype2/{version}/freetype-{version}.tar.xz" + if version == "2.13.2": + sha256sum = "12991c4e55c506dd7f9b765933e62fd2be2e06d421505d7950a132e4f1bb484d" + else: + raise Exception(f"version {version} not support") + filename = f"freetype-{version}.tar.xz" + path = "freetype_srcs" + check_file = f'freetype-{version}' + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': [], + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ] + } + ] + + diff --git a/components/3rd_party/harfbuzz/CMakeLists.txt b/components/3rd_party/harfbuzz/CMakeLists.txt index 7b9aaac1..3be0f6c6 100644 --- a/components/3rd_party/harfbuzz/CMakeLists.txt +++ b/components/3rd_party/harfbuzz/CMakeLists.txt @@ -66,22 +66,6 @@ # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - list(APPEND ADD_REQUIREMENTS freetype yaml) set(harfbuzz_version_str "${CONFIG_HARFBUZZ_VERSION_MAJOR}.${CONFIG_HARFBUZZ_VERSION_MINOR}.${CONFIG_HARFBUZZ_VERSION_PATCH}") @@ -91,16 +75,6 @@ set(harfbuzz_version_str "${CONFIG_HARFBUZZ_VERSION_MAJOR}.${CONFIG_HARFBUZZ_VER if(PLATFORM_MAIXCAM AND NOT CONFIG_COMPONENTS_COMPILE_FROM_SOURCE) if(CONFIG_TOOLCHAIN_PATH MATCHES "musl") - list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': 'https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/harfbuzz_maixcam_musl_v8.2.1.tar.xz', - 'urls': [], - 'sites': ['https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0'], - 'sha256sum': '0ee057914aeabd4d44c23f776e3dde79a3ec0a34cfe5e0a9c09737d0bf34e7fb', - 'filename': 'harfbuzz_maixcam_musl_v8.2.1.tar.xz', - 'path': 'harfbuzz', - 'check_files': ['harfbuzz_maixcam_musl_v8.2.1'] - }" - ) set(harfbuzz_lib_dir "${DL_EXTRACTED_PATH}/harfbuzz/harfbuzz_maixcam_musl_v8.2.1") set(harfbuzz_include_dir "${harfbuzz_lib_dir}/include/harfbuzz" "${harfbuzz_lib_dir}/include") set(harfbuzz_lib_file "${harfbuzz_lib_dir}/lib/libharfbuzz.a") @@ -124,22 +98,9 @@ if(NOT ADD_INCLUDE) set_property(SOURCE ${harfbuzz_h_path} PROPERTY GENERATED 1) set_property(SOURCE ${harfbuzz_lib_file} PROPERTY GENERATED 1) - set(harfbuzz_url "https://master.dl.sourceforge.net/project/harfbuzz.mirror/${harfbuzz_version_str}/harfbuzz-${harfbuzz_version_str}.tar.xz?viasf=1") - set(harfbuzz_filename "harfbuzz-${harfbuzz_version_str}.tar.xz") set(harfbuzz_unzip_path "${DL_EXTRACTED_PATH}/harfbuzz_srcs") set(harfbuzz_src_path "${harfbuzz_unzip_path}/harfbuzz-${harfbuzz_version_str}") - if(harfbuzz_version_str EQUAL "8.2.1") - set(harfbuzz_file_sha256sum "0fec78f98c9c8faf228957a201c8846f809452c20f8445eb092a1ba6f22dbea5") - endif() - list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${harfbuzz_url}', - 'urls': [], - 'sha256sum': '${harfbuzz_file_sha256sum}', - 'filename': '${harfbuzz_filename}', - 'path': 'harfbuzz_srcs', - 'check_files': ['harfbuzz-${harfbuzz_version_str}'] - }" - ) + if(PLATFORM_M2DOCK) set(harfbuzz_toolchain_file ${CMAKE_CURRENT_LIST_DIR}/toolchain_m2dock.cmake) elseif(PLATFORM_MAIXCAM) diff --git a/components/3rd_party/harfbuzz/component.py b/components/3rd_party/harfbuzz/component.py new file mode 100644 index 00000000..56a6c57b --- /dev/null +++ b/components/3rd_party/harfbuzz/component.py @@ -0,0 +1,62 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + if (not confs.get("PLATFORM_MAIXCAM", None)) or confs.get("CONFIG_COMPONENTS_COMPILE_FROM_SOURCE", None): + # harfbuzz src + version = f"{confs['CONFIG_HARFBUZZ_VERSION_MAJOR']}.{confs['CONFIG_HARFBUZZ_VERSION_MINOR']}.{confs['CONFIG_HARFBUZZ_VERSION_PATCH']}" + url = f"https://master.dl.sourceforge.net/project/harfbuzz.mirror/{version}/harfbuzz-{version}.tar.xz?viasf=1" + if version == "8.2.1": + sha256sum = "0fec78f98c9c8faf228957a201c8846f809452c20f8445eb092a1ba6f22dbea5" + else: + raise Exception(f"version {version} not support") + sites = [] + filename = f"harfbuzz-{version}.tar.xz" + path = "harfbuzz_srcs" + check_file = f'harfbuzz-{version}' + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ] + } + ] + + # maixcam precompiled lib + if "musl" not in confs["CONFIG_TOOLCHAIN_PATH"]: + return [] + version = "8.2.1" + url = "https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/harfbuzz_maixcam_musl_v8.2.1.tar.xz" + if version == "8.2.1": + sha256sum = "0ee057914aeabd4d44c23f776e3dde79a3ec0a34cfe5e0a9c09737d0bf34e7fb" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] + filename = "harfbuzz_maixcam_musl_v8.2.1.tar.xz" + path = "harfbuzz" + check_file = 'harfbuzz_maixcam_musl_v8.2.1' + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ] + } + ] + + diff --git a/components/3rd_party/ini/CMakeLists.txt b/components/3rd_party/ini/CMakeLists.txt index b244c86a..6690fc09 100644 --- a/components/3rd_party/ini/CMakeLists.txt +++ b/components/3rd_party/ini/CMakeLists.txt @@ -50,22 +50,6 @@ aux_source_directory("inifile2/src" ADD_SRCS) # collect all source file in src # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib register_component() diff --git a/components/3rd_party/lvgl/CMakeLists.txt b/components/3rd_party/lvgl/CMakeLists.txt index 592a911a..f9da3912 100644 --- a/components/3rd_party/lvgl/CMakeLists.txt +++ b/components/3rd_party/lvgl/CMakeLists.txt @@ -1,30 +1,7 @@ -set(version_str "${CONFIG_LVGL_VERSION_MAJOR}.${CONFIG_LVGL_VERSION_MINOR}.${CONFIG_LVGL_VERSION_PATCH}") -set(url "https://github.com/lvgl/lvgl/archive/refs/tags/v${version_str}.tar.gz") -set(filename "lvgl-${version_str}.tar.gz") +set(version_str "${CONFIG_LVGL_VERSION_MAJOR}.${CONFIG_LVGL_VERSION_MAJOR}.${CONFIG_LVGL_VERSION_MAJOR}") set(unzip_dir_name "lvgl-${version_str}") -if(version_str EQUAL "8.3.5") - set(file_sha256sum "2b28a12b70a01cfbe8145abbc56f57fc0e9d7e34cacce5acda19a175fadf5935") -elseif(version_str EQUAL "8.3.10") - set(file_sha256sum "f27c4a963501871390c5aa415dfcbdfd46297a4a33f86c2d2c35b34d385ee39d") -elseif(version_str EQUAL "9.0.0") - set(file_sha256sum "73ae6ef7b44b434b41f25755ce4f6f5d23c49c1c254c4b7774b5a9cf83a46b7f") -elseif(version_str EQUAL "9.1.0") - set(file_sha256sum "6930f1605d305fcd43f31d5f470ecf4a013c4ce0980e78ee4c33b96a589bf433") -else() - message(FATAL_ERROR "lvgl version ${version_str} not support, please edit CMakeLists.txt to add support") -endif() -list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${url}', - 'urls': [], - 'sites': [], - 'sha256sum': '${file_sha256sum}', - 'filename': '${filename}', - 'path': 'lvgl_srcs/${unzip_dir_name}', - 'rename': {'${unzip_dir_name}': 'lvgl'}, - 'check_files': ['lvgl'] - }" -) + set(unzip_path "${DL_EXTRACTED_PATH}/lvgl_srcs/${unzip_dir_name}") set(src_path "${unzip_path}/lvgl") # MaixCDK/dl/extracted/lvgl_srcs/lvgl-9.0.0/lvgl diff --git a/components/3rd_party/lvgl/component.py b/components/3rd_party/lvgl/component.py new file mode 100644 index 00000000..24a875ac --- /dev/null +++ b/components/3rd_party/lvgl/component.py @@ -0,0 +1,36 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + version = f"{confs['CONFIG_LVGL_VERSION_MAJOR']}.{confs['CONFIG_LVGL_VERSION_MAJOR']}.{confs['CONFIG_LVGL_VERSION_MAJOR']}" + url = f"https://github.com/lvgl/lvgl/archive/refs/tags/v{version}.tar.gz" + if version == "9.1.0": + sha256sum = "6930f1605d305fcd43f31d5f470ecf4a013c4ce0980e78ee4c33b96a589bf433" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] + filename = f"lvgl-{version}.tar.gz" + path = f"lvgl_srcs/lvgl-{version}" + check_file = 'lvgl' + rename = { + 'lvgl-{version}': 'lvgl' + } + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + + diff --git a/components/3rd_party/media_server/CMakeLists.txt b/components/3rd_party/media_server/CMakeLists.txt index e9af0143..71cca84d 100644 --- a/components/3rd_party/media_server/CMakeLists.txt +++ b/components/3rd_party/media_server/CMakeLists.txt @@ -1,14 +1,7 @@ set(media_server_version_str "${CONFIG_MEDIA_SERVER_VERSION_MAJOR}.${CONFIG_MEDIA_SERVER_VERSION_MINOR}.${CONFIG_MEDIA_SERVER_VERSION_PATCH}") -set(media_server_filename "media_server-${media_server_version_str}.zip") set(media_server_unzip_path "${DL_EXTRACTED_PATH}/media_server") set(src_path "${media_server_unzip_path}/media_server-${media_server_version_str}") -if(${media_server_version_str} VERSION_EQUAL "1.0.0") - set(media_server_url "https://files.catbox.moe/c7rklp.zip") - set(media_server_file_sha256sum "dfe405cedbf3969fbf1f252634e7b1c71e8bb3e2d0857db2fe7e70189474ecd1") -elseif(${media_server_version_str} VERSION_EQUAL "1.0.1") - set(media_server_url "https://files.catbox.moe/acqhv1.zip") - set(media_server_file_sha256sum "ce06dc3d03b6036165956e60afd5eec5bfd37e7746e4b427f2099732478ecc22") -endif() + ############### Add include ################### set(media_server_private_include_dir "${src_path}/librtsp/source/server" @@ -29,9 +22,7 @@ set(media_server_include_dir "${src_path}" ".") list(APPEND ADD_INCLUDE ${media_server_include_dir} -${media_server_private_include_dir}) -set_property(SOURCE ${media_server_include_dir} PROPERTY GENERATED 1) -set_property(SOURCE ${media_server_private_include_dir} PROPERTY GENERATED 1) + ${media_server_private_include_dir}) ############################################### @@ -41,7 +32,6 @@ list(APPEND ADD_SRCS append_srcs_dir(ADD_SRCS "${src_path}" "${src_path}/media") # append source file in src dir to var ADD_SRCS -set_property(SOURCE ${ADD_SRCS} PROPERTY GENERATED 1) # list(REMOVE_ITEM COMPONENT_SRCS "src/test2.c") # FILE(GLOB_RECURSE EXTRA_SRC "src/*.c") # FILE(GLOB EXTRA_SRC "src/*.c") @@ -82,7 +72,7 @@ list(APPEND ADD_STATIC_LIB "${src_path}/libs/librtsp.a" "${src_path}/libs/libsdk.a" "${src_path}/libs/libavcodec.a" "${src_path}/libs/libavbsf.a") -set_property(SOURCE ${ADD_STATIC_LIB} PROPERTY GENERATED 1) + ############################################### ############ Add dynamic libs ################## @@ -100,16 +90,6 @@ set_property(SOURCE ${ADD_STATIC_LIB} PROPERTY GENERATED 1) list(APPEND ADD_DEFINITIONS -D__ERROR__=00*10000000+__LINE__*1000) ############################################### -list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${media_server_url}', - 'urls': [], - 'sites': [], - 'sha256sum': '${media_server_file_sha256sum}', - 'filename': '${media_server_filename}', - 'path': 'media_server', - 'check_files': ['media_server-${media_server_version_str}'] - }" -) # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib register_component() diff --git a/components/3rd_party/media_server/component.py b/components/3rd_party/media_server/component.py new file mode 100644 index 00000000..204e0fd5 --- /dev/null +++ b/components/3rd_party/media_server/component.py @@ -0,0 +1,32 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + version = f"{confs['CONFIG_MEDIA_SERVER_VERSION_MAJOR']}.{confs['CONFIG_MEDIA_SERVER_VERSION_MINOR']}.{confs['CONFIG_MEDIA_SERVER_VERSION_PATCH']}" + if version == "1.0.0": + url = "https://files.catbox.moe/c7rklp.zip" + sha256sum = "dfe405cedbf3969fbf1f252634e7b1c71e8bb3e2d0857db2fe7e70189474ecd1" + elif version == "1.0.1": + url = "https://files.catbox.moe/acqhv1.zip" + sha256sum = "ce06dc3d03b6036165956e60afd5eec5bfd37e7746e4b427f2099732478ecc22" + else: + raise Exception(f"version {version} not support") + filename = f"media_server-{version}.zip" + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': [], + 'sha256sum': sha256sum, + 'filename': filename, + 'path': 'media_server', + 'check_files': [ + f'media_server-{version}' + ] + } + ] + + diff --git a/components/3rd_party/omv/CMakeLists.txt b/components/3rd_party/omv/CMakeLists.txt index 2971ff54..e04484da 100644 --- a/components/3rd_party/omv/CMakeLists.txt +++ b/components/3rd_party/omv/CMakeLists.txt @@ -1,41 +1,7 @@ set(omv_version_str "${CONFIG_OMV_VERSION_MAJOR}.${CONFIG_OMV_VERSION_MINOR}.${CONFIG_OMV_VERSION_PATCH}") -set(omv_filename "omv-${omv_version_str}.zip") set(omv_unzip_path "${DL_EXTRACTED_PATH}/omv") set(src_path "${omv_unzip_path}/omv-${omv_version_str}") -if(${omv_version_str} VERSION_EQUAL "1.0.0") - set(omv_url "https://files.catbox.moe/2c84zd.zip") - set(omv_file_sha256sum "4ef0f61febe32886e5d85bb47f661e5d3455f5fe79b3edaacbe833a22566e985") -elseif(${omv_version_str} VERSION_EQUAL "1.0.1") - set(omv_url "https://files.catbox.moe/gcyi07.zip") - set(omv_file_sha256sum "37f5b8ae6072cdef38678effc07cc6dee223bbbbedd79616a506c303d6cd30f1") -elseif(${omv_version_str} VERSION_EQUAL "1.0.2") - set(omv_url "https://files.catbox.moe/20evr3.zip") - set(omv_file_sha256sum "1aee6d293e955a448aa5bdbd3d8f613c2126a4a49d129aeb1a0fbad22f66d773") -elseif(${omv_version_str} VERSION_EQUAL "1.0.3") - set(omv_url "https://files.catbox.moe/idfwis.zip") - set(omv_file_sha256sum "f6654992a52006fd2e01302fa778a6cee1e99e1f9f78a9eea9f759e4f6199d82") -elseif(${omv_version_str} VERSION_EQUAL "1.0.4") - set(omv_url "https://files.catbox.moe/3za319.zip") - set(omv_file_sha256sum "c36c3b8a0ac141be6d7843f129602ffb600a1f596391cd810c1044e20fbbf472") -elseif(${omv_version_str} VERSION_EQUAL "1.0.5") - set(omv_url "https://files.catbox.moe/d36bwl.zip") - set(omv_file_sha256sum "04075965c44f9957efb425880b6a221bda8b049230bff857340306d938d54ec7") -elseif(${omv_version_str} VERSION_EQUAL "1.0.6") - set(omv_url "https://files.catbox.moe/5iyqf2.zip") - set(omv_file_sha256sum "c025d8438ac814229b0c099d18cee77bdd2296ae24173f69a8e46b5ab71700e6") -elseif(${omv_version_str} VERSION_EQUAL "1.0.7") - set(omv_url "https://files.catbox.moe/ik2hdj.zip") - set(omv_file_sha256sum "450d3b97287055679d73c35e6f9d67a192c68b7ac3f8a0f7c6bf7fa3df48b743") -elseif(${omv_version_str} VERSION_EQUAL "1.0.8") - set(omv_url "https://files.catbox.moe/26rfr9.zip") - set(omv_file_sha256sum "a651cd2988ec7b25a80c41466aed55210162bc679c2b8711211525b970bdf417") -elseif(${omv_version_str} VERSION_EQUAL "1.0.9") - set(omv_url "https://files.catbox.moe/ypel5x.zip") - set(omv_file_sha256sum "770680d55f501a095e846bb8727d9fe0ad6a446be8fbc1671b61da0788977475") -elseif(${omv_version_str} VERSION_EQUAL "1.0.10") - set(omv_url "https://files.catbox.moe/olys7p.zip") - set(omv_file_sha256sum "e3b6d04a5379be52b226434ef0dfce404faf91955dfab0386a189684b99940bd") -endif() + ############### Add include ################### set(omv_include_dir "." "${src_path}/alloc" @@ -150,16 +116,6 @@ set_property(SOURCE "${src_path}/alloc" PROPERTY GENERATED 1) # list(APPEND ADD_DEFINITIONS -DAAAAA222=1 # -DAAAAA333=1) ############################################### -list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${omv_url}', - 'urls': [], - 'sites': [], - 'sha256sum': '${omv_file_sha256sum}', - 'filename': '${omv_filename}', - 'path': 'omv', - 'check_files': ['omv-${omv_version_str}'] - }" -) # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib register_component() diff --git a/components/3rd_party/omv/component.py b/components/3rd_party/omv/component.py new file mode 100644 index 00000000..602c6f2f --- /dev/null +++ b/components/3rd_party/omv/component.py @@ -0,0 +1,34 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + version = f"{confs['CONFIG_OMV_VERSION_MAJOR']}.{confs['CONFIG_OMV_VERSION_MINOR']}.{confs['CONFIG_OMV_VERSION_PATCH']}" + url = f"https://files.catbox.moe/olys7p.zip" + if version == "1.0.10": + sha256sum = "e3b6d04a5379be52b226434ef0dfce404faf91955dfab0386a189684b99940bd" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] + filename = f"omv-{version}.zip" + path = f"omv" + check_file = f'omv-{version}' + rename = {} + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + + diff --git a/components/3rd_party/opencv/CMakeLists.txt b/components/3rd_party/opencv/CMakeLists.txt index 0c78294b..991e2df4 100644 --- a/components/3rd_party/opencv/CMakeLists.txt +++ b/components/3rd_party/opencv/CMakeLists.txt @@ -35,16 +35,6 @@ if(PLATFORM_MAIXCAM AND NOT CONFIG_OPENCV_COMPILE_FROM_SOURCE AND NOT CONFIG_COM if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/opencv4_lib_maixcam") set(opencv_lib_dir "${CMAKE_CURRENT_LIST_DIR}/opencv4_lib_maixcam") elseif(CONFIG_TOOLCHAIN_PATH MATCHES "musl") - list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': 'https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/opencv4_lib_maixcam_musl_4.9.0.tar.xz', - 'urls': [], - 'sites': ['https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0'], - 'sha256sum': 'c4553fe39212b271724d2bb9394e8944678f846f4e58a578da1db3013cbc3dcf', - 'filename': 'opencv4_lib_maixcam_musl_4.9.0.tar.xz', - 'path': 'opencv/opencv4', - 'check_files': ['opencv4_lib_maixcam_musl_4.9.0'] - }" - ) set(opencv_lib_dir "${DL_EXTRACTED_PATH}/opencv/opencv4/opencv4_lib_maixcam_musl_4.9.0") endif() if(opencv_lib_dir) @@ -89,66 +79,9 @@ endif() if(NOT ADD_INCLUDE) - list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': 'https://github.com/opencv/opencv/archive/${version_str}.zip', - 'urls': [], - 'sites': ['https://opencv.org/releases/'], - 'sha256sum': '9b5b64d50bf4a3ddeab430a9b13c5f9e023c9e67639ab50a74d0c298b5a61b74', - 'filename': 'opencv-${version_str}.zip', - 'path': 'opencv/opencv4', - 'check_files': ['opencv-${version_str}'] - }" - ) set(opencv_src_dir "${DL_EXTRACTED_PATH}/opencv/opencv4/opencv-${version_str}") set(opencv_cache_dir "${DL_PKGS_PATH}/opencv/cache") - if(PLATFORM_LINUX) - # list(APPEND opencv_libs "${opencv_install_dir}/lib/opencv4/3rdparty/libippiw.a" - # "${opencv_install_dir}/lib/opencv4/3rdparty/libippicv.a" - # ) - # if arch is intel x86 or x86_64, add download link for opencv_world lib - # get arch use python script - execute_process(COMMAND ${python} -c "import platform;print(platform.machine())" OUTPUT_VARIABLE arch) - if(arch MATCHES "x86_64") - list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': 'https://raw.githubusercontent.com/opencv/opencv_3rdparty/1224f78da6684df04397ac0f40c961ed37f79ccb/ippicv/ippicv_2021.8_lnx_intel64_20230330_general.tgz', - 'urls': [], - 'sites': [], - 'sha256sum': '7cfe0fb0e15ea8f3d2d971c19df2d14382469943d4efa85e48bf358930daa85d', - 'filename': '43219bdc7e3805adcbe3a1e2f1f3ef3b-ippicv_2021.8_lnx_intel64_20230330_general.tgz', - 'path': 'opencv/cache/ippicv', - 'extract': false - }" - "{ - 'url': 'https://github.com/opencv/ade/archive/v0.1.2b.zip', - 'urls': [], - 'sites': ['https://github.com/opencv/ade'], - 'sha256sum': 'a1d2a21e78a5a1b7bd41697a562669d5b5a8e2ab89e8a654c0a80a82aff28e19', - 'filename': '4f93a0844dfc463c617d83b09011819a-v0.1.2b.zip', - 'path': 'opencv/cache/ade', - 'extract': false - } - " - ) - endif() - elseif(PLATFORM_M2DOCK OR PLATFORM_MAIXCAM) - list(APPEND ADD_FILE_DOWNLOADS - "{ - 'url': 'https://github.com/opencv/ade/archive/v0.1.2a.zip', - 'urls': [], - 'sites': ['https://github.com/opencv/ade'], - 'sha256sum': '4e32d16c56c2ecc0d8f4fc48cb9eb4af2be2048e7c71b430aa073b03bb8e1e48', - 'filename': 'fa4b3e25167319cb0fa9432ef8281945-v0.1.2a.zip', - 'path': 'opencv/cache/ade', - 'extract': false - } - " - ) - else() - message(FATAL_ERROR "No opencv config for this board, please edit to add opencv support for this board") - endif() - - # list(APPEND ADD_REQUIREMENTS pthread dl atomic) list(APPEND ADD_DEFINITIONS -fopenmp) diff --git a/components/3rd_party/opencv/component.py b/components/3rd_party/opencv/component.py new file mode 100644 index 00000000..c6d719cc --- /dev/null +++ b/components/3rd_party/opencv/component.py @@ -0,0 +1,124 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + if (not confs.get("PLATFORM_MAIXCAM", None)) or confs.get("CONFIG_COMPONENTS_COMPILE_FROM_SOURCE", None) or confs.get("CONFIG_OPENCV_COMPILE_FROM_SOURCE", None): + # version = f"{confs['CONFIG_PYTHON_VERSION_MAJOR']}.{confs['CONFIG_PYTHON_VERSION_MINOR']}.{confs['CONFIG_PYTHON_VERSION_PATCH']}" + version = "4.9.0" + url = f"https://github.com/opencv/opencv/archive/{version}.zip" + if version == "4.9.0": + sha256sum = "9b5b64d50bf4a3ddeab430a9b13c5f9e023c9e67639ab50a74d0c298b5a61b74" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] + filename = f"opencv-{version}.zip" + path = f"opencv/opencv4" + check_file = f'opencv-{version}' + rename = {} + + files = [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + if confs.get("PLATFORM_MAIXCAM", None): + version = "0.1.2a" + url = f"https://github.com/opencv/ade/archive/v0.1.2a.zip" + if version == "0.1.2a": + sha256sum = "4e32d16c56c2ecc0d8f4fc48cb9eb4af2be2048e7c71b430aa073b03bb8e1e48" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/opencv/ade"] + filename = f"fa4b3e25167319cb0fa9432ef8281945-v0.1.2a.zip" + path = f"opencv/cache/ade" + check_file = f'opencv-{version}' + rename = {} + files = [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename, + 'extract': False + } + ] + elif confs.get("PLATFORM_LINUX", None): + files = [ + { + 'url': f'https://github.com/opencv/ade/archive/v0.1.2b.zip', + 'urls': [], + 'sites': ["https://github.com/opencv/ade"], + 'sha256sum': "a1d2a21e78a5a1b7bd41697a562669d5b5a8e2ab89e8a654c0a80a82aff28e19", + 'filename': "4f93a0844dfc463c617d83b09011819a-v0.1.2b.zip", + 'path': f"opencv/cache/ade", + 'check_files': [ + f'opencv-0.1.2b' + ], + 'rename': {}, + 'extract': False + }, + { + 'url': f'https://raw.githubusercontent.com/opencv/opencv_3rdparty/1224f78da6684df04397ac0f40c961ed37f79ccb/ippicv/ippicv_2021.8_lnx_intel64_20230330_general.tgz', + 'urls': [], + 'sites': [], + 'sha256sum': "7cfe0fb0e15ea8f3d2d971c19df2d14382469943d4efa85e48bf358930daa85d", + 'filename': "43219bdc7e3805adcbe3a1e2f1f3ef3b-ippicv_2021.8_lnx_intel64_20230330_general.tgz", + 'path': "opencv/cache/ippicv", + 'check_files': [ + ], + 'rename': {}, + 'extract': False + } + ] + else: + raise Exception("No opencv config for this board, please edit to add opencv support for this board") + + return files + + if "musl" not in confs["CONFIG_TOOLCHAIN_PATH"]: + return [] + # version = f"{confs['CONFIG_OMV_VERSION_MAJOR']}.{confs['CONFIG_OMV_VERSION_MINOR']}.{confs['CONFIG_OMV_VERSION_PATCH']}" + version = "4.9.0" + url = f"https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/opencv4_lib_maixcam_musl_4.9.0.tar.xz" + if version == "4.9.0": + sha256sum = "c4553fe39212b271724d2bb9394e8944678f846f4e58a578da1db3013cbc3dcf" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] + filename = f"opencv4_lib_maixcam_musl_4.9.0.tar.xz" + path = f"opencv/opencv4" + check_file = f'opencv4_lib_maixcam_musl_4.9.0' + rename = {} + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + diff --git a/components/3rd_party/openssl/CMakeLists.txt b/components/3rd_party/openssl/CMakeLists.txt index c9234956..86379dc1 100644 --- a/components/3rd_party/openssl/CMakeLists.txt +++ b/components/3rd_party/openssl/CMakeLists.txt @@ -66,22 +66,6 @@ # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - if(PLATFORM_LINUX) set(compile_for_host 1) else() @@ -110,16 +94,6 @@ if(NOT compile_for_host) set_property(SOURCE ${target_h_path} PROPERTY GENERATED 1) set_property(SOURCE ${target_lib_file} PROPERTY GENERATED 1) - list(APPEND ADD_FILE_DOWNLOADS - "{ - 'url': 'https://www.openssl.org/source/openssl-3.0.12.tar.gz', - 'urls': [], - 'sites': ['https://www.openssl.org/source/'], - 'sha256sum': 'f93c9e8edde5e9166119de31755fc87b4aa34863662f67ddfcba14d0b6b69b61', - 'filename': 'openssl-3.0.12.tar.gz', - 'path': 'openssl' - }" - ) set(openssl_src_path "${DL_EXTRACTED_PATH}/openssl/openssl-3.0.12") set(openssl_install_path "${target_install_dir}") set(openssl_compile_cmd COMMAND set -x && cd ${openssl_src_path} && echo "-- compile openssl now" && make distclean || true && chmod +x ./Configure && ./Configure linux-generic32 shared -DL_ENDIAN --openssldir=${openssl_install_path} --prefix=${openssl_install_path} && export PATH=${CONFIG_TOOLCHAIN_PATH}:$ENV{PATH} && make CC="${host_prefix}"-gcc RANLIB="${host_prefix}"-ranlib LD="${host_prefix}"-ld MAKEDEPPROG="${host_prefix}"-gcc PROCESSOR=${arch} -j`nproc` && make install_sw) diff --git a/components/3rd_party/openssl/component.py b/components/3rd_party/openssl/component.py new file mode 100644 index 00000000..3d53e8d2 --- /dev/null +++ b/components/3rd_party/openssl/component.py @@ -0,0 +1,35 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + # version = f"{confs['CONFIG_OMV_VERSION_MAJOR']}.{confs['CONFIG_OMV_VERSION_MINOR']}.{confs['CONFIG_OMV_VERSION_PATCH']}" + version = "3.0.12" + url = f"https://www.openssl.org/source/openssl-3.0.12.tar.gz" + if version == "3.0.12": + sha256sum = "f93c9e8edde5e9166119de31755fc87b4aa34863662f67ddfcba14d0b6b69b61" + else: + raise Exception(f"version {version} not support") + sites = ['https://www.openssl.org/source/'] + filename = f"openssl-3.0.12.tar.gz" + path = f"openssl" + check_file = f'openssl-{version}' + rename = {} + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + + diff --git a/components/3rd_party/pybind11/CMakeLists.txt b/components/3rd_party/pybind11/CMakeLists.txt index 7077c1ff..a669062d 100644 --- a/components/3rd_party/pybind11/CMakeLists.txt +++ b/components/3rd_party/pybind11/CMakeLists.txt @@ -54,22 +54,5 @@ list(APPEND ADD_PRIVATE_INCLUDE "") # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - - register_component() diff --git a/components/3rd_party/python3/CMakeLists.txt b/components/3rd_party/python3/CMakeLists.txt index 24bb1c74..bba1caa8 100644 --- a/components/3rd_party/python3/CMakeLists.txt +++ b/components/3rd_party/python3/CMakeLists.txt @@ -66,22 +66,6 @@ # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - set(compile_for_host 0) if(CONFIG_PYTHON_VERSION_MAJOR STREQUAL "0") @@ -130,16 +114,6 @@ if(NOT compile_for_host) if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/python_target_install") set(python_lib_dir "${CMAKE_CURRENT_LIST_DIR}/python_target_install") elseif(CONFIG_TOOLCHAIN_PATH MATCHES "musl") - list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': 'https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/python3_lib_maixcam_musl_3.11.6.tar.xz', - 'urls': [], - 'sites': ['https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0'], - 'sha256sum': '92e14b22e708612c6e280931cc247b4266da9a6bac8459edf25bfb4cebcbac66', - 'filename': 'python3_lib_maixcam_musl_3.11.6.tar.xz', - 'path': 'python3', - 'check_files': ['python3_lib_maixcam_musl_3.11.6'] - }" - ) set(python_lib_dir "${DL_EXTRACTED_PATH}/python3/python3_lib_maixcam_musl_3.11.6") endif() if(python_lib_dir) @@ -211,46 +185,8 @@ if(NOT compile_for_host) set_property(SOURCE ${python_h_path} PROPERTY GENERATED 1) set_property(SOURCE ${python_lib_file} PROPERTY GENERATED 1) - set(python_url "https://www.python.org/ftp/python/${python_version_str}/Python-${python_version_str}.tar.xz") - set(python_filename "Python-${python_version_str}.tar.xz") set(python_unzip_path "${DL_EXTRACTED_PATH}/python_srcs") set(python_src_path "${python_unzip_path}/Python-${python_version_str}") - if(python_version_str EQUAL "3.8.5") - set(file_sha256sum "e3003ed57db17e617acb382b0cade29a248c6026b1bd8aad1f976e9af66a83b0") - elseif(python_version_str EQUAL "3.10.12") - set(file_sha256sum "afb74bf19130e7a47d10312c8f5e784f24e0527981eab68e20546cfb865830b8") - elseif(python_version_str EQUAL "3.11.6") - set(file_sha256sum "0fab78fa7f133f4f38210c6260d90d7c0d5c7198446419ce057ec7ac2e6f5f38") - endif() - if(NOT file_sha256sum) - message(FATAL_ERROR "please edit here to add sha256sum for python version ${python_version_str} which download from ${python_url}") - endif() - list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${python_url}', - 'urls': [], - 'sites': [], - 'sha256sum': '${file_sha256sum}', - 'filename': '${python_filename}', - 'path': 'python_srcs', - 'check_files': ['Python-${python_version_str}'] - }" - "{ - 'url': 'https://zlib.net/zlib-1.3.tar.xz', - 'urls': [], - 'sites': ['https://zlib.net/'], - 'sha256sum': '8a9ba2898e1d0d774eca6ba5b4627a11e5588ba85c8851336eb38de4683050a7', - 'filename': 'zlib-1.3.tar.xz', - 'path': 'zlib' - }" - "{ - 'url': 'https://www.openssl.org/source/openssl-3.0.12.tar.gz', - 'urls': [], - 'sites': ['https://www.openssl.org/source/'], - 'sha256sum': 'f93c9e8edde5e9166119de31755fc87b4aa34863662f67ddfcba14d0b6b69b61', - 'filename': 'openssl-3.0.12.tar.gz', - 'path': 'openssl' - }" - ) set(zlib_src_path "${DL_EXTRACTED_PATH}/zlib/zlib-1.3") set(zlib_install_path "${python_target_install_dir}") set(openssl_src_path "${DL_EXTRACTED_PATH}/openssl/openssl-3.0.12") diff --git a/components/3rd_party/python3/component.py b/components/3rd_party/python3/component.py new file mode 100644 index 00000000..57adb0f4 --- /dev/null +++ b/components/3rd_party/python3/component.py @@ -0,0 +1,80 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + if (not confs.get("PLATFORM_MAIXCAM", None)) or confs.get("CONFIG_COMPONENTS_COMPILE_FROM_SOURCE", None): + version = f"{confs['CONFIG_PYTHON_VERSION_MAJOR']}.{confs['CONFIG_PYTHON_VERSION_MINOR']}.{confs['CONFIG_PYTHON_VERSION_PATCH']}" + url = f"https://www.python.org/ftp/python/{version}/Python-{version}.tar.xz" + if version == "3.11.6": + sha256sum = "92e14b22e708612c6e280931cc247b4266da9a6bac8459edf25bfb4cebcbac66" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] + filename = f"Python-{version}.tar.xz" + path = f"python_srcs" + check_file = f'Python-{version}' + rename = {} + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + }, + { + 'url': 'https://zlib.net/zlib-1.3.tar.xz', + 'urls': [], + 'sites': ['https://zlib.net/'], + 'sha256sum': '8a9ba2898e1d0d774eca6ba5b4627a11e5588ba85c8851336eb38de4683050a7', + 'filename': 'zlib-1.3.tar.xz', + 'path': 'zlib' + }, + { + 'url': 'https://www.openssl.org/source/openssl-3.0.12.tar.gz', + 'urls': [], + 'sites': ['https://www.openssl.org/source/'], + 'sha256sum': 'f93c9e8edde5e9166119de31755fc87b4aa34863662f67ddfcba14d0b6b69b61', + 'filename': 'openssl-3.0.12.tar.gz', + 'path': 'openssl' + } + ] + if "musl" not in confs["CONFIG_TOOLCHAIN_PATH"]: + return [] + # version = f"{confs['CONFIG_OMV_VERSION_MAJOR']}.{confs['CONFIG_OMV_VERSION_MINOR']}.{confs['CONFIG_OMV_VERSION_PATCH']}" + version = "3.11.6" + url = f"https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/python3_lib_maixcam_musl_3.11.6.tar.xz" + if version == "3.11.6": + sha256sum = "92e14b22e708612c6e280931cc247b4266da9a6bac8459edf25bfb4cebcbac66" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] + filename = f"python3_lib_maixcam_musl_3.11.6.tar.xz" + path = f"python3" + check_file = f'python3_lib_maixcam_musl_3.11.6' + rename = { + }, + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + diff --git a/components/3rd_party/qrcode/CMakeLists.txt b/components/3rd_party/qrcode/CMakeLists.txt index a01d9483..89962c5c 100644 --- a/components/3rd_party/qrcode/CMakeLists.txt +++ b/components/3rd_party/qrcode/CMakeLists.txt @@ -1,23 +1,9 @@ set(version_str "2.1.0") -set(url "https://github.com/zxing-cpp/zxing-cpp/archive/refs/tags/v${version_str}.tar.gz") -set(filename "zxing-cpp-${version_str}.tar.gz") set(unzip_path "${DL_EXTRACTED_PATH}/zxing-cpp") set(src_path "${unzip_path}/zxing-cpp-${version_str}") set(file_sha256sum "6d54e403592ec7a143791c6526c1baafddf4c0897bb49b1af72b70a0f0c4a3fe") -list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${url}', - 'urls': [], - 'sites': [], - 'sha256sum': '${file_sha256sum}', - 'filename': '${filename}', - 'path': 'zxing-cpp', - 'check_files': ['zxing-cpp-${version_str}'] - }" -) - - ################# Add include ################# list(APPEND ADD_INCLUDE "${src_path}/core/src" "${src_path}/core/src/aztec" diff --git a/components/3rd_party/qrcode/component.py b/components/3rd_party/qrcode/component.py new file mode 100644 index 00000000..a1786a1d --- /dev/null +++ b/components/3rd_party/qrcode/component.py @@ -0,0 +1,35 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + # version = f"{confs['CONFIG_OMV_VERSION_MAJOR']}.{confs['CONFIG_OMV_VERSION_MINOR']}.{confs['CONFIG_OMV_VERSION_PATCH']}" + version = "2.1.0" + url = f"https://github.com/zxing-cpp/zxing-cpp/archive/refs/tags/v{version}.tar.gz" + if version == "2.1.0": + sha256sum = "6d54e403592ec7a143791c6526c1baafddf4c0897bb49b1af72b70a0f0c4a3fe" + else: + raise Exception(f"version {version} not support") + sites = ['https://www.openssl.org/source/'] + filename = f"zxing-cpp-{version}.tar.gz" + path = f"zxing-cpp" + check_file = f'zxing-cpp-{version}' + rename = {} + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + + diff --git a/components/3rd_party/rlottie/CMakeLists.txt b/components/3rd_party/rlottie/CMakeLists.txt index 82f5666b..26c69246 100644 --- a/components/3rd_party/rlottie/CMakeLists.txt +++ b/components/3rd_party/rlottie/CMakeLists.txt @@ -1,23 +1,8 @@ set(version_str "0.2") -set(url "https://github.com/Samsung/rlottie/archive/refs/tags/v${version_str}.tar.gz") -set(filename "rlottie-${version_str}.tar.gz") set(unzip_path "${DL_EXTRACTED_PATH}/rlottie") set(src_path "${unzip_path}/rlottie-${version_str}") -set(file_sha256sum "030ccbc270f144b4f3519fb3b86e20dd79fb48d5d55e57f950f12bab9b65216a") - -list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${url}', - 'urls': [], - 'sites': [], - 'sha256sum': '${file_sha256sum}', - 'filename': '${filename}', - 'path': 'rlottie', - 'check_files': ['rlottie-${version_str}'] - }" -) - ################# Add include ################# list(APPEND ADD_INCLUDE "${src_path}/inc" diff --git a/components/3rd_party/rlottie/component.py b/components/3rd_party/rlottie/component.py new file mode 100644 index 00000000..af7ee9e4 --- /dev/null +++ b/components/3rd_party/rlottie/component.py @@ -0,0 +1,35 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + # version = f"{confs['CONFIG_OMV_VERSION_MAJOR']}.{confs['CONFIG_OMV_VERSION_MINOR']}.{confs['CONFIG_OMV_VERSION_PATCH']}" + version = "0.2" + url = f"https://github.com/Samsung/rlottie/archive/refs/tags/v{version}.tar.gz" + if version == "0.2": + sha256sum = "030ccbc270f144b4f3519fb3b86e20dd79fb48d5d55e57f950f12bab9b65216a" + else: + raise Exception(f"version {version} not support") + sites = [] + filename = f"rlottie-{version}.tar.gz" + path = f"rlottie" + check_file = f'rlottie-{version}' + rename = {} + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + + diff --git a/components/3rd_party/sdl/CMakeLists.txt b/components/3rd_party/sdl/CMakeLists.txt index 257ba301..71361704 100644 --- a/components/3rd_party/sdl/CMakeLists.txt +++ b/components/3rd_party/sdl/CMakeLists.txt @@ -66,22 +66,6 @@ # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # write build python version to CMAKE_BINARY_DIR/config/python_version.txt # file(WRITE ${CMAKE_BINARY_DIR}/config/sdl_version.txt "${CONFIG_SDL_VERSION_MAJOR}.${CONFIG_SDL_VERSION_MINOR}.${CONFIG_SDL_VERSION_PATCH}") @@ -132,23 +116,8 @@ if(NOT ADD_INCLUDE) endif() set_property(SOURCE ${sdl_lib_file} PROPERTY GENERATED 1) - set(sdl_url "https://github.com/libsdl-org/SDL/releases/download/release-${sdl_version_str}/SDL2-${sdl_version_str}.tar.gz") - set(sdl_filename "SDL2-${sdl_version_str}.tar.gz") set(sdl_unzip_path "${DL_EXTRACTED_PATH}/sdl_srcs") set(sdl_src_path "${sdl_unzip_path}/SDL2-${sdl_version_str}") - if(sdl_version_str EQUAL "2.28.4") - set(sdl_file_sha256sum "888b8c39f36ae2035d023d1b14ab0191eb1d26403c3cf4d4d5ede30e66a4942c") - endif() - list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${sdl_url}', - 'urls': [], - 'sites': [], - 'sha256sum': '${sdl_file_sha256sum}', - 'filename': '${sdl_filename}', - 'path': 'sdl_srcs', - 'check_files': ['SDL2-${sdl_version_str}'] - }" - ) if(PLATFORM_LINUX) set(sdl_compile_cmd COMMAND set -x && cd ${sdl_src_path} && make distclean || true && chmod +x ./configure && ./configure --prefix=${sdl_target_install_dir} ${static_shared_flag} --with-pic && echo "-- compile now" && make -j`nproc` && make install) diff --git a/components/3rd_party/sdl/component.py b/components/3rd_party/sdl/component.py new file mode 100644 index 00000000..7d91b834 --- /dev/null +++ b/components/3rd_party/sdl/component.py @@ -0,0 +1,34 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + version = f"{confs['CONFIG_SDL_VERSION_MAJOR']}.{confs['CONFIG_SDL_VERSION_MINOR']}.{confs['CONFIG_SDL_VERSION_PATCH']}" + url = f"https://github.com/libsdl-org/SDL/releases/download/release-{version}/SDL2-{version}.tar.gz" + if version == "2.28.4": + sha256sum = "888b8c39f36ae2035d023d1b14ab0191eb1d26403c3cf4d4d5ede30e66a4942c" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] + filename = f"SDL2-{version}.tar.gz" + path = "sdl_srcs" + check_file = f'SDL2-{version}' + rename = {} + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + + diff --git a/components/3rd_party/sunxi_mpp/CMakeLists.txt b/components/3rd_party/sunxi_mpp/CMakeLists.txt index bb7447d1..dc2487b1 100644 --- a/components/3rd_party/sunxi_mpp/CMakeLists.txt +++ b/components/3rd_party/sunxi_mpp/CMakeLists.txt @@ -1,15 +1,7 @@ if(PLATFORM_MAIXCAM) set(sunxi_mpp_version_str "${CONFIG_SUNXI_MPP_VERSION_MAJOR}.${CONFIG_SUNXI_MPP_VERSION_MINOR}.${CONFIG_SUNXI_MPP_VERSION_PATCH}") -set(sunxi_mpp_url "https://files.catbox.moe/e35tyl.xz") -set(sunxi_mpp_filename "sunxi_mpp-${sunxi_mpp_version_str}.tar.xz") set(sunxi_mpp_unzip_path "${DL_EXTRACTED_PATH}/sunxi_mpp") set(sunxi_mpp_src_path "${sunxi_mpp_unzip_path}/sunxi-mpp-${sunxi_mpp_version_str}") -if(sunxi_mpp_version_str EQUAL "1.0.0") - # https://files.catbox.moe/iruptg.xz - set(sunxi_mpp_file_sha256sum "0a5f0b10be5af10ef32d40e7eb40da05ee544cfe7503be28e6febc937a1e696e") -elseif(sunxi_mpp_version_str EQUAL "1.0.1") - set(sunxi_mpp_file_sha256sum "5c20195c9600092b3cd79e7d96485920208e3ccfa56d1399f330493616b510a8") -endif() ############### Add include ################### set(sunxi_mpp_include_dir ${sunxi_mpp_src_path}/include/algo_aw/ @@ -235,16 +227,6 @@ set_property(SOURCE ${sunxi_mpp_dynamic_lib_file} PROPERTY GENERATED 1) # list(APPEND ADD_DEFINITIONS -DAAAAA222=1 # -DAAAAA333=1) ############################################### -list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${sunxi_mpp_url}', - 'urls': [], - 'sites': [], - 'sha256sum': '${sunxi_mpp_file_sha256sum}', - 'filename': '${sunxi_mpp_filename}', - 'path': 'sunxi_mpp', - 'check_files': ['sunxi-mpp-${sunxi_mpp_version_str}'] - }" -) # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib register_component() diff --git a/components/3rd_party/sunxi_mpp/component.py b/components/3rd_party/sunxi_mpp/component.py new file mode 100644 index 00000000..dea2e121 --- /dev/null +++ b/components/3rd_party/sunxi_mpp/component.py @@ -0,0 +1,34 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + version = "1.0.1" + url = "https://files.catbox.moe/e35tyl.xz" + if version == "1.0.1": + sha256sum = "5c20195c9600092b3cd79e7d96485920208e3ccfa56d1399f330493616b510a8" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] + filename = f"sunxi_mpp-{version}.tar.xz" + path = "sunxi_mpp" + check_file = f'sunxi-mpp-{version}' + rename = {} + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + + diff --git a/components/3rd_party/websocket/CMakeLists.txt b/components/3rd_party/websocket/CMakeLists.txt index eda43884..c2b1c411 100644 --- a/components/3rd_party/websocket/CMakeLists.txt +++ b/components/3rd_party/websocket/CMakeLists.txt @@ -1,14 +1,3 @@ -list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': 'https://master.dl.sourceforge.net/project/websocket.mirror/0.8.2/WebSocket%2B%2B_0.8.2.tar.gz?viasf=1', - 'urls': [], - 'sites': ['https://github.com/zaphoyd/websocketpp/archive/refs/tags/0.8.2.tar.gz'], - 'sha256sum': '8b1773ea2832751071ac19d2708314d68316dd3916434c7dc0dd58cef14d51cd', - 'filename': 'WebSocketpp_0.8.2.tar.gz', - 'path': 'websocketpp', - 'rename': {'zaphoyd-websocketpp-0e42417': 'websocketpp-0.8.2'}, - 'check_files': ['websocketpp-0.8.2'] - }" -) set(websocketpp_root "${DL_EXTRACTED_PATH}/websocketpp/websocketpp-0.8.2") @@ -72,21 +61,6 @@ list(APPEND ADD_INCLUDE "${websocketpp_root}" # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib register_component() diff --git a/components/3rd_party/websocket/component.py b/components/3rd_party/websocket/component.py new file mode 100644 index 00000000..b9bcd486 --- /dev/null +++ b/components/3rd_party/websocket/component.py @@ -0,0 +1,34 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + version = "0.8.2" + url = "https://master.dl.sourceforge.net/project/websocket.mirror/0.8.2/WebSocket%2B%2B_0.8.2.tar.gz?viasf=1" + if version == "0.8.2": + sha256sum = "8b1773ea2832751071ac19d2708314d68316dd3916434c7dc0dd58cef14d51cd" + else: + raise Exception(f"version {version} not support") + sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] + filename = "WebSocketpp_0.8.2.tar.gz" + path = "websocketpp" + check_file = 'websocketpp-0.8.2' + rename = {'zaphoyd-websocketpp-0e42417': 'websocketpp-0.8.2'} + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': sites, + 'sha256sum': sha256sum, + 'filename': filename, + 'path': path, + 'check_files': [ + check_file + ], + 'rename': rename + } + ] + + diff --git a/components/basic/CMakeLists.txt b/components/basic/CMakeLists.txt index 74aa7020..9fda0653 100644 --- a/components/basic/CMakeLists.txt +++ b/components/basic/CMakeLists.txt @@ -66,22 +66,6 @@ list(APPEND ADD_REQUIREMENTS pthread stdc++fs ini) # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib register_component() diff --git a/components/comm/CMakeLists.txt b/components/comm/CMakeLists.txt index dc76be7b..1f11021c 100644 --- a/components/comm/CMakeLists.txt +++ b/components/comm/CMakeLists.txt @@ -59,22 +59,6 @@ list(APPEND ADD_REQUIREMENTS basic peripheral) # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib register_component() diff --git a/components/maixcam_lib/CMakeLists.txt b/components/maixcam_lib/CMakeLists.txt index ddac9490..748d454c 100644 --- a/components/maixcam_lib/CMakeLists.txt +++ b/components/maixcam_lib/CMakeLists.txt @@ -4,35 +4,9 @@ list(APPEND ADD_INCLUDE "include") # sophgo-middleware set(middleware_version_str "${CONFIG_SOPHGO_MIDDLEWARE_VERSION_MAJOR}.${CONFIG_SOPHGO_MIDDLEWARE_VERSION_MINOR}.${CONFIG_SOPHGO_MIDDLEWARE_VERSION_PATCH}") -set(middleware_filename "sophgo-middleware-${middleware_version_str}.tar.xz") set(middleware_unzip_path "${DL_EXTRACTED_PATH}/sophgo-middleware") set(middleware_src_path "${middleware_unzip_path}/sophgo-middleware-${middleware_version_str}") -if(${middleware_version_str} VERSION_EQUAL "0.0.1") - set(middleware_url "https://files.catbox.moe/bq5duu.xz") - set(middleware_file_sha256sum "524021c333d9c601bd1e3a962dce02711269cc7bc342679ff317aa038e9679bd") -elseif(${middleware_version_str} VERSION_EQUAL "0.0.2") - set(middleware_url "https://files.catbox.moe/ojil79.xz") - set(middleware_file_sha256sum "d696e6099537ed3f7cf2eaa1dc2a0bf63dea729f15b433b70e163ae5e53523d2") -elseif(${middleware_version_str} VERSION_EQUAL "0.0.3") - set(middleware_url "https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/sophgo-middleware-0.0.3.tar.xz") - set(middleware_file_sha256sum "1b96ffc2ce5c4f684bfb8ca15214dfe67eb6531ebd6e5811692613387d45f890") -elseif(${middleware_version_str} VERSION_EQUAL "0.0.4") - set(middleware_url "https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/sophgo-middleware-0.0.4.tar.xz") - set(middleware_file_sha256sum "e239b4be072c3835962a8f73d24dcc88f9258ae9d90edae94419b39823dc4c14") -else() - message(FATAL_ERROR "No sophgo middleware version ${version_str} support, please edit to add sophgo middleware support for this version") -endif() -list(APPEND ADD_FILE_DOWNLOADS "{ - 'url': '${middleware_url}', - 'urls': [], - 'sites': [], - 'sha256sum': '${middleware_file_sha256sum}', - 'filename': '${middleware_filename}', - 'path': 'sophgo-middleware', - 'check_files': ['sophgo-middleware-${middleware_version_str}'] - }" -) if(CONFIG_MAIXCAM_LIB_COMPILE_FROM_SOURCE) set(source_dir "maixcdk_maixcam_lib") @@ -277,22 +251,6 @@ endif() # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib # register_component() diff --git a/components/maixcam_lib/component.py b/components/maixcam_lib/component.py new file mode 100644 index 00000000..81c7c0ea --- /dev/null +++ b/components/maixcam_lib/component.py @@ -0,0 +1,29 @@ + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + version = f"{confs['CONFIG_SOPHGO_MIDDLEWARE_VERSION_MAJOR']}.{confs['CONFIG_SOPHGO_MIDDLEWARE_VERSION_MINOR']}.{confs['CONFIG_SOPHGO_MIDDLEWARE_VERSION_PATCH']}" + if version == "0.0.4": + url = "https://github.com/sipeed/MaixCDK/releases/download/v0.0.0/sophgo-middleware-0.0.4.tar.xz" + sha256sum = "e239b4be072c3835962a8f73d24dcc88f9258ae9d90edae94419b39823dc4c14" + else: + raise Exception(f"version {version} not support") + filename = f"sophgo-middleware-${version}.tar.xz" + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': [], + 'sha256sum': sha256sum, + 'filename': filename, + 'path': 'sophgo-middleware', + 'check_files': [ + f'sophgo-middleware-{version}' + ] + } + ] + + diff --git a/components/network/CMakeLists.txt b/components/network/CMakeLists.txt index 280dbff7..d9a09645 100644 --- a/components/network/CMakeLists.txt +++ b/components/network/CMakeLists.txt @@ -73,22 +73,6 @@ register_component() # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib # register_component() diff --git a/components/nn/CMakeLists.txt b/components/nn/CMakeLists.txt index 7456d792..7b0081fa 100644 --- a/components/nn/CMakeLists.txt +++ b/components/nn/CMakeLists.txt @@ -70,22 +70,6 @@ register_component() # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib # register_component() diff --git a/components/peripheral/CMakeLists.txt b/components/peripheral/CMakeLists.txt index 53f2d149..fd9d3a7e 100644 --- a/components/peripheral/CMakeLists.txt +++ b/components/peripheral/CMakeLists.txt @@ -68,22 +68,6 @@ list(APPEND ADD_REQUIREMENTS basic) # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib register_component() diff --git a/components/vision/CMakeLists.txt b/components/vision/CMakeLists.txt index 196df00d..dbdb6c99 100644 --- a/components/vision/CMakeLists.txt +++ b/components/vision/CMakeLists.txt @@ -39,6 +39,8 @@ if(PLATFORM_LINUX) list(APPEND ADD_REQUIREMENTS sdl) elseif(PLATFORM_MAIXCAM) list(APPEND ADD_REQUIREMENTS maixcam_lib media_server) + set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group vision/libvision.a -lmaixcam_lib -Wl,--end-group" PARENT_SCOPE) + set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--start-group vision/libvision.a -lmaixcam_lib -Wl,--end-group" PARENT_SCOPE) endif() ############################################### @@ -76,22 +78,6 @@ endif() # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) ############################################### -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib register_component() diff --git a/dl/README.md b/dl/README.md index 5c386ca7..0f4940da 100644 --- a/dl/README.md +++ b/dl/README.md @@ -6,8 +6,41 @@ Downloaded files should be put in pkgs directory. Extracted files should be put in extracted directory. so: -* If you are developing a package, and need data files, cause only code should be add to git repo, you should put the data files on internet, and download them is `dl/pkgs` directory, to use them, extract them to `dl/extracted` directory. You just need edit the `CMakeLists.txt` file, edit `ADD_FILE_DOWNLOADS` variable, and use the extracted files with `${DL_EXTRACTED_PATH}/your_path`. +* If you are developing a package, and need data files, cause only code should be add to git repo, you should put the data files on internet, and download them is `dl/pkgs` directory, to use them, extract them to `dl/extracted` directory. You just need edit the `components.py` which next to `CMakeLists.txt` file, add `add_file_downloads` function, this will tell maixcdk to download and extract them before compile, so you can use the extracted files with `${DL_EXTRACTED_PATH}/your_path` in your `CMakeLists.txt` > e.g. For python packages, will be downloaded to `dl/pkgs/python_srcs`, and extracted to `dl/extracted/python_srcs`, which download commands in CMakelists.txt. +`add_file_downloads` example: +```python + +def add_file_downloads(confs : dict) -> list: + ''' + @param confs kconfig vars, dict type + @return list type, items is dict type + ''' + version = f"{confs['CONFIG_MEDIA_SERVER_VERSION_MAJOR']}.{confs['CONFIG_MEDIA_SERVER_VERSION_MINOR']}.{confs['CONFIG_MEDIA_SERVER_VERSION_PATCH']}" + if version == "1.0.0": + url = "https://master.dl.sourceforge.net/projectxxxxxx.zip" + sha256sum = "dfe405cedbf3969fbf1f252634e7b1c71e8bb3e2d0857db2fe7e70189474ecd1" + elif version == "1.0.1": + url = "https://master.dl.sourceforge.net/projectxxxxxx1.0.1.zip" + else: + raise Exception(f"version {version} not support") + filename = f"media_server-{version}.zip" + + return [ + { + 'url': f'{url}', + 'urls': [], + 'sites': [], + 'sha256sum': sha256sum, + 'filename': filename, + 'path': 'media_server', + 'check_files': [ + f'media_server-{version}' + ] + } + ] +``` + * If you users to compile projects, you can download files manually to dl/pkgs directory first, when compile `pkgs_info.json` will be write to this directory, all files need to be downloaded will be listed in this file. diff --git a/docs/doc/dev/quick_start.md b/docs/doc/dev/quick_start.md index 988388df..fe5ccf43 100644 --- a/docs/doc/dev/quick_start.md +++ b/docs/doc/dev/quick_start.md @@ -70,7 +70,7 @@ maixcdk build * 打包发布 -在工程目录下,使用 `maixcdk -P maixcam release` 可以为 `maixcam` 打包一个程序包并且存放在`dist`目录,可以上传发布到[MaixHub 应用商店](https://maixhub.com/app)。 +在工程目录下,使用 `maixcdk -p maixcam release` 可以为 `maixcam` 打包一个程序包并且存放在`dist`目录,可以上传发布到[MaixHub 应用商店](https://maixhub.com/app)。 安装包使用方法: * 方法一: 直接解压拷贝到设置执行`chmod +x main.sh && ./main.sh`即可运行。 diff --git a/examples/hello_world/main/CMakeLists.txt b/examples/hello_world/main/CMakeLists.txt index 2aeb7c96..d3f518c3 100644 --- a/examples/hello_world/main/CMakeLists.txt +++ b/examples/hello_world/main/CMakeLists.txt @@ -23,7 +23,7 @@ append_srcs_dir(ADD_SRCS "src") # append source file in src dir to var ADD ############################################### ###### Add required/dependent components ###### -list(APPEND ADD_REQUIREMENTS basic) +list(APPEND ADD_REQUIREMENTS basic vision) ############################################### ###### Add link search path for requirements/libs ###### diff --git a/test/test_examples/test_cases.sh b/test/test_examples/test_cases.sh index bcbdcdfb..8d4b4130 100755 --- a/test/test_examples/test_cases.sh +++ b/test/test_examples/test_cases.sh @@ -36,7 +36,8 @@ function test_start() { test_script $1 if [ $? -ne 0 ]; then - echo "Error: $1 failed to execute." + echo "Error: $1 failed to execute." + exit 1 fi } diff --git a/tools/cmake/build.py b/tools/cmake/build.py index 060025b0..c77f11b9 100644 --- a/tools/cmake/build.py +++ b/tools/cmake/build.py @@ -1,18 +1,158 @@ - import subprocess + import os from multiprocessing import cpu_count import shutil import sys import re +import traceback + +try: + curr_dir = os.path.abspath(os.path.dirname(__file__)) +except Exception: + print("-- [ERROR] Please upgrate maixtool by pip install -U maixtool") + sys.exit(1) + +if curr_dir not in sys.path: + sys.path.insert(0, curr_dir) + +from file_downloader import download_extract_files thread_num = cpu_count() +def parse_kconfigs(config_path, toolchain_config_path): + configs = {} + with open(config_path, "r") as f: + lines = f.readlines() + for line in lines: + line = line.strip() + if line.startswith("#") or line == "": + continue + k,v = line.split("=", 1) + if v == "y": + v = True + configs[k] = v + with open(toolchain_config_path, "r") as f: + lines = f.readlines() + for line in lines: + line = line.strip() + if line.startswith("#") or line == "": + continue + if line.startswith("set("): + k, v = line.split("(", 1)[1].rsplit(")", 1)[0].split(" ", 1) + configs[k] = v + return configs + +def get_components_dirs(find_dirs): + components = {} + for dir in find_dirs: + if (not dir) or not os.path.exists(dir): + continue + for name in os.listdir(dir): + path = os.path.join(dir, name, "CMakeLists.txt") + if os.path.exists(path): + components[name] = os.path.dirname(path) + return components + +def get_components_files(components, valid_components, kconfigs): + files = {} + for name in valid_components: + py_path = os.path.join(components[name], "component.py") + if not os.path.exists(py_path): + continue + g = {} + with open(py_path, "r", encoding="utf-8") as f: + exec(f.read(), g) + if "add_file_downloads" in g: + try: + files[name] = g["add_file_downloads"](kconfigs) + except Exception as e: + print("\n\n---- ERROR -----") + traceback.print_exc() + print("----------------") + print(f"[ERROR] execute compoent [{name}]'s component.py failed") + sys.exit(1) + return files + +def find_valid_components(components): + ''' + get project depends(not accurately, just exclude some obvious not depend components) + return valid components name + ''' + # get components quire + depends = {} + for name, dir in components.items(): + cmakelist = os.path.join(dir, "CMakeLists.txt") + with open(cmakelist, "r", encoding="utf-8") as f: + content = f.read() + match = re.findall(r'list\(APPEND ADD_REQUIREMENTS(.*?)\)', content, re.DOTALL|re.MULTILINE) + match = list(set(" ".join(match).split())) + depends[name] = [] + for r in match: + if r in components: + depends[name].append(r) + # find main depends + def get_depend_recursive(name): + d = depends[name] + for r in depends[name]: + d.extend(get_depend_recursive(r)) + d = list(set(d)) + return d + valid = ["main"] + valid.extend(get_depend_recursive("main")) + return valid + +def get_components_find_dirs(configs): + final = [] + find_dirs = [ # same as compile.cmake find_components in project macro + configs.get("MAIXCDK_EXTRA_COMPONENTS_PATH", ""), + configs.get("PY_PKG_COMPONENTS_PATH", ""), + configs.get("PY_USR_PKG_COMPONENTS_PATH", ""), + os.path.join(configs["SDK_PATH"], "components"), + os.path.join(configs["SDK_PATH"], "components", "3rd_party"), + configs["PROJECT_PATH"], + os.path.join(configs["PROJECT_PATH"], "components"), + os.path.join(configs["PROJECT_PATH"], "..", "components"), + ] + for dir in find_dirs: + if (not dir) or not os.path.exists(dir): + continue + final.append(dir) + return final + +def get_all_components_dl_info(find_dirs, kconfigs): + components = get_components_dirs(find_dirs) + valid_components = find_valid_components(components) + files_info = get_components_files(components, valid_components, kconfigs) + return files_info + def rebuild(build_path, configs, verbose): os.makedirs(build_path, exist_ok=True) os.chdir(build_path) - if not os.path.exists(os.path.join(build_path, "config", "global_config.mk")): + config_path = os.path.join(build_path, "config", "global_config.mk") + toolchain_config_path = os.path.join(build_path, "config", "toolchain_config.cmake") + if not os.path.exists(config_path): menuconfig(configs["SDK_PATH"], build_path, configs, False) + + # find and download all files, save to sdk_path/dl/pkgs_info.json + all_configs = configs.copy() + kconfigs = parse_kconfigs(config_path, toolchain_config_path) + all_configs.update(kconfigs) + find_dirs = get_components_find_dirs(configs) + files_info = get_all_components_dl_info(find_dirs, all_configs) + for name, files in files_info.items(): + if len(files) > 0: + print(f"\n-- Download files for component {name}") + try: + download_extract_files(files) + except Exception as e: + print("\n\n---- ERROR -----") + traceback.print_exc() + print("----------------") + print(f"[ERROR] download for compoent [{name}] failed, please check its component.py") + sys.exit(1) + + # cmake cmd = ["cmake", "-G", configs["CMAKE_GENERATOR"]] for k, v in configs.items(): cmd.append("-D{}={}".format(k, v)) @@ -31,6 +171,8 @@ def rebuild(build_path, configs, verbose): code += "#define PROJECT_ID \"{}\"\n".format(configs["PROJECT_ID"]) code += "#endif\n" f.write(code) + + # build build(build_path, configs, verbose) def build(build_path, configs, verbose): @@ -119,3 +261,14 @@ def menuconfig(sdk_path, build_path, configs, gui = True): os.remove(name) print("-- clean build dir complete") +if __name__ == "__main__": + cmd = sys.argv[1] + if cmd == "get_valid_components": + find_dirs = sys.argv[2:] + for dir in find_dirs: + if " " in dir: + raise Exception("Path can not contain space or special charactors") + components = get_components_dirs(find_dirs) + valid_components = find_valid_components(components) + print(";".join(valid_components), end="") + diff --git a/tools/cmake/compile.cmake b/tools/cmake/compile.cmake index 8af4437e..434f6174 100644 --- a/tools/cmake/compile.cmake +++ b/tools/cmake/compile.cmake @@ -18,7 +18,7 @@ set(g_dist_ignore_libs "" CACHE INTERNAL "g_dist_ignore_libs") set(g_link_search_path "" CACHE INTERNAL "g_link_search_path") set(g_includes "" CACHE INTERNAL "g_includes") set(g_srcs "" CACHE INTERNAL "g_srcs") -set(g_files_download_info "" CACHE INTERNAL "g_files_download_info") +# set(g_files_download_info "" CACHE INTERNAL "g_files_download_info") set(g_enabled_components "" CACHE INTERNAL "g_enabled_components") # Set project dir, so just projec can include this cmake file!!! @@ -147,7 +147,11 @@ function(register_component) if(ADD_LINK_SEARCH_PATH) foreach(path ${ADD_LINK_SEARCH_PATH}) if(NOT EXISTS "${path}") - prepend(lib_full "${component_dir}/" ${path}) + if(IS_ABSOLUTE ${lib}) + set(lib_full ${lib}) + else() + prepend(lib_full "${component_dir}/" ${path}) + endif() if(NOT EXISTS "${lib_full}") message(FATAL_ERROR "Can not find ${path} or ${lib_full}") endif() @@ -168,7 +172,11 @@ function(register_component) if(ADD_STATIC_LIB) foreach(lib ${ADD_STATIC_LIB}) if(NOT EXISTS "${lib}") - prepend(lib_full "${component_dir}/" ${lib}) + if(IS_ABSOLUTE ${lib}) + set(lib_full ${lib}) + else() + prepend(lib_full "${component_dir}/" ${lib}) + endif() if(NOT EXISTS "${lib_full}") get_property(is_generated SOURCE ${lib} PROPERTY GENERATED) if(NOT is_generated) @@ -186,7 +194,11 @@ function(register_component) set(dynamic_libs ${g_dynamic_libs}) foreach(lib ${ADD_DYNAMIC_LIB}) if(NOT EXISTS "${lib}") - prepend(lib_full "${component_dir}/" ${lib}) + if(IS_ABSOLUTE ${lib}) + set(lib_full ${lib}) + else() + prepend(lib_full "${component_dir}/" ${lib}) + endif() if(NOT EXISTS "${lib_full}") get_property(is_generated SOURCE ${lib} PROPERTY GENERATED) if(NOT is_generated) @@ -235,17 +247,17 @@ function(register_component) add_dependencies(${component_name} ${component_name}_file_depends) endif() - # Add files to download list to g_files_download_info - set(files ${g_files_download_info}) - if(ADD_FILE_DOWNLOADS) - foreach(file ${ADD_FILE_DOWNLOADS}) - string(REPLACE "\n" " " file ${file}) - string(REPLACE "\r" " " file ${file}) - list(APPEND files "${component_name}+${file}") - endforeach() - endif() - # append file to global variable g_files_download_info - set(g_files_download_info ${files} CACHE INTERNAL "g_files_download_info") + # # Add files to download list to g_files_download_info + # set(files ${g_files_download_info}) + # if(ADD_FILE_DOWNLOADS) + # foreach(file ${ADD_FILE_DOWNLOADS}) + # string(REPLACE "\n" " " file ${file}) + # string(REPLACE "\r" " " file ${file}) + # list(APPEND files "${component_name}+${file}") + # endforeach() + # endif() + # # append file to global variable g_files_download_info + # set(g_files_download_info ${files} CACHE INTERNAL "g_files_download_info") endfunction() function(is_path_component ret param_path) @@ -545,15 +557,28 @@ macro(project name) message(STATUS "Components priority config fail ${component_dirs_sorted}, check config file:${component_priority_conf_file}") endif() + # guess components used + set(cmd COMMAND ${python} -u ${SDK_PATH}/tools/cmake/build.py get_valid_components ${SDK_PATH}/components ${SDK_PATH}/components/3rd_party ${MAIXCDK_EXTRA_COMPONENTS_PATH} ${PY_PKG_COMPONENTS_PATH} ${PY_USR_PKG_COMPONENTS_PATH} ${PROJECT_SOURCE_DIR}/../components ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/components) + execute_process(${cmd} RESULT_VARIABLE cmd_res OUTPUT_VARIABLE component_valid) + if(NOT cmd_res EQUAL 0) + message(FATAL_ERROR "Get valid components failed") + endif() + message("-- Only call enabled components: ${component_valid}") + # Call CMakeLists.txt foreach(component_dir ${component_dirs_sorted}) get_filename_component(base_dir ${component_dir} NAME) - add_subdirectory(${component_dir} ${base_dir} EXCLUDE_FROM_ALL) - if(TARGET ${base_dir}) - add_dependencies(${base_dir} update_build_info) # add build info dependence - else() - message(STATUS "component ${base_dir} not enabled") - endif() + list(FIND component_valid ${base_dir} INDEX) + if(INDEX EQUAL -1) + message(STATUS "Ignore component ${base_dir}") + else() + add_subdirectory(${component_dir} ${base_dir} EXCLUDE_FROM_ALL) + if(TARGET ${base_dir}) + add_dependencies(${base_dir} update_build_info) # add build info dependence + else() + message(STATUS "component ${base_dir} not enabled") + endif() + endif() endforeach() # update all global vars according to g_enabled_components @@ -583,7 +608,7 @@ macro(project name) set(${var_name} ${new_items} CACHE INTERNAL ${var_name}) endfunction() - update_global_var(g_files_download_info) + # update_global_var(g_files_download_info) update_global_var(g_includes) update_global_var(g_srcs) update_global_var(g_dynamic_libs) @@ -595,15 +620,15 @@ macro(project name) endforeach() # Download files according to g_files_download_info - if(g_files_download_info) - message(STATUS "Start download files") - set(download_cmd COMMAND ${python} -u ${SDK_PATH}/tools/file_downloader.py ${g_files_download_info}) - execute_process(${download_cmd} RESULT_VARIABLE cmd_res) - if(NOT cmd_res EQUAL 0) - message(FATAL_ERROR "Download files failed") - endif() - message(STATUS "Download files complete") - endif() + # if(g_files_download_info) + # message(STATUS "Start download files") + # set(download_cmd COMMAND ${python} -u ${SDK_PATH}/tools/file_downloader.py ${g_files_download_info}) + # execute_process(${download_cmd} RESULT_VARIABLE cmd_res) + # if(NOT cmd_res EQUAL 0) + # message(FATAL_ERROR "Download files failed") + # endif() + # message(STATUS "Download files complete") + # endif() # write global variables to ${CMAKE_BINARY_DIR}/config/cmake_global_variables.json set(write_global_vars_cmd COMMAND ${python} -u ${SDK_PATH}/tools/cmake/save_global_vars.py @@ -612,7 +637,7 @@ macro(project name) --var srcs ${g_srcs} --var dynamic_libs ${g_dynamic_libs} --var link_search_path ${g_link_search_path} - --var files_download_info ${g_files_download_info} + # --var files_download_info ${g_files_download_info} ) execute_process(${write_global_vars_cmd} RESULT_VARIABLE cmd_res) if(NOT cmd_res EQUAL 0) diff --git a/tools/file_downloader.py b/tools/cmake/file_downloader.py similarity index 98% rename from tools/file_downloader.py rename to tools/cmake/file_downloader.py index ac974035..356c51ab 100644 --- a/tools/file_downloader.py +++ b/tools/cmake/file_downloader.py @@ -19,7 +19,7 @@ import zipfile import lzma import json -sdk_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +sdk_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) lock = Lock() @@ -262,7 +262,7 @@ def download_extract_files(items): extract_dir = os.path.join(sdk_path, "dl", "extracted", item["path"]) if not os.path.exists(pkg_path): print("\n-------------------------------------------------------------------") - print("-- Downloading {} from:\n {},\n save to: {}\n you can also download it manually and save to this position{}{}".format( + print("-- Downloading {} from:\n {}\n save to: {}\n you can also download it manually and save to this position{}{}".format( item["filename"], item["url"], pkg_path, "\n other urls: {}".format(item["urls"]) if item["urls"] else "", "\n sites: {}".format(item["sites"]) if item["sites"] else "")) @@ -286,6 +286,7 @@ def download_extract_files(items): continue renamed_files = [] if "rename" in item: + print(item) for _from, _to in item["rename"].items(): from_path = os.path.join(extract_dir, _from) to_path = os.path.join(extract_dir, _to)