linux & windows package lib location fix
This commit is contained in:
parent
884c258669
commit
7304faf1ae
5 changed files with 22 additions and 18 deletions
|
@ -13,7 +13,7 @@ import 'package:ffi/ffi.dart';
|
||||||
import 'stockfish_bindings_generated.dart';
|
import 'stockfish_bindings_generated.dart';
|
||||||
import 'stockfish_state.dart';
|
import 'stockfish_state.dart';
|
||||||
|
|
||||||
const String _libName = 'stockfish';
|
const String _libName = 'flutter_stockfish_plugin';
|
||||||
const String _releaseType = kDebugMode ? 'Debug' : 'Release';
|
const String _releaseType = kDebugMode ? 'Debug' : 'Release';
|
||||||
|
|
||||||
/// The dynamic library in which the symbols for [StockfishChessEngineBindings] can be found.
|
/// The dynamic library in which the symbols for [StockfishChessEngineBindings] can be found.
|
||||||
|
@ -21,17 +21,20 @@ final DynamicLibrary _dylib = () {
|
||||||
if (Platform.isMacOS || Platform.isIOS) {
|
if (Platform.isMacOS || Platform.isIOS) {
|
||||||
return DynamicLibrary.open('$_libName.framework/$_libName');
|
return DynamicLibrary.open('$_libName.framework/$_libName');
|
||||||
}
|
}
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid || Platform.isLinux) {
|
||||||
return DynamicLibrary.open('lib$_libName.so');
|
return DynamicLibrary.open('lib$_libName.so');
|
||||||
}
|
}
|
||||||
if (Platform.isLinux) {
|
if (Platform.isWindows) {
|
||||||
|
return DynamicLibrary.open('$_libName.dll');
|
||||||
|
}
|
||||||
|
/*if (Platform.isLinux) {
|
||||||
return DynamicLibrary.open(
|
return DynamicLibrary.open(
|
||||||
'${File(Platform.resolvedExecutable).parent.parent.path}/plugins/flutter_stockfish_plugin/shared/lib$_libName.so');
|
'${File(Platform.resolvedExecutable).parent.parent.path}/plugins/flutter_stockfish_plugin/shared/lib$_libName.so');
|
||||||
}
|
}
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
return DynamicLibrary.open(
|
return DynamicLibrary.open(
|
||||||
'${File(Platform.resolvedExecutable).parent.parent.parent.path}/plugins/flutter_stockfish_plugin/shared/$_releaseType/$_libName.dll');
|
'${File(Platform.resolvedExecutable).parent.parent.parent.path}/plugins/flutter_stockfish_plugin/shared/$_releaseType/$_libName.dll');
|
||||||
}
|
}*/
|
||||||
throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}');
|
throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}');
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
cmake_minimum_required(VERSION 3.22)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
# Project-level configuration.
|
# Project-level configuration.
|
||||||
set(PROJECT_NAME "stockfish")
|
set(PROJECT_NAME "flutter_stockfish_plugin")
|
||||||
project(${PROJECT_NAME} LANGUAGES CXX)
|
project(${PROJECT_NAME} LANGUAGES CXX)
|
||||||
|
|
||||||
# Invoke the build for native code shared with the other target platforms.
|
# 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.
|
# List of absolute paths to libraries that should be bundled with the plugin.
|
||||||
# This list could contain prebuilt libraries, or libraries created by an
|
# This list could contain prebuilt libraries, or libraries created by an
|
||||||
# external build triggered from this build file.
|
# external build triggered from this build file.
|
||||||
set(stockfish_bundled_libraries
|
set(flutter_stockfish_plugin_bundled_libraries
|
||||||
# Defined in ../src/CMakeLists.txt.
|
# Defined in ../src/CMakeLists.txt.
|
||||||
# This can be changed to accomodate different builds.
|
# This can be changed to accomodate different builds.
|
||||||
$<TARGET_FILE:stockfish>
|
$<TARGET_FILE:flutter_stockfish_plugin>
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,23 +3,24 @@
|
||||||
# the plugin to fail to compile for some customers of the plugin.
|
# the plugin to fail to compile for some customers of the plugin.
|
||||||
cmake_minimum_required(VERSION 3.18)
|
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")
|
file(GLOB_RECURSE cppPaths "Stockfish/src/*.cpp")
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
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
|
#old: -Wshadow -Wmissing-declarations -fno-exceptions -std=c++17 -fPIC -Wall -Wextra -march=native
|
||||||
#set(CMAKE_CXX_FLAGS_RELEASE "-O3 -flto -march=native")
|
#set(CMAKE_CXX_FLAGS_RELEASE "-O3 -flto -march=native")
|
||||||
set(NNUE_NAME nn-5af11540bbfe.nnue)
|
set(NNUE_NAME nn-5af11540bbfe.nnue)
|
||||||
|
|
||||||
add_library(stockfish SHARED
|
add_library(flutter_stockfish_plugin SHARED
|
||||||
"stockfish.cpp"
|
"stockfish.cpp"
|
||||||
"stream_fix.cpp"
|
"stream_fix.cpp"
|
||||||
${cppPaths}
|
${cppPaths}
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(stockfish PROPERTIES
|
set_target_properties(flutter_stockfish_plugin PROPERTIES
|
||||||
PUBLIC_HEADER stockfish.h
|
PUBLIC_HEADER stockfish.h
|
||||||
OUTPUT_NAME "stockfish"
|
OUTPUT_NAME "flutter_stockfish_plugin"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
@ -28,9 +29,9 @@ else()
|
||||||
add_definitions(-include stream_fix.h)
|
add_definitions(-include stream_fix.h)
|
||||||
endif()
|
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
|
PUBLIC
|
||||||
"./"
|
"./"
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,7 +24,7 @@ const char *QUITOK = "quitok\n";
|
||||||
int main(int, char **);
|
int main(int, char **);
|
||||||
|
|
||||||
int stockfish_init() {
|
int stockfish_init() {
|
||||||
std::cout << "Init Stockfish: Nothing todo!";
|
//std::cout << "Init Stockfish: Nothing todo!";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
cmake_minimum_required(VERSION 3.22)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
# Project-level configuration.
|
# Project-level configuration.
|
||||||
set(PROJECT_NAME "stockfish")
|
set(PROJECT_NAME "flutter_stockfish_plugin")
|
||||||
project(${PROJECT_NAME} LANGUAGES CXX)
|
project(${PROJECT_NAME} LANGUAGES CXX)
|
||||||
|
|
||||||
# Invoke the build for native code shared with the other target platforms.
|
# 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.
|
# List of absolute paths to libraries that should be bundled with the plugin.
|
||||||
# This list could contain prebuilt libraries, or libraries created by an
|
# This list could contain prebuilt libraries, or libraries created by an
|
||||||
# external build triggered from this build file.
|
# external build triggered from this build file.
|
||||||
set(stockfish_bundled_libraries
|
set(flutter_stockfish_plugin_bundled_libraries
|
||||||
# Defined in ../src/CMakeLists.txt.
|
# Defined in ../src/CMakeLists.txt.
|
||||||
# This can be changed to accomodate different builds.
|
# This can be changed to accomodate different builds.
|
||||||
$<TARGET_FILE:stockfish>
|
$<TARGET_FILE:flutter_stockfish_plugin>
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue