Просмотр исходного кода

Adding Ubuntu 20.04 qemu and docker support for building lz4

Updating the lz4 library to 1.9.4 to address the security vulnerability found in version 1.9.3

Added ArchLinux qemu and docker support for building lz4 as well

resolves #9007

Signed-off-by: lumberyard-employee-dm <[email protected]>
lumberyard-employee-dm 2 лет назад
Родитель
Сommit
21063635c1

+ 35 - 0
package-system/lz4/Dockerfile.aarch64

@@ -0,0 +1,35 @@
+
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+
+FROM arm64v8/ubuntu:20.04
+
+WORKDIR /data/workspace
+
+ARG DOCKER_BUILD_SCRIPT
+
+# Initilize apt cache
+RUN apt-get clean && apt-get update
+
+# Install the development packages needed to build lz4 from source
+RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y git \
+                       build-essential \
+                       cmake \
+                       ninja-build \
+                       clang
+
+RUN apt upgrade -y
+
+# Prepare a target folder within the container to install the build artifacts
+RUN mkdir -p /data/workspace/src && \
+    mkdir -p /data/workspace/build && \
+    mkdir -p /data/workspace/package
+
+ARG CACHEBUST=1
+
+# Copy the build script specific to this Docker script in order to execute the build
+COPY ${DOCKER_BUILD_SCRIPT} /data/workspace/
+COPY src /data/workspace/src/

+ 35 - 0
package-system/lz4/Dockerfile.x86_64

@@ -0,0 +1,35 @@
+
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+
+FROM amd64/ubuntu:20.04
+
+WORKDIR /data/workspace
+
+ARG DOCKER_BUILD_SCRIPT
+
+# Initilize apt cache
+RUN apt-get clean && apt-get update
+
+# Install the development packages needed to build lz4 from source
+RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y git \
+                       build-essential \
+                       cmake \
+                       ninja-build \
+                       clang
+
+RUN apt upgrade -y
+
+# Prepare a target folder within the container to install the build artifacts
+RUN mkdir -p /data/workspace/src && \
+    mkdir -p /data/workspace/build && \
+    mkdir -p /data/workspace/package
+
+ARG CACHEBUST=1
+
+# Copy the build script specific to this Docker script in order to execute the build
+COPY ${DOCKER_BUILD_SCRIPT} /data/workspace/
+COPY src /data/workspace/src/

+ 13 - 11
package-system/lz4/Findlz4.cmake

@@ -1,7 +1,7 @@
 #
 # Copyright (c) Contributors to the Open 3D Engine Project.
 # For complete copyright and license terms please see the LICENSE at the root of this distribution.
-# 
+#
 # SPDX-License-Identifier: Apache-2.0 OR MIT
 #
 #
@@ -13,21 +13,23 @@ if (TARGET ${TARGET_WITH_NAMESPACE})
     return()
 endif()
 
-set(${LIB_NAME}_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/${LIB_NAME}/${LIB_NAME}/include)
-set(${LIB_NAME}_LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/${LIB_NAME}/${LIB_NAME}/lib)
+set(${LIB_NAME}_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/${LIB_NAME}/include)
+set(${LIB_NAME}_LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/${LIB_NAME}/lib)
 set(${LIB_NAME}_LIBRARY_DEBUG   ${${LIB_NAME}_LIBS_DIR}/../debug/lib/${CMAKE_STATIC_LIBRARY_PREFIX}lz4d${CMAKE_STATIC_LIBRARY_SUFFIX})
 set(${LIB_NAME}_LIBRARY_RELEASE ${${LIB_NAME}_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lz4${CMAKE_STATIC_LIBRARY_SUFFIX})
 
-set(${LIB_NAME}_LIBRARY
-    "$<$<CONFIG:profile>:${${LIB_NAME}_LIBRARY_RELEASE}>"
-    "$<$<CONFIG:release>:${${LIB_NAME}_LIBRARY_RELEASE}>"
-    "$<$<CONFIG:debug>:${${LIB_NAME}_LIBRARY_DEBUG}>")
 
-add_library(${TARGET_WITH_NAMESPACE} INTERFACE IMPORTED GLOBAL)
+add_library(${TARGET_WITH_NAMESPACE} STATIC IMPORTED GLOBAL)
 ly_target_include_system_directories(
     TARGET ${TARGET_WITH_NAMESPACE} INTERFACE ${${LIB_NAME}_INCLUDE_DIR})
-target_link_libraries(
-    ${TARGET_WITH_NAMESPACE}
-    INTERFACE ${${LIB_NAME}_LIBRARY})
+
+set_target_properties(${TARGET_WITH_NAMESPACE} PROPERTIES
+    IMPORTED_LOCATION ${${LIB_NAME}_LIBRARY_RELEASE}
+)
+
+if (${PAL_PLATFORM_NAME} STREQUAL "Windows")
+    # IMPORTED_LOCATION_DEBUG property could be set here if it is desired that Windows
+    # uses a debug version of lz4
+endif()
 
 set(${LIB_NAME}_FOUND True)

+ 12 - 0
package-system/lz4/LICENSE

@@ -0,0 +1,12 @@
+This repository uses 2 different licenses :
+- all files in the `lib` directory use a BSD 2-Clause license
+- all other files use a GPLv2 license, unless explicitly stated otherwise
+
+Relevant license is reminded at the top of each source file,
+and with presence of COPYING or LICENSE file in associated directories.
+
+This model is selected to emphasize that
+files in the `lib` directory are designed to be included into 3rd party applications,
+while all other files, in `programs`, `tests` or `examples`,
+are intended to be used "as is", as part of their intended scenarios,
+with no intention to support 3rd party integration use cases.

+ 168 - 0
package-system/lz4/build-archlinux.sh

@@ -0,0 +1,168 @@
+#!/bin/bash
+
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+
+# TEMP_FOLDER and TARGET_INSTALL_ROOT get set from the pull_and_build_from_git.py script
+
+# Determine the host architecture
+CURRENT_HOST_ARCH=$(uname -m)
+
+# Use the host architecture if not supplied
+TARGET_ARCH=${1:-$(uname -m)}
+
+# If the host and target architecture does not match, make sure the necessary cross compilation packages are installed
+if [ "${CURRENT_HOST_ARCH}" != ${TARGET_ARCH} ]
+then
+    pkg_list=(docker docker-buildx docker-compose qemu qemu-user-static-binfmt)
+    echo "Checking cross compiling requirements."
+    for package_check in "${pkg_list[@]}"
+    do
+        echo "Checking package $package_check"
+        pacman -Qi $package_check > /dev/null 2>&1
+        if [ $? -ne 0 ]
+        then
+            echo ""
+            echo "Missing package $package_check. Make sure to install it with your local package manager."
+            echo ""
+            exit 1
+        fi
+    done
+
+    # Only cross compilation of an ARM64 image on an x86_64 host is supported
+    if [ "${TARGET_ARCH}" = "aarch64" ]
+    then
+        # Make sure qemu-system-aarch64 is installed properly
+        pacman -Qi qemu-system-aarch64 > /dev/null 2>&1
+        if [ $? -ne 0 ]
+        then
+            echo ""
+            echo "qemu-system-aarch64 package needs to be installed."
+            echo "Use pacman to install it"
+            exit 1
+        fi
+        echo ""
+        echo "Cross compiling aarch64 on an amd64 machine validated."
+        echo ""
+    fi
+else
+    echo "Building ${TARGET_ARCH} natively."
+fi
+
+# Set the library name prefix to lz4
+LIB_NAME="lz4"
+
+# Setup the docker arguments for the target architecture
+if [ "${TARGET_ARCH}" = "x86_64" ]
+then
+    echo "Processing Docker for x86_64"
+    TARGET_DOCKER_FILE=Dockerfile.x86_64
+    TARGET_DOCKER_PLATFORM_ARG=linux/amd64
+    DOCKER_IMAGE_NAME=${LIB_NAME}_linux_3p
+elif [ "${TARGET_ARCH}" = "aarch64" ]
+then
+    echo "Processing Docker for aarch64"
+    TARGET_DOCKER_FILE=Dockerfile.aarch64
+    TARGET_DOCKER_PLATFORM_ARG=linux/arm64v8
+    DOCKER_IMAGE_NAME=${LIB_NAME}_linux_aarch64_3p
+else
+    echo "Unsupported architecture ${TARGET_ARCH}"
+    exit 1
+fi
+
+# Make sure docker is installed
+DOCKER_VERSION=$(docker --version)
+if [ $? -ne 0 ]
+then
+    echo "Required package docker is not installed"
+    echo "docker can installed using the 'docker' package"
+    exit 1
+fi
+echo "Detected Docker Version $DOCKER_VERSION"
+
+DOCKER_BUILD_SCRIPT=docker_build_${LIB_NAME}_linux.sh
+
+if [ ! -f $DOCKER_BUILD_SCRIPT ]
+then
+    echo "Invalid docker build script ${DOCKER_BUILD_SCRIPT}"
+    exit 1
+fi
+
+# Prepare the docker file and use the temp folder as the context root
+cp -f ${DOCKER_BUILD_SCRIPT} temp/
+
+pushd temp
+
+# Build the Docker Image
+echo "Building the docker build script for ${DOCKER_IMAGE_NAME}"
+docker buildx build --platform ${TARGET_DOCKER_PLATFORM_ARG} --build-arg DOCKER_BUILD_SCRIPT=$DOCKER_BUILD_SCRIPT -f ${TEMP_FOLDER}/../${TARGET_DOCKER_FILE} -t ${DOCKER_IMAGE_NAME}:latest ${TEMP_FOLDER}
+if [ $? -ne 0 ]
+then
+    echo "Error occurred creating Docker image ${DOCKER_IMAGE_NAME}:latest."
+    echo "The following command failed:"
+    echo ""
+    echo "docker buildx build --platform ${TARGET_DOCKER_PLATFORM_ARG} --build-arg DOCKER_BUILD_SCRIPT=$DOCKER_BUILD_SCRIPT -f ${TEMP_FOLDER}/../${TARGET_DOCKER_FILE} -t ${DOCKER_IMAGE_NAME}:latest ${TEMP_FOLDER}"
+    echo ""
+    exit 1
+fi
+
+
+# Capture the Docker Image ID
+IMAGE_ID=$(docker images -q ${DOCKER_IMAGE_NAME}:latest)
+if [ -z $IMAGE_ID ]
+then
+    echo "Error: Cannot find Image ID for ${DOCKER_IMAGE_NAME}"
+    exit 1
+fi
+
+
+# Run the Docker Image
+echo "Running build script in the docker image"
+docker run --platform ${TARGET_DOCKER_PLATFORM_ARG} --tty ${DOCKER_IMAGE_NAME}:latest /data/workspace/${DOCKER_BUILD_SCRIPT}
+if [ $? -ne 0 ]
+then
+    echo Failed to build from docker image ${DOCKER_IMAGE_NAME}:latest
+    echo "To log into and troubleshoot the docker container, run the following command:"
+    echo ""
+    echo "docker run --platform ${TARGET_DOCKER_PLATFORM_ARG} -it --tty ${DOCKER_IMAGE_NAME}:latest"
+    echo ""
+    exit 1
+fi
+
+
+# Capture the container ID
+echo "Capturing the Container ID"
+CONTAINER_ID=$(docker container ls -l -q --filter "ancestor=${DOCKER_IMAGE_NAME}:latest")
+if [ -z $CONTAINER_ID ]
+then
+    echo "Error: Cannot find Container ID for Image ${DOCKER_IMAGE_NAME}"
+    exit 1
+fi
+
+
+# Copy the build artifacts from the Docker Container
+echo "Copying the built contents from the docker container for image ${DOCKER_IMAGE_NAME}"
+
+mkdir -p build
+docker cp --quiet $CONTAINER_ID:/data/workspace/package/. build
+if [ $? -ne 0 ]
+then
+    echo "Error occurred copying build artifacts from Docker image ${DOCKER_IMAGE_NAME}:latest."
+    exit 1
+fi
+
+
+# Clean up the docker image and container
+echo "Cleaning up container"
+docker container rm $CONTAINER_ID || (echo "Warning: unable to clean up container for image ${DOCKER_IMAGE_NAME}")
+
+echo "Cleaning up image"
+docker rmi --force $IMAGE_ID  || (echo "Warning: unable to clean up image ${DOCKER_IMAGE_NAME}")
+
+popd
+
+exit 0

+ 20 - 0
package-system/lz4/build-linux-aarch64.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+
+HOST_OS=$(cat /etc/os-release 2>/dev/null | grep "^NAME" | sed -E -e 's/NAME=(.+)/\1/')
+# Remove any surrounding quotes from the OS
+HOST_OS=$(sed -E 's/^"(.*)"$/\1/' <<< ${HOST_OS})
+
+if [ "${HOST_OS}" = "Arch Linux" ]; then
+    bash ./build-archlinux.sh aarch64
+else
+    bash ./build-linux.sh aarch64
+fi
+
+exit $?

+ 20 - 0
package-system/lz4/build-linux-x86_64.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+
+HOST_OS=$(cat /etc/os-release 2>/dev/null | grep "^NAME" | sed -E -e 's/NAME=(.+)/\1/')
+# Remove any surrounding quotes from the OS
+HOST_OS=$(sed -E 's/^"(.*)"$/\1/' <<< ${HOST_OS})
+
+if [ "${HOST_OS}" = "Arch Linux" ]; then
+    ./build-archlinux.sh x86_64
+else
+    ./build-linux.sh x86_64
+fi
+
+exit $?

+ 170 - 0
package-system/lz4/build-linux.sh

@@ -0,0 +1,170 @@
+#!/bin/bash
+
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+
+# TEMP_FOLDER and TARGET_INSTALL_ROOT get set from the pull_and_build_from_git.py script
+
+# Determine the host architecture
+CURRENT_HOST_ARCH=$(uname -m)
+
+# Use the host architecture if not supplied
+TARGET_ARCH=${1:-$(uname -m)}
+
+# If the host and target architecture does not match, make sure the necessary cross compilation packages are installed
+if [ "${CURRENT_HOST_ARCH}" != ${TARGET_ARCH} ]
+then
+    echo "Checking cross compiling requirements."
+    for package_check in docker-ce qemu binfmt-support qemu-user-static
+    do
+        echo "Checking package $package_check"
+        dpkg -s $package_check > /dev/null 2>&1
+        if [ $? -ne 0 ]
+        then
+            echo ""
+            echo "Missing package $package_check. Make sure to install it with your local package manager."
+            echo ""
+            exit 1
+        fi
+    done
+
+    # Only cross compilation of an ARM64 image on an x86_64 host is supported
+    if [ "${TARGET_ARCH}" = "aarch64" ]
+    then
+        # Make sure qemu-aarch64 is installed properly
+        QEMU_AARCH_COUNT=$(update-binfmts --display | grep qemu-aarch64 | wc -l)
+        if [ $QEMU_AARCH_COUNT -eq 0 ]
+        then
+            echo ""
+            echo "QEMU aarch64 binary format not registered."
+            echo "Run the following command to register"
+            echo ""
+            echo "sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes"
+            echo ""
+            exit 1
+        fi
+        echo ""
+        echo "Cross compiling aarch64 on an amd64 machine validated."
+        echo ""
+    fi
+else
+    echo "Building ${TARGET_ARCH} natively."
+fi
+
+# Set the library name prefix to lz4
+LIB_NAME="lz4"
+
+# Setup the docker arguments for the target architecture
+if [ "${TARGET_ARCH}" = "x86_64" ]
+then
+    echo "Processing Docker for x86_64"
+    TARGET_DOCKER_FILE=Dockerfile.x86_64
+    TARGET_DOCKER_PLATFORM_ARG=linux/amd64
+    DOCKER_IMAGE_NAME=${LIB_NAME}_linux_3p
+elif [ "${TARGET_ARCH}" = "aarch64" ]
+then
+    echo "Processing Docker for aarch64"
+    TARGET_DOCKER_FILE=Dockerfile.aarch64
+    TARGET_DOCKER_PLATFORM_ARG=linux/arm64v8
+    DOCKER_IMAGE_NAME=${LIB_NAME}_linux_aarch64_3p
+else
+    echo "Unsupported architecture ${TARGET_ARCH}"
+    exit 1
+fi
+
+# Make sure docker is installed
+DOCKER_VERSION=$(docker --version)
+if [ $? -ne 0 ]
+then
+    echo "Required package docker is not installed"
+    echo "Follow instructions on https://docs.docker.com/engine/install/ubuntu/ to install docker properly"
+    exit 1
+fi
+echo "Detected Docker Version $DOCKER_VERSION"
+
+DOCKER_BUILD_SCRIPT=docker_build_${LIB_NAME}_linux.sh
+
+if [ ! -f $DOCKER_BUILD_SCRIPT ]
+then
+    echo "Invalid docker build script ${DOCKER_BUILD_SCRIPT}"
+    exit 1
+fi
+
+# Prepare the docker file and use the temp folder as the context root
+cp -f ${DOCKER_BUILD_SCRIPT} temp/
+
+pushd temp
+
+# Build the Docker Image
+echo "Building the docker build script for ${DOCKER_IMAGE_NAME}"
+docker build --platform ${TARGET_DOCKER_PLATFORM_ARG} --build-arg DOCKER_BUILD_SCRIPT=$DOCKER_BUILD_SCRIPT -f ${TEMP_FOLDER}/../${TARGET_DOCKER_FILE} -t ${DOCKER_IMAGE_NAME}:latest ${TEMP_FOLDER}
+if [ $? -ne 0 ]
+then
+    echo "Error occurred creating Docker image ${DOCKER_IMAGE_NAME}:latest."
+    echo "The following command failed:"
+    echo ""
+    echo "docker build --platform ${TARGET_DOCKER_PLATFORM_ARG} --build-arg DOCKER_BUILD_SCRIPT=$DOCKER_BUILD_SCRIPT -f ${TEMP_FOLDER}/../${TARGET_DOCKER_FILE} -t ${DOCKER_IMAGE_NAME}:latest ${TEMP_FOLDER}"
+    echo ""
+    exit 1
+fi
+
+
+# Capture the Docker Image ID
+IMAGE_ID=$(docker images -q ${DOCKER_IMAGE_NAME}:latest)
+if [ -z $IMAGE_ID ]
+then
+    echo "Error: Cannot find Image ID for ${DOCKER_IMAGE_NAME}"
+    exit 1
+fi
+
+
+# Run the Docker Image
+echo "Running build script in the docker image"
+docker run --platform ${TARGET_DOCKER_PLATFORM_ARG} --tty ${DOCKER_IMAGE_NAME}:latest /data/workspace/${DOCKER_BUILD_SCRIPT}
+if [ $? -ne 0 ]
+then
+    echo Failed to build from docker image ${DOCKER_IMAGE_NAME}:latest
+    echo "The following command failed:"
+    echo ""
+    echo "docker run --platform ${TARGET_DOCKER_PLATFORM_ARG} -it --tty ${DOCKER_IMAGE_NAME}:latest"
+    echo ""
+    exit 1
+fi
+
+
+# Capture the container ID
+echo "Capturing the Container ID"
+CONTAINER_ID=$(docker container ls -l -q --filter "ancestor=${DOCKER_IMAGE_NAME}:latest")
+if [ -z $CONTAINER_ID ]
+then
+    echo "Error: Cannot find Container ID for Image ${DOCKER_IMAGE_NAME}"
+    exit 1
+fi
+
+
+# Copy the build artifacts from the Docker Container
+echo "Copying the built contents from the docker container for image ${DOCKER_IMAGE_NAME}"
+
+mkdir -p build
+docker cp --quiet $CONTAINER_ID:/data/workspace/package/. build
+if [ $? -ne 0 ]
+then
+    echo "Error occurred copying build artifacts from Docker image ${DOCKER_IMAGE_NAME}:latest."
+    exit 1
+fi
+
+
+# Clean up the docker image and container
+echo "Cleaning up container"
+docker container rm $CONTAINER_ID || (echo "Warning: unable to clean up container for image ${DOCKER_IMAGE_NAME}")
+
+echo "Cleaning up image"
+docker rmi --force $IMAGE_ID  || (echo "Warning: unable to clean up image ${DOCKER_IMAGE_NAME}")
+
+popd
+
+exit 0

+ 77 - 0
package-system/lz4/build_config.json

@@ -0,0 +1,77 @@
+{
+    "git_url": "https://github.com/lz4/lz4.git",
+    "git_tag": "v1.9.4",
+    "package_name": "lz4",
+    "package_version": "1.9.4-rev1",
+    "package_url": "http://lz4.github.io/lz4/",
+    "package_license": "BSD-2-Clause",
+    "package_license_file": "LICENSE",
+    "cmake_find_source": "Findlz4.cmake",
+    "cmake_find_target": "Findlz4.cmake",
+    "cmake_src_subfolder": "build/cmake",
+    "additional_src_files": [
+    ],
+    "cmake_generate_args_common": [
+        "-DBUILD_SHARED_LIBS=0",
+        "-DCMAKE_CXX_STANDARD=17"
+    ],
+    "cmake_build_args_common": [
+        "-j"
+    ],
+    "build_configs":[
+        "Release"
+    ],
+    "Platforms": {
+        "Windows": {
+            "Windows": {
+                "cmake_generate_args_release": [
+                    "-G",
+                    "\"Visual Studio 16\""
+                ]
+            },
+            "Android": {
+                "cmake_generate_args_release": [
+                    "-G",
+                    "Ninja Multi-Config",
+                    "-DCMAKE_TOOLCHAIN_FILE=../../../../Scripts/cmake/Platform/Android/Toolchain_android.cmake",
+                    "-DCMAKE_BUILD_TYPE=Release"
+                ]
+            }
+        },
+        "Darwin": {
+            "Mac": {
+                "cmake_generate_args_release": [
+                    "-G",
+                    "Xcode",
+                    "-DCMAKE_TOOLCHAIN_FILE=../../../../Scripts/cmake/Platform/Mac/Toolchain_mac.cmake"
+                ]
+            },
+            "iOS": {
+                "cmake_generate_args_release": [
+                    "-G",
+                    "Xcode",
+                    "-DCMAKE_MACOSX_BUNDLE=OFF",
+                    "-DCMAKE_TOOLCHAIN_FILE=../../../../Scripts/cmake/Platform/iOS/Toolchain_ios.cmake"
+                ]
+            }
+        },
+        "Linux": {
+            "Linux": {
+                "custom_build_cmd": [
+                    "./build-linux-x86_64.sh"
+                ],
+                "custom_install_cmd": [
+                    "./package-linux.sh"
+                ]
+            },
+            "Linux-aarch64": {
+                "custom_build_cmd": [
+                    "./build-linux-aarch64.sh"
+                ],
+                "custom_install_cmd": [
+                    "./package-linux.sh"
+                ]
+            }
+        }
+    }
+}

+ 0 - 92
package-system/lz4/build_package_image.py

@@ -1,92 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright (c) Contributors to the Open 3D Engine Project.
-# For complete copyright and license terms please see the LICENSE at the root of this distribution.
-# 
-# SPDX-License-Identifier: Apache-2.0 OR MIT
-#
-#
-
-from pathlib import Path
-from tempfile import TemporaryDirectory
-import argparse
-import os
-import shutil
-
-import sys
-sys.path.append(str(Path(__file__).parent.parent.parent / 'Scripts'))
-from builders.vcpkgbuilder import VcpkgBuilder
-import builders.monkeypatch_tempdir_cleanup
-
-def main():
-    parser = argparse.ArgumentParser()
-    parser.add_argument(
-        '--platform-name',
-        dest='platformName',
-        choices=['windows', 'android', 'mac', 'ios', 'linux', 'linux-aarch64'],
-        default=VcpkgBuilder.defaultPackagePlatformName(),
-    )
-    args = parser.parse_args()
-    vcpkg_platform_map = {
-        'windows': 'windows',
-        'android': 'android',
-        'mac': 'mac',
-        'ios': 'ios',
-        'linux': 'linux',
-        'linux-aarch64': 'linux' 
-    }
-
-    vcpkg_platform = vcpkg_platform_map[args.platformName]
-    if args.platformName == 'linux-aarch64':
-        os.environ['VCPKG_FORCE_SYSTEM_BINARIES'] = '1'
-
-    packageSystemDir = Path(__file__).resolve().parents[1]
-    packageSourceDir = packageSystemDir / 'lz4'
-    outputDir = packageSystemDir / f'lz4-{args.platformName}'
-
-    cmakeFindFile = packageSourceDir / f'Findlz4_{args.platformName}.cmake'
-    if not cmakeFindFile.exists():
-        cmakeFindFile = packageSourceDir / 'Findlz4.cmake'
-
-    with TemporaryDirectory() as tempdir:
-        tempdir = Path(tempdir)
-        
-        builder = VcpkgBuilder(
-            packageName='lz4',
-            portName='lz4',
-            vcpkgDir=tempdir,
-            targetPlatform=vcpkg_platform,
-            static=True
-        )
-        
-        builder.cloneVcpkg('09019cbc9abcb728217c4c99625932defe1b781c')
-        builder.bootstrap()
-        builder.build()
-        
-        builder.copyBuildOutputTo(
-            outputDir,
-            extraFiles={
-                next(builder.vcpkgDir.glob(f'buildtrees/lz4/src/*/LICENSE')): outputDir / builder.packageName / 'LICENSE',
-                next(builder.vcpkgDir.glob(f'buildtrees/lz4/src/*/README.md')): outputDir / builder.packageName / 'README.md',
-            },
-            subdir='lz4'
-        )
-        
-        # vcpkg's commit 751fc19 uses lz4 version 2.3 at commit 1a49edf
-        builder.writePackageInfoFile(
-            outputDir,
-            settings={
-                'PackageName': f'lz4-1.9.3-vcpkg-rev4-{args.platformName}',
-                'URL': 'https://github.com/lz4/lz4',
-                'License': 'BSD-2-Clause',
-                'LicenseFile': 'lz4/LICENSE'
-            },
-        )
-        
-        shutil.copy2(
-            src=cmakeFindFile,
-            dst=outputDir / 'Findlz4.cmake'
-        )
-
-if __name__ == '__main__':
-    main()

+ 30 - 0
package-system/lz4/docker_build_lz4_linux.sh

@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+
+# Build only release variants
+lib_name="lz4"
+build_configs=(Release)
+
+cmake_src_dir="src/build/cmake"
+
+# Configure using the Ninja Multi-Config generator
+cmake -S ${cmake_src_dir} -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-fPIC -O2" -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=/data/workspace/package
+if [ $? -ne 0 ]; then
+    echo "Error configuring cmake for ${lib_name}"
+    exit 1
+fi
+
+for config in "${build_configs[@]}"
+do
+    cmake --build build --target install
+    if [ $? -ne 0 ]; then
+        echo "Failed to build and package ${lib_name} for Linux (${config})"
+        exit 1
+    fi
+done
+
+exit 0

+ 13 - 0
package-system/lz4/package-linux.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+
+
+
+cp -r $TEMP_FOLDER/build/lib $TARGET_INSTALL_ROOT
+cp -r $TEMP_FOLDER/build/include $TARGET_INSTALL_ROOT
+
+exit 0

+ 5 - 5
package_build_list_host_linux-aarch64.json

@@ -20,7 +20,7 @@
         "ISPCTexComp-36b80aa-rev2-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/ISPCTexComp --platform-name Linux-aarch64 --clean",
         "libsamplerate-0.2.1-rev2-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/libsamplerate --platform-name Linux-aarch64 --clean",
         "Lua-5.4.4-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Lua --platform-name Linux-aarch64 --clean",
-        "lz4-1.9.3-vcpkg-rev4-linux-aarch64": "package-system/lz4/build_package_image.py --platform-name linux-aarch64",
+        "lz4-1.9.4-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py  ../../package-system/lz4 --platform-name Linux-aarch64 --clean",
         "mcpp-2.7.2_az.1-rev1-linux-aarch64": "package-system/mcpp/get_and_build_mcpp.py mcpp-2.7.2_az.1-rev1",
         "mikkelsen-1.0.0.4-linux-aarch64": "package-system/mikkelsen/build_package_image.py --platform linux-aarch64",
         "NvCloth-v1.1.6-4-gd243404-pr58-rev1-linux-aarch64": "package-system/NvCloth/build_package_image.py --platform-name linux-aarch64",
@@ -39,7 +39,7 @@
         "SQLite-3.37.2-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/sqlite --platform-name Linux-aarch64 --clean",
         "tiff-4.2.0.15-rev3-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name Linux-aarch64 --clean",
         "v-hacd-2.3-1a49edf-rev1-linux-aarch64": "package-system/v-hacd/build_package_image.py --platform-name linux-aarch64",
-	"vulkan-validationlayers-1.2.198-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/vulkan-validationlayers --platform-name Linux-aarch64 --clean",
+        "vulkan-validationlayers-1.2.198-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/vulkan-validationlayers --platform-name Linux-aarch64 --clean",
         "zlib-1.2.11-rev5-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Linux-aarch64 --clean"
     },
     "build_from_folder": {
@@ -56,10 +56,10 @@
         "freetype-2.11.1-rev1-linux-aarch64": "package-system/freetype/temp/freetype-linux-aarch64",
         "googlebenchmark-1.7.0-rev1-linux-aarch64": "package-system/googlebenchmark/temp/googlebenchmark-linux-aarch64",
         "googletest-1.8.1-rev4-linux-aarch64": "package-system/googletest/temp/googletest-linux-aarch64",
-        "ISPCTexComp-36b80aa-rev2-linux-aarch64": "package-system/ISPCTexComp/temp/ISPCTexComp-linux-aarch64", 
+        "ISPCTexComp-36b80aa-rev2-linux-aarch64": "package-system/ISPCTexComp/temp/ISPCTexComp-linux-aarch64",
         "libsamplerate-0.2.1-rev2-linux-aarch64": "package-system/libsamplerate/temp/libsamplerate-linux-aarch64",
         "Lua-5.4.4-rev1-linux-aarch64": "package-system/Lua/temp/Lua-linux-aarch64",
-        "lz4-1.9.3-vcpkg-rev4-linux-aarch64": "package-system/lz4-linux-aarch64",
+        "lz4-1.9.4-rev1-linux-aarch64": "package-system/lz4/temp/lz4-linux-aarch64",
         "mikkelsen-1.0.0.4-linux-aarch64": "package-system/mikkelsen-linux-aarch64",
         "mcpp-2.7.2_az.1-rev1-linux-aarch64": "package-system/mcpp-linux-aarch64",
         "NvCloth-v1.1.6-4-gd243404-pr58-rev1-linux-aarch64": "package-system/NvCloth-linux-aarch64",
@@ -78,7 +78,7 @@
         "SQLite-3.37.2-rev1-linux-aarch64": "package-system/sqlite/temp/SQLite-linux-aarch64",
         "tiff-4.2.0.15-rev3-linux-aarch64": "package-system/tiff/temp/tiff-linux-aarch64",
         "v-hacd-2.3-1a49edf-rev1-linux-aarch64": "package-system/v-hacd-linux-aarch64",
- 	"vulkan-validationlayers-1.2.198-rev1-linux-aarch64": "package-system/vulkan-validationlayers/temp/vulkan-validationlayers-linux-aarch64",
+        "vulkan-validationlayers-1.2.198-rev1-linux-aarch64": "package-system/vulkan-validationlayers/temp/vulkan-validationlayers-linux-aarch64",
         "zlib-1.2.11-rev5-linux-aarch64": "package-system/zlib/temp/zlib-linux-aarch64"
     }
 }

+ 4 - 2
package_build_list_host_linux.json

@@ -39,7 +39,8 @@
         "mikkelsen-1.0.0.4-linux": "package-system/mikkelsen/build_package_image.py",
         "qt-5.15.2-rev8-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Qt --platform-name Linux --package-root ../../package-system/Qt/temp --clean",
         "zlib-1.2.11-rev5-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Linux --package-root ../../package-system --clean",
-        "lz4-1.9.3-vcpkg-rev4-linux": "package-system/lz4/build_package_image.py --platform-name linux",
+        "lz4-1.9.4-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/lz4 --platform-name Linux --package-root ../../package-system/lz4/temp --clean",
+        "lz4-1.9.4-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/lz4 --platform-name Linux-aarch64 --package-root ../../package-system/lz4/temp --clean",
         "expat-2.4.2-rev2-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/expat --platform-name Linux --package-root ../../package-system/expat/temp --clean",
         "vulkan-validationlayers-1.2.198-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/vulkan-validationlayers --platform-name Linux --package-root ../../package-system/vulkan-validationlayers/temp --clean"
     },
@@ -81,7 +82,8 @@
         "xxhash-0.7.4-rev1-multiplatform": "package-system/xxhash-multiplatform",
         "qt-5.15.2-rev8-linux": "package-system/Qt/temp/qt-linux",
         "zlib-1.2.11-rev5-linux": "package-system/zlib-linux",
-        "lz4-1.9.3-vcpkg-rev4-linux": "package-system/lz4-linux",
+        "lz4-1.9.4-rev1-linux": "package-system/lz4/temp/lz4-linux",
+        "lz4-1.9.4-rev1-linux-aarch64": "package-system/lz4/temp/lz4-linux-aarch64",
         "expat-2.4.2-rev2-linux": "package-system/expat/temp/expat-linux",
         "vulkan-validationlayers-1.2.198-rev1-linux": "package-system/vulkan-validationlayers/temp/vulkan-validationlayers-linux"
     }