Pārlūkot izejas kodu

Added option to build minimal vcmi library as needed by lobby

Ivan Savenko 1 gadu atpakaļ
vecāks
revīzija
39da7b3e32
3 mainītis faili ar 107 papildinājumiem un 83 dzēšanām
  1. 5 0
      CMakeLists.txt
  2. 100 83
      lib/CMakeLists.txt
  3. 2 0
      lib/json/JsonValidator.cpp

+ 5 - 0
CMakeLists.txt

@@ -44,6 +44,7 @@ option(ENABLE_LUA "Enable compilation of LUA scripting module" OFF)
 option(ENABLE_TRANSLATIONS "Enable generation of translations for launcher and editor" ON)
 option(ENABLE_NULLKILLER_AI "Enable compilation of Nullkiller AI library" ON)
 option(ENABLE_GITVERSION "Enable Version.cpp with Git commit hash" ON)
+option(ENABLE_MINIMAL_LIB "Build only core parts of vcmi library that are required for game lobby" OFF)
 
 # Compilation options
 
@@ -248,6 +249,10 @@ if(ENABLE_SINGLE_APP_BUILD)
 	add_definitions(-DENABLE_SINGLE_APP_BUILD)
 endif()
 
+if(ENABLE_MINIMAL_LIB)
+	add_definitions(-DENABLE_MINIMAL_LIB)
+endif()
+
 if(APPLE_IOS)
 	set(CMAKE_MACOSX_RPATH 1)
 	set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0)

+ 100 - 83
lib/CMakeLists.txt

@@ -1,6 +1,48 @@
 set(lib_SRCS
 	StdInc.cpp
 
+	filesystem/AdapterLoaders.cpp
+	filesystem/CArchiveLoader.cpp
+	filesystem/CBinaryReader.cpp
+	filesystem/CCompressedStream.cpp
+	filesystem/CFileInputStream.cpp
+	filesystem/CFilesystemLoader.cpp
+	filesystem/CMemoryBuffer.cpp
+	filesystem/CMemoryStream.cpp
+	filesystem/CZipLoader.cpp
+	filesystem/CZipSaver.cpp
+	filesystem/FileInfo.cpp
+	filesystem/Filesystem.cpp
+	filesystem/MinizipExtensions.cpp
+	filesystem/ResourcePath.cpp
+
+	json/JsonNode.cpp
+	json/JsonParser.cpp
+	json/JsonRandom.cpp
+	json/JsonUtils.cpp
+	json/JsonValidator.cpp
+	json/JsonWriter.cpp
+
+	logging/CBasicLogConfigurator.cpp
+	logging/CLogger.cpp
+	logging/VisualLogger.cpp
+
+	network/NetworkConnection.cpp
+	network/NetworkHandler.cpp
+	network/NetworkServer.cpp
+
+	vstd/DateUtils.cpp
+	vstd/StringUtils.cpp
+
+	CConfigHandler.cpp
+	CConsoleHandler.cpp
+	CThreadHelper.cpp
+	TextOperations.cpp
+	VCMIDirs.cpp
+)
+
+set(lib_MAIN_SRCS
+
 	battle/AccessibilityInfo.cpp
 	battle/BattleAction.cpp
 	battle/BattleAttackInfo.cpp
@@ -46,38 +88,13 @@ set(lib_SRCS
 	events/PlayerGotTurn.cpp
 	events/TurnStarted.cpp
 
-	filesystem/AdapterLoaders.cpp
-	filesystem/CArchiveLoader.cpp
-	filesystem/CBinaryReader.cpp
-	filesystem/CCompressedStream.cpp
-	filesystem/CFileInputStream.cpp
-	filesystem/CFilesystemLoader.cpp
-	filesystem/CMemoryBuffer.cpp
-	filesystem/CMemoryStream.cpp
-	filesystem/CZipLoader.cpp
-	filesystem/CZipSaver.cpp
-	filesystem/FileInfo.cpp
-	filesystem/Filesystem.cpp
-	filesystem/MinizipExtensions.cpp
-	filesystem/ResourcePath.cpp
-
 	json/JsonBonus.cpp
-	json/JsonNode.cpp
-	json/JsonParser.cpp
-	json/JsonRandom.cpp
-	json/JsonUtils.cpp
-	json/JsonValidator.cpp
-	json/JsonWriter.cpp
 
 	gameState/CGameState.cpp
 	gameState/CGameStateCampaign.cpp
 	gameState/InfoAboutArmy.cpp
 	gameState/TavernHeroesPool.cpp
 
-	logging/CBasicLogConfigurator.cpp
-	logging/CLogger.cpp
-	logging/VisualLogger.cpp
-
 	mapObjectConstructors/AObjectTypeHandler.cpp
 	mapObjectConstructors/CBankInstanceConstructor.cpp
 	mapObjectConstructors/CObjectClassesHandler.cpp
@@ -128,10 +145,6 @@ set(lib_SRCS
 	modding/IdentifierStorage.cpp
 	modding/ModUtility.cpp
 
-	network/NetworkConnection.cpp
-	network/NetworkHandler.cpp
-	network/NetworkServer.cpp
-
 	networkPacks/NetPacksLib.cpp
 
 	pathfinder/CGPathNode.cpp
@@ -225,9 +238,6 @@ set(lib_SRCS
 	spells/effects/RemoveObstacle.cpp
 	spells/effects/Sacrifice.cpp
 
-	vstd/DateUtils.cpp
-	vstd/StringUtils.cpp
-
 	ArtifactUtils.cpp
 	BasicTypes.cpp
 	BattleFieldHandler.cpp
@@ -236,8 +246,6 @@ set(lib_SRCS
 	CArtifactInstance.cpp
 	CBonusTypeHandler.cpp
 	CBuildingHandler.cpp
-	CConfigHandler.cpp
-	CConsoleHandler.cpp
 	CCreatureHandler.cpp
 	CCreatureSet.cpp
 	CGameInfoCallback.cpp
@@ -249,7 +257,6 @@ set(lib_SRCS
 	CScriptingModule.cpp
 	CSkillHandler.cpp
 	CStack.cpp
-	CThreadHelper.cpp
 	CTownHandler.cpp
 	GameSettings.cpp
 	IGameCallback.cpp
@@ -264,12 +271,14 @@ set(lib_SRCS
 	RoadHandler.cpp
 	ScriptHandler.cpp
 	TerrainHandler.cpp
-	TextOperations.cpp
 	TurnTimerInfo.cpp
-	VCMIDirs.cpp
 	VCMI_Lib.cpp
 )
 
+if (NOT ENABLE_MINIMAL_LIB)
+	list(APPEND lib_SRCS ${lib_MAIN_SRCS})
+endif()
+
 # Version.cpp is a generated file
 if(ENABLE_GITVERSION)
 	list(APPEND lib_SRCS ${CMAKE_BINARY_DIR}/Version.cpp)
@@ -280,14 +289,61 @@ endif()
 
 set(lib_HEADERS
 	../include/vstd/CLoggerBase.h
+	../include/vstd/DateUtils.h
+	../include/vstd/StringUtils.h
 	../Global.h
 	../AUTHORS.h
 	StdInc.h
 
+	filesystem/AdapterLoaders.h
+	filesystem/CArchiveLoader.h
+	filesystem/CBinaryReader.h
+	filesystem/CCompressedStream.h
+	filesystem/CFileInputStream.h
+	filesystem/CFilesystemLoader.h
+	filesystem/CInputOutputStream.h
+	filesystem/CInputStream.h
+	filesystem/CMemoryBuffer.h
+	filesystem/CMemoryStream.h
+	filesystem/COutputStream.h
+	filesystem/CStream.h
+	filesystem/CZipLoader.h
+	filesystem/CZipSaver.h
+	filesystem/FileInfo.h
+	filesystem/Filesystem.h
+	filesystem/ISimpleResourceLoader.h
+	filesystem/MinizipExtensions.h
+	filesystem/ResourcePath.h
+
+	json/JsonBonus.h
+	json/JsonFormatException.h
+	json/JsonNode.h
+	json/JsonParser.h
+	json/JsonRandom.h
+	json/JsonUtils.h
+	json/JsonValidator.h
+	json/JsonWriter.h
+
+	logging/CBasicLogConfigurator.h
+	logging/CLogger.h
+	logging/VisualLogger.h
+
+	network/NetworkConnection.h
+	network/NetworkDefines.h
+	network/NetworkHandler.h
+	network/NetworkInterface.h
+	network/NetworkServer.h
+
+	CConfigHandler.h
+	CConsoleHandler.h
+	CThreadHelper.h
+	TextOperations.h
+	VCMIDirs.h
+)
+
+set(lib_MAIN_HEADERS
 	../include/vstd/ContainerUtils.h
 	../include/vstd/RNG.h
-	../include/vstd/DateUtils.h
-	../include/vstd/StringUtils.h
 
 	../include/vcmi/events/AdventureEvents.h
 	../include/vcmi/events/ApplyDamage.h
@@ -385,35 +441,6 @@ set(lib_HEADERS
 	events/PlayerGotTurn.h
 	events/TurnStarted.h
 
-	filesystem/AdapterLoaders.h
-	filesystem/CArchiveLoader.h
-	filesystem/CBinaryReader.h
-	filesystem/CCompressedStream.h
-	filesystem/CFileInputStream.h
-	filesystem/CFilesystemLoader.h
-	filesystem/CInputOutputStream.h
-	filesystem/CInputStream.h
-	filesystem/CMemoryBuffer.h
-	filesystem/CMemoryStream.h
-	filesystem/COutputStream.h
-	filesystem/CStream.h
-	filesystem/CZipLoader.h
-	filesystem/CZipSaver.h
-	filesystem/FileInfo.h
-	filesystem/Filesystem.h
-	filesystem/ISimpleResourceLoader.h
-	filesystem/MinizipExtensions.h
-	filesystem/ResourcePath.h
-
-	json/JsonBonus.h
-	json/JsonFormatException.h
-	json/JsonNode.h
-	json/JsonParser.h
-	json/JsonRandom.h
-	json/JsonUtils.h
-	json/JsonValidator.h
-	json/JsonWriter.h
-
 	gameState/CGameState.h
 	gameState/CGameStateCampaign.h
 	gameState/EVictoryLossCheckResult.h
@@ -423,10 +450,6 @@ set(lib_HEADERS
 	gameState/TavernSlot.h
 	gameState/QuestInfo.h
 
-	logging/CBasicLogConfigurator.h
-	logging/CLogger.h
-	logging/VisualLogger.h
-
 	mapObjectConstructors/AObjectTypeHandler.h
 	mapObjectConstructors/CBankInstanceConstructor.h
 	mapObjectConstructors/CDefaultObjectTypeHandler.h
@@ -487,12 +510,6 @@ set(lib_HEADERS
 	modding/ModUtility.h
 	modding/ModVerificationInfo.h
 
-	network/NetworkConnection.h
-	network/NetworkDefines.h
-	network/NetworkHandler.h
-	network/NetworkInterface.h
-	network/NetworkServer.h
-
 	networkPacks/ArtifactLocation.h
 	networkPacks/BattleChanges.h
 	networkPacks/Component.h
@@ -622,8 +639,6 @@ set(lib_HEADERS
 	CArtifactInstance.h
 	CBonusTypeHandler.h
 	CBuildingHandler.h
-	CConfigHandler.h
-	CConsoleHandler.h
 	CCreatureHandler.h
 	CCreatureSet.h
 	CGameInfoCallback.h
@@ -640,7 +655,6 @@ set(lib_HEADERS
 	CSoundBase.h
 	CStack.h
 	CStopWatch.h
-	CThreadHelper.h
 	CTownHandler.h
 	ExtraOptionsInfo.h
 	FunctionList.h
@@ -667,14 +681,16 @@ set(lib_HEADERS
 	ScopeGuard.h
 	StartInfo.h
 	TerrainHandler.h
-	TextOperations.h
 	TurnTimerInfo.h
 	UnlockGuard.h
-	VCMIDirs.h
 	vcmi_endian.h
 	VCMI_Lib.h
 )
 
+if (NOT ENABLE_MINIMAL_LIB)
+	list(APPEND lib_HEADERS ${lib_MAIN_HEADERS})
+endif()
+
 assign_source_group(${lib_SRCS} ${lib_HEADERS})
 
 if(ENABLE_STATIC_LIBS)
@@ -682,6 +698,7 @@ if(ENABLE_STATIC_LIBS)
 else()
 	add_library(vcmi SHARED ${lib_SRCS} ${lib_HEADERS})
 endif()
+
 set_target_properties(vcmi PROPERTIES COMPILE_DEFINITIONS "VCMI_DLL=1")
 target_link_libraries(vcmi PUBLIC
 	minizip::minizip ZLIB::ZLIB

+ 2 - 0
lib/json/JsonValidator.cpp

@@ -422,6 +422,7 @@ static std::string additionalPropertiesCheck(JsonValidator & validator, const Js
 
 static bool testFilePresence(const std::string & scope, const ResourcePath & resource)
 {
+#ifndef ENABLE_MINIMAL_LIB
 	std::set<std::string> allowedScopes;
 	if(scope != ModScope::scopeBuiltin() && !scope.empty()) // all real mods may have dependencies
 	{
@@ -441,6 +442,7 @@ static bool testFilePresence(const std::string & scope, const ResourcePath & res
 		if (CResourceHandler::get(entry)->existsResource(resource))
 			return true;
 	}
+#endif
 	return false;
 }