QSanguosha-Rara/QSanguosha-For-Hegemony

View on GitHub
README.builds

Summary

Maintainability
Test Coverage
INFORMATION OF HOW TO BUILD THE REPOSITORY
Tips: "~" stands for the folder where the repo is in.

To build QSanguosha with VS2013

1. Download the following packages:
(1) QT libraries for Windows (Visual Studio 2013, 5.3.1) x86: http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-windows-x86-msvc2013-5.3.1.exe
                                                         x64: http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-windows-x86-msvc2013_64-5.3.1.exe
(2) QT Visual Studio Add-in (for Qt 5) http://download.qt-project.org/official_releases/vsaddin/qt-vs-addin-1.2.3-opensource.exe
   and then install them.

2. Download the swigwin (swig for Windows, 3.0.2) http://sourceforge.net/projects/swig/files/swigwin/
   Create a ~/tools/swig folder under your source directory. Unzip swigwin and copy all unzipped files to ~/tools/swig.

3. Open Qsanguosha.sln right under ~/builds/vs2013, change the Configuration to Release Qt5|Win32.

4. Right click project "QSanguosha" in your Solution Explorer, select "Properties", go to "Debugging" tab, set "Working Directory" to "$(ProjectDir)..\..\" (do not enter the quote marks). Then select "OK".

4.1. [optional] Right click "sanguosha.ts" in the folder "Translaton Files" in project "QSanguosha", select "lrelease".

5. You are now able to build the solution. When compilation succeeded, the QSanguosha.exe is in ~/Bin folder. You should move this file to ~ folder.

6. Copy 6 files from Qt libraries to ~, they are listed below:
   Qt5Core.dll
   Qt5Gui.dll
   Qt5Network.dll
   Qt5Qml.dll
   Qt5Quick.dll
   Qt5Widgets.dll

   Copy 2 files from VS redist to ~, they are listed below:
   msvcp120.dll
   msvcr120.dll

7. Double-click the QSanguosha.exe and have fun!

To build QSanguosha in Mac OS X

1. Install XCode from App Store and enable the command tools.

2. Download and install the libraries and Qt Creator from http://download.qt-project.org/official_releases/qt/5.3/5.3.1/qt-opensource-mac-x64-clang-5.3.1.dmg

3. Download the source code and install swig from http://sourceforge.net/projects/swig/files/swig/ and make sure the version of swig is 3.0.2 or later.
   Tips: unzip the source code tarball and open a terminal, type:
   ./configure --without-pcre
   make
   sudo make install

4. Open a terminal here, type:
   cd swig
   swig -c++ -lua sanguosha.i

5. Open QSanguosha.pro with Qt Creator, configure the project and make sure the project is compiled with clang. Change the configuration to Release.

6. You are now able to build the solution. When compilation succeeded, the QSanguosha.app folder is in ~/../Build-QSanguosha-**/ folder.
   I highly recommend you move this folder to ~.

7. This step is the most important and difficult one. Please pay a lot of attention to read this step.
   Open a terminal here, type:
   otool -L QSanguosha.app/Contents/MacOS/QSanguosha

You'll see something like this:
   QSanguosha.app/Contents/MacOS/QSanguosha:
   ./libfmodex.dylib (compatibility version 1.0.0, current version 1.0.0)
   libfreetype.1.dylib (compatibility version 1.0.0, current version 1.0.0)
   (QtDir)/5.3/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.3.0, current version 5.3.0)
   (QtDir)/5.3/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.3.0, current version 5.3.0)
   (QtDir)/5.3/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.3.0, current version 5.3.0)
   (QtDir)/5.3/clang_64/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.3.0, current version 5.3.0)
   (QtDir)/5.3/clang_64/lib/QtQml.framework/Versions/5/QtQml (compatibility version 5.3.0, current version 5.3.0)
   (QtDir)/5.3/clang_64/lib/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.3.0, current version 5.3.0)
   /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
   /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
   /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

Pay attention to the 2 lines contains libfmodex.dylib or libfreetype.1.dylib.
using install_name_tool to change the path of the 2 library files to their absolute paths, like this:
   install_name_tool -change ./libfmodex.dylib ~/lib/mac/lib/libfmodex.dylib QSanguosha.app/Contents/MacOS/QSanguosha
   install_name_tool -change libfreetype.1.dylib ~/lib/mac/lib/libfreetype.dylib  QSanguosha.app/Contents/MacOS/QSanguosha

Type:
   otool -L QSanguosha.app/Contents/MacOS/QSanguosha

if you see all the directories is absolute path, it should succeed. (~ stands for the project dir)
   QSanguosha.app/Contents/MacOS/QSanguosha:
   ~/lib/mac/lib/libfmodex.dylib (compatibility version 1.0.0, current version 1.0.0)
   ~/lib/mac/lib/libfreetype.dylib (compatibility version 1.0.0, current version 1.0.0)
   (QtDir)/5.3/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.3.0, current version 5.3.0)
   (QtDir)/5.3/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.3.0, current version 5.3.0)
   (QtDir)/5.3/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.3.0, current version 5.3.0)
   (QtDir)/5.3/clang_64/lib/QtGui.framework/Versions/5/QtGui (compatibility version 5.3.0, current version 5.3.0)
   (QtDir)/5.3/clang_64/lib/QtQml.framework/Versions/5/QtQml (compatibility version 5.3.0, current version 5.3.0)
   (QtDir)/5.3/clang_64/lib/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.3.0, current version 5.3.0)
   /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
   /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
   /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

Type:
   macdeployqt QSanguosha.app/

Some times the macdeployqt is not in the system directories, in this case you should go to the Qt Install Dir and find this file.

Type:
   otool -L QSanguosha.app/Contents/MacOS/QSanguosha

if you see all the non-system libraries is in @executable_path, it should succeed.
   QSanguosha.app/Contents/MacOS/QSanguosha:
   @executable_path/../Frameworks/libfmodex.dylib (compatibility version 1.0.0, current version 1.0.0)
   @executable_path/../Frameworks/libfreetype.dylib (compatibility version 1.0.0, current version 1.0.0)
   @executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.3.0, current version 5.3.0)
   @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.3.0, current version 5.3.0)
   @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.3.0, current version 5.3.0)
   @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.3.0, current version 5.3.0)
   @executable_path/../Frameworks/QtQml.framework/Versions/5/QtQml (compatibility version 5.3.0, current version 5.3.0)
   @executable_path/../Frameworks/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.3.0, current version 5.3.0)
   /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
   /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
   /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

8.copy the following folders and files to QSanguosha.app/Contents/MacOS/, they are listed below:
   ai-selector/
   audio/
   developers/
   diy/
   font/
   image/
   lang/
   lua/
   rule/
   skins/
   ui-script/
   qt_zh_CN.qm
   sanguosha.qss

8.1 [optional] select Tools/External/QtLinguist/lrelease, copy ~/Builds/sanguosha.qm to QSanguosha.app/Contents/MacOS.

9. Double-click QSanguosha.app folder and have fun!

To build QSanguosha in Linux or using MinGW

1. Download and install the libraries and Qt Creator from Qt offical website or software sources, make sure the version of Qt libraries is 5.3.1.
   (I strongly recommand you download the libraries and Qt Creator from software sources in Linux, because the compliation causes a lot of time)
   (If you are using MinGW, make sure the version of MinGW is compatible with Qt Libraries)

2. (Linux)Download and install the swig from http://sourceforge.net/projects/swig/files/swig/ or software sources, make sure the version of swig is 3.0.2 or later.
   Tips: unzip the source code tarball and open a terminal, type:
   ./configure --without-pcre
   make
   sudo make install

2. (MinGW)Download the swigwin (swig for Windows, 3.0.2) http://sourceforge.net/projects/swig/files/swigwin/
   Create a ~/tools/swig folder under your source directory. Unzip swigwin and copy all unzipped files to ~/tools/swig.

3. Open a terminal here, type:
(Linux)
   cd swig
   swig -c++ -lua sanguosha.i
   cd ../lib/linux
   (x86)cd x86 (or) (x64)cd x64
   sudo cp libfmodex*.so /usr/lib (root password required)
   sudo ldconfig

(MinGW)
   cd swig
   ..\tools\swig\swig.exe -c++ -lua sanguosha.i

4. Open QSanguosha.pro, configure the project and make sure the project is compiled with g++. Change the configuration to Release.

4.1 [optional] select Tools/External/QtLinguist/lrelease, copy ~/Builds/sanguosha.qm to ~.

5. You are now able to build the solution. When compilation succeeded, the (MinGW)QSanguosha.exe or (Linux)QSanguosha is in ~/../Build-QSanguosha-**/ folder. You should move this file to ~ folder.

6. (MinGW only)Copy 6 files from Qt libraries to ~, they are listed below:
   Qt5Core.dll
   Qt5Gui.dll
   Qt5Network.dll
   Qt5Qml.dll
   Qt5Quick.dll
   Qt5Widgets.dll

   (MinGW only)Copy 3 files from MinGW bin folder to ~, they are listed below:
   libgcc_s_dw2-1.dll
   libstdc++-6.dll
   libwinpthread-1.dll

7. Double-click (MinGW)QSanguosha.exe or (Linux)QSanguosha and have fun!

To build QSanguosha targeting Android on Windows

Notice: Android version is still not fully supported.

1. You'll need the following packages.
(1) Qt 5.3.1 for Android, including Qt Creator & MinGW 4.8.
(3) swig 3.0.2 for Windows.
(4) Android SDK. (Android Development Tools is recommended, via which you can download and manage Android SDKs)
(5) Android NDK
(6) JDK 1.7
(7) USB driver specified to your Android device. (optional, to deploy APK directly onto your device and debug)
(8) Apache Ant 1.9, usually packed in ADT

2. Unzip swigwin and run
   swig -c++ -lua ~/swig/sanguosha.i

3. Unzip Android SDK, Android NDK. Install JDK and your USB driver(optional).

4. Start Qt Creator and click Options -> Android. Fill and confirm JDK location, Android SDK location, Android NDK location and Ant executable.

5. Open QSanguosha.pro with Qt Creator. Confirm the archtecture of your Android device (ARMv7 or x86) and select the corresponding kit.

6. To deploy APK via USB, connect your Android device to your PC via USB. Enable debug mode. Click Run (Ctrl + R) and select your device in the popup window.
   OR add two custom process steps to create an APK but do not deploy it to any device.
   (1) Command: < YOUR MinGW PATH >\mingw32-make.exe
       Arguments: install INSTALL_ROOT=android-build
       Working Directory: %{buildDir}
   (2) Command: < YOUR Qt library PATH >\bin\androiddeployqt.exe
       Arguments: --input android-libQSanguosha.so-deployment-settings.json --output android-build --deployment bundled --ant <YOUR Apache Ant PATH>/bin/ant.bat --android-platform android-19
       Working Directory: %{buildDir}
   Click build (Ctrl + B) and you'll get an APK in < YOUR build directory >/android-build/bin, and install the APK manually.

7. Copy the following files and folders from ~ into <one of YOUR SD card>/Android/data/org.qsgsrara.qsanguosha
   ai-selector
   audio
   diy
   font
   hero-skin
   image
   lang
   lua
   rule
   skins
   style-sheet
   ui-script

8. (optional) Add the Chinese language pack.
   run lrelease QSanguosha.pro
   copy ~/builds/sanguosha.qm and ~/qt_zh_CN.qm into Android/data/org.qsgsrara.qsanguosha mentioned in step 7.