From 0fc558acb684dfe17d2679424f096f10db9785b4 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Wed, 19 Jul 2017 19:50:05 +0300 Subject: [PATCH] WIP clang makefile (doesn't link) --- makefile | 31 ++++++++++++++++++++++++++----- src/gui/im/Schema.cpp | 7 ++++--- src/hacks/LagExploit.cpp | 2 +- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/makefile b/makefile index ad5065d4..e25d84fb 100644 --- a/makefile +++ b/makefile @@ -1,19 +1,32 @@ +ifndef CLANG CXX=$(shell sh -c "which g++-6 || which g++") CC=$(shell sh -c "which gcc-6 || which gcc") +LD=$(CXX) +else +CXX=clang++ +CC=clang +LD=ld.lld +endif DEFINES=_GLIBCXX_USE_CXX11_ABI=0 _POSIX=1 FREETYPE_GL_USE_VAO RAD_TELEMETRY_DISABLED LINUX=1 USE_SDL _LINUX=1 POSIX=1 GNUC=1 NO_MALLOC_OVERRIDE WARNING_FLAGS=-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -COMMON_FLAGS=-fpermissive -O3 -shared -Wno-unknown-pragmas -fmessage-length=0 -m32 -fvisibility=hidden -fPIC -march=native +COMMON_FLAGS=-fpermissive -O3 -shared -Wno-unknown-pragmas -fmessage-length=0 -m32 -fvisibility=hidden -fPIC -march=native -mtune=native + +ifdef CLANG +COMMON_FLAGS+=-Wno-c++11-narrowing +endif ifdef BUILD_DEBUG COMMON_FLAGS+=-g3 -ggdb else +ifndef CLANG COMMON_FLAGS+=-flto endif +endif CFLAGS=$(COMMON_FLAGS) -CXXFLAGS=-std=gnu++1z $(COMMON_FLAGS) +CXXFLAGS=-std=gnu++14 $(COMMON_FLAGS) ifndef NO_WARNINGS CFLAGS+=$(WARNING_FLAGS) @@ -27,11 +40,19 @@ SDKFOLDER=$(realpath source-sdk-2013/mp/src) SIMPLE_IPC_DIR = $(realpath simple-ipc/src/include) INCLUDES=-Iucccccp -isystemsrc/freetype-gl -isystemsrc/imgui -isystem/usr/local/include/freetype2 -isystem/usr/include/freetype2 -I$(SIMPLE_IPC_DIR) -isystem$(SDKFOLDER)/public -isystem$(SDKFOLDER)/mathlib -isystem$(SDKFOLDER)/common -isystem$(SDKFOLDER)/public/tier1 -isystem$(SDKFOLDER)/public/tier0 -isystem$(SDKFOLDER) LIB_DIR=lib -LDFLAGS=-m32 -fno-gnu-unique -D_GLIBCXX_USE_CXX11_ABI=0 -shared -L$(realpath $(LIB_DIR)) +LDFLAGS=-shared -L$(realpath $(LIB_DIR)) +ifdef CLANG +LDFLAGS+=-melf_i386 +else +LDFLAGS+=-m32 -fno-gnu-unique +endif + ifndef BUILD_DEBUG +ifndef CLANG LDFLAGS+=-flto endif -LDLIBS=-static -lc -lstdc++ -ltier0 -lvstdlib -l:libSDL2-2.0.so.0 -static -lGLEW -lfreetype -lpthread +endif +LDLIBS=-l:libSDL2-2.0.so.0 -static -l:libc.so.6 -static -l:libstdc++.so.6 -l:libtier0.so -l:libvstdlib.so -static -l:libGLEW.so -l:libfreetype.so SRC_DIR = src RES_DIR = res OUT_NAME = libcathook.so @@ -126,7 +147,7 @@ src/sdk/utlbuffer.o : CFLAGS+=-w $(TARGET): $(OBJECTS) @echo Building cathook - @$(CXX) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $(TARGET) + $(LD) -o $(TARGET) $(LDFLAGS) $(OBJECTS) $(LDLIBS) clean: find src -type f -name '*.o' -delete diff --git a/src/gui/im/Schema.cpp b/src/gui/im/Schema.cpp index c264a95f..3cbe0c50 100644 --- a/src/gui/im/Schema.cpp +++ b/src/gui/im/Schema.cpp @@ -7,6 +7,8 @@ #include "Schema.hpp" + +#include "../../helpers.h" #include "../../cvwrapper.h" #include "../../logging.h" @@ -23,13 +25,12 @@ CatVar* FindCatVar(const std::string name) { ListEntry_Dummy* FromJson(nlohmann::json json) { if (json.is_string()) { const std::string var_name = json; - logging::Info("[Debug] Variable: %s", var_name.c_str()); ListEntry_Dummy* cv; try { cv = (ListEntry_Dummy*)(new ListEntry_Variable(*FindCatVar(var_name))); } catch (std::runtime_error& er) { logging::Info("[Error] %s", er.what()); - cv = (ListEntry_Dummy*)(new ListEntry_Label("malformed object")); + cv = (ListEntry_Dummy*)(new ListEntry_Label(format("[", var_name, "]"))); } return cv; } else if (json.is_object()) { @@ -129,7 +130,7 @@ CatCommand reloadscheme("reloadscheme", "Reload Scheme", []() { } for (const auto& v : CatVarList()) { if (map_present.find(v) == map_present.end()) { - logging::Info("%s is not in any list!", v->name.c_str()); + logging::Info("%s is not present in the GUI!", v->name.c_str()); } } //TraverseList(&main_list); diff --git a/src/hacks/LagExploit.cpp b/src/hacks/LagExploit.cpp index 4799835d..09d4409e 100644 --- a/src/hacks/LagExploit.cpp +++ b/src/hacks/LagExploit.cpp @@ -12,7 +12,7 @@ namespace hacks { namespace shared { namespace lagexploit { CatVar toggle(CV_SWITCH, "removecond_toggle", "0", "Toggle Lag Exploit", "Toggle lag exploit (RemoveCond)"); CatVar key(CV_KEY, "removecond_key", "0", "RemoveCond Key"); CatVar lagMasterSwitch(CV_SWITCH, "removecond_master", "1", "Master Lag Exploit Switch", "Master switch for the lag exploit\nDisabling this disables everything else that uses remove conds"); -CatVar lagValue(CV_INT, "removecond_value", "450", "RemoveCond Value", "Value of user cmds to spam with"); +CatVar lagValue(CV_INT, "removecond_value", "900", "RemoveCond Value", "Value of user cmds to spam with"); CatCommand do_lagexploit("removecond", "RemoveCond (for use in scripts)", []() { AddExploitTicks(6);