Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
lakwsh committed Nov 26, 2023
1 parent a8822ae commit 73fd863
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 313 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
- 'main'
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
schedule:
- cron: '30 03 01 */3 *'

jobs:
build_linux:
Expand All @@ -20,29 +25,24 @@ jobs:
sudo apt install gcc-5-multilib g++-5-multilib
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 100
- name: Checkout hl2sdk-l4d2
uses: actions/checkout@v3
with:
repository: lakwsh/hl2sdk-l4d2
path: hl2sdk-l4d2

- name: Checkout code
uses: actions/checkout@v3
with:
path: l4dtoolz

- name: Build L4DToolZ
working-directory: l4dtoolz
run: make all

- name: Upload L4DToolZ
uses: actions/upload-artifact@v3
with:
name: l4dtoolz-${{github.run_id}}
path: l4dtoolz/Release/l4dtoolz.so


build_windows:
runs-on: windows-2022
steps:
Expand All @@ -51,51 +51,41 @@ jobs:
with:
repository: lakwsh/hl2sdk-l4d2
path: hl2sdk-l4d2

- name: Checkout code
uses: actions/checkout@v3
with:
path: l4dtoolz

- name: Setup msbuild
uses: microsoft/[email protected]

- name: Build hl2sdk
working-directory: hl2sdk-l4d2
run: msbuild tier1\tier1-2005.vcxproj /p:Configuration=Release /p:Platform=Win32 -maxcpucount:8

- name: Build L4DToolZ
working-directory: l4dtoolz
run: msbuild l4dtoolz.vcxproj /p:Configuration=Release /p:Platform=Win32 -maxcpucount:8

- name: Upload L4DToolZ
uses: actions/upload-artifact@v3
with:
name: l4dtoolz-${{github.run_id}}
path: l4dtoolz/Release/l4dtoolz.dll


upload_files:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Upload README
uses: actions/upload-artifact@v3
with:
name: l4dtoolz-${{github.run_id}}
path: README.md

- name: Upload README_EN
uses: actions/upload-artifact@v3
with:
name: l4dtoolz-${{github.run_id}}
path: README_EN.md

- name: Download vdf
run: wget https://oss.lakwsh.net/l4dtoolz.vdf

- name: Upload vdf
uses: actions/upload-artifact@v3
with:
Expand Down
101 changes: 9 additions & 92 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,112 +1,29 @@
# (C)2004-2010 Metamod:Source Development Team
# Makefile written by David "BAILOPAN" Anderson

#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################

PROJECT = l4dtoolz
OBJECTS = l4dtoolz.cpp signature.cpp

##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
##############################################

OPT_FLAGS = -Ofast -pipe
GCC4_FLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
DEBUG_FLAGS = -g -ggdb3 -D_DEBUG
CPP = gcc
CPP_OSX = clang

##########################
### SDK CONFIGURATIONS ###
##########################

HL2SDK = ../hl2sdk-l4d2
HL2PUB = $(HL2SDK)/public


OS := $(shell uname -s)

ifeq "$(OS)" "Darwin"
LIB_EXT = dylib
HL2LIB = $(HL2SDK)/lib/mac
else
LIB_EXT = so
HL2LIB = $(HL2SDK)/lib/linux
endif


LIB_EXT = so
HL2LIB = $(HL2SDK)/lib/linux
LIB_PREFIX = lib
ifneq "$(OS)" "Darwin"
LIB_SUFFIX = _srv.$(LIB_EXT)
else
LIB_SUFFIX = .$(LIB_EXT)
endif


CFLAGS += -std=c++11
LIB_SUFFIX = _srv.$(LIB_EXT)

LINK += $(HL2LIB)/tier1_i486.a $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) $(LIB_PREFIX)tier0$(LIB_SUFFIX)

INCLUDE += -I. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/vstdlib -I$(HL2PUB)/tier0 \
-I$(HL2PUB)/tier1 -I$(HL2PUB)/game/server

################################################
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
################################################

BINARY = $(PROJECT).$(LIB_EXT)
BIN_DIR = Release
LINK += -shared

ifeq "$(DEBUG)" "true"
BIN_DIR = Debug
CFLAGS += $(DEBUG_FLAGS)
else
BIN_DIR = Release
CFLAGS += $(OPT_FLAGS)
endif


ifeq "$(OS)" "Darwin"
CPP = $(CPP_OSX)
LIB_EXT = dylib
CFLAGS += -DOSX -D_OSX
LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5
else
LIB_EXT = so
CFLAGS += -D_LINUX
LINK += -shared
endif

IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")

ifeq "$(IS_CLANG)" "1"
CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/")
CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/")
else
CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1)
CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3)
endif

CFLAGS += -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp \
-Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca \
-Dstrcmpi=strcasecmp -DCOMPILER_GCC -Wall -Wno-non-virtual-dtor -Wno-overloaded-virtual \
-Werror -fPIC -fno-exceptions -fno-rtti -msse -m32 -fno-strict-aliasing

# Clang || GCC >= 4
ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
CFLAGS += $(GCC4_FLAGS)
endif

# Clang >= 3 || GCC >= 4.7
ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1"
CFLAGS += -Wno-delete-non-virtual-dtor
endif

# OS is Linux and not using clang
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1"
LINK += -static-libgcc
endif
CFLAGS += -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -D_snprintf=snprintf \
-Dstrnicmp=strncasecmp -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp \
-std=c++11 -Wall -Werror -fPIC -fno-exceptions -fno-rtti -msse -m32 -Ofast -pipe -D_LINUX \
-fvisibility=hidden -fvisibility-inlines-hidden -static-libgcc -fno-strict-aliasing

OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)

Expand Down
Loading

0 comments on commit 73fd863

Please sign in to comment.