Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous fixes and improvements #8

Merged
merged 4 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
variables:
MODULE_NAME: require.core
DEPENDENCIES: $(System.DefaultWorkingDirectory)/dependencies
GARRYSMOD_COMMON: $(System.DefaultWorkingDirectory)/dependencies/garrysmod_common
GARRYSMOD_COMMON_BRANCH: master
GARRYSMOD_COMMON_REPOSITORY: https://github.com/danielga/garrysmod_common.git
PROJECT_GENERATOR_VERSION: 2
REPOSITORY_DIR: $(System.DefaultWorkingDirectory)
DISABLE_X86_64_BUILD: true
trigger:
tags:
include:
- '*'
jobs:
- job: windows
displayName: Windows
pool:
name: Azure Pipelines
vmImage: windows-2019
timeoutInMinutes: 10
variables:
BOOTSTRAP_URL: https://raw.githubusercontent.com/danielga/garrysmod_common/master/build/bootstrap.ps1
BUILD_SCRIPT: $(System.DefaultWorkingDirectory)/dependencies/garrysmod_common/build/build.ps1
COMPILER_PLATFORM: vs2019
PROJECT_OS: windows
PREMAKE5: $(System.DefaultWorkingDirectory)/dependencies/windows/premake-core/premake5.exe
PREMAKE5_URL: https://github.com/premake/premake-core/releases/download/v5.0.0-alpha15/premake-5.0.0-alpha15-windows.zip
steps:
- powershell: 'Invoke-Expression ((New-Object System.Net.WebClient).DownloadString("$env:BOOTSTRAP_URL"))'
displayName: Bootstrap
- powershell: '& "$env:BUILD_SCRIPT"'
displayName: Build
- task: CopyFiles@2
displayName: 'Copy files to $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)/projects/windows/vs2019'
Contents: '*/Release/*.dll'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
CleanTargetFolder: true
flattenFolders: true
preserveTimestamp: true
- task: PublishBuildArtifacts@1
displayName: 'Publish build artifacts'
inputs:
ArtifactName: windows
- job: linux
displayName: Linux
pool:
name: Azure Pipelines
vmImage: ubuntu-16.04
timeoutInMinutes: 10
variables:
BOOTSTRAP_URL: https://raw.githubusercontent.com/danielga/garrysmod_common/master/build/bootstrap.sh
BUILD_SCRIPT: $(System.DefaultWorkingDirectory)/dependencies/garrysmod_common/build/build.sh
COMPILER_PLATFORM: gmake
PREMAKE5: $(System.DefaultWorkingDirectory)/dependencies/linux/premake-core/premake5
PROJECT_OS: linux
PREMAKE5_URL: https://github.com/premake/premake-core/releases/download/v5.0.0-alpha15/premake-5.0.0-alpha15-linux.tar.gz
CC: gcc-9
CXX: g++-9
AR: gcc-ar-9
NM: gcc-nm-9
RANLIB: gcc-ranlib-9
steps:
- bash: 'curl -s -L "$BOOTSTRAP_URL" | bash'
displayName: Bootstrap
- bash: |
sudo apt-get update && sudo apt-get install -y g++-9-multilib
$BUILD_SCRIPT
displayName: Build
- task: CopyFiles@2
displayName: 'Copy files to $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)/projects/linux/gmake'
Contents: '*/Release/*.dll'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
CleanTargetFolder: true
flattenFolders: true
preserveTimestamp: true
- task: PublishBuildArtifacts@1
displayName: 'Publish build artifacts'
inputs:
ArtifactName: linux
- job: publish
displayName: Publish to GitHub Releases
pool:
name: Azure Pipelines
vmImage: ubuntu-18.04
timeoutInMinutes: 5
dependsOn:
- windows
- linux
steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download build artifacts'
inputs:
downloadType: specific
parallelizationLimit: 12
- task: GitHubRelease@1
displayName: 'Publish GitHub release $(build.sourceBranchName)'
inputs:
gitHubConnection: 'GitHub danielga'
releaseNotesSource: inline
assets: '$(System.ArtifactsDirectory)/**'
addChangeLog: false
2 changes: 1 addition & 1 deletion license.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ gmod_require
Modules for Garry's Mod for obtaining pointers to functions inside of
modules (specially useful for loading Lua only modules).
-----------------------------------------------------------------------
Copyright (c) 2015-2019, Daniel Almeida
Copyright (c) 2015-2020, Daniel Almeida
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
14 changes: 5 additions & 9 deletions premake5.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
PROJECT_GENERATOR_VERSION = 2

newoption({
trigger = "gmcommon",
description = "Sets the path to the garrysmod_common (https://github.com/danielga/garrysmod_common) directory",
value = "path to garrysmod_common directory"
})

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(path.join(gmcommon, "generator.v2.lua"))
local gmcommon = assert(_OPTIONS.gmcommon or os.getenv("GARRYSMOD_COMMON"),
"you didn't provide a path to your garrysmod_common (https://github.com/danielga/garrysmod_common) directory")
include(gmcommon)

CreateWorkspace({name = "require.core", abi_compatible = true})
CreateProject({serverside = true, manual_files = true})
IncludeLuaShared()
IncludeSDKCommon()
IncludeSDKTier0()
IncludeSDKTier1()

files({"source/main.cpp", "source/loadlib.hpp"})

Expand All @@ -26,9 +25,6 @@ CreateWorkspace({name = "require.core", abi_compatible = true})

CreateProject({serverside = false, manual_files = true})
IncludeLuaShared()
IncludeSDKCommon()
IncludeSDKTier0()
IncludeSDKTier1()

files({"source/main.cpp", "source/loadlib.hpp"})

Expand Down
16 changes: 9 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# gmod\_require

Modules for Garry's Mod for obtaining pointers to functions inside of modules (specially useful for loading Lua only modules).
Modules for Garry's Mod for obtaining pointers to functions inside of modules (specially useful for loading Lua only modules).

## Compiling

The only supported compilation platform for this project on Windows is **Visual Studio 2017** on **release** mode.
On Linux, everything should work fine as is, on **release** mode.
For Mac OSX, any **Xcode (using the GCC compiler)** version *MIGHT* work as long as the **Mac OSX 10.7 SDK** is used, on **release** mode.
These restrictions are not random; they exist because of ABI compatibility reasons.
If stuff starts erroring or fails to work, be sure to check the correct line endings (\\n and such) are present in the files for each OS.
The only supported compilation platform for this project on Windows is **Visual Studio 2017**. However, it's possible it'll work with *Visual Studio 2015* and *Visual Studio 2019* because of the unified runtime.

On Linux, everything should work fine as is.

For macOS, any **Xcode (using the GCC compiler)** version *MIGHT* work as long as the **Mac OSX 10.7 SDK** is used.

If stuff starts erroring or fails to work, be sure to check the correct line endings (\n and such) are present in the files for each OS.

## Requirements

This project requires [garrysmod\_common][1], 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][1].
This project requires [garrysmod_common][1], 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][1].

[1]: https://github.com/danielga/garrysmod_common
1 change: 1 addition & 0 deletions source/loadlib_pos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <dlfcn.h>
#include <stdlib.h>
#include <cstring>
#include <linux/limits.h>

char GoodSeparator = '/';
char BadSeparator = '\0';
Expand Down
5 changes: 2 additions & 3 deletions source/main.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#include <GarrysMod/Lua/Interface.h>
#include <GarrysMod/Lua/LuaInterface.h>
#include <GarrysMod/Lua/LuaShared.h>
#include <GarrysMod/Interfaces.hpp>
#include <GarrysMod/FactoryLoader.hpp>
#include <cstdint>
#include <cstring>
#include "loadlib.hpp"

static SourceSDK::FactoryLoader lua_shared_loader(
"lua_shared", false, IS_SERVERSIDE, "garrysmod/bin/" );
static SourceSDK::FactoryLoader lua_shared_loader( "lua_shared" );
static GarrysMod::Lua::ILuaShared *lua_shared = nullptr;

static const size_t maximum_path_pushes = 100000;
Expand Down