docker_build_linux.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/bash
  2. #
  3. # Copyright (c) Contributors to the Open 3D Engine Project.
  4. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. #
  6. # SPDX-License-Identifier: Apache-2.0 OR MIT
  7. #
  8. # Validate the bld path input
  9. BUILD_FOLDER=${DOCKER_BUILD_PATH}
  10. if [ "${BUILD_FOLDER}" == "" ]
  11. then
  12. echo "Missing required build target folder environment"
  13. exit 1
  14. elif [ "${BUILD_FOLDER}" == "temp" ]
  15. then
  16. echo "Build target folder environment cannot be 'temp'"
  17. exit 1
  18. fi
  19. # Copy the source folder from the read-only $WORKSPACE/temp/src to $WORKSPACE/src
  20. # since the build process will write/modify the source path
  21. echo "Preparing source folder '$WORKSPACE/src'"
  22. cp -r $WORKSPACE/temp/src/GameLift-Cpp-ServerSDK-5.1.2/ $WORKSPACE/src || (echo "Error copying src from $WORKSPACE/temp" && exit 1)
  23. SRC_PATH=$WORKSPACE/src
  24. if [ ! -d ${SRC_PATH} ]
  25. then
  26. echo "Missing expected source path at ${SRC_PATH}"
  27. exit 1
  28. fi
  29. # Prepare the build root
  30. BUILD_PATH_ROOT=${WORKSPACE}/aws/build
  31. if [ -d ${BUILD_PATH_ROOT} ]
  32. then
  33. rm -rf ${BUILD_PATH_ROOT}
  34. fi
  35. mkdir -p ${BUILD_PATH_ROOT}
  36. # Apply an additional linker flag option to resolve 'undefined reference to `dlopen' errors
  37. export LDFLAGS="-Wl,--no-as-needed -ldl"
  38. echo "Preparing BUILD_PATH_ROOT '${BUILD_PATH_ROOT}'"
  39. # Perform a cmake project generation and build
  40. #
  41. # Arguments:
  42. # $1 : BUILD path
  43. # $2 : Build SHARED libs
  44. # $3 : Build Type
  45. build_package() {
  46. echo "Generating $1"
  47. lib_type=$1
  48. if [ "$lib_type" == "Shared" ]
  49. then
  50. build_shared=ON
  51. else
  52. build_shared=OFF
  53. fi
  54. CMD_CMAKE_GENERATE="\
  55. cmake -S ${SRC_PATH} -B ${BUILD_PATH_ROOT}/${lib_type} \
  56. -G \"Unix Makefiles\" \
  57. -DBUILD_SHARED_LIBS=$build_shared \
  58. -DCMAKE_BUILD_TYPE=Release \
  59. -DCMAKE_MODULE_PATH=$DOWNLOADED_PACKAGE_FOLDERS"
  60. echo $CMD_CMAKE_GENERATE
  61. eval $CMD_CMAKE_GENERATE
  62. if [ $? -ne 0 ]
  63. then
  64. echo "Error generating AWS Gamelift Server SDK build"
  65. exit 1
  66. fi
  67. CMD_CMAKE_BUILD="\
  68. cmake --build ${BUILD_PATH_ROOT}/${lib_type}"
  69. echo $CMD_CMAKE_BUILD
  70. eval $CMD_CMAKE_BUILD
  71. if [ $? -ne 0 ]
  72. then
  73. echo "Error building the ${lib_type} configuration for AWS Gamelift Server SDK"
  74. exit 1
  75. fi
  76. if [ ! -d ${BUILD_PATH_ROOT}/${lib_type}/prefix ]
  77. then
  78. echo "Error locating built binaries at ${BUILD_PATH_ROOT}/${lib_type}/prefix"
  79. exit 1
  80. fi
  81. }
  82. # Build the shared library file
  83. build_package Shared
  84. # Build the static library file
  85. build_package Static
  86. # Prepare the build folder to copy out of the docker image and copy the required build artifacts
  87. mkdir -p ${BUILD_FOLDER}
  88. cp -r ${BUILD_PATH_ROOT}/Static/prefix/include ${BUILD_FOLDER}/
  89. cp -r ${BUILD_PATH_ROOT}/Static/prefix/cmake ${BUILD_FOLDER}/
  90. cp -r ${BUILD_PATH_ROOT}/Static/prefix/lib ${BUILD_FOLDER}/
  91. cp -r ${BUILD_PATH_ROOT}/Shared/prefix/lib ${BUILD_FOLDER}/bin
  92. # Copy the license and notice files
  93. cp $WORKSPACE/temp/src/GameLift-Cpp-ServerSDK-5.1.2/LICENSE_AMAZON_GAMELIFT_SDK.TXT ${BUILD_FOLDER}/
  94. cp $WORKSPACE/temp/src/GameLift-Cpp-ServerSDK-5.1.2/NOTICE_C++_AMAZON_GAMELIFT_SDK.TXT ${BUILD_FOLDER}/
  95. echo "Build Succeeded."
  96. exit 0