Skip to content

Commit

Permalink
fix desktop runtime errors on windows&linux
Browse files Browse the repository at this point in the history
  • Loading branch information
takenagain committed Jan 9, 2025
1 parent 63486cc commit 638f0ba
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,24 @@ class KdfOperationsLocalExecutable implements IKdfOperations {
}

try {
// Store the config in a temp file to avoid command line argument and
// environment variable value size limits (varies from 4-128 KB).
final tempDir = await Directory.systemTemp.createTemp('mm_coins_');
final configFile = File(p.join(tempDir.path, 'kdf_config.json'));
await configFile.writeAsString(args.join());

final environment = Map<String, String>.from(Platform.environment)
..['MM_CONF_PATH'] = configFile.path;

final newProcess = await Process.start(
executablePath,
args,
[],
environment: environment,
runInShell: true,
);
await newProcess.exitCode.then((_) async {
await tempDir.delete(recursive: true);
});

_logCallback('Launched executable: $executablePath');
_attachProcessListeners(newProcess);
Expand Down
13 changes: 13 additions & 0 deletions packages/komodo_defi_framework/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,16 @@ set(komodo_defi_framework_bundled_libraries
${KDF_PATH}
PARENT_SCOPE
)

# For local development/debugging/testing
# Copies the KDF binary to $HOME/.local/bin to make it accessible
# This simplifies debug environment setup - avoids adding platform-dependent
# paths to vscode debugging configurations or environment variables
set(FINAL_INSTALL_DIR "$ENV{HOME}/.local/bin")
set(KDF_PATH "${CMAKE_CURRENT_SOURCE_DIR}/bin/kdf")
add_custom_command(
TARGET ${PLUGIN_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${KDF_PATH}
"${FINAL_INSTALL_DIR}/kdf"
)
22 changes: 22 additions & 0 deletions packages/komodo_defi_framework/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,25 @@ set(mm2_bundled_libraries
"${CMAKE_CURRENT_SOURCE_DIR}/bin/kdf.exe"
PARENT_SCOPE
)

# For local development/debugging/testing
# Copies the KDF binary to APPDATA to make it accessible
# This simplifies debug environment setup - avoids adding platform-dependent
# paths to vscode debugging configurations or environment variables
set(APP_NAME "KomodoPlatform")
set(FINAL_INSTALL_DIR "$ENV{APPDATA}/${APP_NAME}")
file(GLOB EXE_DLL_FILES "${CMAKE_CURRENT_SOURCE_DIR}/bin/*.exe" "${CMAKE_CURRENT_SOURCE_DIR}/bin/*.dll")
add_custom_command(
TARGET ${PLUGIN_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${FINAL_INSTALL_DIR}"
)
foreach(FILE ${EXE_DLL_FILES})
get_filename_component(FILE_NAME ${FILE} NAME)
add_custom_command(
TARGET ${PLUGIN_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${FILE}"
"${FINAL_INSTALL_DIR}/${FILE_NAME}"
VERBATIM
)
endforeach()

0 comments on commit 638f0ba

Please sign in to comment.