diff --git a/.github/workflows/extensions.yml b/.github/workflows/extensions.yml index 12be4ceb1e..06e4737e80 100644 --- a/.github/workflows/extensions.yml +++ b/.github/workflows/extensions.yml @@ -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 diff --git a/.gitignore b/.gitignore index 52645712a7..cd55d5af70 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ *.zip release/* releases/* +extensions/vcproj32/* +extensions/vcproj64/* hemtt hemtt.exe tools/temp diff --git a/extensions/.clang-format b/extensions/.clang-format new file mode 100644 index 0000000000..89eb4f4686 --- /dev/null +++ b/extensions/.clang-format @@ -0,0 +1,9 @@ +BasedOnStyle: Google +IndentWidth: 4 +ColumnLimit: 160 +DerivePointerAlignment: false +PointerAlignment: Left +NamespaceIndentation: All +IncludeBlocks: Merge + +AllowShortBlocksOnASingleLine: true diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 74f22ef9c3..d8021ea4b2 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -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}") diff --git a/extensions/advanced_ballistics/CMakeLists.txt b/extensions/advanced_ballistics/CMakeLists.txt index 55d84810d1..9319d0bbd7 100644 --- a/extensions/advanced_ballistics/CMakeLists.txt +++ b/extensions/advanced_ballistics/CMakeLists.txt @@ -9,4 +9,14 @@ set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES FOLDER Extensions) 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() \ No newline at end of file +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 $ ${PROJECT_SOURCE_DIR}/../${FINAL_DLL_NAME} +) diff --git a/extensions/artillerytables/CMakeLists.txt b/extensions/artillerytables/CMakeLists.txt index 5b6d3863c9..bd897c5103 100644 --- a/extensions/artillerytables/CMakeLists.txt +++ b/extensions/artillerytables/CMakeLists.txt @@ -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 $ ${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() diff --git a/extensions/break_line/CMakeLists.txt b/extensions/break_line/CMakeLists.txt index 5d29d295c8..320df7a103 100644 --- a/extensions/break_line/CMakeLists.txt +++ b/extensions/break_line/CMakeLists.txt @@ -9,4 +9,14 @@ set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES FOLDER Extensions) 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() \ No newline at end of file +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 $ ${PROJECT_SOURCE_DIR}/../${FINAL_DLL_NAME} +) diff --git a/extensions/break_line/ace_break_line.cpp b/extensions/break_line/ace_break_line.cpp index 909c2a1ebb..3c169e6a88 100644 --- a/extensions/break_line/ace_break_line.cpp +++ b/extensions/break_line/ace_break_line.cpp @@ -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 splitString(const std::string & input) { diff --git a/extensions/build/.gitignore b/extensions/build/.gitignore deleted file mode 100644 index 86d0cb2726..0000000000 --- a/extensions/build/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore \ No newline at end of file diff --git a/extensions/clipboard/CMakeLists.txt b/extensions/clipboard/CMakeLists.txt index b8f846844c..6c5668bcdd 100644 --- a/extensions/clipboard/CMakeLists.txt +++ b/extensions/clipboard/CMakeLists.txt @@ -9,4 +9,14 @@ set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES FOLDER Extensions) 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() \ No newline at end of file +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 $ ${PROJECT_SOURCE_DIR}/../${FINAL_DLL_NAME} +) diff --git a/extensions/clipboard/ace_clipboard.cpp b/extensions/clipboard/ace_clipboard.cpp index 2ca85711df..d463a4634e 100644 --- a/extensions/clipboard/ace_clipboard.cpp +++ b/extensions/clipboard/ace_clipboard.cpp @@ -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; diff --git a/extensions/fcs/CMakeLists.txt b/extensions/fcs/CMakeLists.txt index b5c7b5671f..e7e6913882 100644 --- a/extensions/fcs/CMakeLists.txt +++ b/extensions/fcs/CMakeLists.txt @@ -9,4 +9,14 @@ set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES FOLDER Extensions) 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() \ No newline at end of file +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 $ ${PROJECT_SOURCE_DIR}/../${FINAL_DLL_NAME} +) diff --git a/extensions/fcs/ace_fcs.cpp b/extensions/fcs/ace_fcs.cpp index 3ca32f439f..f15066bc11 100644 --- a/extensions/fcs/ace_fcs.cpp +++ b/extensions/fcs/ace_fcs.cpp @@ -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 splitString(std::string input) { diff --git a/extensions/parse_imagepath/CMakeLists.txt b/extensions/parse_imagepath/CMakeLists.txt index e38a4bb506..251796a95e 100644 --- a/extensions/parse_imagepath/CMakeLists.txt +++ b/extensions/parse_imagepath/CMakeLists.txt @@ -9,4 +9,14 @@ set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES FOLDER Extensions) 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() \ No newline at end of file +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 $ ${PROJECT_SOURCE_DIR}/../${FINAL_DLL_NAME} +) diff --git a/extensions/parse_imagepath/ace_parse_imagepath.cpp b/extensions/parse_imagepath/ace_parse_imagepath.cpp index eda1af0d6e..98b1cfa50f 100644 --- a/extensions/parse_imagepath/ace_parse_imagepath.cpp +++ b/extensions/parse_imagepath/ace_parse_imagepath.cpp @@ -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) { diff --git a/tools/compileExtensions.py b/tools/compileExtensions.py new file mode 100644 index 0000000000..8864d98e7a --- /dev/null +++ b/tools/compileExtensions.py @@ -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...")