Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions .github/workflows/build-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ jobs:

# Only get the changes that can be built
# First, get the diff output
DIFF=$(git diff ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} \
--no-ext-diff --unified=0 \
--exit-code -a --no-prefix -- $FILE | egrep "^\+[^\+]" | egrep -v "^\+\+\+ ")
DIFF=$(git diff ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} \
--no-ext-diff --unified=0 \
-a --no-prefix -- $FILE | grep -E "^\+[^\+]" | grep -Ev "^\+\+\+ " || true)

# Use an associative array to track which packages we've already processed
declare -A PROCESSED_PACKAGES
Expand Down Expand Up @@ -272,17 +272,25 @@ jobs:
echo ANDROID_NDK_HOME=$ndkRoot >> $env:GITHUB_ENV
echo ANDROID_NDK_ROOT=$ndkRoot >> $env:GITHUB_ENV

- name: Install clang/gcc
if: runner.os == 'Linux'
env:
CLANG_VER: 15
GCC_VER: 9
run: |
sudo apt-get install -y clang-${{ env.CLANG_VER }} clang++-${{ env.CLANG_VER }} gcc-${{ env.GCC_VER }} g++-${{ env.GCC_VER }} libclang-${{ env.CLANG_VER }}-dev
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ env.CLANG_VER }} 10
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{ env.CLANG_VER }} 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_VER }} 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${{ env.GCC_VER }} 10
- name: Install clang/gcc
if: runner.os == 'Linux'
env:
CLANG_VER: 18
GCC_VER: 9
run: |
wget -qO /tmp/llvm.sh https://apt.llvm.org/llvm.sh
chmod +x /tmp/llvm.sh
sudo /tmp/llvm.sh ${{ env.CLANG_VER }}
sudo apt-get install -y lld-${{ env.CLANG_VER }} clang-tools-${{ env.CLANG_VER }} libclang-${{ env.CLANG_VER }}-dev gcc-${{ env.GCC_VER }} g++-${{ env.GCC_VER }}
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ env.CLANG_VER }} 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{ env.CLANG_VER }} 100
sudo update-alternatives --set clang /usr/bin/clang-${{ env.CLANG_VER }}
sudo update-alternatives --set clang++ /usr/bin/clang++-${{ env.CLANG_VER }}
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_VER }} 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${{ env.GCC_VER }} 10
echo "CC=$(which clang-${{ env.CLANG_VER }})" >> $GITHUB_ENV
echo "CXX=$(which clang++-${{ env.CLANG_VER }})" >> $GITHUB_ENV
clang --version

- name: Install additional build dependencies
if: runner.os == 'Linux'
Expand Down
48 changes: 43 additions & 5 deletions Scripts/extras/archive_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def hash_file(file_path:str, hash_algorithm:str='md5')->str:

# we don't follow symlinks here, this is strictly to check actual packages.
with open(file_path, 'rb') as afile:
buf = afile.read()
hasher.update(buf)
for chunk in iter(lambda: afile.read(1024 * 1024), b''):
hasher.update(chunk)
hash_result = hasher.hexdigest()

return hash_result
Expand Down Expand Up @@ -101,7 +101,40 @@ def download_and_verify(src_url: str, src_zip_hash:str, src_zip_hash_algorithm:s

return str(tgt_filename)

def extract_package(src_package_file: str, target_folder:str):
def _strip_tar_top_level(tar_file):
members = tar_file.getmembers()
top_level_names = set()

for member in members:
if not (member_parts := pathlib.PurePosixPath(member.name).parts):
continue
if member_parts[0] == '/' or '..' in member_parts:
raise RuntimeError(f"Archive contains an unsafe path: {member.name}")
top_level_names.add(member_parts[0])

if len(top_level_names) != 1:
raise RuntimeError("Archive must contain exactly one top-level directory to strip")

top_level_name = top_level_names.pop()
stripped_members = []
for member in members:
member_parts = pathlib.PurePosixPath(member.name).parts
if len(member_parts) == 1:
if not member.isdir():
raise RuntimeError(f"Archive top-level entry is not a directory: {member.name}")
continue

member.name = pathlib.PurePosixPath(*member_parts[1:]).as_posix()
if member.islnk():
link_parts = pathlib.PurePosixPath(member.linkname).parts
if link_parts and link_parts[0] == top_level_name:
member.linkname = pathlib.PurePosixPath(*link_parts[1:]).as_posix()
stripped_members.append(member)

return stripped_members


def extract_package(src_package_file: str, target_folder: str, strip_top_level: bool = False):

src_package_file_path = pathlib.Path(src_package_file)
target_folder_path = pathlib.Path(target_folder)
Expand All @@ -111,19 +144,24 @@ def extract_package(src_package_file: str, target_folder:str):

package_name, package_ext = os.path.splitext(str(src_package_file_path.name))

destination_path = target_folder_path / package_name
destination_path = target_folder_path if strip_top_level else target_folder_path / package_name

print(f"{INDENT}Extracting {src_package_file_path} to {destination_path}")

if package_ext in ARCHIVE_EXTS_ZIP:
if strip_top_level:
raise RuntimeError("Stripping the top-level directory is not supported for zip archives")
import zipfile
with zipfile.ZipFile(str(src_package_file_path.resolve()), 'r') as dep_zip:
dep_zip.extractall(destination_path)
elif package_ext in ARCHIVE_EXTS_TAR:
import tarfile
with tarfile.open(str(src_package_file_path.resolve())) as tar_file:
tarfile.extractall(destination_path)
members = _strip_tar_top_level(tar_file) if strip_top_level else None
tar_file.extractall(destination_path, members=members)
elif package_ext in ARCHIVE_EXTS_7ZIP:
if strip_top_level:
raise RuntimeError("Stripping the top-level directory is not supported for 7Zip archives")
try:
os.makedirs(destination_path, exist_ok=True)
subprocess.call(['7z', 'x', '-y', str(src_package_file_path.resolve())], cwd=destination_path)
Expand Down
10 changes: 7 additions & 3 deletions Scripts/extras/pull_and_build_from_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* package_name : The base name of the package, used for constructing the filename and folder structures
* package_url : The package url that will be placed in the PackageInfo.json
* package_license : The type of license that will be described in the PackageInfo.json
* package_license_file : The name of the source code license file (expected at the root of the source folder pulled from git)
* package_license_file : The source-relative path to the package license file

The following keys can exist at the root level or the target-platform level:

Expand All @@ -48,6 +48,7 @@

* src_package_url : The download URI to retrieve the source package compressed tar from
* src_package_sha1 : The sha1 fingerprint of the downloaded source package compressed tar for verification
* src_package_strip_top_level : (optional) Extract a tar source package directly into the source folder by stripping its single top-level directory. Defaults to false.

** Note: Either both git_url + git_tag/git_commit OR src_package_url + src_package_sha1 must be supplied, but not both

Expand Down Expand Up @@ -280,6 +281,7 @@ def _get_value(value_key, required=True, default=None):
self.git_tag = _get_value("git_tag", required=False)
self.src_package_url = _get_value("src_package_url", required=False)
self.src_package_sha1 = _get_value("src_package_sha1", required=False)
self.src_package_strip_top_level = _get_value("src_package_strip_top_level", required=False, default=False)

if not self.git_url and not self.src_package_url:
raise BuildError(f"Either 'git_url' or 'src_package_url' must be provided for the source in the build config.")
Expand All @@ -290,6 +292,8 @@ def _get_value(value_key, required=True, default=None):
raise BuildError(f"Missing 'git_tag' entry for the git repo {self.git_url} in the build config.")
if self.src_package_url and not self.src_package_sha1:
raise BuildError(f"Missing 'src_package_sha1' entry for the source package at {self.src_package_url} in the build config.")
if type(self.src_package_strip_top_level) is not bool:
raise BuildError("Invalid build config. 'src_package_strip_top_level' must be a boolean.")

self.package_version = _get_value("package_version")
self.patch_file = _get_value("patch_file", required=False)
Expand Down Expand Up @@ -664,7 +668,8 @@ def sync_source(self):
src_zip_hash_algorithm="sha1",
target_folder=self.base_temp_folder)
extracted_package_path = extract_package(src_package_file=downloaded_package_file,
target_folder=self.src_folder.resolve())
target_folder=self.src_folder.resolve(),
strip_top_level=self.package_info.src_package_strip_top_level)

else:
raise BuildError(f"Missing both 'git_url' and 'src_package_url' from the build config")
Expand Down Expand Up @@ -1407,4 +1412,3 @@ def prepare_build(platform_name, base_folder, build_folder, package_root_folder,

print(err)
exit(1)

4 changes: 2 additions & 2 deletions package-system/Qt/FindQt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ endif()

# Force-set QtCore's version here to ensure CMake detects Qt's existence and allows AUTOMOC to work
set(Qt6Core_VERSION_MAJOR "6" CACHE STRING "Qt's major version" FORCE)
set(Qt6Core_VERSION_MINOR "10" CACHE STRING "Qt's minor version" FORCE)
set(Qt6Core_VERSION_MINOR "11" CACHE STRING "Qt's minor version" FORCE)
set(Qt6Core_VERSION_PATCH "2" CACHE STRING "Qt's patch version" FORCE)
mark_as_advanced(Qt6Core_VERSION_MAJOR)
mark_as_advanced(Qt6Core_VERSION_MINOR)
Expand Down Expand Up @@ -98,7 +98,7 @@ foreach(component ${QT6_COMPONENTS})
add_library(3rdParty::Qt::${component} ALIAS Qt6::${component})
mark_as_advanced(Qt6${component}_DIR) # Hiding from GUI

# Qt only has debug and release, we map the configurations we use in o3de. We map all the configurations
# Qt only has debug and release, we map the configurations we use in o3de. We map all the configurations
# except debug to release
foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES)
string(TOUPPER ${conf} UCONF)
Expand Down
Loading
Loading