0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2016-07-16

環境

  1. Mac OS X 10.11.5 (英語)
  2. Xcode 7.3.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: 2253, done.
     remote: Total 2253 (delta 0), reused 0 (delta 0), pack-reused 2252
     Receiving objects: 100% (2253/2253), 423.46 KiB | 212.00 KiB/s, done.
     Resolving deltas: 100% (1213/1213), done.
     Checking connectivity... done.
    
  2. cocos2d-x-3.12 用に git checkout

    1. cocos2d-x-3.12 にバンドルされている v3-deps-99 リリース (2016-06-16) は、日付からコミット e9e004f (2016-06-07) であると仮定

       $ cd cocos2d-x-3rd-party-libs-src
       $ git checkout e9e004f
       Note: checking out 'e9e004f'.
      
       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 e9e004f... Merge pull request #113 from zilongshanren/fix-cmake-typo
      
  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.6.0_1
     git 2.9.2
     libtool 2.4.6
    
  4. README.md に従って bitcode を有効に

    1. build/ios.ini の

       cfg_build_bitcode=
      

       cfg_build_bitcode="-fembed-bitcode"
      

      に変更

  5. iOS 用に release ビルド

     $ cd build
     $ ./build.sh -p=ios --libs=chipmunk,curl,freetype,jpeg,lua,luajit,openssl,png,tiff,webp,websockets --arch=all --mode=release
    
  6. --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)
    
    1. そもそも cocos2d-x-3.12/external に rapidjson は存在しない
1. コミット e9e004 の contrib/src に存在しているのに v3-deps-99 リリースの cocos2d-x-3.12/external に存在しないもののリスト
    1. angle
    2. glew
    3. iconv
    4. ogg
    5. openssl
    6. rapidjson
2. 逆に cocos2d-x-3.12/external に存在して contrib/src に存在しないもののリスト
    1. Box2D
    2. ConvertUTF
    3. bullet
    4. clipper
    5. edtaa3func
    6. flatbuffers
    7. json
    8. poly2tri
    9. recast
    10. spidermonkey (prebuilt/ios/libjs_static.a も存在する)
    11. tinyxml2
    12. unzip
    13. xxhash
    14. xxtea
    15. (プラットフォーム固有の *-specific は除く)
3. 両者に共通して存在するもののリスト
    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)
    7. png
    8. sqlite (sqlite3 in external)
    9. tiff
    10. webp
    11. websockets
    12. zlib
4. 両者に共通するもの全てを ```--libs``` に指定すると、以下のエラーが出る

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

5. 従って glfw と sqlite はビルドしない
6. また cocos2d-x-3.12/external/curl/prebuilt/ios に libssl.a が存在するので openssl もビルドする
    1. 同様に curl に含まれている libcrypto.a もビルド指定するべきだと思うが、勝手にビルドされてた
7. external/zlib/prebuilt に ios ディレクトリが存在しないので zlib もビルドしない

ビルド結果を cocos2d-x-3.1.2/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
$ ln -s ../../../../../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 -r ../../include/ios ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/curl/include
$ 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
$ diff ../../include/ios/curl/curlbuild-64.h ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/curl/include/curl/curlbuild.h

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

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

$ mv libssl.a libssl.a.dist
$ ln -s ../../../../../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
$ ln -s ../../../../../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

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

$ cd ../../..
  1. これも差異はなさそう

lua

$ cd lua/lua/prebuilt/ios

$ mkdir bin-src
$ cp ../../*.c ../../*.h bin-src
$ mkdir src-src
$ cp ../../../../../../cocos2d-x-3rd-party-libs-src/contrib/ios-arm64/lua/src/*.c ../../../../../../cocos2d-x-3rd-party-libs-src/contrib/ios-arm64/lua/src/*.h src-src
$ diff -r bin-src src-src
diff -r bin-src/ldump.c src-src/ldump.c
47c47,48
<  DumpVar(x,D);
---
>  int32_t i = x;
>  DumpVar(i,D);
65c66
<   size_t size=0;
---
>   uint32_t size=0;
70c71
<   size_t size=s->tsv.len+1;		/* include trailing '\0' */
---
>   uint32_t size=s->tsv.len+1;		/* include trailing '\0' */
diff -r bin-src/llex.c src-src/llex.c
179d178
<   struct lconv *cv = localeconv();
181c180
<   ls->decpoint = (cv ? cv->decimal_point[0] : '.');
---
>   ls->decpoint = '.';
Only in src-src: luac.c
diff -r bin-src/luaconf.h src-src/luaconf.h
12a13,14
> #include <stdint.h>
> #include <sys/types.h>
39d40
< #define LUA_USE_READLINE	/* needs some extra libraries */
44c45
< #define LUA_DL_DYLD		/* does not need extra library */
---
> //#define LUA_DL_DYLD		/* does not need extra library */
413,416c414,417
< #if LUAI_BITSINT >= 32
< #define LUAI_UINT32	unsigned int
< #define LUAI_INT32	int
< #define LUAI_MAXINT32	INT_MAX
---
> 
> #define LUAI_UINT32	uint32_t
> #define LUAI_INT32	int32_t
> #define LUAI_MAXINT32	0x7fffffff
418,426c419
< #define LUAI_MEM	ptrdiff_t
< #else
< /* 16-bit ints */
< #define LUAI_UINT32	unsigned long
< #define LUAI_INT32	long
< #define LUAI_MAXINT32	LONG_MAX
< #define LUAI_UMEM	unsigned long
< #define LUAI_MEM	long
< #endif
---
> #define LUAI_MEM	ssize_t
701c694
< #define LUA_DL_DLOPEN
---
> //#define LUA_DL_DLOPEN
705c698
< #define LUA_DL_DLL
---
> //#define LUA_DL_DLL
diff -r bin-src/lundump.c src-src/lundump.c
63c63
<  int x;
---
>  int32_t x;
78c78
<  size_t size;
---
>  uint32_t size;
222,223c222,223
<  *h++=(char)sizeof(int);
<  *h++=(char)sizeof(size_t);
---
>  *h++=(char)sizeof(int32_t);
>  *h++=(char)sizeof(uint32_t);

$ rm -rf bin-src src-src

$ cd ../../../..
  1. 何故か *.c まで external に入ってるので、それらも比較
  2. 色々違う
  3. lua は使わないはずなので、とりあえず配置しない

luajit

  1. lua と同じく配置しない

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
$ ln -s ../../../../../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
$ ln -s ../../../../../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
$ ln -s ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/webp/prebuilt/libwebp.a

$ cd ../../..

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
$ ln -s ../../../../../cocos2d-x-3rd-party-libs-src/build/ios/websockets/prebuilt/libwebsockets.a

$ cd ../../..
  1. lws_config.h が external にしか存在しないが libwebsockets.h は同じ
    1. この差異もとりあえず無視
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?