Sfoglia il codice sorgente

Travis steps in own scripts

Thomas Buck 10 anni fa
parent
commit
3cd82ede59

+ 6
- 8
.travis.yml Vedi File

@@ -5,18 +5,16 @@ compiler:
5 5
     - gcc
6 6
 
7 7
 before_install:
8
-    - sudo add-apt-repository -y ppa:zoogie/sdl2-snapshots
9
-    - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
10
-    - sudo apt-get -qq -y update
8
+    - if [ "$TRAVIS_OS_NAME" = "linux" ]; then cmake/travis_before_install_linux.sh; fi
9
+    - if [ "$TRAVIS_OS_NAME" = "osx" ]; then cmake/travis_before_install_mac.sh; fi
11 10
 
12 11
 install:
13
-    - sudo apt-get -qq -y install libsdl2-dev libsdl2-ttf-dev libalut-dev libpng12-dev zlib1g-dev
14
-    - if [ "$CC" = "gcc" ]; then sudo apt-get install gcc-4.8; fi
15
-    - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8; fi
12
+    - if [ "$TRAVIS_OS_NAME" = "linux" ]; then cmake/travis_install_linux.sh; fi
13
+    - if [ "$TRAVIS_OS_NAME" = "osx" ]; then cmake/travis_install_mac.sh; fi
16 14
 
17 15
 before_script:
18
-    - if [ "$CC" = "gcc" ]; then export CC="gcc-4.8"; fi
19
-    - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8"; fi
16
+    - if [ "$TRAVIS_OS_NAME" = "linux" ]; then cmake/travis_before_script_linux.sh; fi
17
+    - if [ "$TRAVIS_OS_NAME" = "osx" ]; then cmake/travis_before_script_mac.sh; fi
20 18
 
21 19
 script:
22 20
     - (mkdir build && cd build && cmake .. && make)

+ 6
- 4
CMakeLists.txt Vedi File

@@ -32,12 +32,14 @@ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
32 32
 
33 33
 # Compiler specific flags
34 34
 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
35
-    set (WARNINGS "${WARNINGS} -Weverything -Wno-padded -Wno-packed")
35
+    set (WARNINGS "${WARNINGS} -Weverything")
36
+    set (WARNINGS "${WARNINGS} -Wno-padded -Wno-packed")
36 37
     set (WARNINGS "${WARNINGS} -Wno-global-constructors -Wno-exit-time-destructors")
37 38
     set (WARNINGS "${WARNINGS} -Wno-documentation-unknown-command -Wno-c++98-compat-pedantic")
38
-    set (WARNINGS "${WARNINGS} -Wno-missing-prototypes -Wno-missing-variable-declarations")
39
-    set (WARNINGS "${WARNINGS} -Wno-disabled-macro-expansion")
40
-    set (WARNINGS "${WARNINGS} -Wno-shorten-64-to-32 -Wno-sign-conversion")
39
+
40
+    set (WARNINGS "${WARNINGS} -Wno-sign-conversion")
41
+    #set (WARNINGS "${WARNINGS} -Wno-shorten-64-to-32")
42
+
41 43
     set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11")
42 44
     set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0 -ftrapv")
43 45
     set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -O2 -fomit-frame-pointer")

+ 2
- 1
ChangeLog.md Vedi File

@@ -3,7 +3,8 @@
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5 5
     [ 20140705 ]
6
-    * Added basic Travis CI support (Linux + clang only)
6
+    * Added basic Travis CI support
7
+    * Removed global object, using lazy initialization
7 8
 
8 9
     [ 20140704 ]
9 10
     * Removed unnecessary #include dependencies

+ 3
- 4
TODO.md Vedi File

@@ -30,8 +30,7 @@
30 30
 
31 31
 # Travis CI
32 32
 
33
-* Currently only building on Linux with clang, SDL, SDL_TTF, ALUT and PNG
34
-* Should also build with gcc, but needs newer gcc (4.8) with C++11 support
35
-* Should also build on Mac, but needs different before_install / install scripts,
36
-  that can detect the platform they’re running on
33
+* Currently only building on Linux
34
+    * Should also build on Mac, but needs different before_install / install scripts,
35
+      that can detect the platform they’re running on
37 36
 

+ 0
- 0
cmake/setup_mac.sh Vedi File


+ 0
- 0
cmake/setup_win.bat Vedi File


+ 6
- 0
cmake/travis_before_install_linux.sh Vedi File

@@ -0,0 +1,6 @@
1
+#!/bin/bash
2
+
3
+sudo add-apt-repository -y ppa:zoogie/sdl2-snapshots
4
+sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
5
+sudo apt-get -qq -y update
6
+

+ 3
- 0
cmake/travis_before_install_mac.sh Vedi File

@@ -0,0 +1,3 @@
1
+#!/bin/bash
2
+
3
+

+ 5
- 0
cmake/travis_before_script_linux.sh Vedi File

@@ -0,0 +1,5 @@
1
+#!/bin/bash
2
+
3
+if [ "$CC" = "gcc" ]; then export CC="gcc-4.8"; fi
4
+if [ "$CXX" = "g++" ]; then export CXX="g++-4.8"; fi
5
+

+ 3
- 0
cmake/travis_before_script_mac.sh Vedi File

@@ -0,0 +1,3 @@
1
+#!/bin/bash
2
+
3
+

+ 6
- 0
cmake/travis_install_linux.sh Vedi File

@@ -0,0 +1,6 @@
1
+#!/bin/bash
2
+
3
+sudo apt-get -qq -y install libsdl2-dev libsdl2-ttf-dev libalut-dev libpng12-dev zlib1g-dev
4
+if [ "$CC" = "gcc" ]; then sudo apt-get install gcc-4.8; fi
5
+if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8; fi
6
+

+ 3
- 0
cmake/travis_install_mac.sh Vedi File

@@ -0,0 +1,3 @@
1
+#!/bin/bash
2
+
3
+

+ 23
- 26
src/main.cpp Vedi File

@@ -34,67 +34,64 @@
34 34
 #error No Windowing Library selected!
35 35
 #endif
36 36
 
37
-Camera gCamera;
38
-Console gConsole;
39
-FontManager gFont;
40
-Game gGame;
41
-Menu gMenu;
42
-OpenRaider gOpenRaider;
43
-Render gRender;
44
-TextureManager gTextureManager;
45
-World gWorld;
46
-
47
-#ifdef USING_AL
48
-SoundAL gSound;
49
-#else
50
-SoundNull gSound;
51
-#endif
52
-
53
-#ifdef USING_SDL
54
-WindowSDL gWindow;
55
-#endif
56
-
57 37
 Camera &getCamera() {
38
+    static Camera gCamera;
58 39
     return gCamera;
59 40
 }
60 41
 
61 42
 Console &getConsole() {
43
+    static Console gConsole;
62 44
     return gConsole;
63 45
 }
64 46
 
65 47
 Font &getFont() {
48
+    static FontManager gFont;
66 49
     return gFont;
67 50
 }
68 51
 
69 52
 Game &getGame() {
53
+    static Game gGame;
70 54
     return gGame;
71 55
 }
72 56
 
73 57
 Menu &getMenu() {
58
+    static Menu gMenu;
74 59
     return gMenu;
75 60
 }
76 61
 
77 62
 OpenRaider &getOpenRaider() {
63
+    static OpenRaider gOpenRaider;
78 64
     return gOpenRaider;
79 65
 }
80 66
 
81 67
 Render &getRender() {
68
+    static Render gRender;
82 69
     return gRender;
83 70
 }
84 71
 
85 72
 Sound &getSound() {
73
+#ifdef USING_AL
74
+    static SoundAL gSound;
75
+#else
76
+    static SoundNull gSound;
77
+#endif
86 78
     return gSound;
87 79
 }
88 80
 
89 81
 TextureManager &getTextureManager() {
82
+    static TextureManager gTextureManager;
90 83
     return gTextureManager;
91 84
 }
92 85
 
93 86
 Window &getWindow() {
87
+#ifdef USING_SDL
88
+    static WindowSDL gWindow;
89
+#endif
94 90
     return gWindow;
95 91
 }
96 92
 
97 93
 World &getWorld() {
94
+    static World gWorld;
98 95
     return gWorld;
99 96
 }
100 97
 
@@ -151,13 +148,13 @@ int main(int argc, char *argv[]) {
151 148
 
152 149
     // Try to load a configuration
153 150
     if (configArg) {
154
-        if (gOpenRaider.loadConfig(argv[1]) != 0) {
151
+        if (getOpenRaider().loadConfig(argv[1]) != 0) {
155 152
             std::cout << "Could not find the specified config file. Aborting..." << std::endl;
156 153
             return 2;
157 154
         }
158 155
     } else {
159
-        if (gOpenRaider.loadConfig(DEFAULT_CONFIG_FILE) != 0) {
160
-            if (gOpenRaider.loadConfig(DEFAULT_CONFIG_PATH "/" DEFAULT_CONFIG_FILE) != 0) {
156
+        if (getOpenRaider().loadConfig(DEFAULT_CONFIG_FILE) != 0) {
157
+            if (getOpenRaider().loadConfig(DEFAULT_CONFIG_PATH "/" DEFAULT_CONFIG_FILE) != 0) {
161 158
                 std::cout << "Could not find a config file. Aborting..." << std::endl;
162 159
                 return 3;
163 160
             }
@@ -165,15 +162,15 @@ int main(int argc, char *argv[]) {
165 162
     }
166 163
 
167 164
     // Initialize everything
168
-    int error = gOpenRaider.initialize();
165
+    int error = getOpenRaider().initialize();
169 166
     if (error != 0) {
170 167
         std::cout << "Could not initialize OpenRaider (" << error << ")!" << std::endl;
171 168
         return 4;
172 169
     }
173 170
 
174 171
     // Enter Main loop
175
-    gConsole.print("Starting %s", VERSION);
176
-    gOpenRaider.run();
172
+    getConsole().print("Starting %s", VERSION);
173
+    getOpenRaider().run();
177 174
 
178 175
     return 0;
179 176
 }

Loading…
Annulla
Salva