Browse Source

Use boost::chrono instead of std::chrono

Eduardo Bart 8 years ago
parent
commit
50c2db100e
3 changed files with 72 additions and 47 deletions
  1. 1
    2
      src/framework/CMakeLists.txt
  2. 4
    4
      src/framework/stdext/time.cpp
  3. 67
    41
      tools/make_snapshot.sh

+ 1
- 2
src/framework/CMakeLists.txt View File

@@ -173,11 +173,10 @@ message(STATUS "Build revision: ${BUILD_REVISION}")
173 173
 add_definitions(-D"BUILD_REVISION=\\\"${BUILD_REVISION}\\\"")
174 174
 
175 175
 # find boost
176
-set(REQUIRED_BOOST_COMPONENTS locale system filesystem regex thread)
176
+set(REQUIRED_BOOST_COMPONENTS locale system filesystem regex thread chrono)
177 177
 if(WIN32)
178 178
     set(Boost_THREADAPI win32)
179 179
     set(framework_DEFINITIONS ${framework_DEFINITIONS} -DBOOST_THREAD_USE_LIB) # fix boost thread linkage
180
-    set(REQUIRED_BOOST_COMPONENTS ${REQUIRED_BOOST_COMPONENTS} chrono) # mingw32 does not have std::thread
181 180
 endif()
182 181
 set(Boost_USE_MULTITHREADED ON)
183 182
 set(Boost_USE_STATIC_LIBS ${USE_STATIC_LIBS})

+ 4
- 4
src/framework/stdext/time.cpp View File

@@ -21,19 +21,19 @@
21 21
  */
22 22
 
23 23
 #include "time.h"
24
-#include <chrono>
24
+#include <boost/chrono.hpp>
25 25
 #include <unistd.h>
26 26
 
27 27
 namespace stdext {
28 28
 
29
-const static auto startup_time = std::chrono::high_resolution_clock::now();
29
+const static auto startup_time = boost::chrono::high_resolution_clock::now();
30 30
 
31 31
 ticks_t millis()
32 32
 {
33
-    return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startup_time).count();
33
+    return boost::chrono::duration_cast<boost::chrono::milliseconds>(boost::chrono::high_resolution_clock::now() - startup_time).count();
34 34
 }
35 35
 ticks_t micros() {
36
-    return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - startup_time).count();
36
+    return boost::chrono::duration_cast<boost::chrono::microseconds>(boost::chrono::high_resolution_clock::now() - startup_time).count();
37 37
 }
38 38
 
39 39
 void millisleep(size_t ms)

+ 67
- 41
tools/make_snapshot.sh View File

@@ -9,7 +9,22 @@ mingwplatform="i486-mingw32"
9 9
 mingwbin="/usr/$mingwplatform/bin"
10 10
 makejobs=4
11 11
 
12
-[ "$1" == "--replace" ] && replace=true || replace=false
12
+replace=false
13
+rebuild=true
14
+for arg in "$@"; do
15
+    case "$arg" in
16
+        --no-rebuild)
17
+            rebuild=false
18
+            ;;
19
+        --replace)
20
+            replace=true
21
+            ;;
22
+        *)
23
+            echo "usage: $0 [--replace] [--no-rebuild]"
24
+            exit
25
+            ;;
26
+    esac
27
+done
13 28
 
14 29
 # setup work directory
15 30
 mkdir -p $workdir
@@ -25,58 +40,71 @@ fi
25 40
 
26 41
 cd $workdir/otclient
27 42
 revision=`git rev-list --all | wc -l`
28
-commit=`git describe --dirty --always`
43
+commit=`git describe --always`
29 44
 version=`cat CMakeLists.txt | grep "set(VERSION" | sed 's/.*"\([^"]*\)".*/\1/'`
30 45
 
31
-# set flags
46
+# build for i686
32 47
 export CFLAGS="-march=i686 -m32"
33 48
 export CXXFLAGS="-march=i686 -m32"
34 49
 export LDFLAGS="-march=i686 -m32"
35 50
 
51
+LIBPATH=/usr/lib
52
+if [ -d /usr/lib32 ]; then
53
+    LIBPATH=/usr/lib32
54
+fi
55
+
56
+if $rebuild; then
57
+    rm -rf build.win32
58
+    rm -rf build.win32dx9
59
+    rm -rf build.linux32
60
+fi
61
+
36 62
 # compile for win32
37
-rm -rf build.win32
38
-mkdir build.win32
63
+mkdir -p build.win32
39 64
 cd build.win32
40
-cmake -DCMAKE_TOOLCHAIN_FILE=$workdir/otclient/src/framework/cmake/${mingwplatform}_toolchain.cmake \
41
-    -DCMAKE_BUILD_TYPE=Release \
42
-    -DBOT_PROTECTION=OFF \
43
-    -DBUILD_REVISION=$revision \
44
-    -DBUILD_COMMIT=$commit \
45
-    .. || exit
65
+if $rebuild; then
66
+    cmake -DCMAKE_TOOLCHAIN_FILE=$workdir/otclient/src/framework/cmake/${mingwplatform}_toolchain.cmake \
67
+        -DCMAKE_BUILD_TYPE=Release \
68
+        -DBOT_PROTECTION=OFF \
69
+        -DBUILD_REVISION=$revision \
70
+        -DBUILD_COMMIT=$commit \
71
+        .. || exit
72
+fi
46 73
 make -j$makejobs || exit
47 74
 cd ..
48 75
 
49 76
 # compile for win32
50
-rm -rf build.win32dx9
51
-mkdir build.win32dx9
77
+mkdir -p build.win32dx9
52 78
 cd build.win32dx9
53
-cmake -DCMAKE_TOOLCHAIN_FILE=$workdir/otclient/src/framework/cmake/${mingwplatform}_toolchain.cmake \
54
-    -DCMAKE_BUILD_TYPE=Release \
55
-    -DBOT_PROTECTION=OFF \
56
-    -DOPENGLES=2.0 \
57
-    -DBUILD_REVISION=$revision \
58
-    -DBUILD_COMMIT=$commit \
59
-    .. || exit
79
+if $rebuild; then
80
+    cmake -DCMAKE_TOOLCHAIN_FILE=$workdir/otclient/src/framework/cmake/${mingwplatform}_toolchain.cmake \
81
+        -DCMAKE_BUILD_TYPE=Release \
82
+        -DBOT_PROTECTION=OFF \
83
+        -DOPENGLES=2.0 \
84
+        -DBUILD_REVISION=$revision \
85
+        -DBUILD_COMMIT=$commit \
86
+        .. || exit
87
+fi
60 88
 make -j$makejobs || exit
61 89
 cd ..
62 90
 
63
-# compile for linux 64
64
-rm -rf build.linux32
65
-mkdir build.linux32
91
+# compile for linux32
92
+mkdir -p build.linux32
66 93
 cd build.linux32
67
-export CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"
68
-export LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
69
-cmake -DCMAKE_BUILD_TYPE=Release \
70
-    -DBOT_PROTECTION=OFF \
71
-    -DBUILD_REVISION=$revision \
72
-    -DBUILD_COMMIT=$commit \
73
-    .. || exit
94
+if $rebuild; then
95
+    cmake -DCMAKE_BUILD_TYPE=Release \
96
+        -DBOT_PROTECTION=OFF \
97
+        -DBUILD_REVISION=$revision \
98
+        -DBUILD_COMMIT=$commit \
99
+        -DCMAKE_LIBRARY_PATH=$LIBPATH \
100
+        .. || exit
101
+fi
74 102
 make -j$makejobs || exit
75 103
 cd ..
76 104
 
77 105
 ##################################################
78 106
 # create win32 package
79
-pkg_suffix="-linux64-$version"
107
+pkg_suffix="-linux32-$version"
80 108
 pkgname="$name$pkg_suffix"
81 109
 pkgzip="$pkgname.tgz"
82 110
 cd $workdir
@@ -85,10 +113,12 @@ mkdir $pkgname
85 113
 cd $pkgname
86 114
 
87 115
 # copy otclient files
88
-cp -R $workdir/otclient/mods .
116
+mkdir mods
117
+cp $workdir/otclient/mods/README.txt mods/
89 118
 cp -R $workdir/otclient/modules .
90
-cp $workdir/otclient/build.linux64/otclient .
91
-cp $workdir/otclient/build.linux64/otclient.map .
119
+cp -R $workdir/otclient/data .
120
+cp $workdir/otclient/build.linux32/otclient .
121
+cp $workdir/otclient/build.linux32/otclient.map .
92 122
 cp $workdir/otclient/init.lua .
93 123
 cp $workdir/otclient/otclientrc.lua .
94 124
 cp $workdir/otclient/BUGS .
@@ -129,7 +159,8 @@ mkdir $pkgname
129 159
 cd $pkgname
130 160
 
131 161
 # copy otclient files
132
-cp -R $workdir/otclient/mods .
162
+mkdir mods
163
+cp $workdir/otclient/mods/README.txt mods/
133 164
 cp -R $workdir/otclient/modules .
134 165
 cp -R $workdir/otclient/data .
135 166
 cp $mingwbin/libEGL.dll .
@@ -146,7 +177,7 @@ cp $workdir/otclient/AUTHORS AUTHORS.txt
146 177
 cp $workdir/otclient/BUGS BUGS.txt
147 178
 cp $workdir/otclient/LICENSE LICENSE.txt
148 179
 cp $workdir/otclient/README.md README.txt
149
-unix2dos LICENSE.txt README.txt BUGS.txt AUTHORS.txt
180
+unix2dos LICENSE.txt README.txt BUGS.txt AUTHORS.txt mods/README.txt
150 181
 
151 182
 # remove git files
152 183
 find -name '.git*' -exec rm -rf {} \;
@@ -171,11 +202,6 @@ zip -9 -qr $pkgzip $pkgname
171 202
 echo "Package generated to $pkgzip"
172 203
 
173 204
 # test win32 otclient
174
-mkdir otclient/modules/game_tibiafiles/860/
175
-cp $workdir/Tibia/*.spr otclient/modules/game_tibiafiles/860/
176
-cp $workdir/Tibia/*.dat otclient/modules/game_tibiafiles/860/
177
-
178
-
179 205
 cd otclient
180 206
 wine build.win32/otclient.exe
181 207
 rm -f *.log

Loading…
Cancel
Save