Skip to content

Commit

Permalink
optimzie downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed May 11, 2024
1 parent 323675f commit bb420a7
Show file tree
Hide file tree
Showing 50 changed files with 991 additions and 729 deletions.
26 changes: 1 addition & 25 deletions components/3rd_party/asio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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()

25 changes: 25 additions & 0 deletions components/3rd_party/asio/component.py
Original file line number Diff line number Diff line change
@@ -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'
]
}
]


29 changes: 2 additions & 27 deletions components/3rd_party/brotli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions components/3rd_party/brotli/component.py
Original file line number Diff line number Diff line change
@@ -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
]
}
]


15 changes: 0 additions & 15 deletions components/3rd_party/cpp-httplib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
26 changes: 0 additions & 26 deletions components/3rd_party/cvi_tpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()

35 changes: 35 additions & 0 deletions components/3rd_party/cvi_tpu/component.py
Original file line number Diff line number Diff line change
@@ -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
]
}
]


31 changes: 0 additions & 31 deletions components/3rd_party/freetype/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions components/3rd_party/freetype/component.py
Original file line number Diff line number Diff line change
@@ -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
]
}
]


41 changes: 1 addition & 40 deletions components/3rd_party/harfbuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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")
Expand All @@ -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)
Expand Down
Loading

0 comments on commit bb420a7

Please sign in to comment.