Update to latest pkmnlib
This commit is contained in:
parent
94de1d4dca
commit
01622c7c73
|
@ -1,11 +1,44 @@
|
||||||
cmake_minimum_required(VERSION 3.17)
|
cmake_minimum_required(VERSION 3.17)
|
||||||
project(PkmnLibTools)
|
project(PkmnLibTools)
|
||||||
|
|
||||||
|
include(CPM.cmake)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(STATICC TRUE)
|
set(STATICC TRUE)
|
||||||
|
|
||||||
include(CMakeLists.txt.in)
|
option(WINDOWS "Whether the build target is Windows or not." OFF)
|
||||||
include_pkmnlib()
|
|
||||||
|
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/include)
|
||||||
|
CPMAddPackage(
|
||||||
|
NAME PkmnLib
|
||||||
|
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/PkmnLib.git
|
||||||
|
GIT_TAG master
|
||||||
|
OPTIONS
|
||||||
|
"SHARED=${SHARED}"
|
||||||
|
"WINDOWS=${WINDOWS}"
|
||||||
|
"ANGELSCRIPT_DEBUGGER=OFF"
|
||||||
|
)
|
||||||
|
execute_process(COMMAND ln -sf ${PkmnLib_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/include/PkmnLib)
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
|
||||||
|
include_directories(${PkmnLib_BINARY_DIR}/include/)
|
||||||
|
|
||||||
|
CPMAddPackage(
|
||||||
|
NAME Angelscript
|
||||||
|
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/Angelscript.git
|
||||||
|
GIT_TAG master
|
||||||
|
DOWNLOAD_ONLY YES
|
||||||
|
)
|
||||||
|
include_directories(${Angelscript_SOURCE_DIR}/angelscript/include)
|
||||||
|
include_directories(${Angelscript_SOURCE_DIR}/add_on)
|
||||||
|
|
||||||
|
if (WINDOWS)
|
||||||
|
MESSAGE(WARNING, "Using Windows Build.")
|
||||||
|
# Add a definition for the compiler, so we can use it in C++ as well.
|
||||||
|
ADD_DEFINITIONS(-D WINDOWS=1)
|
||||||
|
# -m64: Build a 64 bit library
|
||||||
|
add_compile_options(-m64)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-allow-multiple-definition")
|
||||||
|
endif (WINDOWS)
|
||||||
|
|
||||||
file(GLOB_RECURSE SRC_FILES src/*.cpp src/*.hpp)
|
file(GLOB_RECURSE SRC_FILES src/*.cpp src/*.hpp)
|
||||||
add_executable(PkmnLibTools ${SRC_FILES})
|
add_executable(PkmnLibTools ${SRC_FILES})
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 2.8.12)
|
|
||||||
|
|
||||||
project(PkmnLibTools NONE)
|
|
||||||
|
|
||||||
include(ExternalProject)
|
|
||||||
ExternalProject_Add(pkmnlib
|
|
||||||
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/PkmnLib
|
|
||||||
GIT_TAG master
|
|
||||||
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/PkmnLib"
|
|
||||||
CONFIGURE_COMMAND ""
|
|
||||||
BUILD_COMMAND ""
|
|
||||||
INSTALL_COMMAND ""
|
|
||||||
TEST_COMMAND ""
|
|
||||||
CMAKE_ARGS "-DSHARED=${SHARED} -DWINDOWS=${WINDOWS} -DSTATICC=${STATICC}"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
function(include_pkmnlib)
|
|
||||||
# Download and unpack googletest at configure time
|
|
||||||
configure_file(CMakeLists.txt.in PkmnLib/download/CMakeLists.txt)
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
|
||||||
RESULT_VARIABLE result
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/download)
|
|
||||||
if (result)
|
|
||||||
message(FATAL_ERROR "CMake step for pkmnlib failed: ${result}")
|
|
||||||
endif ()
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
|
||||||
RESULT_VARIABLE result
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/download)
|
|
||||||
if (result)
|
|
||||||
message(FATAL_ERROR "Build step for pkmnlib failed: ${result}")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Add googletest directly to our build. This defines
|
|
||||||
# the gtest and gtest_main targets.
|
|
||||||
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/bin
|
|
||||||
EXCLUDE_FROM_ALL)
|
|
||||||
|
|
||||||
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include)
|
|
||||||
execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/src
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include/PkmnLib)
|
|
||||||
execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/extern
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include/extern)
|
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/extern/AngelscriptDebuggerServer/extern/asio-1.18.2/include
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/bin/CreatureLib/include
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/bin/Angelscript/src/AngelscriptProj/angelscript/include
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/bin/CreatureLib/bin/Arbutils/include)
|
|
||||||
|
|
||||||
|
|
||||||
endfunction()
|
|
|
@ -17,7 +17,8 @@ static PkmnLib::Battling::BattleLibrary* BuildLibrary(AngelScriptResolver* scrip
|
||||||
auto statCalc = new PkmnLib::Battling::StatCalculator();
|
auto statCalc = new PkmnLib::Battling::StatCalculator();
|
||||||
auto lib = new PkmnLib::Battling::BattleLibrary(
|
auto lib = new PkmnLib::Battling::BattleLibrary(
|
||||||
BuildStaticLibrary(), statCalc, new PkmnLib::Battling::DamageLibrary(),
|
BuildStaticLibrary(), statCalc, new PkmnLib::Battling::DamageLibrary(),
|
||||||
new PkmnLib::Battling::ExperienceLibrary(), scriptResolver, new PkmnLib::Battling::MiscLibrary(&GetTime));
|
new PkmnLib::Battling::ExperienceLibrary(), scriptResolver, new PkmnLib::Battling::MiscLibrary(&GetTime),
|
||||||
|
new PkmnLib::Battling::CaptureLibrary());
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,28 +40,11 @@ void ScriptCompiler::Compile(const std::string& inPath, const std::string& outPa
|
||||||
std::ifstream t(dirEntry.path().c_str());
|
std::ifstream t(dirEntry.path().c_str());
|
||||||
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
|
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
|
||||||
resolver->CreateScript(
|
resolver->CreateScript(
|
||||||
(dirEntry.path().parent_path().stem().string() + "/" + dirEntry.path().stem().string()).c_str(),
|
(dirEntry.path().parent_path().stem().string() + "/" + dirEntry.path().stem().string()), str);
|
||||||
str.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolver->FinalizeModule();
|
resolver->FinalizeModule();
|
||||||
|
|
||||||
auto scripts = resolver->GetTypeDatabase();
|
|
||||||
for (const auto& type : scripts) {
|
|
||||||
|
|
||||||
std::cout << "=== ";
|
|
||||||
if ((uint8_t)type.first < 128) {
|
|
||||||
std::cout << ScriptCategoryHelper::ToString(type.first);
|
|
||||||
} else {
|
|
||||||
std::cout << PkmnScriptCategoryHelper::ToString((PkmnScriptCategory)type.first);
|
|
||||||
}
|
|
||||||
std::cout << "\t===" << std::endl;
|
|
||||||
|
|
||||||
for (const auto& s : type.second) {
|
|
||||||
std::cout << s.first << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::filesystem::path dir(outPath);
|
std::filesystem::path dir(outPath);
|
||||||
std::cout << dir << std::endl;
|
std::cout << dir << std::endl;
|
||||||
resolver->WriteByteCodeToFile(outPath.c_str());
|
resolver->WriteByteCodeToFile(outPath.c_str());
|
||||||
|
|
Loading…
Reference in New Issue