Add initial MacOS support

This commit is contained in:
Marek Kraus 2022-12-06 17:15:53 +01:00
parent a68c54ed2b
commit eb086f6fe3
5 changed files with 14 additions and 6 deletions

2
.gitignore vendored
View File

@ -76,3 +76,5 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
build/
.DS_Store

View File

@ -58,8 +58,11 @@ elseif(UNIX AND NOT APPLE)
elseif(APPLE)
target_sources(libblisp_obj PRIVATE
${CMAKE_SOURCE_DIR}/vendor/libserialport/macosx.c)
target_link_libraries(libblisp_obj PRIVATE "-framework IOKit" "-framework CoreFoundation")
target_compile_definitions(libblisp_obj PRIVATE LIBSERIALPORT_ATBUILD "SP_API=__attribute__((visibility(\"default\")))")
target_link_libraries(libblisp PRIVATE "-framework IOKit" "-framework CoreFoundation")
target_compile_definitions(libblisp_obj PRIVATE
LIBSERIALPORT_ATBUILD
"SP_PRIV=__attribute__((visibility(\"hidden\")))"
"SP_API=__attribute__((visibility(\"default\")))")
target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport)
write_file(${CMAKE_SOURCE_DIR}/vendor/libserialport/config.h "// bypass errors.")
endif()

View File

@ -2,7 +2,7 @@
#include <blisp.h>
#include <blisp_util.h>
#include <libserialport.h>
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View File

@ -12,4 +12,6 @@ target_link_libraries(blisp PRIVATE
if(WIN32)
target_link_libraries(blisp PRIVATE Setupapi.lib)
elseif(APPLE)
target_link_libraries(blisp PRIVATE "-framework IOKit" "-framework CoreFoundation")
endif()

View File

@ -5,6 +5,8 @@
#include <string.h>
#include <inttypes.h>
#include "blisp_struct.h"
#include <assert.h>
#include <stdlib.h>
#ifdef __linux__
#include <unistd.h>
@ -14,6 +16,8 @@
typedef SSIZE_T ssize_t;
#include <windows.h>
#define PATH_MAX MAX_PATH
#elif defined(__APPLE__)
#include <sys/syslimits.h>
#endif
#define REG_EXTENDED 1
@ -30,9 +34,6 @@ static void* cmd_write_argtable[6];
// Ugh. This stuff is just so messy without C++17 or Qt...
// These are not thread safe, but it doesn't place the responsibility
// to free an allocated buffer on the caller.nn
#include <string.h>
#include <assert.h>
#include <stdlib.h>
static void get_executable_path(char* buffer_out, uint32_t max_size) {
assert (max_size >= PATH_MAX); // n.b. 1024 on MacOS. 4K on most Linux.