diff --git a/.drone.yml b/.drone.yml index 524b294..97ca04a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -74,30 +74,8 @@ steps: - cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /drone/src/build-release-windows/ - export WINEARCH=win64 - wine build-release-windows/pkmnLibTests.exe -s --duration=true --force-colors=true - - name: conan-deploy - image: deukhoofd/linux64builder - volumes: - - name: conan-data - path: /root/.conan/data - environment: - CONAN_LOGIN_USERNAME: - from_secret: conan_username - CONAN_PASSWORD: - from_secret: conan_password - commands: - - rm -rf build-debug - - rm -rf build-release - - rm -rf build-release-windows - - conan remote add epsilon-public https://packages.p-epsilon.com/ - - cmake -DCMAKE_BUILD_TYPE=Release . -B build-conan -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=clang++ -DWINDOWS=0 - - conan export-pkg . $DRONE_COMMIT@epsilon/$DRONE_BRANCH --build-folder build-conan -s compiler='clang' -s compiler.version=8 -s compiler.libcxx='libstdc++11' --force - - conan alias PkmnLib/latest@epsilon/$DRONE_BRANCH PkmnLib/$DRONE_COMMIT@epsilon/$DRONE_BRANCH - - conan user -p -r=epsilon-public - - conan upload PkmnLib/$DRONE_COMMIT@epsilon/$DRONE_BRANCH --all -r=epsilon-public --force - - conan upload PkmnLib/latest@epsilon/$DRONE_BRANCH --all -r=epsilon-public --force - - conan user --clean --- kind: signature -hmac: ba0cd11e5fc5d2154fc5adec2cb488c828d7a50e29f621d8c9ceee42d51b1005 +hmac: ecda7946c935600dff9785e1068de0bdc7c1a637ad8c9c3724f10708e00194fe ... diff --git a/CMakeLists.txt b/CMakeLists.txt index cd1782d..5b8353b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,23 @@ cmake_minimum_required(VERSION 3.13) include(CheckIPOSupported) - project(pkmnLib) -# Enable all warnings, and make them error when occurring. -add_compile_options(-Wall -Wextra -Werror) + # We like new stuff, so set the c++ standard to c++20. set(CMAKE_CXX_STANDARD 20) set(CMAKE_POSITION_INDEPENDENT_CODE ON) option(WINDOWS "Whether the build target is Windows or not." OFF) -option(SHARED "Whether we should build a shared library, instead of a static one." OFF) +option(SHARED "Whether we should build a shared library, instead of a static one." ON) option(TESTS "Whether the test executable should be build as well." OFF) option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF) set(SCRIPT_PROVIDER "angelscript" CACHE STRING "Which script provider to use.") set(LEVEL_SIZE "8" CACHE STRING "Number of bits to store the level as. Can be 8") +include(CMakeLists.txt.creaturelib.in) +include(CMakeLists.txt.angelscript.in) + +include_creaturelib() +include_angelscript() if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") add_compile_options(-fconcepts) @@ -58,9 +61,6 @@ else () message(FATAL_ERROR, "Invalid level size was given.") endif () -include(CmakeConanSetup.cmake) -SetupConan() - message(STATUS "Using Conan Libs:") foreach (_conanLib ${CONAN_LIBS}) message(STATUS "\t ${_conanLib}") @@ -104,6 +104,9 @@ endif () file(GLOB_RECURSE CORE_SRC_FILES ${FILE_SOURCE}) add_library(pkmnLib ${LIBTYPE} ${CORE_SRC_FILES}) target_precompile_headers(pkmnLib PUBLIC src/Precompiled.hxx) +# Enable all warnings, and make them error when occurring. +target_compile_options(pkmnLib PRIVATE -Wall -Wextra -Werror) + # If interprocedural optimization is available, apply it check_ipo_supported(RESULT IPO_SUPPORTED) @@ -154,6 +157,9 @@ if (TESTS) # Create Test executable file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") add_executable(pkmnLibTests ${TEST_FILES} extern/doctest.hpp) + # Enable all warnings, and make them error when occurring. + target_compile_options(pkmnLibTests PRIVATE -Wall -Wextra -Werror) + message(STATUS "${_TESTLINKS}") target_link_libraries(pkmnLibTests PUBLIC ${_TESTLINKS}) diff --git a/CMakeLists.txt.angelscript.in b/CMakeLists.txt.angelscript.in new file mode 100644 index 0000000..ee978d6 --- /dev/null +++ b/CMakeLists.txt.angelscript.in @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(angelscript-download NONE) + +include(ExternalProject) + +ExternalProject_Add(AngelscriptProj + GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/Angelscript.git + GIT_TAG master + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/Angelscript" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) + +function(include_angelscript) + configure_file(CMakeLists.txt.angelscript.in Angelscript/download/CMakeLists.txt) + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Angelscript/download) + if (result) + message(FATAL_ERROR "CMake step for angelscript failed: ${result}") + endif () + execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Angelscript/download) + if (result) + message(FATAL_ERROR "Build step for angelscript failed: ${result}") + endif () + + SET(BUILD_SHARED_LIBS ${SHARED}) + SET(LINK_STD_STATICALLY ${STATICC}) + add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/Angelscript/src/AngelscriptProj/angelscript/projects/cmake + ${CMAKE_CURRENT_BINARY_DIR}/Angelscript/bin + EXCLUDE_FROM_ALL) + + execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/Angelscript/include) + include_directories(SYSTEM ${CMAKE_CURRENT_BINARY_DIR}/Angelscript/src/AngelscriptProj/angelscript/include) +endfunction() \ No newline at end of file diff --git a/CMakeLists.txt.creaturelib.in b/CMakeLists.txt.creaturelib.in new file mode 100644 index 0000000..e5b96a7 --- /dev/null +++ b/CMakeLists.txt.creaturelib.in @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(creaturelib-download NONE) + +include(ExternalProject) +ExternalProject_Add(CreatureLibProj + GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/CreatureLib + GIT_TAG master + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/CreatureLib" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + CMAKE_ARGS "-DSHARED=${SHARED} -DWINDOWS=${WINDOWS} -DSTATICC=${STATICC}" + ) + + + +function(include_creaturelib) + configure_file(CMakeLists.txt.creaturelib.in CreatureLib/download/CMakeLists.txt) + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/download) + if (result) + message(FATAL_ERROR "CMake step for arbutils failed: ${result}") + endif () + execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/download) + if (result) + message(FATAL_ERROR "Build step for arbutils failed: ${result}") + endif () + + add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/src/CreatureLibProj + ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/bin + EXCLUDE_FROM_ALL) + + execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/include) + execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/src/CreatureLibProj/src + ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/include/CreatureLib) + + include_directories(${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/bin/Arbutils/include ${CMAKE_CURRENT_BINARY_DIR}/CreatureLib/include) +endfunction() \ No newline at end of file diff --git a/CmakeConanSetup.cmake b/CmakeConanSetup.cmake deleted file mode 100644 index f643427..0000000 --- a/CmakeConanSetup.cmake +++ /dev/null @@ -1,36 +0,0 @@ -function(SetupConan) - # If conan isn't set up yet, we need to install the dependencies. - if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - message(WARNING "The file conanbuildinfo.cmake doesn't exist, running conan install.") - - # If we're linking C statically, we also want to do so for our dependencies. - set(CONAN_STATIC_C False) - if (STATICC) - set(CONAN_STATIC_C True) - endif (STATICC) - - if (NOT WINDOWS) - execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build=outdated - -s compiler=clang - -s compiler.libcxx=libstdc++11 - -o *:shared=True - -o *:staticC=${CONAN_STATIC_C} - -o AngelScript:link_std_statically=True - -o CreatureLib:level_size=${LEVEL_SIZE} - ) - else () - execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated - -s compiler=gcc - -s compiler.version=$ENV{CONAN_ENV_COMPILER_VERSION} - -s compiler.libcxx=libstdc++11 - -s os=Windows - -o *:shared=True - -o *:staticC=${CONAN_STATIC_C} - -o AngelScript:link_std_statically=True - -o CreatureLib:level_size=${LEVEL_SIZE} - ) - endif () - endif () - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - conan_basic_setup() -endfunction() \ No newline at end of file diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index c2efd67..0000000 --- a/conanfile.py +++ /dev/null @@ -1,59 +0,0 @@ -from conans import ConanFile, CMake -from conans.errors import ConanInvalidConfiguration - - -class PkmnLibConan(ConanFile): - name = "PkmnLib" - license = "TODO" - url = "https://git.p-epsilon.com/Deukhoofd/PkmnLib" - description = "An implementation of CreatureLib to handle Pokemon battling." - settings = "os", "compiler", "build_type" - options = {"shared": [True, False], "script_handler": ["angelscript"], "staticC": [True, False]} - default_options = {"shared": True, "script_handler": "angelscript", "staticC": False} - generators = "cmake" - exports_sources = "*" - compiler = "clang" - - def build(self): - cmake = CMake(self) - self.output.info("Target OS: %s." % self.settings.os) - if self.settings.os == "Windows": - self.output.warn("Noticed Windows target, setting Cmake WINDOWS=On.") - cmake.definitions["WINDOWS"] = "On" - if self.options.shared: - self.output.info("Building shared library.") - cmake.definitions["SHARED"] = "On" - if self.options.staticC: - cmake.definitions["STATICC"] = "On" - cmake.configure() - cmake.build() - - def package(self): - self.copy("*.hpp", dst="include/PkmnLib", src="src") - self.copy("*.hxx", dst="include/PkmnLib", src="src") - self.copy("*.h", dst="include/extern", src="extern") - self.copy("*.dll", dst="bin", keep_path=False) - self.copy("*.so", dst="lib", keep_path=False) - - def package_info(self): - self.cpp_info.libs = ["libpkmnLib"] - - - def imports(self): - if self.settings.os == "Windows": - self.copy("*.dll", "", "bin") - - - def configure(self): - if self.options.script_handler == "angelscript": - self.options["AngelScript"].shared = True - if self.options.staticC: - self.options["AngelScript"].link_std_statically = True - - def requirements(self): - self.requires("Arbutils/latest@epsilon/master") - self.requires("CreatureLib/latest@epsilon/master") - if self.options.script_handler == "angelscript": - self.requires("AngelScript/2.35@AngelScript/Deukhoofd") - else: - raise ConanInvalidConfiguration("Invalid Script Handler was specified: " + self.options.script_handler) \ No newline at end of file