This commit is contained in:
Marek Kraus 2022-09-13 11:03:39 +02:00
parent 4f6df4fb46
commit e9217452e4
5 changed files with 36 additions and 29 deletions

View File

@ -3,30 +3,26 @@ project(blisp C)
set(CMAKE_C_STANDARD 23)
add_subdirectory(vendor/argtable3)
add_subdirectory(tools/blisp)
add_executable(blisp src/main.c src/cmd/write.c)
target_include_directories(blisp PRIVATE vendor/argtable3/src)
target_link_libraries(blisp PRIVATE argtable3)
target_sources(blisp PRIVATE
${CMAKE_SOURCE_DIR}/vendor/libserialport/serialport.c
${CMAKE_SOURCE_DIR}/vendor/libserialport/timing.c)
if(WIN32)
target_link_libraries(blisp PRIVATE Setupapi.lib)
target_compile_definitions(blisp PRIVATE LIBSERIALPORT_MSBUILD)
target_sources(blisp PRIVATE
${CMAKE_SOURCE_DIR}/vendor/libserialport/windows.c)
elseif(UNIX AND NOT APPLE)
target_sources(blisp PRIVATE
${CMAKE_SOURCE_DIR}/vendor/libserialport/linux.c
${CMAKE_SOURCE_DIR}/vendor/libserialport/linux_termios.c)
target_compile_definitions(blisp PRIVATE
LIBSERIALPORT_ATBUILD
"SP_API=__attribute__((visibility(\"default\")))"
"SP_PRIV=__attribute__((visibility(\"hidden\")))")
target_include_directories(blisp PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport)
write_file(${CMAKE_SOURCE_DIR}/vendor/libserialport/config.h "// bypass errors.")
endif()
#target_sources(blisp PRIVATE
# ${CMAKE_SOURCE_DIR}/vendor/libserialport/serialport.c
# ${CMAKE_SOURCE_DIR}/vendor/libserialport/timing.c)
#
#if(WIN32)
# target_link_libraries(blisp PRIVATE Setupapi.lib)
# target_compile_definitions(blisp PRIVATE LIBSERIALPORT_MSBUILD)
# target_sources(blisp PRIVATE
# ${CMAKE_SOURCE_DIR}/vendor/libserialport/windows.c)
#elseif(UNIX AND NOT APPLE)
# target_sources(blisp PRIVATE
# ${CMAKE_SOURCE_DIR}/vendor/libserialport/linux.c
# ${CMAKE_SOURCE_DIR}/vendor/libserialport/linux_termios.c)
# target_compile_definitions(blisp PRIVATE
# LIBSERIALPORT_ATBUILD
# "SP_API=__attribute__((visibility(\"default\")))"
# "SP_PRIV=__attribute__((visibility(\"hidden\")))")
# target_include_directories(blisp PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport)
# write_file(${CMAKE_SOURCE_DIR}/vendor/libserialport/config.h "// bypass errors.")
#endif()

View File

@ -0,0 +1,6 @@
add_subdirectory(${CMAKE_SOURCE_DIR}/vendor/argtable3 ${CMAKE_CURRENT_BINARY_DIR}/argtable3)
add_executable(blisp src/main.c src/cmd/write.c)
target_include_directories(blisp PRIVATE "${CMAKE_SOURCE_DIR}/vendor/argtable3/src")
target_link_libraries(blisp PRIVATE argtable3)

View File

@ -1,5 +1,10 @@
#include "../cmd.h"
#include <argtable3.h>
#include "argtable3.h"
void blisp_flash_firmware(const char* firmware_path) {
printf("");
}
#define REG_EXTENDED 1
#define REG_ICASE (REG_EXTENDED << 1)
@ -35,7 +40,7 @@ uint8_t
cmd_write_parse_exec(int argc, char** argv) {
int errors = arg_parse(argc, argv, cmd_write_argtable);
if (errors == 0) {
printf("yeet\n");
blisp_flash_firmware(binary_to_write->filename[0]); // TODO: Error code?
return 1;
} else if (cmd->count == 1) {
cmd_write_args_print_glossary();

View File

@ -1,8 +1,8 @@
#include "argtable3.h"
#include "cmd.h"
#include <argtable3.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
struct cmd* cmds[] = {
&cmd_write