LoginSignup
3
1

More than 5 years have passed since last update.

cocos2d-x-3rd-party-libs-src (v3-deps-136) を bitcode 有効にしてビルド

Posted at

cocos2d-x-3.16 の external を bitcode 有効にしてビルド

環境

  1. macOS 10.13.3 (英語)
  2. Xcode 9.2

手順

  1. cocos2d-x-3rd-party-libs-src を git clone

    $ git clone https://github.com/cocos2d/cocos2d-x-3rd-party-libs-src.git
    Cloning into 'cocos2d-x-3rd-party-libs-src'...
    remote: Counting objects: 2613, done.
    remote: Total 2613 (delta 0), reused 0 (delta 0), pack-reused 2613
    Receiving objects: 100% (2613/2613), 501.42 KiB | 1.04 MiB/s, done.
    Resolving deltas: 100% (1413/1413), done.
    $ cd cocos2d-x-3rd-party-libs-src
    
  2. cocos2d-x-3.16 用に git checkout

    1. cocos2d-x-3rd-party-libs-bin の v3-deps-136 リリース (2017-06-26) は、日付からコミット 124e386 (2017-06-20) であると仮定

      $ git checkout 124e386
      Note: checking out '124e386'.

      You are in 'detached HEAD' state. You can look around, make experimental
      changes and commit them, and you can discard any commits you make in this
      state without impacting any branches by performing another checkout.

      If you want to create a new branch to retain commits you create, you may
      do so (now or later) by using -b with the checkout command again. Example:

      git checkout -b

      HEAD is now at 124e386 Bullet support (#152)

  3. README.md に従ってビルド用のツールをインストール

    $ brew update
    $ brew install git
    $ brew install cmake
    $ brew install autoconf
    $ brew install automake
    $ brew install libtool
    $ brew list --versions
    autoconf 2.69
    automake 1.15.1
    cmake 3.10.2
    git 2.16.1
    libtool 2.4.6_1
    
  4. README.md に従って bitcode を有効に

    1. build/ios.ini の

      cfg_build_bitcode=
      

      cfg_build_bitcode="-fembed-bitcode"
      

      に変更

    2. また curl で以下のエラーが出る

      connect.c:1087:12: error: 'connectx' is only available on iOS 9.0 or newer [-Werror,-Wunguarded-availability]
      rc = connectx(sockfd, &endpoints, SAE_ASSOCID_ANY,
      ^~~~~~~~
      /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk/usr/include/sys/socket.h:713:5: note: 'connectx' has been explicitly marked partial here
      int connectx(int, const sa_endpoints_t , sae_associd_t, unsigned int,
      ^
      connect.c:1087:12: note: enclose 'connectx' in a __builtin_available check to silence this warning
      rc = connectx(sockfd, &endpoints, SAE_ASSOCID_ANY,
      ^~~~~~~~
      1 error generated.
      make[2]: *
      * [libcurl_la-connect.lo] Error 1

      1. contrib/bootstrap 内の -miphoneos-version-min=6.0-miphoneos-version-min=10.0 に置換( 3 箇所)
  5. ダウンロードできない URL を修正

    1. http://download.osgeo.org/libtiff/tiff-4.0.3.tar.gzNot Found になってるので

      1. contrib/src/tiff/rules.mak の

        TIFF_URL := http://download.osgeo.org/libtiff/tiff-$(TIFF_VERSION).tar.gz
        

        TIFF_URL := http://download.osgeo.org/libtiff/old/tiff-$(TIFF_VERSION).tar.gz
        

        に変更

  6. iOS 用に release ビルド

    $ cd build
    $ ./build.sh -p=ios --libs=png,zlib,websockets,curl,freetype,jpeg,tiff,webp,chipmunk,openssl,bullet --arch=all
    
    1. --libs=all だと lua でエラーが起きる

      loslib.c:39:22: error: 'system' is unavailable: not available on iOS
      lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));

    2. rapidjson を指定すると、以下のエラーが起きる

      checking rapidjson is in png zlib lua luajit websockets curl freetype jpeg tiff webp chipmunk openssl rapidjson, bullet
      Invalid library names! Only png zlib lua luajit websockets curl freetype jpeg tiff webp chipmunk openssl rapidjson, bullet is acceptable!

ビルド結果を cocos2d-x-3.14/external へ配置

$ cd cocos2d-x/external

png

$ cd png/prebuilt/ios

$ diff -r ../../include/ios ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/png/include

$ mv libpng.a libpng.a.dist
$ cp -p ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/png/prebuilt/libpng.a .

$ cd ../../..
  1. 差異はなかった

zlib

  1. zlib/prebuilt/ios は存在しない

websockets

$ cd websockets/prebuilt/ios

$ diff -r ../../include/ios ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/websockets/include
Only in ../../include/ios: lws_config-arm32.h
Only in ../../include/ios: lws_config-arm64.h
Only in ../../include/ios: lws_config-i386.h
Only in ../../include/ios: lws_config-x86_64.h
Only in ../../include/ios: lws_config.h

$ mv libwebsockets.a libwebsockets.a.dist
$ cp -p ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/websockets/prebuilt/libwebsockets.a .

$ cd ../../..
  1. lws_config*.h が external にしか存在しないが libwebsockets.h は同じ
    1. この差異はとりあえず無視

curl (with crypto and ssl)

$ cd curl/prebuilt/ios

$ diff -rq ../../include/ios ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/curl/include
Only in ../../include/ios/curl: curlbuild-arm32.h
Only in ../../include/ios/curl: curlbuild-arm64.h
Only in ../../include/ios/curl: curlbuild-i386.h
Only in ../../include/ios/curl: curlbuild-x86_64.h
Files ../../include/ios/curl/curlbuild.h and ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/curl/include/curl/curlbuild.h differ

$ cat ../../include/ios/curl/curlbuild.h
#ifdef __arm64__
#include "curlbuild-arm64.h"
#elif __arm__
#include "curlbuild-arm32.h"
#elif __i386__
#include "curlbuild-i386.h"
#elif __x86_64__
#include "curlbuild-x86_64.h"
#else
#error "Unsupported architecture!"
#endif
$ diff ../../include/ios/curl/curlbuild-arm64.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/curl/include/curl/curlbuild.h
$ diff ../../include/ios/curl/curlbuild-arm32.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/curl/include/curl/curlbuild.h
136c136
< #define CURL_PULL_STDINT_H 1
---
> /* #undef CURL_PULL_STDINT_H */
143c143
< #define CURL_PULL_INTTYPES_H 1
---
> /* #undef CURL_PULL_INTTYPES_H */
163c163
< #define CURL_SIZEOF_LONG 4
---
> #define CURL_SIZEOF_LONG 8
175c175
< #define CURL_TYPEOF_CURL_OFF_T int64_t
---
> #define CURL_TYPEOF_CURL_OFF_T long
181c181
< #define CURL_FORMAT_CURL_OFF_T "lld"
---
> #define CURL_FORMAT_CURL_OFF_T "ld"
184c184
< #define CURL_FORMAT_CURL_OFF_TU "llu"
---
> #define CURL_FORMAT_CURL_OFF_TU "lu"
187c187
< #define CURL_FORMAT_OFF_T "%lld"
---
> #define CURL_FORMAT_OFF_T "%ld"
193c193
< #define CURL_SUFFIX_CURL_OFF_T LL
---
> #define CURL_SUFFIX_CURL_OFF_T L
196c196
< #define CURL_SUFFIX_CURL_OFF_TU ULL
---
> #define CURL_SUFFIX_CURL_OFF_TU UL
$ diff ../../include/ios/curl/curlbuild-i386.h ../../include/ios/curl/curlbuild-arm32.h
$ diff ../../include/ios/curl/curlbuild-x86_64.h ../../include/ios/curl/curlbuild-arm64.h

$ mv libcurl.a libcurl.a.dist
$ cp -p ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/curl/prebuilt/libcurl.a .

$ cd ../../..
  1. external の curlbuild.h は他のファイルを読み込んでおり、64 ビット用は元のファイルと同一
    1. この差異もとりあえず無視

freetype

$ cd freetype2/prebuilt/ios

$ diff -r ../../include/ios ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/freetype/include

$ mv libfreetype.a libfreetype.a.dist
$ cp -p ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/freetype/prebuilt/libfreetype.a .

$ cd ../../..
  1. 差異はなかった

jpeg

$ cd jpeg/prebuilt/ios

$ diff -r ../../include/ios ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/jpeg/include
diff -r ../../include/ios/jconfig.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/jpeg/include/jconfig.h
21c21
< /* Define "boolean" as unsigned char, not int, on Windows systems. */
---
> /* Define "boolean" as unsigned char, not enum, on Windows systems. */
25a26,31
> #ifndef FALSE         /* in case these macros already exist */
> #define FALSE 0       /* values of boolean */
> #endif
> #ifndef TRUE
> #define TRUE  1
> #endif
diff -r ../../include/ios/jmorecfg.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/jpeg/include/jmorecfg.h
5c5
<  * Modified 1997-2012 by Guido Vollbeding.
---
>  * Modified 1997-2013 by Guido Vollbeding.
17a18,20
>  *   9   for 9-bit sample values
>  *   10  for 10-bit sample values
>  *   11  for 11-bit sample values
19,21c22,30
<  * Only 8 and 12 are legal data precisions for lossy JPEG according to the
<  * JPEG standard, and the IJG code does not support anything else!
<  * We do not support run-time selection of data precision, sorry.
---
>  * Only 8, 9, 10, 11, and 12 bits sample data precision are supported for
>  * full-feature DCT processing.  Further depths up to 16-bit may be added
>  * later for the lossless modes of operation.
>  * Run-time selection and conversion of data precision will be added later
>  * and are currently not supported, sorry.
>  * Exception:  The transcoding part (jpegtran) supports all settings in a
>  * single instance, since it operates on the level of DCT coefficients and
>  * not sample values.  The DCT coefficients are of the same type (16 bits)
>  * in all cases (see below).
24c33
< #define BITS_IN_JSAMPLE  8    /* use 8 or 12 */
---
> #define BITS_IN_JSAMPLE  8    /* use 8, 9, 10, 11, or 12 */
79a89,130
> #if BITS_IN_JSAMPLE == 9
> /* JSAMPLE should be the smallest type that will hold the values 0..511.
>  * On nearly all machines "short" will do nicely.
>  */
> 
> typedef short JSAMPLE;
> #define GETJSAMPLE(value)  ((int) (value))
> 
> #define MAXJSAMPLE    511
> #define CENTERJSAMPLE 256
> 
> #endif /* BITS_IN_JSAMPLE == 9 */
> 
> 
> #if BITS_IN_JSAMPLE == 10
> /* JSAMPLE should be the smallest type that will hold the values 0..1023.
>  * On nearly all machines "short" will do nicely.
>  */
> 
> typedef short JSAMPLE;
> #define GETJSAMPLE(value)  ((int) (value))
> 
> #define MAXJSAMPLE    1023
> #define CENTERJSAMPLE 512
> 
> #endif /* BITS_IN_JSAMPLE == 10 */
> 
> 
> #if BITS_IN_JSAMPLE == 11
> /* JSAMPLE should be the smallest type that will hold the values 0..2047.
>  * On nearly all machines "short" will do nicely.
>  */
> 
> typedef short JSAMPLE;
> #define GETJSAMPLE(value)  ((int) (value))
> 
> #define MAXJSAMPLE    2047
> #define CENTERJSAMPLE 1024
> 
> #endif /* BITS_IN_JSAMPLE == 11 */
> 
> 
255c306,309
< #ifdef HAVE_BOOLEAN
---
> #ifndef HAVE_BOOLEAN
> #if defined FALSE || defined TRUE || defined QGLOBAL_H
> /* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */
> typedef int boolean;
264a319
> #endif
302,306c357,362
< /* Note: if you selected 12-bit data precision, it is dangerous to turn off
<  * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit
<  * precision, so jchuff.c normally uses entropy optimization to compute
<  * usable tables for higher precision.  If you don't want to do optimization,
<  * you'll have to supply different default Huffman tables.
---
> /* Note: if you selected more than 8-bit data precision, it is dangerous to
>  * turn off ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only
>  * good for 8-bit precision, so arithmetic coding is recommended for higher
>  * precision.  The Huffman encoder normally uses entropy optimization to
>  * compute usable tables for higher precision.  Otherwise, you'll have to
>  * supply different default Huffman tables.
317c373
< #define IDCT_SCALING_SUPPORTED        /* Output rescaling via IDCT? */
---
> #define IDCT_SCALING_SUPPORTED        /* Output rescaling via IDCT? (Requires DCT_ISLOW)*/
diff -r ../../include/ios/jpeglib.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/jpeg/include/jpeglib.h
5c5
<  * Modified 2002-2012 by Guido Vollbeding.
---
>  * Modified 2002-2015 by Guido Vollbeding.
42c42
< #define JPEG_LIB_VERSION_MINOR  0
---
> #define JPEG_LIB_VERSION_MINOR  2
46,47c46,47
<  * All of these are specified by the JPEG standard, so don't change them
<  * if you want to be compatible.
---
>  * All of these are specified by the JPEG standard,
>  * so don't change them if you want to be compatible.
160c160,161
<    * downsampled_width = ceil(image_width * Hi/Hmax * DCT_h_scaled_size/DCTSIZE)
---
>    * downsampled_width =
>    *   ceil(image_width * Hi/Hmax * DCT_h_scaled_size/block_size)
165,167c166,172
<   /* This flag is used only for decompression.  In cases where some of the
<    * components will be ignored (eg grayscale output from YCbCr image),
<    * we can skip most computations for the unused components.
---
>   /* For decompression, in cases where some of the components will be
>    * ignored (eg grayscale output from YCbCr image), we can skip most
>    * computations for the unused components.
>    * For compression, some of the components will need further quantization
>    * scale by factor of 2 after DCT (eg BG_YCC output from normal RGB input).
>    * The field is first set TRUE for decompression, FALSE for compression
>    * in initial_setup, and then adapted in color conversion setup.
169c174
<   boolean component_needed;   /* do we need the value of this component? */
---
>   boolean component_needed;
218,219c223,224
<   JCS_RGB,        /* red/green/blue */
<   JCS_YCbCr,      /* Y/Cb/Cr (also known as YUV) */
---
>   JCS_RGB,        /* red/green/blue, standard RGB (sRGB) */
>   JCS_YCbCr,      /* Y/Cb/Cr (also known as YUV), standard YCC */
221c226,228
<   JCS_YCCK        /* Y/Cb/Cr/K */
---
>   JCS_YCCK,       /* Y/Cb/Cr/K */
>   JCS_BG_RGB,     /* big gamut red/green/blue, bg-sRGB */
>   JCS_BG_YCC      /* big gamut Y/Cb/Cr, bg-sYCC */
975c982
<                 unsigned char * inbuffer,
---
>                 const unsigned char * inbuffer,

$ mv libjpeg.a libjpeg.a.dist
$ cp -p ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/jpeg/prebuilt/libjpeg.a .

$ cd ../../..
  1. 差異があるが、とりあえず無視

tiff

$ cd tiff/prebuilt/ios

$ diff -rq ../../include/ios ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/tiff/include
Only in ../../include/ios: tiffconf-32.h
Only in ../../include/ios: tiffconf-64.h
Files ../../include/ios/tiffconf.h and ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/tiff/include/tiffconf.h differ
$ diff ../../include/ios/tiffconf-64.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/tiff/include/tiffconf.h

$ mv libtiff.a libtiff.a.dist
$ cp -p ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/tiff/prebuilt/libtiff.a .

$ cd ../../..
  1. external の tiffconf.h__LP64__ が定義されてると tiffconf-64.h を読み込み、それが cocos2d-x-3rd-party-libs-src の tiffconf.h と同一
    1. この差異もとりあえず無視

webp

$ cd webp/prebuilt/ios

$ diff -r ../../include/ios ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/webp/include/webp

$ mv libwebp.a libwebp.a.dist
$ cp -p ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/webp/prebuilt/libwebp.a .

$ cd ../../..
  1. これも差異はなかった

chipmunk

$ cd chipmunk/prebuilt/ios

$ diff -r ../../include ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/chipmunk/include
diff -r ../../include/chipmunk/chipmunk.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/chipmunk/include/chipmunk/chipmunk.h
31,35c31
<     #if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
<         #define CP_EXPORT __declspec(dllexport)
<     #else
<       #define CP_EXPORT
<     #endif
---
>   #define CP_EXPORT __declspec(dllexport)

$ mv libchipmunk.a libchipmunk.a.dist
$ cp -p ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/chipmunk/prebuilt/libchipmunk.a .

$ cd ../../..
  1. diff で差異が見つかった
    1. external のバージョンは cocos2d-x-3rd-party-libs-bin 固有のコードで、本家には存在しないし chipmunk/cocos2d.patch にも存在しない
      1. cocos2d-x-3rd-party-libs-bin は cocos2d-x-3rd-party-libs-src からビルドしているものではないのかも・・・
      2. #ifdef WIN32 で囲まれた部分での差異なのでコンパイル結果には影響ないはず
        1. この差異はとりあえず無視

openssl

$ cd openssl/prebuilt/ios

$ diff -rq ../../include/ios ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/ssl/include
Only in ../../include/ios/openssl: opensslconf-arm32.h
Only in ../../include/ios/openssl: opensslconf-arm64.h
Only in ../../include/ios/openssl: opensslconf-i386.h
Only in ../../include/ios/openssl: opensslconf-x86_64.h
Files ../../include/ios/openssl/opensslconf.h and ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/ssl/include/openssl/opensslconf.h differ

$ cat ../../include/ios/openssl/opensslconf.h
#ifdef __arm64__
#include "opensslconf-arm64.h"
#elif __arm__
#include "opensslconf-arm32.h"
#elif __i386__
#include "opensslconf-i386.h"
#elif __x86_64__
#include "opensslconf-x86_64.h"
#else
#error "Unsupported architecture!"
#endif
$ diff ../../include/ios/openssl/opensslconf-arm64.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/ssl/include/openssl/opensslconf.h
171c171
< #define RC4_INT unsigned char
---
> #define RC4_INT unsigned int
$ diff ../../include/ios/openssl/opensslconf-arm32.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/ssl/include/openssl/opensslconf.h
164c164
< # define BN_LLONG
---
> # undef BN_LLONG
166c166
< # undef SIXTY_FOUR_BIT_LONG
---
> # define SIXTY_FOUR_BIT_LONG
168c168
< # define THIRTY_TWO_BIT
---
> # undef THIRTY_TWO_BIT
171c171
< #define RC4_INT unsigned char
---
> #define RC4_INT unsigned int
$ diff ../../include/ios/openssl/opensslconf-i386.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/ssl/include/openssl/opensslconf.h
164c164
< # define BN_LLONG
---
> # undef BN_LLONG
166c166
< # undef SIXTY_FOUR_BIT_LONG
---
> # define SIXTY_FOUR_BIT_LONG
168c168
< # define THIRTY_TWO_BIT
---
> # undef THIRTY_TWO_BIT
$ diff ../../include/ios/openssl/opensslconf-x86_64.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/ssl/include/openssl/opensslconf.h

$ mv libcrypto.a libcrypto.a.dist
$ cp -p ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/crypto/prebuilt/libcrypto.a .

$ mv libssl.a libssl.a.dist
$ cp -p ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/ssl/prebuilt/libssl.a .

$ cd ../../..
  1. diff で差異が見つかったが、これも無視

bullet

$ cd bullet/prebuilt/ios

$ diff -r ../../include ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/bullet/include
Only in ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/bullet/include/bullet/BulletMultiThreaded/GpuSoftBodySolvers/DX11: HLSL
Only in ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/bullet/include/bullet/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL: AMD
Only in ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/bullet/include/bullet/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL: Apple
Only in ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/bullet/include/bullet/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL: Intel
Only in ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/bullet/include/bullet/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL: MiniCL
Only in ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/bullet/include/bullet/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL: NVidia
Only in ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/bullet/include/bullet/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL: OpenCLC10

$ for i in "libBulletCollision.a" "libBulletDynamics.a" "libBulletMultiThreaded.a" "libLinearMath.a" "libMiniCL.a"; do mv $i $i.dist; cp -p ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/bullet/prebuilt/$i .; done

$ cd ../../..
  1. 差異はあったが、全てからディレクトリ
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1