linux & windows package lib location fix

This commit is contained in:
jusax23 2023-11-01 12:15:47 +01:00
parent 884c258669
commit 7304faf1ae
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41
5 changed files with 22 additions and 18 deletions

View file

@ -13,7 +13,7 @@ import 'package:ffi/ffi.dart';
import 'stockfish_bindings_generated.dart';
import 'stockfish_state.dart';
const String _libName = 'stockfish';
const String _libName = 'flutter_stockfish_plugin';
const String _releaseType = kDebugMode ? 'Debug' : 'Release';
/// The dynamic library in which the symbols for [StockfishChessEngineBindings] can be found.
@ -21,17 +21,20 @@ final DynamicLibrary _dylib = () {
if (Platform.isMacOS || Platform.isIOS) {
return DynamicLibrary.open('$_libName.framework/$_libName');
}
if (Platform.isAndroid) {
if (Platform.isAndroid || Platform.isLinux) {
return DynamicLibrary.open('lib$_libName.so');
}
if (Platform.isLinux) {
if (Platform.isWindows) {
return DynamicLibrary.open('$_libName.dll');
}
/*if (Platform.isLinux) {
return DynamicLibrary.open(
'${File(Platform.resolvedExecutable).parent.parent.path}/plugins/flutter_stockfish_plugin/shared/lib$_libName.so');
}
if (Platform.isWindows) {
return DynamicLibrary.open(
'${File(Platform.resolvedExecutable).parent.parent.parent.path}/plugins/flutter_stockfish_plugin/shared/$_releaseType/$_libName.dll');
}
}*/
throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}');
}();

View file

@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.22)
# Project-level configuration.
set(PROJECT_NAME "stockfish")
set(PROJECT_NAME "flutter_stockfish_plugin")
project(${PROJECT_NAME} LANGUAGES CXX)
# Invoke the build for native code shared with the other target platforms.
@ -14,9 +14,9 @@ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DI
# List of absolute paths to libraries that should be bundled with the plugin.
# This list could contain prebuilt libraries, or libraries created by an
# external build triggered from this build file.
set(stockfish_bundled_libraries
set(flutter_stockfish_plugin_bundled_libraries
# Defined in ../src/CMakeLists.txt.
# This can be changed to accomodate different builds.
$<TARGET_FILE:stockfish>
$<TARGET_FILE:flutter_stockfish_plugin>
PARENT_SCOPE
)

View file

@ -3,23 +3,24 @@
# the plugin to fail to compile for some customers of the plugin.
cmake_minimum_required(VERSION 3.18)
project(stockfish VERSION 0.0.1 LANGUAGES CXX)
project(flutter_stockfish_plugin VERSION 0.0.1 LANGUAGES CXX)
file(GLOB_RECURSE cppPaths "Stockfish/src/*.cpp")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-O3 -flto -march=native")
set(CMAKE_CXX_FLAGS "-O3 -flto")
#set(CMAKE_CXX_FLAGS "-O3 -flto -march=native")
#old: -Wshadow -Wmissing-declarations -fno-exceptions -std=c++17 -fPIC -Wall -Wextra -march=native
#set(CMAKE_CXX_FLAGS_RELEASE "-O3 -flto -march=native")
set(NNUE_NAME nn-5af11540bbfe.nnue)
add_library(stockfish SHARED
add_library(flutter_stockfish_plugin SHARED
"stockfish.cpp"
"stream_fix.cpp"
${cppPaths}
)
set_target_properties(stockfish PROPERTIES
set_target_properties(flutter_stockfish_plugin PROPERTIES
PUBLIC_HEADER stockfish.h
OUTPUT_NAME "stockfish"
OUTPUT_NAME "flutter_stockfish_plugin"
)
if(MSVC)
@ -28,9 +29,9 @@ else()
add_definitions(-include stream_fix.h)
endif()
target_compile_definitions(stockfish PUBLIC DART_SHARED_LIB)
target_compile_definitions(flutter_stockfish_plugin PUBLIC DART_SHARED_LIB)
target_include_directories(stockfish
target_include_directories(flutter_stockfish_plugin
PUBLIC
"./"
)

View file

@ -24,7 +24,7 @@ const char *QUITOK = "quitok\n";
int main(int, char **);
int stockfish_init() {
std::cout << "Init Stockfish: Nothing todo!";
//std::cout << "Init Stockfish: Nothing todo!";
return 0;
}

View file

@ -5,7 +5,7 @@
cmake_minimum_required(VERSION 3.22)
# Project-level configuration.
set(PROJECT_NAME "stockfish")
set(PROJECT_NAME "flutter_stockfish_plugin")
project(${PROJECT_NAME} LANGUAGES CXX)
# Invoke the build for native code shared with the other target platforms.
@ -15,9 +15,9 @@ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DI
# List of absolute paths to libraries that should be bundled with the plugin.
# This list could contain prebuilt libraries, or libraries created by an
# external build triggered from this build file.
set(stockfish_bundled_libraries
set(flutter_stockfish_plugin_bundled_libraries
# Defined in ../src/CMakeLists.txt.
# This can be changed to accomodate different builds.
$<TARGET_FILE:stockfish>
$<TARGET_FILE:flutter_stockfish_plugin>
PARENT_SCOPE
)