Debian Codegraph @

packaging/windows/package-helpers

raw
1 # Helper functions to do win32 cross builds. Source this file, and
2 # you'll get a few mana- functions in your shell:
3 # - mana-configure-win32 -- runs cmake to configure the source tree
4 # for a win32 build
5 # - mana-build-win32 -- runs mana-configure-win32, followed by make
6 # - mana-build-translations -- copies the translations into a dir
7 # structure suitable for nsis
8 # - mana-build-nsis -- build the nsis installer (run the other stips
9 # first!)
10 # - mana-build-win32-installer -- runs all steps required to get the
11 # windows installer
12 # - mana-nuke-cmake-stuff -- cleans up all files created by cmake
13 #
14 # A few environement variables can influence those functions:
15 # - MANA_BASE -- mana source top directory. Automatically set when
16 # you source this file from the top directory, or the windows packaging
17 # directory
18 # - VERSION -- read from CMakeLists.txt if not specified
19 # - TOOLCHAINFILE -- the cmake toolchainfile, searched in top dir,
20 # your home, and /build/nightlies. See toolchain.cmake.example
21 # for an example file
22 # - MANALIBS -- the directory containing the dlls copied into the
23 # windows installer. Default is using the last directory in the
24 # toolchains SET(CMAKE_FIND_ROOT_PATH
25 #
26 # Also, please note that the untgz nsis Plugins is needed to create
27 # an installer.
28 # The default nsis Plugins folder in most Linux distros is:
29 # in /usr/share/nsis/Plugins/
30 #
31 # The default folder to use the toolchain in most Linux distros is:
32 # /usr/i586msvc-mingw32/
33
34 # MANA_BASE should point to the top directory of the source tree
35 if [ -z "$MANA_BASE" ]; then
36 if [ -f INSTALL ]; then
37 MANA_BASE=`pwd`
38 elif [ -f setup.nsi ]; then
39 cd ../.. && MANA_BASE=`pwd`
40 else
41 echo "Unable to guess mana base directory, please set MANA_BASE manually"
42 fi
43 else
44 echo "MANA_BASE already set to $MANA_BASE, ignoring"
45 fi
46
47 if [ -z "$VERSION" ]; then
48 VERSION=`grep 'SET(VERSION .*)' $MANA_BASE/CMakeLists.txt | \
49 sed 's/.* //' | sed 's/)//'`
50 fi
51 echo "Building for version $VERSION"
52
53 if [ -z "`which unix2dos`" ]; then
54 echo "You're missing unix2dos. Please install it (probably in dos2unix)."
55 fi
56
57 # TOOLCHAINFILE should point to a cmake toolchain file,
58 # see toolchain.cmake.example
59 if [ -z "$TOOLCHAINFILE" ]; then
60 if [ -f $MANA_BASE/toolchain.cmake ]; then
61 TOOLCHAINFILE=$MANA_BASE/toolchain.cmake
62 elif [ -f ~/toolchain.cmake ]; then
63 TOOLCHAINFILE=~/.toolchain.cmake
64 elif [ -f /build/nightlies/toolchain.cmake ]; then
65 TOOLCHAINFILE=/build/nightlies/toolchain.cmake
66 else
67 echo "Unable to find a toolchain file, please set TOOLCHAINFILE manually"
68 fi
69 else
70 echo "TOOLCHAINFILE already set to $TOOLCHAINFILE, ignoring"
71 fi
72
73 if [ -z "$MANALIBS" ]; then
74 MANALIBS=`grep 'SET(CMAKE_FIND_ROOT_PATH ' $TOOLCHAINFILE | \
75 sed 's/\s*)\s*//' | sed 's/.* //'`
76 if [ -z "$MANALIBS" ]; then
77 echo "Unable to guess library directory for MANALIBS"
78 fi
79 fi
80
81 # configure the build tree for a cross-build, which can be built
82 # by just typing 'make'
83 mana-configure-win32(){
84 cd $MANA_BASE
85 cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVERSION=$VERSION \
86 -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINFILE
87 }
88
89 mana-build-win32(){
90 mana-configure-win32
91 make
92 }
93
94 # build the translations for use in the nsi
95 mana-build-translations(){
96 cd $MANA_BASE/po
97 for i in *.gmo; do
98 _LC=`echo $i|sed 's/\..*//'`
99 mkdir -p ../translations/$_LC/LC_MESSAGES
100 cp -v $i ../translations/$_LC/LC_MESSAGES/mana.mo
101 done
102 }
103
104 mana-build-nsis(){
105 unix2dos -n $MANA_BASE/README $MANA_BASE/README.txt
106 cd $MANA_BASE/packaging/windows
107 makensis -DDLLDIR=$MANALIBS/lib -DPRODUCT_VERSION=$VERSION -DUPX=true -DEXESUFFIX=/src setup.nsi
108 }
109
110 # do everything...
111 mana-build-win32-installer(){
112 mana-configure-win32
113 mana-build-win32
114 mana-build-translations
115 mana-build-nsis
116 }
117
118 mana-nuke-cmake-stuff(){
119 find $MANA_BASE -name CMakeFiles -type d -exec rm -Rf '{}' \; 2>/dev/null
120 find $MANA_BASE -name CMakeCache.txt -type f -exec rm '{}' \; 2>/dev/null
121 }