瀏覽代碼

Script updates for cityhash-1.1-rev1 on Linux aarch64 (ARM64) (#183)

* Initial update to support city through the packaging system scripti (For Linux) and aarch64
* Add cityhash entry for linux-aarch64 and fix ordering for linux
* Fix the build_cityhash_linux.sh check for aarch64. Remove commented out lines in Dockerfile.linux
* build script file cleanup

Signed-off-by: Steve Pham <[email protected]>
Steve Pham 2 年之前
父節點
當前提交
3b77f32b76

+ 36 - 0
package-system/cityhash/Dockerfile.linux

@@ -0,0 +1,36 @@
+
+# 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
+#
+
+# This docker file uses ubuntu 20.04 as the base image so that the AWS Native C++ libraries will use OpenSSL 3 as the base
+# for its dependencies
+#
+
+FROM public.ecr.aws/ubuntu/ubuntu:20.04_stable
+ 
+WORKDIR /data/workspace
+
+ARG DOCKER_BUILD_SCRIPT
+
+# Initilize apt cache
+RUN apt-get clean && apt-get update
+
+ENV LANG=en_US.UTF-8
+
+# Install the development packages needed to build Qt from source
+RUN apt-get install -y build-essential \
+                       autotools-dev 
+
+RUN apt upgrade -y
+
+# Prepare a target folder within the container to install the build artifacts tp
+RUN mkdir -p /data/workspace/build
+
+ARG CACHEBUST=1
+
+# Copy the build script specific to this Docker script in order to execute the build
+COPY $DOCKER_BUILD_SCRIPT /data/workspace/
+

+ 31 - 0
package-system/cityhash/Findcityhash.cmake.linux

@@ -0,0 +1,31 @@
+#
+# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
+# its licensors.
+#
+# For complete copyright and license terms please see the LICENSE at the root of this
+# distribution (the "License"). All use of this software is governed by the License,
+# or, if provided, by the license below or the license accompanying this file. Do not
+# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#
+
+set(MY_NAME "cityhash")
+
+set(TARGET_WITH_NAMESPACE "3rdParty::${MY_NAME}")
+if (TARGET ${TARGET_WITH_NAMESPACE})
+    return()
+endif()
+
+set(${MY_NAME}_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/cityhash/include)
+set(${MY_NAME}_LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/cityhash/lib)
+set(${MY_NAME}_LIBRARY ${${MY_NAME}_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}cityhash${CMAKE_STATIC_LIBRARY_SUFFIX})
+
+
+add_library(${TARGET_WITH_NAMESPACE} INTERFACE IMPORTED GLOBAL)
+ly_target_include_system_directories(TARGET ${TARGET_WITH_NAMESPACE} INTERFACE ${${MY_NAME}_INCLUDE_DIR})
+
+target_link_libraries(${TARGET_WITH_NAMESPACE} 
+                      INTERFACE ${${MY_NAME}_LIBRARY}
+                      )
+
+set(${MY_NAME}_FOUND True)

+ 46 - 0
package-system/cityhash/build_cityhash_linux.sh

@@ -0,0 +1,46 @@
+#!/bin/bash
+
+
+echo "Configuring cityhash"
+cd src
+
+INSTALL_DIR=/data/workspace/build
+
+if [ "$(uname -m)"="aarch64" ]
+then
+    echo "Configuring cityhash for ARM64"
+    ./configure --build=arm --prefix=$INSTALL_DIR
+else 
+    echo "Configuring cityhash for x86_64"
+    ./configure --prefix=$INSTALL_DIR
+fi
+
+if [ $? -ne 0 ]
+then
+    echo "Failed configuring cityhash"
+    exit 1
+fi
+
+make all
+if [ $? -ne 0 ]
+then
+    echo "Failed building cityhash"
+    exit 1
+fi
+
+make check
+if [ $? -ne 0 ]
+then
+    echo "Failed testing cityhash"
+    exit 1
+fi
+
+make install
+if [ $? -ne 0 ]
+then
+    echo "Failed installing cityhash"
+    exit 1
+fi
+
+echo "cityhash built successfully"
+exit 0

+ 26 - 0
package-system/cityhash/build_config.json

@@ -0,0 +1,26 @@
+{
+    "git_url":"https://github.com/google/cityhash.git",
+    "git_tag": "master",
+    "git_commit": "f5dc54147fcce12cefd16548c8e760d68ac04226",
+    "package_name":"cityhash",
+    "package_version":"1.1-rev1",
+    "package_url":"https://github.com/google/cityhash",
+    "package_license":"BSD-3-Clause",
+    "package_license_file":"COPYING",
+    "Platforms":{
+        "Linux":{
+            "Linux":{
+                "cmake_find_source":"Findcityhash.cmake.linux",
+                "cmake_find_target":"Findcityhash.cmake",
+                "custom_build_cmd": [
+                    "./build_linux.sh"
+                ],
+                "custom_install_cmd": [
+                    "./install_linux.sh"
+                ]
+            },
+            "Linux-aarch64": "@Linux"
+        }
+    }
+}
+

+ 94 - 0
package-system/cityhash/build_linux.sh

@@ -0,0 +1,94 @@
+#!/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
+
+
+DOCKER_BUILD_SCRIPT=build_cityhash_linux.sh
+DOCKER_IMAGE_NAME=cityhash_3p
+
+
+# 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"
+
+
+# Copy the custom build script to docker context folder
+cp $DOCKER_BUILD_SCRIPT temp/
+
+pushd temp
+
+# Build the Docker Image
+echo "Creating docker image  ${DOCKER_IMAGE_NAME}"
+docker build --build-arg DOCKER_BUILD_SCRIPT=${DOCKER_BUILD_SCRIPT} -f ../Dockerfile.linux -t ${DOCKER_IMAGE_NAME}:latest . 
+if [ $? -ne 0 ]
+then
+    echo "Error occurred creating Docker image ${DOCKER_IMAGE_NAME}:latest." 
+    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_IMAGE_NAME}"
+docker run -v $TEMP_FOLDER/src:/data/workspace/src --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
+    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/build/. 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
+

+ 21 - 0
package-system/cityhash/install_linux.sh

@@ -0,0 +1,21 @@
+#!/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_DIR=$TEMP_FOLDER/build
+TMP_RELEASE_DIR=$BUILD_DIR/install/lib/release
+
+OUT_RELEASE=$TARGET_INSTALL_ROOT/lib/release
+
+mkdir -p $OUT_RELEASE
+
+cp -r $BUILD_DIR/* $TARGET_INSTALL_ROOT/
+if [ $? -ne 0 ]; then
+    echo Unable to copy
+    exit 1
+fi
+
+exit 0

+ 2 - 0
package_build_list_host_linux-aarch64.json

@@ -11,6 +11,7 @@
         "AWSNativeSDK-1.9.50-rev2-linux-openssl-1-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AWSNativeSDK --platform-name Linux-OpenSSL-1-aarch64 --clean",
         "AWSNativeSDK-1.9.50-rev2-linux-openssl-3-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AWSNativeSDK --platform-name Linux-OpenSSL-3-aarch64 --clean",
         "azslc-1.8.15-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/azslc --platform-name Linux-aarch64 --clean",
+        "cityhash-1.1-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/cityhash --platform-name Linux-aarch64 --clean",
         "DirectXShaderCompilerDxc-1.6.2112-o3de-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/DirectXShaderCompiler --platform-name Linux-aarch64 --clean",
         "expat-2.4.2-rev2-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/expat --platform-name Linux-aarch64 --clean",
         "freetype-2.11.1-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/freetype --platform-name Linux-aarch64 --clean",
@@ -47,6 +48,7 @@
         "AWSNativeSDK-1.9.50-rev2-linux-openssl-1-aarch64": "package-system/AWSNativeSDK/temp/AWSNativeSDK-linux-openssl-1-aarch64",
         "AWSNativeSDK-1.9.50-rev2-linux-openssl-3-aarch64": "package-system/AWSNativeSDK/temp/AWSNativeSDK-linux-openssl-3-aarch64",
         "azslc-1.8.15-rev1-linux-aarch64": "package-system/azslc/temp/azslc-linux-aarch64",
+        "cityhash-1.1-rev1-linux-aarch64": "package-system/cityhash/temp/cityhash-linux-aarch64",
         "DirectXShaderCompilerDxc-1.6.2112-o3de-rev1-linux-aarch64": "package-system/DirectXShaderCompiler/temp/DirectXShaderCompilerDxc-linux-aarch64",
         "expat-2.4.2-rev2-linux-aarch64": "package-system/expat/temp/expat-linux-aarch64",
         "freetype-2.11.1-rev1-linux-aarch64": "package-system/freetype/temp/freetype-linux-aarch64",

+ 2 - 0
package_build_list_host_linux.json

@@ -8,6 +8,7 @@
         "AWSGameLiftServerSDK-3.4.2-rev1-linux": "package-system/AWSGameLiftServerSDK/build_package_image.py --platform-name linux",
         "AWSNativeSDK-1.9.50-rev2-linux-openssl-1": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AWSNativeSDK --platform-name Linux-OpenSSL-1 --package-root ../../package-system/AWSNativeSDK/temp --clean",
         "AWSNativeSDK-1.9.50-rev2-linux-openssl-3": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AWSNativeSDK --platform-name Linux-OpenSSL-3 --package-root ../../package-system/AWSNativeSDK/temp --clean",
+        "cityhash-1.1-rev1-linux":  "Scripts/extras/pull_and_build_from_git.py ../../package-system/cityhash --platform-name Linux --clean",
         "Lua-5.4.4-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Lua --platform-name Linux --package-root ../../package-system/Lua/temp --clean",
         "AwsIotDeviceSdkCpp-1.15.2-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/AwsIotDeviceSdkCpp --platform-name Linux --package-root ../../package-system --clean",
         "freetype-2.11.1-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/freetype --platform-name Linux --package-root ../../package-system/freetype/temp --clean",
@@ -47,6 +48,7 @@
         "AWSGameLiftServerSDK-3.4.2-rev1-linux": "package-system/AWSGameLiftServerSDK-linux",
         "AWSNativeSDK-1.9.50-rev2-linux-openssl-1": "package-system/AWSNativeSDK/temp/AWSNativeSDK-linux-openssl-1",
         "AWSNativeSDK-1.9.50-rev2-linux-openssl-3": "package-system/AWSNativeSDK/temp/AWSNativeSDK-linux-openssl-3",
+        "cityhash-1.1-rev1-linux": "package-system/cityhash/temp/cityhash-linux",
         "Lua-5.4.4-rev1-linux": "package-system/Lua/temp/Lua-linux",
         "AwsIotDeviceSdkCpp-1.15.2-rev1-linux": "package-system/AwsIotDeviceSdkCpp-linux",
         "freetype-2.11.1-rev1-linux": "package-system/freetype/temp/freetype-linux",