Add ACSVM building to CMake

Currently this breaks some parts of the ACS functionality ... before I made a handful of small extensions to ACSVM's slightly-limited C API myself, and I didn't get them into the actual repo yet.

But now that we've moved to actual C++ compiling, I will likely just flat-out rewrite the SRB2 side of the code in C++ so it can use the library directly.
This commit is contained in:
Sally Coolatta 2022-12-22 09:44:38 -05:00
parent 2a790d10da
commit 88ffab9f3c
6 changed files with 138 additions and 14 deletions

View file

@ -135,6 +135,7 @@ if("${SRB2_CONFIG_SYSTEM_LIBRARIES}")
find_package(OPENMPT REQUIRED)
find_package(GME REQUIRED)
find_package(DiscordRPC REQUIRED)
find_package(acsvm REQUIRED)
endif()
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})

View file

@ -130,6 +130,8 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32
k_profiles.c
k_specialstage.c
k_roulette.c
k_acs.c
k_acs-func.c
)
if("${CMAKE_COMPILER_IS_GNUCC}" AND "${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
@ -198,6 +200,8 @@ target_link_libraries(SRB2SDL2 PRIVATE DiscordRPC::DiscordRPC)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC -DUSE_STUN)
target_sources(SRB2SDL2 PRIVATE discord.c stun.c)
target_link_libraries(SRB2SDL2 PRIVATE acsvm::acsvm)
set(SRB2_HAVE_THREADS ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)

View file

@ -34,6 +34,19 @@
#include "s_sound.h"
#include "r_textures.h"
ACSVM_String *ACSVM_MapScope_GetString(ACSVM_MapScope *map, ACSVM_Word index)
{
(void)map;
(void)index;
return NULL;
}
ACSVM_ThreadInfo *ACSVM_AllocThreadInfo(void *activator)
{
(void)activator;
return NULL;
}
/*--------------------------------------------------
static bool ACS_GetMobjTypeFromString(const char *word, mobjtype_t *type)

View file

@ -28,13 +28,13 @@
#include "p_tick.h"
#include "p_local.h"
#include "CAPI/BinaryIO.h"
#include "CAPI/Environment.h"
#include "CAPI/Module.h"
#include "CAPI/PrintBuf.h"
#include "CAPI/Scope.h"
#include "CAPI/String.h"
#include "CAPI/Thread.h"
#include <CAPI/BinaryIO.h>
#include <CAPI/Environment.h>
#include <CAPI/Module.h>
#include <CAPI/PrintBuf.h>
#include <CAPI/Scope.h>
#include <CAPI/String.h>
#include <CAPI/Thread.h>
static ACSVM_Environment *ACSenv = NULL;

View file

@ -21,13 +21,17 @@
#include "p_polyobj.h"
#include "d_player.h"
#include "CAPI/BinaryIO.h"
#include "CAPI/Environment.h"
#include "CAPI/Module.h"
#include "CAPI/PrintBuf.h"
#include "CAPI/Scope.h"
#include "CAPI/String.h"
#include "CAPI/Thread.h"
#include <CAPI/BinaryIO.h>
#include <CAPI/Environment.h>
#include <CAPI/Module.h>
#include <CAPI/PrintBuf.h>
#include <CAPI/Scope.h>
#include <CAPI/String.h>
#include <CAPI/Thread.h>
// Temp
ACSVM_String *ACSVM_MapScope_GetString(ACSVM_MapScope *map, ACSVM_Word index);
ACSVM_ThreadInfo *ACSVM_AllocThreadInfo(void *activator);
//
// Special global script types.

View file

@ -540,3 +540,105 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
target_include_directories(discord-rpc INTERFACE "${DiscordRPC_SOURCE_DIR}/include")
add_library(DiscordRPC::DiscordRPC ALIAS discord-rpc)
endif()
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
CPMAddPackage(
NAME acsvm
VERSION 0
URL "https://github.com/DavidPH/ACSVM/archive/7011af443dd03e8592d7810b0b91f46c49bdde59.zip"
EXCLUDE_FROM_ALL ON
DOWNLOAD_ONLY YES
)
if(acsvm_ADDED)
# Sal -- While ACSVM can be built as a shared library, a lot of its options are
# tied to directories existing, because the project suggests just copying it into
# your own project directly. I don't want us to do that, so I made our own target.
set(
acsvm_SOURCES
ACSVM/Action.cpp
ACSVM/Action.hpp
ACSVM/Array.cpp
ACSVM/Array.hpp
ACSVM/BinaryIO.cpp
ACSVM/BinaryIO.hpp
ACSVM/CallFunc.cpp
ACSVM/CallFunc.hpp
ACSVM/Code.hpp
ACSVM/CodeData.cpp
ACSVM/CodeData.hpp
ACSVM/CodeList.hpp
ACSVM/Environment.cpp
ACSVM/Environment.hpp
ACSVM/Error.cpp
ACSVM/Error.hpp
ACSVM/Function.cpp
ACSVM/Function.hpp
ACSVM/HashMap.hpp
ACSVM/HashMapFixed.hpp
ACSVM/ID.hpp
ACSVM/Init.cpp
ACSVM/Init.hpp
ACSVM/Jump.cpp
ACSVM/Jump.hpp
ACSVM/Module.cpp
ACSVM/Module.hpp
ACSVM/ModuleACS0.cpp
ACSVM/ModuleACSE.cpp
ACSVM/PrintBuf.cpp
ACSVM/PrintBuf.hpp
ACSVM/Scope.cpp
ACSVM/Scope.hpp
ACSVM/Script.cpp
ACSVM/Script.hpp
ACSVM/Serial.cpp
ACSVM/Serial.hpp
ACSVM/Stack.hpp
ACSVM/Store.hpp
ACSVM/String.cpp
ACSVM/String.hpp
ACSVM/Thread.cpp
ACSVM/Thread.hpp
ACSVM/ThreadExec.cpp
ACSVM/Tracer.cpp
ACSVM/Tracer.hpp
ACSVM/Types.hpp
ACSVM/Vector.hpp
Util/Floats.cpp
Util/Floats.hpp
# temp
CAPI/Array.cpp
CAPI/Array.h
CAPI/BinaryIO.cpp
CAPI/BinaryIO.h
CAPI/Environment.cpp
CAPI/Environment.h
CAPI/Floats.cpp
CAPI/Floats.h
CAPI/Module.cpp
CAPI/Module.h
CAPI/PrintBuf.cpp
CAPI/PrintBuf.h
CAPI/Scope.cpp
CAPI/Scope.h
CAPI/String.cpp
CAPI/String.h
CAPI/Thread.cpp
CAPI/Thread.h
CAPI/Types.h
)
list(TRANSFORM acsvm_SOURCES PREPEND "${acsvm_SOURCE_DIR}/")
add_library(acsvm "${SRB2_INTERNAL_LIBRARY_TYPE}" ${acsvm_SOURCES})
target_compile_features(acsvm PRIVATE cxx_std_11)
#target_compile_definitions(ACSVM_SHARED="${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}")
target_include_directories(acsvm INTERFACE "${acsvm_SOURCE_DIR}")
target_link_libraries(acsvm PRIVATE acsvm::acsvm)
add_library(acsvm::acsvm ALIAS acsvm)
endif()
endif()