Skip to content

Commit

Permalink
Merge pull request #30 from danielga/update-project-generator
Browse files Browse the repository at this point in the history
Update project generator
  • Loading branch information
danielga authored Oct 11, 2019
2 parents 4561bb1 + 991e99d commit b6db9b6
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 177 deletions.
38 changes: 21 additions & 17 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
version: '{build}'
skip_non_tags: true
image: Visual Studio 2017
image: Visual Studio 2019
clone_depth: 1
init:
- cmd: git config --global core.autocrlf true
- ps: git config --global core.autocrlf true
environment:
MODULE_NAME: serversecure.core
REPOSITORY_DIR: $(APPVEYOR_BUILD_FOLDER)
DEPENDENCIES: $(APPVEYOR_BUILD_FOLDER)/dependencies
GARRYSMOD_COMMON: $(APPVEYOR_BUILD_FOLDER)/dependencies/garrysmod_common
GARRYSMOD_COMMON_REPOSITORY: https://github.com/danielga/garrysmod_common.git
GARRYSMOD_COMMON_BRANCH: master
SOURCE_SDK: $(APPVEYOR_BUILD_FOLDER)/dependencies/sourcesdk-minimal
SOURCE_SDK_REPOSITORY: https://github.com/danielga/sourcesdk-minimal.git
SOURCE_SDK_BRANCH: master
PREMAKE5_URL: https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-windows.zip
PREMAKE5_EXECUTABLE: premake5.exe
PREMAKE5: $(APPVEYOR_BUILD_FOLDER)/dependencies/windows/premake-core/premake5.exe
BUILD_SCRIPT: $(APPVEYOR_BUILD_FOLDER)/dependencies/garrysmod_common/build/ci.ps1
GARRYSMOD_COMMON_REPOSITORY: https://github.com/danielga/garrysmod_common.git
BUILD_SCRIPT: $(APPVEYOR_BUILD_FOLDER)/dependencies/garrysmod_common/build/build.ps1
BOOTSTRAP_URL: https://raw.githubusercontent.com/danielga/garrysmod_common/master/build/bootstrap.ps1
PROJECT_OS: windows
TARGET_OS: win32
COMPILER_PLATFORM: vs2017
TARGET_OS_64: win64
TARGET_ARCHITECTURE: x86
TARGET_ARCHITECTURE_64: x86_64
PROJECT_GENERATOR_VERSION: 2
COMPILER_PLATFORM: vs2019
DISABLE_X86_64_BUILD: true
install:
- cmd: >-
if not exist "%DEPENDENCIES%/" mkdir "%DEPENDENCIES%"
if exist "%GARRYSMOD_COMMON%/premake5.lua" (echo "garrysmod_common directory is good, pulling any latest changes" & git -C "%GARRYSMOD_COMMON%" pull & git -C "%GARRYSMOD_COMMON%" submodule update --init --recursive)
if not exist "%GARRYSMOD_COMMON%/premake5.lua" (echo "garrysmod_common directory is empty, doing git clone of the remote repo" & git clone --recursive "%GARRYSMOD_COMMON_REPOSITORY%" "%GARRYSMOD_COMMON%")
cache:
- $(APPVEYOR_BUILD_FOLDER)/dependencies/
- $(APPVEYOR_BUILD_FOLDER)/projects/
- ps: 'Invoke-Expression ((New-Object System.Net.WebClient).DownloadString("$env:BOOTSTRAP_URL"))'
build_script:
- cmd: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat" && powershell -File "%BUILD_SCRIPT%"'
- ps: '& "$env:BUILD_SCRIPT"'
test: off
artifacts:
- path: projects/$(PROJECT_OS)/$(COMPILER_PLATFORM)/release/gmsv_$(MODULE_NAME)_$(TARGET_OS).dll
- path: projects/$(PROJECT_OS)/$(COMPILER_PLATFORM)/$(TARGET_ARCHITECTURE)/Release/gmsv_$(MODULE_NAME)_$(TARGET_OS).dll
name: gmsv_$(MODULE_NAME)_$(TARGET_OS).dll
- path: projects/$(PROJECT_OS)/$(COMPILER_PLATFORM)/$(TARGET_ARCHITECTURE_64)/Release/gmsv_$(MODULE_NAME)_$(TARGET_OS_64).dll
name: gmsv_$(MODULE_NAME)_$(TARGET_OS_64).dll
deploy:
- provider: GitHub
tag: $(APPVEYOR_REPO_TAG_NAME)
auth_token:
secure: Kcf0IrxCRLDEYu42alXhUjIettCA8LbmmGkwy2CMykU2I7cZMr22BWXHVLWUJvk5
artifact: projects/$(PROJECT_OS)/$(COMPILER_PLATFORM)/release/gmsv_$(MODULE_NAME)_$(TARGET_OS).dll
artifact: gmsv_$(MODULE_NAME)_$(TARGET_OS).dll,gmsv_$(MODULE_NAME)_$(TARGET_OS_64).dll
force_update: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/projects/
38 changes: 17 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,34 @@ env:
REPOSITORY_DIR="$TRAVIS_BUILD_DIR"
DEPENDENCIES="$TRAVIS_BUILD_DIR/dependencies"
GARRYSMOD_COMMON="$TRAVIS_BUILD_DIR/dependencies/garrysmod_common"
GARRYSMOD_COMMON_REPOSITORY="https://github.com/danielga/garrysmod_common.git"
GARRYSMOD_COMMON_BRANCH=master
SOURCE_SDK="$TRAVIS_BUILD_DIR/dependencies/sourcesdk-minimal"
SOURCE_SDK_REPOSITORY="https://github.com/danielga/sourcesdk-minimal.git"
SOURCE_SDK_BRANCH=master
BUILD_SCRIPT="$TRAVIS_BUILD_DIR/dependencies/garrysmod_common/build/build.sh"
BOOTSTRAP_URL="https://raw.githubusercontent.com/danielga/garrysmod_common/master/build/bootstrap.sh"
TARGET_OS="$TRAVIS_OS_NAME"
TARGET_OS_64="${TRAVIS_OS_NAME}64"
TARGET_ARCHITECTURE=x86
TARGET_ARCHITECTURE_64=x86_64
PROJECT_GENERATOR_VERSION=2
COMPILER_PLATFORM=gmake
BUILD_SCRIPT="$TRAVIS_BUILD_DIR/dependencies/garrysmod_common/build/ci.sh"
GARRYSMOD_COMMON_REPOSITORY="https://github.com/danielga/garrysmod_common.git"
PREMAKE5_EXECUTABLE=premake5
DISABLE_X86_64_BUILD=true
matrix:
include:
- os: linux
dist: trusty
dist: bionic
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- linux-libc-dev:i386
- g++-8-multilib
env:
- PREMAKE5="$TRAVIS_BUILD_DIR/dependencies/linux/premake-core/premake5"
PROJECT_OS=linux
PREMAKE5_URL="https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-linux.tar.gz"
before_install:
- export CC=gcc-8
export CXX=g++-8
Expand All @@ -37,26 +44,15 @@ matrix:
env:
- PREMAKE5="$TRAVIS_BUILD_DIR/dependencies/macosx/premake-core/premake5"
PROJECT_OS=macosx
cache:
directories:
- "$TRAVIS_BUILD_DIR/dependencies"
- "$TRAVIS_BUILD_DIR/projects"
install:
- mkdir -p "$DEPENDENCIES"
- if [ ! -f "$GARRYSMOD_COMMON/premake5.lua" ]; then
echo "garrysmod_common directory is empty, doing git clone of the remote repo";
git clone --recursive "$GARRYSMOD_COMMON_REPOSITORY" "$GARRYSMOD_COMMON";
else
echo "garrysmod_common directory is good, pulling any latest changes";
git -C "$GARRYSMOD_COMMON" pull;
git -C "$GARRYSMOD_COMMON" submodule update --init --recursive;
fi
PREMAKE5_URL="https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-macosx.tar.gz"
install: "curl -s -L \"$BOOTSTRAP_URL\" | bash"
script: "$BUILD_SCRIPT"
deploy:
provider: releases
skip_cleanup: true
file:
- "${TRAVIS_BUILD_DIR}/projects/${PROJECT_OS}/${COMPILER_PLATFORM}/release/gmsv_${MODULE_NAME}_${TARGET_OS}.dll"
- "${TRAVIS_BUILD_DIR}/projects/${PROJECT_OS}/${COMPILER_PLATFORM}/${TARGET_ARCHITECTURE}/Release/gmsv_${MODULE_NAME}_${TARGET_OS}.dll"
- "${TRAVIS_BUILD_DIR}/projects/${PROJECT_OS}/${COMPILER_PLATFORM}/${TARGET_ARCHITECTURE_64}/Release/gmsv_${MODULE_NAME}_${TARGET_OS_64}.dll"
on:
tags: true
api_key:
Expand Down
2 changes: 1 addition & 1 deletion license.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
gmsv_serversecure
A module for Garry's Mod that mitigates exploits on the Source engine.
-----------------------------------------------------------------------
Copyright (c) 2015-2018, Daniel Almeida
Copyright (c) 2015-2019, Daniel Almeida
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
7 changes: 4 additions & 3 deletions projects/premake5.lua → premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ newoption({

local gmcommon = _OPTIONS.gmcommon or os.getenv("GARRYSMOD_COMMON")
assert(gmcommon ~= nil, "you didn't provide a path to your garrysmod_common (https://github.com/danielga/garrysmod_common) directory")
include(gmcommon)
include(path.join(gmcommon, "generator.v2.lua"))

CreateWorkspace({name = "serversecure.core", abi_compatible = true})
CreateProject({serverside = true})
IncludeLuaShared()
IncludeSDKCommon()
IncludeSDKTier0()
IncludeSDKTier1()
IncludeSteamAPI()
IncludeDetouring()
IncludeScanning()
files({
"../source/netfilter/*.cpp",
"../source/netfilter/*.hpp"
"source/netfilter/*.cpp",
"source/netfilter/*.hpp"
})
1 change: 0 additions & 1 deletion projects/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If stuff starts erroring or fails to work, be sure to check the correct line end
## Requirements

This project requires [garrysmod_common][4], a framework to facilitate the creation of compilations files (Visual Studio, make, XCode, etc). Simply set the environment variable '**GARRYSMOD\_COMMON**' or the premake option '**gmcommon**' to the path of your local copy of [garrysmod_common][4].
We also use [SourceSDK2013][5], so set the environment variable '**SOURCE_SDK**' or the premake option '**sourcesdk**' to the path of your local copy of [SourceSDK2013][5]. The previous links to [SourceSDK2013][5] point to my own fork of VALVe's repo and for good reason: Garry's Mod has lots of backwards incompatible changes to interfaces and it's much smaller, being perfect for automated build systems like Travis-CI (which is used for this project).
We also use [SourceSDK2013][5], so set the environment variable '**SOURCE\_SDK**' or the premake option '**sourcesdk**' to the path of your local copy of [SourceSDK2013][5]. The previous links to [SourceSDK2013][5] point to my own fork of VALVe's repo and for good reason: Garry's Mod has lots of backwards incompatible changes to interfaces and it's much smaller, being perfect for automated build systems like Travis-CI (which is used for this project).

[1]: http://gmodmodules.googlecode.com/svn/trunk/serverplugin_serversecure
[2]: http://gmodmodules.googlecode.com/svn/trunk/serverplugin_serversecure2
Expand Down
4 changes: 2 additions & 2 deletions source/filecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ namespace filecheck
SymbolFinder symfinder;

CNetChan__IsValidFileForTransfer_original =
reinterpret_cast<CNetChan__IsValidFileForTransfer_t>( symfinder.ResolveOnBinary(
global::engine_binary.c_str( ),
reinterpret_cast<CNetChan__IsValidFileForTransfer_t>( symfinder.Resolve(
global::engine_loader.GetModuleLoader( ).GetModule( ),
CNetChan__IsValidFileForTransfer_sig,
CNetChan__IsValidFileForTransfer_siglen
) );
Expand Down
23 changes: 13 additions & 10 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace global

#endif

SourceSDK::FactoryLoader engine_loader( "engine", false, true, "bin/" );
std::string engine_binary = Helpers::GetBinaryFileName( "engine", false, true, "bin/" );
SourceSDK::FactoryLoader engine_loader( "engine" );
IServer *server = nullptr;

LUA_FUNCTION_STATIC( GetClientCount )
Expand All @@ -37,6 +36,14 @@ namespace global
{
SymbolFinder symfinder;

void *temp_server = symfinder.Resolve(
engine_loader.GetModuleLoader( ).GetModule( ),
IServer_sig,
IServer_siglen
);
if( temp_server == nullptr )
LUA->ThrowError( "failed to locate IServer" );

server =

#if defined SYSTEM_POSIX
Expand All @@ -49,23 +56,19 @@ namespace global

#endif

( symfinder.ResolveOnBinary(
engine_binary.c_str( ),
IServer_sig,
IServer_siglen
) );
( temp_server );
}

if( server == nullptr )
LUA->ThrowError( "failed to locate IServer" );
LUA->ThrowError( "failed to dereference IServer" );

LUA->CreateTable( );

LUA->PushString( "serversecure 1.5.24" );
LUA->PushString( "serversecure 1.5.25" );
LUA->SetField( -2, "Version" );

// version num follows LuaJIT style, xxyyzz
LUA->PushNumber( 10524 );
LUA->PushNumber( 10525 );
LUA->SetField( -2, "VersionNum" );

LUA->PushCFunction( GetClientCount );
Expand Down
3 changes: 1 addition & 2 deletions source/main.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <string>
#include <GarrysMod/Interfaces.hpp>
#include <GarrysMod/FactoryLoader.hpp>

#if defined DEBUG

Expand All @@ -23,7 +23,6 @@ class IServer;
namespace global
{
extern SourceSDK::FactoryLoader engine_loader;
extern std::string engine_binary;
extern IServer *server;

#if defined DEBUG
Expand Down
Loading

0 comments on commit b6db9b6

Please sign in to comment.