LoginSignup
4
0

More than 5 years have passed since last update.

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

Last updated at Posted at 2017-01-09

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

環境

  1. Mac OS X 10.12.2 (英語)
  2. Xcode 8.2.1

手順

  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: 2385, done.
    remote: Total 2385 (delta 0), reused 0 (delta 0), pack-reused 2385
    Receiving objects: 100% (2385/2385), 443.39 KiB | 138.00 KiB/s, done.
    Resolving deltas: 100% (1285/1285), done.
    $ cd cocos2d-x-3rd-party-libs-src
    
  2. cocos2d-x-3.14 用に git checkout

    1. cocos2d-x-3.14 の v3-deps-16 リリース (2016-12-15) は、日付からコミット b8e116d (2016-11-21) であると仮定

      $ git checkout b8e116d
      Note: checking out 'b8e116d'.
      
      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 <new-branch-name>
      
      HEAD is now at b8e116d... Merge pull request #128 from minggo/v3
      
  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
    cmake 3.7.1
    git 2.11.0
    libtool 2.4.6_1
    
  4. README.md に従って bitcode を有効に

    1. build/ios.ini の

      cfg_build_bitcode=
      

      cfg_build_bitcode="-fembed-bitcode"
      

      に変更

  5. ダウンロードできない URL を修正

    1. http://zlib.net/zlib-1.2.8.tar.gz404 Not Found になってるので

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

        ZLIB_URL := http://zlib.net/zlib-$(ZLIB_VERSION).tar.gz
        

        ZLIB_URL := http://zlib.net/fossils/zlib-$(ZLIB_VERSION).tar.gz
        

        に変更

    2. https://chipmunk-physics.net/release/Chipmunk-7.x/Chipmunk-7.0.1.tgz が SSL 証明書エラーを起こすので

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

        CHIPMUNK_URL := https://chipmunk-physics.net/release/Chipmunk-7.x/Chipmunk-$(CHIPMUNK_VERSION).tgz
        

        CHIPMUNK_URL := http://chipmunk-physics.net/release/Chipmunk-7.x/Chipmunk-$(CHIPMUNK_VERSION).tgz
        

        に変更

    3. (2017-04) http://heanet.dl.sourceforge.net/sourceforge/freetype/freetype2/2.5.5/freetype-2.5.5.tar.gz404 Not Found になってるので

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

        FREETYPE2_URL := $(SF)/freetype/freetype2/$(FREETYPE2_VERSION)/freetype-$(FREETYPE2_VERSION).tar.gz
        

        FREETYPE2_URL := http://download.savannah.gnu.org/releases/freetype/freetype-$(FREETYPE2_VERSION).tar.gz
        

        に変更

    4. (2017-04) http://heanet.dl.sourceforge.net/sourceforge/libpng/libpng16/1.6.16/libpng-1.6.16.tar.xz404 Not Found になってるので

      1. contrib/src/main.mak の

        SF := http://heanet.dl.sourceforge.net/sourceforge
        

        SF := http://jaist.dl.sourceforge.net/sourceforge
        

        に変更

  6. iOS 用に release ビルド

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

      create folder for library with specify arch. ios/rapidjson/prebuilt/x86_64
      cp: .../cocos2d-x-3rd-party-libs-src/build/../contrib/install-ios/x86_64/lib/librapidjson.a: No such file or directory
      Copying needed heder files
      cleaning up
      yes
      create fat library librapidjson for 
      error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: no input files specified
      fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo [input_file] ... [-arch <arch_type> input_file] ... [-info] [-detailed_info] [-output output_file] [-create] [-arch_blank <arch_type>] [-thin <arch_type>] [-remove <arch_type>] ... [-extract <arch_type>] ... [-extract_family <arch_type>] ... [-verify_arch <arch_type> ...] [-replace <arch_type> <file_name>] ...
      fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can't open input file: ios/rapidjson/prebuilt/librapidjson.a (No such file or directory)
      
    2. コミット b8e116d の contrib/src に存在しているのに cocos2d-x-3.14/external に存在しないもののリスト

      1. angle
      2. glew
      3. iconv
      4. ogg
      5. openssl
    3. 逆に cocos2d-x-3.14/external に存在して contrib/src に存在しないもののリスト

      1. Box2D
      2. ConvertUTF
      3. bullet
      4. clipper
      5. edtaa3func
      6. flatbuffers
      7. poly2tri
      8. rapidxml
      9. recast
      10. spidermonkey
      11. tinyxml2
      12. unzip
      13. xxhash
      14. xxtea
      15. (プラットフォーム固有の *-specific は除く)
    4. 両者に共通して存在するもののリスト

      1. chipmunk
      2. curl
      3. freetype (freetype2 in external)
      4. glfw (glfw3 in external)
      5. jpeg
      6. lua (lua/lua in external)
      7. luajit (lua/luajit in external)
      8. png
      9. rapidjson (json in external)
      10. sqlite (sqlite3 in external)
      11. tiff
      12. webp
      13. websockets
      14. zlib
    5. 両者に共通するもの全てを --libs に指定すると、以下のエラーが出る

      Invalid library names! Only png zlib lua luajit websockets curl freetype jpeg tiff webp chipmunk openssl rapidjson is acceptable!
      
    6. 従って glfw と sqlite はビルドしない

    7. rapidjson も上記のエラーが出るのでビルドしない

    8. external/zlib/prebuilt に ios ディレクトリが存在しないので zlib もビルドしない

    9. cocos2d-x-3.14/external/curl/prebuilt/ios に libssl.a が存在するが

      1. openssl をビルド指定しなくても libssl.a は curl 配下でビルドされる
      2. 同様に、ビルド指定しなくても libcrypto.a と libz.a も curl 配下でビルドされる
    10. build の最初の方で以下の警告が出るが

      SDKROOT not specified, assuming /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk
      
      1. SDKROOT を設定すると以下のエラーが出てしまったので指定しない

        CMake Error at /usr/local/Cellar/cmake/3.7.1/share/cmake/Modules/CMakeTestCCompiler.cmake:51 (message):
          The C compiler "/usr/bin/xcrun" is not able to compile a simple test
          program.
        

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

$ cd cocos2d-x/external

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. この差異はとりあえず無視

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-32.h
Only in ../../include/ios/curl: curlbuild-64.h
Files ../../include/ios/curl/curlbuild.h and ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/curl/include/curl/curlbuild.h differ
Files ../../include/ios/curl/curlver.h and ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/curl/include/curl/curlver.h differ
$ diff ../../include/ios/curl/curlbuild-64.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/curl/include/curl/curlbuild.h
$ diff ../../include/ios/curl/curlver.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/curl/include/curl/curlver.h
33c33
< #define LIBCURL_VERSION "7.50.0-DEV"
---
> #define LIBCURL_VERSION "7.50.0"
71c71
< #define LIBCURL_TIMESTAMP "DEV"
---
> #define LIBCURL_TIMESTAMP "Thu Jul 21 08:55:43 UTC 2016"

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

$ 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. external の curlbuild.h__LP64__ が定義されてると curlbuild-64.h を読み込み、それが cocos2d-x-3rd-party-libs-src の curlbuild.h と同一
    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. 差異があるが、とりあえず無視

lua, luajit

  1. 使わないので省略

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. これも差異はなかった

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. これも差異はなかった

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.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. この差異もとりあえず無視
4
0
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
4
0