From 57cafd1fe1243077c63fd589d54d0efdd53ab3cd Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 22 Apr 2015 21:06:35 -0400 Subject: [PATCH] A lot of makefile tweaks --- Makefile | 48 ++++++++++++++++++++++------------------ config/themes.json | 13 ++++++----- include/jsoncpp.cpp | 2 +- src/common.h | 8 +++++++ src/network/SFTP.h | 1 + src/settings/Config.h | 5 ----- src/widgets/EditPane.cpp | 2 +- 7 files changed, 44 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index 745f322..af5d206 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,8 @@ -#Try using clang, if it's installed -ifneq (`command -v clang`,) - CC = clang - CXX = clang++ -endif +CXX += -I include -CXX += -Iinclude - -SOURCES = $(wildcard include/**/*.cpp src/network/*.cpp src/settings/*.cpp include/*.cpp) +SOURCES = $(wildcard include/**/*.cpp include/*.cpp src/settings/*.cpp) OBJECTS = $(patsubst %.cpp,%.o, $(SOURCES)) -TARGET = build/Tyro.a +TYRO_LIB = build/Tyro.a JSON_FILES = $(patsubst config/%.json,%.json, $(wildcard config/*.json)) @@ -16,12 +10,10 @@ PROGRAM_SRC = $(wildcard src/*.cpp src/widgets/*.cpp) PROGRAM = build/Tyro PROGRAM_OBJECTS = $(patsubst %.cpp,%.o, $(PROGRAM_SRC)) -WX_LDLIBS = $(shell wx-config --libs base core aui stc adv) -lssh2 +WX_LDLIBS = $(shell wx-config --libs base core aui stc adv) WX_CXXFLAGS = $(shell wx-config --cxxflags) WX_RES = $(shell wx-config --rescomp) -LDLIBS = $(TARGET) - DEV_CXXFLAGS = -g -Wall -Wextra -DDEBUG CXXFLAGS = -Os -DNDEBUG @@ -30,17 +22,22 @@ TESTS = $(patsubst %.cpp,%,$(TEST_SRC)) OS ?= $(shell uname -s) +LDLIBS = + ifeq ($(OS),Darwin) CXX += -std=c++98 -mmacosx-version-min=10.5 -else +endif +ifeq ($(OS),Linux) CXX += -std=c++11 endif - ifeq ($(OS),Windows_NT) - LDLIBS += -L/lib + CXX += -I/include -DWIN32 + LDLIBS += -L/lib -lwsock32 endif -all: build json_wrapper $(TARGET) $(PROGRAM) +LDLIBS += -lssh2 + +all: build json_wrapper $(TYRO_LIB) $(PROGRAM) dev: CXXFLAGS= $(DEV_CXXFLAGS) dev: all @@ -54,14 +51,19 @@ json_wrapper_build: build: @mkdir -p build -$(TARGET): $(OBJECTS) +sftp_o: + $(CXX) $(CXXFLAGS) $(LDLIBS) -c -o src/network/SFTP.o src/network/SFTP.cpp + +$(TYRO_LIB): build sftp_o +$(TYRO_LIB): OBJECTS += src/network/SFTP.o +$(TYRO_LIB): $(OBJECTS) ar rcs $@ $(OBJECTS) ranlib $@ -$(PROGRAM): CXXFLAGS += $(WX_CXXFLAGS) $(TARGET) +$(PROGRAM): CXXFLAGS += $(WX_CXXFLAGS) $(TYRO_LIB) $(PROGRAM): - $(CXX) $(WX_CXXFLAGS) $(PROGRAM_SRC) $(LDLIBS) $(WX_LDLIBS) -o $(PROGRAM) + $(CXX) $(CXXFLAGS) $(PROGRAM_SRC) $(TYRO_LIB) $(WX_LDLIBS) -o $(PROGRAM) run: @@ -91,7 +93,7 @@ exe: msw_resource all # OS X application bundle Tyro.app: all resources/platform/osx/Info.plist - SetFile -t APPL $(TARGET) + SetFile -t APPL $(TYRO_LIB) -mkdir Tyro.app -mkdir Tyro.app/Contents -mkdir Tyro.app/Contents/MacOS @@ -102,8 +104,10 @@ Tyro.app: all resources/platform/osx/Info.plist cp build/Tyro Tyro.app/Contents/MacOS/Tyro cp resources/platform/osx/tyro.icns Tyro.app/Contents/Resources/ +$(TESTS): $(TYRO_LIB) + $(foreach var, $(TEST_SRC), $(CXX) $(CXXFLAGS) $(var) $(TYRO_LIB) -o $(patsubst %.cpp,%, $(var));) + .PHONY: tests -tests: LDLIBS = $(TARGET) -lssh2 tests: $(TESTS) sh ./tests/runtests.sh @@ -114,6 +118,6 @@ clean: rm -f config/*_json.h rm -rf *.o rm -rf Tyro.app - rm -rf build $(OBJECTS) $(PROGRAM) $(TARGET) $(TESTS) + rm -rf build $(OBJECTS) $(PROGRAM) $(TYRO_LIB) $(TESTS) find . -name "*.gc*" -exec rm {} \; rm -rf `find . -name "*.dSYM" -print` diff --git a/config/themes.json b/config/themes.json index a3dc451..8e80638 100644 --- a/config/themes.json +++ b/config/themes.json @@ -23,12 +23,12 @@ }, "foreground": { "default": [101, 123, 131], - "keyword1": [133, 153, 0], - "keyword2": [42, 161, 152], + "keyword1": [220, 50, 47], + "keyword2": [203, 75, 22], "keyword3": [181, 137, 0], - "keyword4": [181, 137, 0], - "keyword5": [181, 137, 0], - "keyword6": [181, 137, 0], + "keyword4": [133, 153, 0], + "keyword5": [42, 161, 152], + "keyword6": [38, 139, 210], "comment": [147, 161, 161], "comment_line": [147, 161, 161], "comment_doc": [131, 148, 150], @@ -55,6 +55,7 @@ "error": [220, 50, 47] }, "bold": { + "keyword1": true, "keyword2": true, "operator": true, "label": true, @@ -71,4 +72,4 @@ "background": [238, 232, 213] } } -} \ No newline at end of file +} diff --git a/include/jsoncpp.cpp b/include/jsoncpp.cpp index bd5bf83..a6b47fb 100644 --- a/include/jsoncpp.cpp +++ b/include/jsoncpp.cpp @@ -73,7 +73,7 @@ license you like. -#include "json/json.h" +#include #ifndef JSON_IS_AMALGAMATION #error "Compile with -I PATH_TO_JSON_DIRECTORY" diff --git a/src/common.h b/src/common.h index 75cea5e..580a324 100644 --- a/src/common.h +++ b/src/common.h @@ -4,6 +4,7 @@ #ifndef TYRO_COMMON_H #define TYRO_COMMON_H +// C++ Standard Lib includes #include #include #include @@ -14,5 +15,12 @@ using namespace std; +// JSON +#include + +typedef Json::Value JsonValue; +typedef Json::Reader JsonReader; +typedef Json::Writer JsonWriter; + #endif // TYRO_COMMON_H diff --git a/src/network/SFTP.h b/src/network/SFTP.h index dd236de..d81aa17 100644 --- a/src/network/SFTP.h +++ b/src/network/SFTP.h @@ -15,6 +15,7 @@ #ifdef WIN32 // Define this so I actually get functions out of the windows header file + #undef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #include #else diff --git a/src/settings/Config.h b/src/settings/Config.h index 022f650..1cac70c 100644 --- a/src/settings/Config.h +++ b/src/settings/Config.h @@ -2,11 +2,6 @@ #define TYRO_CONFIG_H #include "../common.h" -#include - -typedef Json::Value JsonValue; -typedef Json::Reader JsonReader; -typedef Json::Writer JsonWriter; class TyroConfig { public: diff --git a/src/widgets/EditPane.cpp b/src/widgets/EditPane.cpp index 562d03d..d275f9e 100644 --- a/src/widgets/EditPane.cpp +++ b/src/widgets/EditPane.cpp @@ -134,7 +134,7 @@ void EditPane::ApplyTheme(string lang, string theme) JsonValue keywords_array = this->GetKeywordList(lang); if (keywords_array.isArray()) { - for(int i = 0; i < keywords_array.size(); i++) + for(unsigned int i = 0; i < keywords_array.size(); i++) { this->SetKeyWords(i, keywords_array[i].asString()); }