From 7304faf1aec4a415de6c473d191c1629044ad8a4 Mon Sep 17 00:00:00 2001 From: jusax23 Date: Wed, 1 Nov 2023 12:15:47 +0100 Subject: [PATCH] linux & windows package lib location fix --- lib/stockfish.dart | 11 +++++++---- linux/CMakeLists.txt | 6 +++--- src/CMakeLists.txt | 15 ++++++++------- src/stockfish.cpp | 2 +- windows/CMakeLists.txt | 6 +++--- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib/stockfish.dart b/lib/stockfish.dart index 0636f28..3c06d41 100644 --- a/lib/stockfish.dart +++ b/lib/stockfish.dart @@ -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}'); }(); diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index 9bcbb05..6b0cdb4 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -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. - $ + $ PARENT_SCOPE ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 69d6386..379f1bc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 "./" ) diff --git a/src/stockfish.cpp b/src/stockfish.cpp index 9991bee..f1e6fba 100644 --- a/src/stockfish.cpp +++ b/src/stockfish.cpp @@ -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; } diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index bcc855d..3ce1e29 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -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. - $ + $ PARENT_SCOPE )