diff options
Diffstat (limited to 'build_files/build_environment')
-rw-r--r-- | build_files/build_environment/CMakeLists.txt | 1 | ||||
-rw-r--r-- | build_files/build_environment/cmake/ffmpeg.cmake | 6 | ||||
-rw-r--r-- | build_files/build_environment/cmake/nasm.cmake | 29 | ||||
-rw-r--r-- | build_files/build_environment/cmake/versions.cmake | 4 | ||||
-rw-r--r-- | build_files/build_environment/cmake/x264.cmake | 7 | ||||
-rw-r--r-- | build_files/build_environment/patches/nasm.diff | 129 |
6 files changed, 176 insertions, 0 deletions
diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt index 876372ca8c4..7e7c5d58d71 100644 --- a/build_files/build_environment/CMakeLists.txt +++ b/build_files/build_environment/CMakeLists.txt @@ -76,6 +76,7 @@ include(cmake/llvm.cmake) include(cmake/clang.cmake) if(APPLE) include(cmake/openmp.cmake) + include(cmake/nasm.cmake) endif() include(cmake/openimageio.cmake) include(cmake/tiff.cmake) diff --git a/build_files/build_environment/cmake/ffmpeg.cmake b/build_files/build_environment/cmake/ffmpeg.cmake index 02e78c605af..7b759ab8f1d 100644 --- a/build_files/build_environment/cmake/ffmpeg.cmake +++ b/build_files/build_environment/cmake/ffmpeg.cmake @@ -143,6 +143,12 @@ if(WIN32) external_zlib_mingw ) endif() +if(APPLE) + add_dependencies( + external_ffmpeg + external_nasm + ) +endif() if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_ffmpeg after_install diff --git a/build_files/build_environment/cmake/nasm.cmake b/build_files/build_environment/cmake/nasm.cmake new file mode 100644 index 00000000000..51d7ebd8830 --- /dev/null +++ b/build_files/build_environment/cmake/nasm.cmake @@ -0,0 +1,29 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ***** END GPL LICENSE BLOCK ***** + +ExternalProject_Add(external_nasm + URL ${NASM_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${NASM_HASH} + PREFIX ${BUILD_DIR}/nasm + PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/nasm/src/external_nasm < ${PATCH_DIR}/nasm.diff + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/nasm + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && make install + INSTALL_DIR ${LIBDIR}/nasm +) diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake index 5ec5553079c..ce2a1191f17 100644 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@ -305,6 +305,10 @@ set(MESA_VERSION 18.3.1) set(MESA_URI ftp://ftp.freedesktop.org/pub/mesa//mesa-${MESA_VERSION}.tar.xz) set(MESA_HASH d60828056d77bfdbae0970f9b15fb1be) +set(NASM_VERSION 2.15.02) +set(NASM_URI https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.xz) +set(NASM_HASH f4fd1329b1713e1ccd34b2fc121c4bcd278c9f91cc4cb205ae8fcd2e4728dd14) + set(XR_OPENXR_SDK_VERSION 1.0.8) set(XR_OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz) set(XR_OPENXR_SDK_HASH c6de63d2e0f9029aa58dfa97cad8ce07) diff --git a/build_files/build_environment/cmake/x264.cmake b/build_files/build_environment/cmake/x264.cmake index 8bcb5a2938f..62a46254a99 100644 --- a/build_files/build_environment/cmake/x264.cmake +++ b/build_files/build_environment/cmake/x264.cmake @@ -39,3 +39,10 @@ ExternalProject_Add(external_x264 if(MSVC) set_target_properties(external_x264 PROPERTIES FOLDER Mingw) endif() + +if(APPLE) + add_dependencies( + external_x264 + external_nasm + ) +endif() diff --git a/build_files/build_environment/patches/nasm.diff b/build_files/build_environment/patches/nasm.diff new file mode 100644 index 00000000000..821e1a1d905 --- /dev/null +++ b/build_files/build_environment/patches/nasm.diff @@ -0,0 +1,129 @@ +diff --git a/output/macho.h b/output/macho.h +index 538c531e..fd5e8849 100644 +--- a/output/macho.h ++++ b/output/macho.h +@@ -60,6 +60,8 @@ + #define LC_SEGMENT 0x1 + #define LC_SEGMENT_64 0x19 + #define LC_SYMTAB 0x2 ++#define LC_VERSION_MIN_MACOSX 0x24 ++#define LC_BUILD_VERSION 0x32 + + /* Symbol type bits */ + #define N_STAB 0xe0 +diff --git a/output/outmacho.c b/output/outmacho.c +index 08147883..de6ec902 100644 +--- a/output/outmacho.c ++++ b/output/outmacho.c +@@ -38,6 +38,8 @@ + + #include "compiler.h" + ++#include <stdlib.h> ++ + #include "nctype.h" + + #include "nasm.h" +@@ -64,6 +66,8 @@ + #define MACHO_SYMCMD_SIZE 24 + #define MACHO_NLIST_SIZE 12 + #define MACHO_RELINFO_SIZE 8 ++#define MACHO_BUILD_VERSION_SIZE 24 ++#define MACHO_VERSION_MIN_MACOSX_SIZE 16 + + #define MACHO_HEADER64_SIZE 32 + #define MACHO_SEGCMD64_SIZE 72 +@@ -1224,6 +1228,46 @@ static void macho_layout_symbols (uint32_t *numsyms, + } + } + ++static bool get_full_version_from_env (const char *variable_name, ++ int *r_major, ++ int *r_minor, ++ int *r_patch) { ++ *r_major = 0; ++ *r_minor = 0; ++ *r_patch = 0; ++ ++ const char *value = getenv(variable_name); ++ if (value == NULL || value[0] == '\0') { ++ return false; ++ } ++ ++ const char *current_value = value; ++ const char *end_value = value + strlen(value); ++ ++ char *endptr; ++ ++ *r_major = strtol(current_value, &endptr, 10); ++ if (endptr >= end_value) { ++ return true; ++ } ++ current_value = endptr + 1; ++ ++ *r_minor = strtol(current_value, &endptr, 10); ++ if (endptr >= end_value) { ++ return true; ++ } ++ current_value = endptr + 1; ++ ++ *r_patch = strtol(current_value, &endptr, 10); ++ ++ return true; ++} ++ ++static bool need_version_min_macosx_command (void) { ++ return getenv("MACOSX_DEPLOYMENT_TARGET") && ++ getenv("MACOSX_SDK_VERSION"); ++} ++ + /* Calculate some values we'll need for writing later. */ + + static void macho_calculate_sizes (void) +@@ -1270,6 +1314,12 @@ static void macho_calculate_sizes (void) + head_sizeofcmds += fmt.segcmd_size + seg_nsects * fmt.sectcmd_size; + } + ++ /* LC_VERSION_MIN_MACOSX */ ++ if (need_version_min_macosx_command()) { ++ ++head_ncmds; ++ head_sizeofcmds += MACHO_VERSION_MIN_MACOSX_SIZE; ++ } ++ + if (nsyms > 0) { + ++head_ncmds; + head_sizeofcmds += MACHO_SYMCMD_SIZE; +@@ -1653,6 +1703,33 @@ static void macho_write (void) + else + nasm_warn(WARN_OTHER, "no sections?"); + ++#define ENCODE_BUILD_VERSION(major, minor, patch) \ ++ (((major) << 16) | ((minor) << 8) | (patch)) ++ ++ if (0) { ++ fwriteint32_t(LC_BUILD_VERSION, ofile); /* cmd == LC_BUILD_VERSION */ ++ fwriteint32_t(MACHO_BUILD_VERSION_SIZE, ofile); /* size of load command */ ++ fwriteint32_t(1, ofile); /* platform */ ++ fwriteint32_t(ENCODE_BUILD_VERSION(10, 13, 0), ofile); /* minos, X.Y.Z is encoded in nibbles xxxx.yy.zz */ ++ fwriteint32_t(ENCODE_BUILD_VERSION(10, 15, 4), ofile); /* sdk, X.Y.Z is encoded in nibbles xxxx.yy.zz */ ++ fwriteint32_t(0, ofile); /* number of tool entries following this */ ++ } ++ ++ if (need_version_min_macosx_command()) { ++ int sdk_major, sdk_minor, sdk_patch; ++ get_full_version_from_env("MACOSX_SDK_VERSION", &sdk_major, &sdk_minor, &sdk_patch); ++ ++ int version_major, version_minor, version_patch; ++ get_full_version_from_env("MACOSX_DEPLOYMENT_TARGET", &version_major, &version_minor, &version_patch); ++ ++ fwriteint32_t(LC_VERSION_MIN_MACOSX, ofile); /* cmd == LC_VERSION_MIN_MACOSX */ ++ fwriteint32_t(MACHO_VERSION_MIN_MACOSX_SIZE, ofile); /* size of load command */ ++ fwriteint32_t(ENCODE_BUILD_VERSION(version_major, version_minor, version_patch), ofile); /* minos, X.Y.Z is encoded in nibbles xxxx.yy.zz */ ++ fwriteint32_t(ENCODE_BUILD_VERSION(sdk_major, sdk_minor, sdk_patch), ofile); /* sdk, X.Y.Z is encoded in nibbles xxxx.yy.zz */ ++ } ++ ++#undef ENCODE_BUILD_VERSION ++ + if (nsyms > 0) { + /* write out symbol command */ + fwriteint32_t(LC_SYMTAB, ofile); /* cmd == LC_SYMTAB */ |