mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
ci(windows): fix fetch submodule path issue
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
# SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
import argparse
|
import argparse
|
||||||
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -261,18 +262,32 @@ class Gitlab(object):
|
|||||||
|
|
||||||
return self.decompress_archive(temp_file.name, destination)
|
return self.decompress_archive(temp_file.name, destination)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _to_win32_long_path(path: str) -> str:
|
||||||
|
normalized_path = os.path.normpath(os.path.abspath(path))
|
||||||
|
if normalized_path.startswith('\\\\?\\'):
|
||||||
|
return normalized_path
|
||||||
|
if normalized_path.startswith('\\\\'):
|
||||||
|
return '\\\\?\\UNC\\' + normalized_path[2:]
|
||||||
|
return '\\\\?\\' + normalized_path
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def decompress_archive(path: str, destination: str) -> str:
|
def decompress_archive(path: str, destination: str) -> str:
|
||||||
full_destination = os.path.abspath(destination)
|
full_destination = os.path.abspath(destination)
|
||||||
# By default max path length is set to 260 characters
|
|
||||||
# Prefix `\\?\` extends it to 32,767 characters
|
|
||||||
if sys.platform == 'win32':
|
|
||||||
full_destination = '\\\\?\\' + full_destination
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with tarfile.open(path, 'r') as archive_file:
|
with tarfile.open(path, 'r') as archive_file:
|
||||||
root_name = archive_file.getnames()[0]
|
members = archive_file.getmembers()
|
||||||
archive_file.extractall(full_destination)
|
root_name = members[0].name
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
# tarfile keeps archive member names in POSIX form. Normalize them before
|
||||||
|
# combining with a long-path-prefixed destination to avoid invalid mixed separators.
|
||||||
|
full_destination = Gitlab._to_win32_long_path(full_destination)
|
||||||
|
members = [copy.copy(member) for member in members]
|
||||||
|
for member in members:
|
||||||
|
member.name = member.name.replace('/', '\\')
|
||||||
|
member.linkname = member.linkname.replace('/', '\\')
|
||||||
|
archive_file.extractall(full_destination, members=members)
|
||||||
except tarfile.TarError as e:
|
except tarfile.TarError as e:
|
||||||
logging.error(f'Error while decompressing archive {path}')
|
logging.error(f'Error while decompressing archive {path}')
|
||||||
raise e
|
raise e
|
||||||
|
|||||||
+12
-12
@@ -97,9 +97,9 @@ endmacro()
|
|||||||
#
|
#
|
||||||
function(__component_dir_quick_check var component_dir)
|
function(__component_dir_quick_check var component_dir)
|
||||||
set(res 1)
|
set(res 1)
|
||||||
get_filename_component(abs_dir ${component_dir} ABSOLUTE)
|
get_filename_component(abs_dir "${component_dir}" ABSOLUTE)
|
||||||
|
|
||||||
get_filename_component(base_dir ${abs_dir} NAME)
|
get_filename_component(base_dir "${abs_dir}" NAME)
|
||||||
string(SUBSTRING "${base_dir}" 0 1 first_char)
|
string(SUBSTRING "${base_dir}" 0 1 first_char)
|
||||||
|
|
||||||
# Check the component directory contains a CMakeLists.txt file
|
# Check the component directory contains a CMakeLists.txt file
|
||||||
@@ -149,8 +149,8 @@ function(__component_add component_dir prefix component_source)
|
|||||||
# so later in the build, these component targets actually contain the properties meant for the
|
# so later in the build, these component targets actually contain the properties meant for the
|
||||||
# corresponding component library.
|
# corresponding component library.
|
||||||
idf_build_get_property(component_targets __COMPONENT_TARGETS)
|
idf_build_get_property(component_targets __COMPONENT_TARGETS)
|
||||||
get_filename_component(abs_dir ${component_dir} ABSOLUTE)
|
get_filename_component(abs_dir "${component_dir}" ABSOLUTE)
|
||||||
get_filename_component(base_dir ${abs_dir} NAME)
|
get_filename_component(base_dir "${abs_dir}" NAME)
|
||||||
|
|
||||||
if(NOT EXISTS "${abs_dir}/CMakeLists.txt")
|
if(NOT EXISTS "${abs_dir}/CMakeLists.txt")
|
||||||
message(FATAL_ERROR "Directory '${component_dir}' does not contain a component.")
|
message(FATAL_ERROR "Directory '${component_dir}' does not contain a component.")
|
||||||
@@ -277,15 +277,15 @@ macro(__component_add_sources sources)
|
|||||||
message(WARNING "SRCS and SRC_DIRS are both specified; ignoring SRC_DIRS.")
|
message(WARNING "SRCS and SRC_DIRS are both specified; ignoring SRC_DIRS.")
|
||||||
endif()
|
endif()
|
||||||
foreach(src ${__SRCS})
|
foreach(src ${__SRCS})
|
||||||
get_filename_component(src "${src}" ABSOLUTE BASE_DIR ${COMPONENT_DIR})
|
get_filename_component(src "${src}" ABSOLUTE BASE_DIR "${COMPONENT_DIR}")
|
||||||
list(APPEND sources ${src})
|
list(APPEND sources "${src}")
|
||||||
endforeach()
|
endforeach()
|
||||||
else()
|
else()
|
||||||
if(__SRC_DIRS)
|
if(__SRC_DIRS)
|
||||||
foreach(dir ${__SRC_DIRS})
|
foreach(dir ${__SRC_DIRS})
|
||||||
get_filename_component(abs_dir ${dir} ABSOLUTE BASE_DIR ${COMPONENT_DIR})
|
get_filename_component(abs_dir "${dir}" ABSOLUTE BASE_DIR "${COMPONENT_DIR}")
|
||||||
|
|
||||||
if(NOT IS_DIRECTORY ${abs_dir})
|
if(NOT IS_DIRECTORY "${abs_dir}")
|
||||||
message(FATAL_ERROR "SRC_DIRS entry '${dir}' does not exist.")
|
message(FATAL_ERROR "SRC_DIRS entry '${dir}' does not exist.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ macro(__component_add_sources sources)
|
|||||||
|
|
||||||
if(dir_sources)
|
if(dir_sources)
|
||||||
foreach(src ${dir_sources})
|
foreach(src ${dir_sources})
|
||||||
get_filename_component(src "${src}" ABSOLUTE BASE_DIR ${COMPONENT_DIR})
|
get_filename_component(src "${src}" ABSOLUTE BASE_DIR "${COMPONENT_DIR}")
|
||||||
list(APPEND sources "${src}")
|
list(APPEND sources "${src}")
|
||||||
endforeach()
|
endforeach()
|
||||||
else()
|
else()
|
||||||
@@ -316,11 +316,11 @@ endmacro()
|
|||||||
|
|
||||||
macro(__component_add_include_dirs lib dirs type)
|
macro(__component_add_include_dirs lib dirs type)
|
||||||
foreach(dir ${dirs})
|
foreach(dir ${dirs})
|
||||||
get_filename_component(_dir ${dir} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_LIST_DIR})
|
get_filename_component(_dir "${dir}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
if(NOT IS_DIRECTORY ${_dir})
|
if(NOT IS_DIRECTORY "${_dir}")
|
||||||
message(FATAL_ERROR "Include directory '${_dir}' is not a directory.")
|
message(FATAL_ERROR "Include directory '${_dir}' is not a directory.")
|
||||||
endif()
|
endif()
|
||||||
target_include_directories(${lib} ${type} ${_dir})
|
target_include_directories(${lib} ${type} "${_dir}")
|
||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user