mirror of
https://github.com/pine64/blisp.git
synced 2025-05-12 19:37:12 +00:00
Add proper Windows support
This commit is contained in:
parent
6b97b239cb
commit
7795de96ff
@ -10,3 +10,6 @@ target_link_libraries(blisp PRIVATE
|
|||||||
argtable3
|
argtable3
|
||||||
libblisp_static)
|
libblisp_static)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
target_link_libraries(blisp PRIVATE Setupapi.lib)
|
||||||
|
endif()
|
@ -6,6 +6,11 @@
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
#include <BaseTsd.h>
|
||||||
|
typedef SSIZE_T ssize_t;
|
||||||
|
#include <windows.h>
|
||||||
|
#define PATH_MAX MAX_PATH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define REG_EXTENDED 1
|
#define REG_EXTENDED 1
|
||||||
@ -20,15 +25,14 @@ static void* cmd_write_argtable[5];
|
|||||||
ssize_t
|
ssize_t
|
||||||
get_binary_folder(char* buffer, uint32_t buffer_size) {
|
get_binary_folder(char* buffer, uint32_t buffer_size) {
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
readlink("/proc/self/exe", buffer, BUFSIZ); // TODO: Error handling
|
readlink("/proc/self/exe", buffer, buffer_size); // TODO: Error handling
|
||||||
char* pos = strrchr(buffer, '/');
|
char* pos = strrchr(buffer, '/');
|
||||||
|
#else
|
||||||
|
GetModuleFileName(NULL, buffer, buffer_size);
|
||||||
|
char* pos = strrchr(buffer, '\\');
|
||||||
|
#endif
|
||||||
pos[0] = '\0';
|
pos[0] = '\0';
|
||||||
return pos - buffer;
|
return pos - buffer;
|
||||||
#else
|
|
||||||
#error NOT IMPLEMENTED
|
|
||||||
WCHAR path[MAX_PATH];
|
|
||||||
GetModuleFileName(NULL, path, ARRAYSIZE(path));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void blisp_flash_firmware() {
|
void blisp_flash_firmware() {
|
||||||
@ -90,7 +94,7 @@ void blisp_flash_firmware() {
|
|||||||
get_binary_folder(exe_path, PATH_MAX); // TODO: Error handling
|
get_binary_folder(exe_path, PATH_MAX); // TODO: Error handling
|
||||||
snprintf(eflash_loader_path, PATH_MAX, "%s/data/%s/eflash_loader_32m.bin", exe_path, device.chip->type_str);
|
snprintf(eflash_loader_path, PATH_MAX, "%s/data/%s/eflash_loader_32m.bin", exe_path, device.chip->type_str);
|
||||||
|
|
||||||
FILE* eflash_loader_file = fopen(eflash_loader_path, "rb");
|
FILE* eflash_loader_file = fopen(eflash_loader_path, "rb"); // TODO: Error handling
|
||||||
uint8_t eflash_loader_header[176];
|
uint8_t eflash_loader_header[176];
|
||||||
fread(eflash_loader_header, 176, 1, eflash_loader_file); // TODO: Error handling
|
fread(eflash_loader_header, 176, 1, eflash_loader_file); // TODO: Error handling
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user