Extensions - Various Improvments (#8227)

This commit is contained in:
PabstMirror 2021-04-22 14:11:56 -05:00
parent 996bbd2a28
commit e6d337a63d
16 changed files with 217 additions and 26 deletions

View File

@ -18,7 +18,9 @@ jobs:
- name: Build
shell: cmd
run: |
cd extensions/build
cd extensions
mkdir build
cd build
cmake .. && cmake --build .
- name: Upload Artifact
uses: actions/upload-artifact@master

2
.gitignore vendored
View File

@ -2,6 +2,8 @@
*.zip
release/*
releases/*
extensions/vcproj32/*
extensions/vcproj64/*
hemtt
hemtt.exe
tools/temp

9
extensions/.clang-format Normal file
View File

@ -0,0 +1,9 @@
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 160
DerivePointerAlignment: false
PointerAlignment: Left
NamespaceIndentation: All
IncludeBlocks: Merge
AllowShortBlocksOnASingleLine: true

View File

@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.0)
cmake_minimum_required (VERSION 3.14)
project (ACE)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
@ -98,16 +98,21 @@ endif()
string(TIMESTAMP ACE_BUILDSTAMP "%Y-%m-%dT%H:%M:%SZ")
set(ACE_VERSION_MAJOR 3)
set(ACE_VERSION_MINOR 13)
set(ACE_VERSION_REVISION 0)
# Get current version from addon
file(READ "../addons/main/script_version.hpp" script_version)
string(REGEX MATCH "#define MAJOR ([0-9]*)" "x" outputX ${script_version})
set(ACE_VERSION_MAJOR ${CMAKE_MATCH_1})
string(REGEX MATCH "#define MINOR ([0-9]*)" "x" outputX ${script_version})
set(ACE_VERSION_MINOR ${CMAKE_MATCH_1})
string(REGEX MATCH "#define PATCHLVL ([0-9]*)" outputX ${script_version})
set(ACE_VERSION_REVISION ${CMAKE_MATCH_1})
EXECUTE_PROCESS(COMMAND git rev-parse --verify HEAD
OUTPUT_VARIABLE T_ACE_VERSION_BUILD
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(SUBSTRING ${T_ACE_VERSION_BUILD} 0 7 ACE_VERSION_BUILD )
message("Building for: " ${ACE_VERSION_MAJOR}.${ACE_VERSION_MINOR}.${ACE_VERSION_REVISION}-${ACE_VERSION_BUILD})
message("Setting ACE Version: " ${ACE_VERSION_MAJOR}.${ACE_VERSION_MINOR}.${ACE_VERSION_REVISION}-${ACE_VERSION_BUILD})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/common/ace_version.hpp.in"
@ -135,7 +140,7 @@ add_subdirectory(fcs)
add_subdirectory(break_line)
add_subdirectory(clipboard)
add_subdirectory(advanced_ballistics)
add_subdirectory(medical)
#add_subdirectory(medical) # After medical re-write this extension is no longer used
add_subdirectory(parse_imagepath)
add_subdirectory(artillerytables)
@ -149,5 +154,14 @@ if (DEVEL)
endif()
# GTest
option(ENABLE_GTEST "ENABLE_GTEST" ON)
if (ENABLE_GTEST)
include(FetchContent)
FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif()
message("Build Type: ${CMAKE_BUILD_TYPE}")

View File

@ -10,3 +10,13 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1)
endif()
# Copy and rename DLL to root
if(USE_64BIT_BUILD)
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}_x64.dll)
else()
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}.dll)
endif()
add_custom_command(TARGET ${ACE_EXTENSION_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ACE_EXTENSION_NAME}> ${PROJECT_SOURCE_DIR}/../${FINAL_DLL_NAME}
)

View File

@ -11,14 +11,23 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1)
endif()
# Copy and rename DLL to root
if(USE_64BIT_BUILD)
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}_x64.dll)
else()
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}.dll)
endif()
add_custom_command(TARGET ${ACE_EXTENSION_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ACE_EXTENSION_NAME}> ${PROJECT_SOURCE_DIR}/../${FINAL_DLL_NAME}
)
# enable_testing()
# set(ACE_TEST_NAME Test_${ACE_EXTENSION_NAME})
# add_executable(${ACE_TEST_NAME} tests/tester.cpp ${SOURCES})
# target_link_libraries(${ACE_TEST_NAME} ace_common)
# target_link_libraries(${ACE_TEST_NAME} ${ACE_EXTENSION_NAME})
# target_link_libraries(${ACE_TEST_NAME} gtest_main)
# add_test(${ACE_TEST_NAME} ${ACE_TEST_NAME})
# set_target_properties(${ACE_TEST_NAME} PROPERTIES FOLDER Tests)
if (TARGET gtest_main) # Add Tests
enable_testing()
set(ACE_TEST_NAME ${ACE_EXTENSION_NAME}_test)
add_executable(${ACE_TEST_NAME} tests/tester.cpp ${SOURCES})
target_link_libraries(${ACE_TEST_NAME} ace_common)
target_link_libraries(${ACE_TEST_NAME} ${ACE_EXTENSION_NAME})
target_link_libraries(${ACE_TEST_NAME} gtest_main)
add_test(${ACE_TEST_NAME} ${ACE_TEST_NAME})
set_target_properties(${ACE_TEST_NAME} PROPERTIES FOLDER Tests)
endif()

View File

@ -10,3 +10,13 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1)
endif()
# Copy and rename DLL to root
if(USE_64BIT_BUILD)
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}_x64.dll)
else()
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}.dll)
endif()
add_custom_command(TARGET ${ACE_EXTENSION_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ACE_EXTENSION_NAME}> ${PROJECT_SOURCE_DIR}/../${FINAL_DLL_NAME}
)

View File

@ -22,6 +22,9 @@
extern "C" {
EXPORT void __stdcall RVExtension(char *output, int outputSize, const char *function);
EXPORT void __stdcall RVExtensionVersion(char *output, int outputSize) {
strncpy(output, ACE_FULL_VERSION_STR, outputSize - 1);
}
}
std::vector<std::string> splitString(const std::string & input) {

View File

@ -1,4 +0,0 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@ -10,3 +10,13 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1)
endif()
# Copy and rename DLL to root
if(USE_64BIT_BUILD)
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}_x64.dll)
else()
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}.dll)
endif()
add_custom_command(TARGET ${ACE_EXTENSION_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ACE_EXTENSION_NAME}> ${PROJECT_SOURCE_DIR}/../${FINAL_DLL_NAME}
)

View File

@ -18,6 +18,9 @@
extern "C" {
EXPORT void __stdcall RVExtension(char *output, int outputSize, const char *function);
EXPORT void __stdcall RVExtensionVersion(char *output, int outputSize) {
strncpy(output, ACE_FULL_VERSION_STR, outputSize - 1);
}
}
std::string gClipboardData;

View File

@ -10,3 +10,13 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1)
endif()
# Copy and rename DLL to root
if(USE_64BIT_BUILD)
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}_x64.dll)
else()
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}.dll)
endif()
add_custom_command(TARGET ${ACE_EXTENSION_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ACE_EXTENSION_NAME}> ${PROJECT_SOURCE_DIR}/../${FINAL_DLL_NAME}
)

View File

@ -28,6 +28,9 @@
extern "C" {
EXPORT void __stdcall RVExtension(char *output, int outputSize, const char *function);
EXPORT void __stdcall RVExtensionVersion(char *output, int outputSize) {
strncpy(output, ACE_FULL_VERSION_STR, outputSize - 1);
}
}
std::vector<std::string> splitString(std::string input) {

View File

@ -10,3 +10,13 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1)
endif()
# Copy and rename DLL to root
if(USE_64BIT_BUILD)
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}_x64.dll)
else()
set(FINAL_DLL_NAME ${ACE_EXTENSION_NAME}.dll)
endif()
add_custom_command(TARGET ${ACE_EXTENSION_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ACE_EXTENSION_NAME}> ${PROJECT_SOURCE_DIR}/../${FINAL_DLL_NAME}
)

View File

@ -19,6 +19,9 @@
extern "C" {
EXPORT void __stdcall RVExtension(char *output, int outputSize, const char *function);
EXPORT void __stdcall RVExtensionVersion(char *output, int outputSize) {
strncpy(output, ACE_FULL_VERSION_STR, outputSize - 1);
}
}
std::string getImagePathFromStructuredText(const std::string & input) {

View File

@ -0,0 +1,97 @@
#!/usr/bin/env python3
# vim: set fileencoding=utf-8 :
# compileExtensions.py (from acre2's make.py)
###############################################################################
# The MIT License (MIT)
# Copyright (c) 2013-2014 Ryan Schultz
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
###############################################################################
import sys
import os.path
import subprocess
import shutil
import time
import timeit
if sys.platform == "win32":
import winreg
def compile_extensions(force_build):
originalDir = os.getcwd()
extensions_root = os.path.join(os.path.dirname(os.getcwd()), "extensions")
os.chdir(extensions_root)
print("\nCompiling extensions in {} with rebuild:{}\n".format(extensions_root, force_build))
if shutil.which("git") == None:
print("Failed to find Git!")
return
if shutil.which("cmake") == None:
print("Failed to find CMake!")
return
if shutil.which("msbuild") == None:
print("Failed to find MSBuild!")
return
try:
buildType = "rebuild" if force_build else "build"
# 32-bit
vcproj32 = os.path.join(extensions_root, "vcproj32")
if not os.path.exists(vcproj32):
os.mkdir(vcproj32)
os.chdir(vcproj32)
subprocess.call(["cmake", "..", "-A", "Win32"]) # note: cmake will update ace_version stuff
subprocess.call(["msbuild", "ACE.sln", "/m", "/t:{}".format(buildType), "/p:Configuration=Release"])
# 64-bit
vcproj64 = os.path.join(extensions_root, "vcproj64")
if not os.path.exists(vcproj64):
os.mkdir(vcproj64)
os.chdir(vcproj64)
subprocess.call(["cmake", "..", "-A", "x64"])
subprocess.call(["msbuild", "ACE.sln", "/m", "/t:{}".format(buildType), "/p:Configuration=Release"])
except Exception as e:
print("Error: COMPILING EXTENSIONS - {}".format(e))
raise
finally:
os.chdir(originalDir)
def main(argv):
if "force" in argv:
argv.remove("force")
force_build = True
else:
force_build = False
compile_extensions(force_build)
if __name__ == "__main__":
start_time = timeit.default_timer()
main(sys.argv)
print("\nTotal Program time elapsed: {0} sec".format(timeit.default_timer() - start_time))
input("Press Enter to continue...")