Build environment: Ensure Python is using static ffi
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 28 Aug 2018 16:53:59 +0000 (18:53 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 28 Aug 2018 16:55:00 +0000 (18:55 +0200)
Surely, need to compile ffi first :)

Good news are: Python seems static enough now!

build_files/build_environment/CMakeLists.txt
build_files/build_environment/cmake/ffi.cmake [new file with mode: 0644]
build_files/build_environment/cmake/python.cmake
build_files/build_environment/cmake/versions.cmake
build_files/build_environment/patches/python_linux.diff

index 512d256..5270a2e 100644 (file)
@@ -139,6 +139,7 @@ endif()
 
 if(UNIX AND NOT APPLE)
        include(cmake/bzip2.cmake)
+       include(cmake/ffi.cmake)
        include(cmake/lzma.cmake)
        include(cmake/ssl.cmake)
        include(cmake/sqlite.cmake)
diff --git a/build_files/build_environment/cmake/ffi.cmake b/build_files/build_environment/cmake/ffi.cmake
new file mode 100644 (file)
index 0000000..18531fd
--- /dev/null
@@ -0,0 +1,38 @@
+# ***** 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_ffi
+       URL ${FFI_URI}
+       URL_HASH SHA256=${FFI_HASH}
+       DOWNLOAD_DIR ${DOWNLOAD_DIR}
+       PREFIX ${BUILD_DIR}/ffi
+       CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ffi/src/external_ffi/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/ffi
+               --enable-shared=no
+               --enable-static=yes
+               --with-pic
+       BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ffi/src/external_ffi/ && make -j${MAKE_THREADS}
+       INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ffi/src/external_ffi/ && make install
+       INSTALL_DIR ${LIBDIR}/ffi
+)
+
+if (UNIX AND NOT APPLE)
+       ExternalProject_Add_Step(external_ffi after_install
+               COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/ffi/lib/libffi.a ${LIBDIR}/ffi/lib/libffi_pic.a
+               DEPENDEES install
+       )
+endif()
index 9d0edd9..cf928ec 100644 (file)
@@ -177,6 +177,7 @@ if(UNIX AND NOT APPLE)
        add_dependencies(
                external_python
                external_bzip2
+               external_ffi
                external_lzma
                external_ssl
                external_sqlite
index a60c510..7ede80a 100644 (file)
@@ -283,6 +283,10 @@ set(BZIP2_VERSION 1.0.6)
 set(BZIP2_URI http://http.debian.net/debian/pool/main/b/bzip2/bzip2_${BZIP2_VERSION}.orig.tar.bz2)
 set(BZIP2_HASH d70a9ccd8bdf47e302d96c69fecd54925f45d9c7b966bb4ef5f56b770960afa7)
 
+set(FFI_VERSION 3.2.1)
+set(FFI_URI ftp://sourceware.org/pub/libffi/libffi-${FFI_VERSION}.tar.gz)
+set(FFI_HASH d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37)
+
 set(LZMA_VERSION 5.2.4)
 set(LZMA_URI https://tukaani.org/xz/xz-${LZMA_VERSION}.tar.bz2)
 set(LZMA_HASH 3313fd2a95f43d88e44264e6b015e7d03053e681860b0d5d3f9baca79c57b7bf)
index 3c65e12..24d625c 100644 (file)
@@ -1,5 +1,5 @@
 diff --git a/setup.py.orig b/setup.py
-index a97a755..ee2bfad 100644
+index a97a755..07ce853 100644
 --- a/setup.py.orig
 +++ b/setup.py
 @@ -1422,13 +1422,13 @@ class PyBuildExt(build_ext):
@@ -27,3 +27,12 @@ index a97a755..ee2bfad 100644
              extra_link_args = zlib_extra_link_args
          else:
              extra_compile_args = []
+@@ -1991,7 +1991,7 @@ class PyBuildExt(build_ext):
+                 print('Header file {} does not exist'.format(ffi_h))
+         ffi_lib = None
+         if ffi_inc is not None:
+-            for lib_name in ('ffi', 'ffi_pic'):
++            for lib_name in ('ffi_pic', ):
+                 if (self.compiler.find_library_file(lib_dirs, lib_name)):
+                     ffi_lib = lib_name
+                     break