2
0
Эх сурвалжийг харах

Merge pull request #129 from tsoding/separate-stb-compilation

Compile stb libs into objects file for debug build
Alexey Kutepov 5 жил өмнө
parent
commit
b722f1ca2e
4 өөрчлөгдсөн 22 нэмэгдсэн , 11 устгасан
  1. 2 1
      .gitignore
  2. 13 4
      Makefile
  3. 7 3
      src/vodus.cpp
  4. 0 3
      src/vodus_main.cpp

+ 2 - 1
.gitignore

@@ -8,4 +8,5 @@ emotes/
 TAGS
 /mapping.csv
 .vscode/
-diffimg
+diffimg
+*.o

+ 13 - 4
Makefile

@@ -18,11 +18,20 @@ DIFFIMG_CXXFLAGS=-Wall -fno-exceptions -std=c++17 -ggdb
 .PHONY: all
 all: vodus.release vodus.debug emote_downloader diffimg Makefile
 
-vodus.release: $(wildcard src/vodus*.cpp) $(wildcard src/core*.cpp)
-	$(CXX) $(VODUS_CXXFLAGS) -O3 -o vodus.release src/vodus.cpp $(VODUS_LIBS)
+vodus.release: $(wildcard src/vodus*.cpp) $(wildcard src/core*.cpp) $(wildcard src/stb_image*.h)
+	$(CXX) $(VODUS_CXXFLAGS) -DVODUS_RELEASE -O3 -o vodus.release src/vodus.cpp $(VODUS_LIBS)
 
-vodus.debug: $(wildcard src/vodus*.cpp) $(wildcard src/core*.cpp)
-	$(CXX) $(VODUS_CXXFLAGS) -O0 -fno-builtin -o vodus.debug src/vodus.cpp $(VODUS_LIBS)
+vodus.debug: $(wildcard src/vodus*.cpp) $(wildcard src/core*.cpp) stb_image.o stb_image_resize.o stb_image_write.o
+	$(CXX) $(VODUS_CXXFLAGS) -O0 -fno-builtin -o vodus.debug src/vodus.cpp $(VODUS_LIBS) stb_image.o stb_image_resize.o stb_image_write.o
+
+stb_image.o: src/stb_image.h
+	$(CC) $(CFLAGS) -x c -ggdb -DSTBI_ONLY_PNG -DSTB_IMAGE_IMPLEMENTATION -c -o stb_image.o src/stb_image.h
+
+stb_image_resize.o: src/stb_image_resize.h
+	$(CC) $(CFLAGS) -x c -ggdb -DSTB_IMAGE_RESIZE_IMPLEMENTATION -c -o stb_image_resize.o src/stb_image_resize.h
+
+stb_image_write.o: src/stb_image_write.h
+	$(CC) $(CFLAGS) -x c -ggdb -DSTB_IMAGE_WRITE_IMPLEMENTATION -c -o stb_image_write.o src/stb_image_write.h
 
 emote_downloader: src/emote_downloader.cpp $(wildcard src/core*.cpp)
 	$(CXX) $(EMOTE_DOWNLOADER_CXXFLAGS) -o emote_downloader src/emote_downloader.cpp $(EMOTE_DOWNLOADER_LIBS)

+ 7 - 3
src/vodus.cpp

@@ -10,11 +10,15 @@
 #include <ft2build.h>
 #include FT_FREETYPE_H
 #include <gif_lib.h>
-#define STB_IMAGE_IMPLEMENTATION
+
+#ifdef VODUS_RELEASE
+#    define STB_IMAGE_IMPLEMENTATION
+#    define STB_IMAGE_RESIZE_IMPLEMENTATION
+#    define STB_IMAGE_WRITE_IMPLEMENTATION
+#endif // VODUS_RELEASE
+
 #include "./stb_image.h"
-#define STB_IMAGE_RESIZE_IMPLEMENTATION
 #include "./stb_image_resize.h"
-#define STB_IMAGE_WRITE_IMPLEMENTATION
 #include "./stb_image_write.h"
 
 extern "C" {

+ 0 - 3
src/vodus_main.cpp

@@ -127,9 +127,6 @@ int main(int argc, char *argv[])
     Emote_Cache emote_cache = { };
     emote_cache.populate_from_file("./mapping.csv", params.font_size);
 
-    // FFMPEG INIT START //////////////////////////////
-    // FFMPEG INIT STOP //////////////////////////////
-
     // TODO(#35): log is not retrived directly from the Twitch API
     //   See https://github.com/PetterKraabol/Twitch-Chat-Downloader
     if (input_filepath == nullptr) {