Skip to content

Commit

Permalink
fix: Replace git submodules with direct code
Browse files Browse the repository at this point in the history
  • Loading branch information
ADRFranklin committed Jan 20, 2025
1 parent da0c976 commit d4c9376
Show file tree
Hide file tree
Showing 23 changed files with 1,753 additions and 8 deletions.
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
[submodule "lib/cmake-modules"]
path = lib/cmake-modules
url = https://github.com/Zeex/cmake-modules.git
[submodule "lib/samp-plugin-sdk"]
path = lib/samp-plugin-sdk
url = https://github.com/maddinat0r/samp-plugin-sdk.git
1 change: 0 additions & 1 deletion lib/cmake-modules
Submodule cmake-modules deleted from b5ec03
1 change: 1 addition & 0 deletions lib/cmake-modules/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
18 changes: 18 additions & 0 deletions lib/cmake-modules/AMXConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
include(CheckIncludeFile)

check_include_file(alloca.h HAVE_ALLOCA_H)
if(HAVE_ALLOCA_H)
add_definitions(-DHAVE_ALLOCA_H)
endif()
check_include_file(inttypes.h HAVE_INTTYPES_H)
if(HAVE_INTTYPES_H)
add_definitions(-DHAVE_INTTYPES_H)
endif()
check_include_file(malloc.h HAVE_MALLOC_H)
if(HAVE_MALLOC_H)
add_definitions(-DHAVE_MALLOC_H)
endif()
check_include_file(stdint.h HAVE_STDINT_H)
if(HAVE_STDINT_H)
add_definitions(-DHAVE_STDINT_H)
endif()
37 changes: 37 additions & 0 deletions lib/cmake-modules/AddSAMPPlugin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function(add_samp_plugin name)
add_library(${name} MODULE ${ARGN})

set_target_properties(${name} PROPERTIES PREFIX "")

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_property(TARGET ${name} APPEND_STRING PROPERTY COMPILE_FLAGS " -m32")
set_property(TARGET ${name} APPEND_STRING PROPERTY LINK_FLAGS " -m32")
endif()

if(CMAKE_COMPILER_IS_GNUCXX)
set_property(TARGET ${name} APPEND_STRING PROPERTY
COMPILE_FLAGS " -Wno-attributes")
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_property(TARGET ${name} APPEND_STRING PROPERTY
COMPILE_FLAGS " -Wno-ignored-attributes")
endif()

if(WIN32 AND CMAKE_COMPILER_IS_GNUCC)
set_property(TARGET ${name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--enable-stdcall-fixup")
endif()

if(CYGWIN)
set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS "WIN32")
set_property(TARGET ${name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--kill-at")
elseif(UNIX AND NOT WIN32 AND NOT APPLE)
set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS "LINUX")
endif()

if(MINGW)
# Work around missing #include <stddef.h> in <SDK>/amx/amx.h.
set_property(TARGET ${name} APPEND_STRING PROPERTY COMPILE_FLAGS " -include stddef.h")
endif()
endfunction()
46 changes: 46 additions & 0 deletions lib/cmake-modules/AddSAMPPluginTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# AddSAMPPluginTest - add tests for SA-MP plugins.
#
# This module reuires the samp-server-cli script to be present in PATH in
# order to be able to run the tests. The script can be downloaded here:
#
# https://github.com/Zeex/samp-server-cli
#
# Additionally the SAMP_SERVER_ROOT environment variable must be defined and
# must point to the SA-MP server's root directory.

include(CMakeParseArguments)

function(add_samp_plugin_test)
set(name "${ARGV0}")

set(options TARGET OUTPUT_FILE SCRIPT TIMEOUT CONFIG WORKING_DIRECTORY)
cmake_parse_arguments(ARG "" "${options}" "" ${ARGN})

find_package(SAMPServerCLI REQUIRED)
set(command ${SAMPServerCLI_EXECUTABLE})

if(ARG_SCRIPT)
list(APPEND args --gamemode ${ARG_SCRIPT})
endif()

if(ARG_TIMEOUT)
list(APPEND args --timeout ${ARG_TIMEOUT})
endif()

if(ARG_WORKING_DIRECTORY)
list(APPEND args --workdir ${ARG_WORKING_DIRECTORY})
endif()

add_test(NAME ${name} COMMAND ${command} ${args} --output
--plugin $<TARGET_FILE:${ARG_TARGET}>)

if(ARG_SCRIPT)
get_filename_component(AMX_PATH ${ARG_SCRIPT} DIRECTORY)
set_tests_properties(${name} PROPERTIES ENVIRONMENT AMX_PATH=${AMX_PATH})
endif()

if(ARG_OUTPUT_FILE)
file(READ ${ARG_OUTPUT_FILE} output)
set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION ${output})
endif()
endfunction()
16 changes: 16 additions & 0 deletions lib/cmake-modules/FindPawnCC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include(FindPackageHandleStandardArgs)

if(WIN32)
set(_PawnCC_EXECUTABLE_NAME pawncc.exe)
else()
set(_PawnCC_EXECUTABLE_NAME pawncc)
endif()

find_file(PawnCC_EXECUTABLE ${_PawnCC_EXECUTABLE_NAME})

mark_as_advanced(PawnCC_EXECUTABLE)

find_package_handle_standard_args(PawnCC
FOUND_VAR PawnCC_FOUND
REQUIRED_VARS PawnCC_EXECUTABLE
)
17 changes: 17 additions & 0 deletions lib/cmake-modules/FindSAMPGDK.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
include(FindPackageHandleStandardArgs)

find_package(SAMPGDK QUIET CONFIG NAMES SAMPGDK)

set(SAMPGDK_INCLUDE_DIRS ${SAMPGDK_INCLUDE_DIR})
set(SAMPGDK_LIBRARY_DIRS ${SAMPGDK_LIBRARY_DIR})

mark_as_advanced(
SAMPGDK_VERSION
SAMPGDK_INCLUDE_DIR
SAMPGDK_LIBRARY_DIR
)

find_package_handle_standard_args(SAMPGDK
REQUIRED_VARS SAMPGDK_INCLUDE_DIRS SAMPGDK_LIBRARY_DIRS
VERSION_VAR SAMPGDK_VERSION
)
24 changes: 24 additions & 0 deletions lib/cmake-modules/FindSAMPSDK.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include(FindPackageHandleStandardArgs)

find_path(SAMPSDK_DIR
NAMES plugin.h
plugincommon.h
HINTS ${SAMP_SDK_ROOT}
ENV SAMP_SDK_ROOT
PATH_SUFFIXES sdk SDK
DOC "Path to SA-MP plugin SDK"
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
)

set(SAMPSDK_INCLUDE_DIR ${SAMPSDK_DIR})

mark_as_advanced(
SAMPSDK_DIR
SAMPSDK_INCLUDE_DIR
)

find_package_handle_standard_args(SAMPSDK
REQUIRED_VARS SAMPSDK_DIR
SAMPSDK_INCLUDE_DIR
)
34 changes: 34 additions & 0 deletions lib/cmake-modules/FindSAMPServer.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
include(FindPackageHandleStandardArgs)

if(WIN32)
set(_SAMPServer_EXECUTABLE_NAME samp-server.exe)
else()
set(_SAMPServer_EXECUTABLE_NAME samp03svr)
endif()

find_file(SAMPServer_EXECUTABLE
NAMES ${_SAMPServer_EXECUTABLE_NAME}
HINTS ENV SAMP_SERVER_ROOT
)
find_path(SAMPServer_DIR
NAMES ${_SAMPServer_EXECUTABLE_NAME}
HINTS ENV SAMP_SERVER_ROOT
)
find_path(SAMPServer_INCLUDE_DIR
NAMES a_samp.inc a_npc.inc
HINTS ${SAMPServer_DIR}/include
${SAMPServer_DIR}/pawno/include
)

mark_as_advanced(
SAMPServer_EXECUTABLE
SAMPServer_DIR
SAMPServer_INCLUDE_DIR
)

find_package_handle_standard_args(SAMPServer
FOUND_VAR SAMPServer_FOUND
REQUIRED_VARS SAMPServer_EXECUTABLE
SAMPServer_DIR
SAMPServer_INCLUDE_DIR
)
28 changes: 28 additions & 0 deletions lib/cmake-modules/FindSAMPServerCLI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
include(FindPackageHandleStandardArgs)

if(WIN32)
set(_SAMPServerCLI_EXECUTABLE_NAME samp-server-cli.bat
samp-server-cli.exe)
else()
set(_SAMPServerCLI_EXECUTABLE_NAME samp-server-cli)
endif()

find_file(SAMPServerCLI_EXECUTABLE
NAMES ${_SAMPServerCLI_EXECUTABLE_NAME}
HINTS ENV SAMP_SERVER_ROOT
)
find_path(SAMPServerCLI_DIR
NAMES ${_SAMPServerCLI_EXECUTABLE_NAME}
HINTS ENV SAMP_SERVER_ROOT
)

mark_as_advanced(
SAMPServerCLI_EXECUTABLE
SAMPServerCLI_DIR
)

find_package_handle_standard_args(SAMPServerCLI
FOUND_VAR SAMPServerCLI_FOUND
REQUIRED_VARS SAMPServerCLI_EXECUTABLE
SAMPServerCLI_DIR
)
14 changes: 14 additions & 0 deletions lib/cmake-modules/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2014-2015 Zeex

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.

14 changes: 14 additions & 0 deletions lib/cmake-modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Name | Description
:--------------------------------------------|:--------------------------------------------------------
[AddSAMPPlugin](AddSAMPPlugin.cmake) | Provides `add_samp_plugin()` function
[AddSAMPPluginTest](AddSAMPPluginTest.cmake) | Provides `add_samp_plugin_test()` function
[AMXConfig](AMXConfig.cmake) | Defines platform-specific macros expected by AMX headers
[FindPawnCC](FindPawnCC.cmake) | Finds Pawn compiler executable
[FindSAMPSDK](FindSAMPSDK.cmake) | Finds SA-MP plugin SDK
[FindSAMPGDK](FindSAMPGDK.cmake) | Finds [GDK][sampgdk] library and headers
[FindSAMPServer](FindSAMPServer.cmake) | Finds SA-MP server executable
[FindSAMPServerCLI](FindSAMPServerCLI.cmake) | Finds [samp-server-cli][samp-server-cli]
-------------------------------------------------------------------------------------------------------

[sampgdk]: https://github.com/Zeex/sampgdk
[samp-server-cli]: https://github.com/Zeex/samp-server-cli
1 change: 0 additions & 1 deletion lib/samp-plugin-sdk
Submodule samp-plugin-sdk deleted from a5ce36
Loading

0 comments on commit d4c9376

Please # to comment.