setup empty husk
This commit is contained in:
commit
bf91297e83
30
.gitignore
vendored
Normal file
30
.gitignore
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
.vs/
|
||||
*.o
|
||||
*.swp
|
||||
~*
|
||||
*~
|
||||
.idea/
|
||||
cmake-build-debug/
|
||||
cmake-build-debugandtest/
|
||||
cmake-build-release/
|
||||
*.stackdump
|
||||
*.coredump
|
||||
compile_commands.json
|
||||
/build*
|
||||
/result*
|
||||
.clangd
|
||||
.cache
|
||||
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
CMakeLists.txt.user*
|
||||
CMakeCache.txt
|
||||
|
||||
*.tox
|
||||
imgui.ini
|
||||
/out
|
||||
CMakePresets.json
|
||||
CMakeUserPresets.json
|
||||
CMakeSettings.json
|
72
CMakeLists.txt
Normal file
72
CMakeLists.txt
Normal file
@ -0,0 +1,72 @@
|
||||
cmake_minimum_required(VERSION 3.24 FATAL_ERROR)
|
||||
|
||||
# cmake setup begin
|
||||
project(solanaceae_factorio)
|
||||
|
||||
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
set(SOLANACEAE_FACTORIO_STANDALONE ON)
|
||||
else()
|
||||
set(SOLANACEAE_FACTORIO_STANDALONE OFF)
|
||||
endif()
|
||||
message("II SOLANACEAE_FACTORIO_STANDALONE " ${SOLANACEAE_FACTORIO_STANDALONE})
|
||||
|
||||
option(SOLANACEAE_FACTORIO_BUILD_PLUGINS "Build the factorio plugins" ${SOLANACEAE_FACTORIO_STANDALONE})
|
||||
|
||||
if (SOLANACEAE_FACTORIO_STANDALONE)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# defaulting to debug mode, if not specified
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
endif()
|
||||
|
||||
# setup my vim ycm :D
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# more paths
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
endif()
|
||||
|
||||
# external libs
|
||||
add_subdirectory(./external EXCLUDE_FROM_ALL) # before increasing warn levels, sad :(
|
||||
|
||||
if (SOLANACEAE_FACTORIO_STANDALONE)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# bump up warning levels appropriately for clang, gcc & msvc
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
add_compile_options(
|
||||
-Wall -Wextra # Reasonable and standard
|
||||
-Wpedantic # Warn if non-standard C++ is used
|
||||
-Wunused # Warn on anything being unused
|
||||
#-Wconversion # Warn on type conversions that may lose data
|
||||
#-Wsign-conversion # Warn on sign conversions
|
||||
-Wshadow # Warn if a variable declaration shadows one from a parent context
|
||||
)
|
||||
|
||||
if (NOT WIN32)
|
||||
#link_libraries(-fsanitize=address)
|
||||
#link_libraries(-fsanitize=address,undefined)
|
||||
#link_libraries(-fsanitize-address-use-after-scope)
|
||||
#link_libraries(-fsanitize=undefined)
|
||||
endif()
|
||||
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
||||
if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# cmake setup end
|
||||
|
||||
add_subdirectory(./src)
|
||||
|
||||
if (SOLANACEAE_FACTORIO_BUILD_PLUGINS)
|
||||
add_subdirectory(./plugins)
|
||||
endif()
|
||||
|
22
external/CMakeLists.txt
vendored
Normal file
22
external/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.24 FATAL_ERROR)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
if (NOT TARGET solanaceae_message3)
|
||||
FetchContent_Declare(solanaceae_message3
|
||||
GIT_REPOSITORY https://github.com/Green-Sky/solanaceae_message3.git
|
||||
GIT_TAG master
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
FetchContent_MakeAvailable(solanaceae_message3)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET solanaceae_plugin)
|
||||
FetchContent_Declare(solanaceae_plugin
|
||||
GIT_REPOSITORY https://github.com/Green-Sky/solanaceae_plugin.git
|
||||
GIT_TAG master
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
FetchContent_MakeAvailable(solanaceae_plugin)
|
||||
endif()
|
||||
|
17
plugins/CMakeLists.txt
Normal file
17
plugins/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.9...3.24 FATAL_ERROR)
|
||||
|
||||
add_library(plugin_factorio SHARED
|
||||
./plugin_factorio.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(plugin_factorio PUBLIC
|
||||
solanaceae_plugin
|
||||
solanaceae_factorio
|
||||
)
|
||||
|
||||
set_target_properties(plugin_factorio PROPERTIES
|
||||
C_VISIBILITY_PRESET hidden
|
||||
)
|
||||
# probably not enough
|
||||
target_compile_definitions(plugin_factorio PUBLIC ENTT_API_IMPORT)
|
||||
|
61
plugins/plugin_factorio.cpp
Normal file
61
plugins/plugin_factorio.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#include <solanaceae/plugin/solana_plugin_v1.h>
|
||||
|
||||
#include <entt/entt.hpp>
|
||||
#include <entt/fwd.hpp>
|
||||
|
||||
#include "factorio.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
static std::unique_ptr<Factorio> g_f = nullptr;
|
||||
|
||||
constexpr const char* plugin_name = "Factorio";
|
||||
|
||||
extern "C" {
|
||||
|
||||
SOLANA_PLUGIN_EXPORT const char* solana_plugin_get_name(void) {
|
||||
return plugin_name;
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
|
||||
return SOLANA_PLUGIN_VERSION;
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api) {
|
||||
std::cout << "PLUGIN " << plugin_name << " START()\n";
|
||||
|
||||
if (solana_api == nullptr) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
|
||||
auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModel);
|
||||
|
||||
// static store, could be anywhere tho
|
||||
// construct with fetched dependencies
|
||||
g_f = std::make_unique<Factorio>(*cr, *rmm);
|
||||
|
||||
// register types
|
||||
PLUG_PROVIDE_INSTANCE(Factorio, plugin_name, g_f.get());
|
||||
} catch (const ResolveException& e) {
|
||||
std::cerr << "PLUGIN " << plugin_name << " " << e.what << "\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) {
|
||||
std::cout << "PLUGIN " << plugin_name << " STOP()\n";
|
||||
|
||||
g_f.reset();
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT float solana_plugin_tick(float) {
|
||||
//return g_rpbot->tick(delta);
|
||||
return 1000.f;
|
||||
}
|
||||
|
||||
} // extern C
|
||||
|
17
src/CMakeLists.txt
Normal file
17
src/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.9...3.24 FATAL_ERROR)
|
||||
|
||||
project(solanaceae)
|
||||
|
||||
add_library(solanaceae_factorio
|
||||
./factorio.hpp
|
||||
./factorio.cpp
|
||||
)
|
||||
|
||||
target_include_directories(solanaceae_factorio PUBLIC .)
|
||||
target_compile_features(solanaceae_factorio PUBLIC cxx_std_17)
|
||||
target_link_libraries(solanaceae_factorio PUBLIC
|
||||
solanaceae_message3
|
||||
)
|
||||
|
||||
########################################
|
||||
|
16
src/factorio.cpp
Normal file
16
src/factorio.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "./factorio.hpp"
|
||||
|
||||
#include <solanaceae/message3/components.hpp>
|
||||
#include <solanaceae/contact/components.hpp>
|
||||
|
||||
Factorio::Factorio(Contact3Registry& cr, RegistryMessageModel& rmm) : _cr(cr), _rmm(rmm) {
|
||||
_rmm.subscribe(this, RegistryMessageModel_Event::message_construct);
|
||||
}
|
||||
|
||||
Factorio::~Factorio(void) {
|
||||
}
|
||||
|
||||
bool Factorio::onEvent(const Message::Events::MessageConstruct& e) {
|
||||
return false;
|
||||
}
|
||||
|
17
src/factorio.hpp
Normal file
17
src/factorio.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <solanaceae/message3/registry_message_model.hpp>
|
||||
|
||||
class Factorio : public RegistryMessageModelEventI {
|
||||
Contact3Registry& _cr;
|
||||
RegistryMessageModel& _rmm;
|
||||
|
||||
public:
|
||||
Factorio(Contact3Registry& cr, RegistryMessageModel& rmm);
|
||||
virtual ~Factorio(void);
|
||||
|
||||
protected: // rmm
|
||||
bool onEvent(const Message::Events::MessageConstruct& e) override;
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user