Skip to content

Commit

Permalink
fix binary rename step on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
takenagain committed Jan 3, 2025
1 parent 4ce5ec8 commit 393b078
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/komodo_defi_framework/app_build/build_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"coins": {
"fetch_at_build_enabled": true,
"update_commit_on_build": true,
"bundled_coins_repo_commit": "77ddee0b05d21161cb83b8dcc40f2d20af3e35ef",
"bundled_coins_repo_commit": "823310fc4985e76e5d9b80a216182bf57d24b477",
"coins_repo_api_url": "https://api.github.com/repos/KomodoPlatform/coins",
"coins_repo_content_url": "https://komodoplatform.github.io/coins",
"coins_repo_branch": "master",
Expand Down
2 changes: 1 addition & 1 deletion packages/komodo_defi_framework/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ foreach(FILE ${EXE_DLL_FILES})
endforeach()

set(mm2_bundled_libraries
"${CMAKE_CURRENT_SOURCE_DIR}/kdf"
"${CMAKE_CURRENT_SOURCE_DIR}/bin/kdf.exe"
PARENT_SCOPE
)
Original file line number Diff line number Diff line change
Expand Up @@ -492,20 +492,33 @@ class FetchDefiApiStep extends BuildStep {
// file build size or if it is required for cache-busting.
}
if (_isBinaryExecutable(platform)) {
_renameExecutable(destinationFolder);
_renameExecutable(platform, destinationFolder);
_setExecutablePermissions(destinationFolder);
}
return Future.value();
}

/// if executable is named "mm2" or "mm2.exe", then rename to "kdf"
void _renameExecutable(String destinationFolder) {
final executableName = Platform.isWindows ? 'mm2.exe' : 'mm2';
void _renameExecutable(String platform, String destinationFolder) {
final executableName = platform == 'windows' ? 'mm2.exe' : 'mm2';
final executablePath = path.join(destinationFolder, executableName);

_log.fine('Looking for executable at: $executablePath');
if (FileSystemEntity.isFileSync(executablePath)) {
final newExecutablePath = path.join(destinationFolder, 'kdf');
File(executablePath).renameSync(newExecutablePath);
_log.info('Renamed executable from $executableName to kdf');
final originalExtension = path.extension(executablePath);
final newExecutableName = 'kdf$originalExtension';
final newExecutablePath = path.join(destinationFolder, newExecutableName);

try {
File(executablePath).renameSync(newExecutablePath);
_log.info(
'Renamed executable from $executableName to $newExecutableName',
);
} catch (e) {
_log.severe('Failed to rename executable: $e');
}
} else {
_log.severe('Executable not found at: $executablePath');
}
}

Expand Down

0 comments on commit 393b078

Please sign in to comment.