فهرست منبع

Script updates for ISPCTexComp-36b80aa on Linux aarch64 (ARM64) (#185)

* Update Linux build for ISPCTextureCompressor to use the pull_and_build_from_git and use docker instead
* Updates for linux-aarch64
* Update docker scripts

Signed-off-by: Steve Pham <[email protected]>
Steve Pham 2 سال پیش
والد
کامیت
99c2a86d68

+ 28 - 0
package-system/ISPCTexComp/Dockerfile.linux

@@ -0,0 +1,28 @@
+#
+# 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 Dockerscript is based off of a built docker image for the ispc compiler so that the 
+# ISPC Text Compression library can use the ispc compiler
+FROM ispc_cpu_env:latest
+ 
+WORKDIR /data/workspace
+
+ENV LANG=en_US.UTF-8
+
+ARG CACHEBUST=1
+
+# Copy the src file locally to the container since the build script will build into the source
+COPY src /data/workspace/src/
+
+# Copy the script to run the build from src
+COPY docker_build_linux.sh /data/workspace/
+
+RUN mkdir -p /data/workspace/src/ISPC/linux && \
+    cd /data/workspace/src/ISPC/linux && \
+    ln -s /home/src/ispc/build/bin/ispc ispc     
+
+

+ 30 - 0
package-system/ISPCTexComp/build_config.json

@@ -0,0 +1,30 @@
+{
+    "git_url": "https://github.com/GameTechDev/ISPCTextureCompressor.git",
+    "git_tag": "master",
+    "git_commit": "36b80aac50ea401a9adde44d86712c2241b2acfd",
+    "package_name": "ISPCTexComp",
+    "package_version": "36b80aa-rev2",
+    "package_url": "https://github.com/GameTechDev/ISPCTextureCompressor",
+    "package_license": "MIT",
+    "package_license_file": "license.txt",
+    "cmake_find_source": "FindISPCTexComp.cmake",
+    "cmake_find_target": "FindISPCTexComp.cmake",
+    "patch_file": "ISPCTexComp_36b80aa.patch",
+    "Platforms": {
+        "Windows": {
+        },
+        "Darwin": {
+        },
+        "Linux": {
+            "Linux": {
+                "custom_build_cmd": [
+                    "./build_linux.sh"
+                ],
+                "custom_install_cmd": [
+                    "./install_linux.sh"
+                ]
+            },
+	       "Linux-aarch64": "@Linux"
+        }
+    }
+}

+ 123 - 0
package-system/ISPCTexComp/build_linux.sh

@@ -0,0 +1,123 @@
+#!/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
+
+
+# Make sure docker is installed
+DOCKER_VERSION=$(docker --version)
+if [ $? -ne 0 ]
+then
+    echo "Required package docker is not installed"
+    exit 1
+fi
+echo "Detected Docker Version $DOCKER_VERSION"
+
+cp docker_build_linux.sh temp/
+
+# The ISPCTextureCompressor relies on the ispc compiler (v1.16.1) from https://github.com/ispc/ispc.git
+# This will be cloned from https://github.com/ispc/ispc.git (branch v1.16.1) and built with the supplied 
+# ubuntu 20.04 docker script (docker/ubuntu/20.04/cpu_ispc_build/Dockerfile) and the resulting docker
+# image will be used to provide the build environment as well as the required ispc tool needed to 
+# build the ISPCTextureCompressor
+echo "Cloning ispc v1.16.1 from git"
+
+rm -rf temp/ispc
+
+git clone https://github.com/ispc/ispc.git --branch v1.16.1 --depth 1 temp/ispc 
+if [ $? -ne 0 ]
+then
+    echo "Error occurred cloning ispc from https://github.com/ispc/ispc.git"
+    exit 1
+fi
+
+# If this is aarch64, we need a special patch
+if [ "$(uname -m)" = "aarch64" ]
+then
+    echo "Applying aarch64 patch"
+    git -C temp/ispc apply ../ispc_linux_patch_arm64.txt
+fi
+
+DOCKER_ISPC_ENV_IMAGE_NAME=ispc_cpu_env
+docker build --build-arg SHA=v1.16.1 -t ${DOCKER_ISPC_ENV_IMAGE_NAME}:latest temp/ispc/docker/ubuntu/20.04/cpu_ispc_build/ -f temp/ispc/docker/ubuntu/20.04/cpu_ispc_build/Dockerfile
+if [ $? -ne 0 ]
+then
+    echo "Error building docker image ${DOCKER_ISPC_ENV_IMAGE_NAME}"
+    exit 1
+fi
+
+# Capture the Docker Image ID for ${DOCKER_ISPC_ENV_IMAGE_NAME}
+DOCKER_ISPC_ENV_IMAGE_ID=$(docker images -q ${DOCKER_ISPC_ENV_IMAGE_NAME}:latest)
+if [ -z $DOCKER_ISPC_ENV_IMAGE_ID ]
+then
+    echo "Error: Cannot find Image ID for ${DOCKER_ISPC_ENV_IMAGE_NAME}"
+    exit 1
+fi
+
+# Using the ispc compiler docker as a base, prepare the docker image to build the ISPCTextureComp library
+DOCKER_ISPC_BUILD_IMAGE_NAME=ispc_text_comp
+
+# Build the image from the base ispc docker to prepare
+docker build -t ${DOCKER_ISPC_BUILD_IMAGE_NAME}:latest -f Dockerfile.linux temp
+if [ $? -ne 0 ]
+then
+    echo "Error building docker image ${DOCKER_ISPC_BUILD_IMAGE_NAME}"
+    exit 1
+fi
+
+# Capture the Docker Image ID for ${DOCKER_ISPC_BUILD_IMAGE_NAME}
+DOCKER_ISPC_BUILD_IMAGE_ID=$(docker images -q ${DOCKER_ISPC_BUILD_IMAGE_NAME}:latest)
+if [ -z $DOCKER_ISPC_BUILD_IMAGE_ID ]
+then
+    echo "Error: Cannot find Image ID for ${DOCKER_ISPC_BUILD_IMAGE_NAME}"
+    exit 1
+fi
+
+# Run the build command in docker through run. 
+docker run -it ${DOCKER_ISPC_BUILD_IMAGE_NAME}:latest /data/workspace/docker_build_linux.sh
+if [ $? -ne 0 ]
+then
+    echo "Error building ISPCTextureComp library"
+    exit 1
+fi
+
+echo "Capturing the Container ID for ${DOCKER_ISPC_BUILD_IMAGE_NAME}:latest"
+DOCKER_ISPC_BUILD_CONTAINER_ID=$(docker container ls -l -q --filter "ancestor=${DOCKER_ISPC_BUILD_IMAGE_NAME}:latest")
+echo "CI=${DOCKER_ISPC_BUILD_CONTAINER_ID}"
+if [ -z $DOCKER_ISPC_BUILD_CONTAINER_ID ]
+then
+    echo "Error: Cannot find Container ID for Image ${DOCKER_ISPC_BUILD_IMAGE_NAME}"
+    exit 1
+fi
+
+# Copy the build artifact to a temp folder for the install script
+rm -rf temp/docker_output
+mkdir -p temp/docker_output
+docker cp $DOCKER_ISPC_BUILD_CONTAINER_ID:/data/workspace/src/build/libispc_texcomp.so temp/docker_output/
+if [ $? -ne 0 ]
+then
+    echo "Error occurred copying libispc_texcomp.so from Docker image ${DOCKER_ISPC_BUILD_IMAGE_NAME}:latest."
+    exit 1
+fi
+
+
+# Clean up the docker image and container
+echo "Cleaning up containers"
+docker container prune -f
+
+echo "Cleaning up image"
+docker rmi --force $DOCKER_ISPC_ENV_IMAGE_ID  || (echo "Warning: unable to clean up image ${DOCKER_ISPC_ENV_IMAGE_NAME}")
+if [ $? -ne 0 ]
+then
+    echo "Warning: unable to clean up image ${DOCKER_ISPC_ENV_IMAGE_NAME}"
+fi
+docker rmi --force $DOCKER_ISPC_BUILD_IMAGE_ID  || (echo "Warning: unable to clean up image ${DOCKER_ISPC_BUILD_IMAGE_NAME}")
+if [ $? -ne 0 ]
+then
+    echo "Warning: unable to clean up image ${DOCKER_ISPC_BUILD_IMAGE_NAME}"
+fi
+
+exit 0
+

+ 29 - 0
package-system/ISPCTexComp/docker_build_linux.sh

@@ -0,0 +1,29 @@
+#!/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
+
+
+WORKSPACE=/data/workspace
+
+SRC_DIR=$WORKSPACE/src
+
+BUILD_DIR=$SRC_DIR/build
+
+cd $SRC_DIR
+if [ $? -ne 0 ]
+then
+    echo "Invalid path ${SRC_DIR}"
+    exit 1
+fi
+
+make -f Makefile.linux
+if [ $? -ne 0 ]
+then
+    echo "Build failed"
+    exit 1
+fi
+
+exit 0

+ 17 - 0
package-system/ISPCTexComp/install_linux.sh

@@ -0,0 +1,17 @@
+#!/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
+
+BIN_PATH=$TARGET_INSTALL_ROOT/bin
+INCLUDE_PATH=$TARGET_INSTALL_ROOT/include/ISPC
+
+mkdir -p $INCLUDE_PATH
+mkdir -p $BIN_PATH
+
+cp -f temp/src/license.txt $TARGET_INSTALL_ROOT/ || exit $?
+cp -f temp/src/ispc_texcomp/ispc_texcomp.h $INCLUDE_PATH/ || exit $?
+cp -f temp/docker_output/libispc_texcomp.so $BIN_PATH/ || exit $?
+

+ 12 - 0
package-system/ISPCTexComp/ispc_linux_patch_arm64.txt

@@ -0,0 +1,12 @@
+diff --git a/docker/ubuntu/20.04/cpu_ispc_build/Dockerfile b/docker/ubuntu/20.04/cpu_ispc_build/Dockerfile
+index 8621e71..9f93d1b 100644
+--- a/docker/ubuntu/20.04/cpu_ispc_build/Dockerfile
++++ b/docker/ubuntu/20.04/cpu_ispc_build/Dockerfile
+@@ -40,6 +40,6 @@ RUN apt-get -y update && apt-get install -y m4 bison flex zlib1g-dev \
+ 
+ RUN mkdir -p build
+ WORKDIR /home/src/ispc/build
+-RUN cmake .. -DX86_ENABLED=ON -DARM_ENABLED=ON -DCMAKE_CXX_FLAGS=-Werror && make -j`nproc` && make check-all
++RUN cmake .. -DX86_ENABLED=OFF -DARM_ENABLED=ON -DCMAKE_CXX_FLAGS=-Werror && make -j`nproc` && make check-all
+ # Add ISPC to PATH
+ ENV PATH=/home/ispc/bin:$PATH

+ 2 - 0
package_build_list_host_linux-aarch64.json

@@ -17,6 +17,7 @@
         "freetype-2.11.1-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/freetype --platform-name Linux-aarch64 --clean",
         "googlebenchmark-1.5.0-rev2-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googlebenchmark --platform-name Linux-aarch64 --clean",
         "googletest-1.8.1-rev4-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googletest --platform-name Linux-aarch64 --clean",
+        "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",
@@ -54,6 +55,7 @@
         "freetype-2.11.1-rev1-linux-aarch64": "package-system/freetype/temp/freetype-linux-aarch64",
         "googlebenchmark-1.5.0-rev2-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", 
         "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",

+ 2 - 2
package_build_list_host_linux.json

@@ -14,7 +14,7 @@
         "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",
         "googlebenchmark-1.7.0-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googlebenchmark --platform-name Linux --package-root ../../package-system --clean",
         "googletest-1.8.1-rev4-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/googletest --platform-name Linux --package-root ../../package-system --clean",
-        "ISPCTexComp-36b80aa-rev1-linux": "package-system/ISPCTexComp/build_package_image.py",
+        "ISPCTexComp-36b80aa-rev2-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/ISPCTexComp --platform-name Linux --clean",
         "png-1.6.37-rev2-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/libpng --platform-name Linux --package-root ../../package-system/libpng/temp --clean",
         "libsamplerate-0.2.1-rev2-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/libsamplerate --platform-name Linux --package-root ../../package-system --clean",
         "mcpp-2.7.2_az.1-rev1-linux": "package-system/mcpp/get_and_build_mcpp.py mcpp-2.7.2_az.1-rev1",
@@ -54,7 +54,7 @@
         "freetype-2.11.1-rev1-linux": "package-system/freetype/temp/freetype-linux",
         "googlebenchmark-1.7.0-rev1-linux": "package-system/googlebenchmark-linux",
         "googletest-1.8.1-rev4-linux": "package-system/googletest-linux",
-        "ISPCTexComp-36b80aa-rev1-linux": "package-system/ISPCTexComp-linux",
+        "ISPCTexComp-36b80aa-rev2-linux": "package-system/ISPCTexComp/temp/ISPCTexComp-linux",
         "png-1.6.37-rev2-linux": "package-system/libpng/temp/png-linux",
         "libsamplerate-0.2.1-rev2-linux": "package-system/libsamplerate-linux",
         "mcpp-2.7.2_az.1-rev1-linux": "package-system/mcpp-linux",