diff --git a/Sources/EmbeddedSwift/Documentation.docc/UsingEmbeddedSwift/Strings.md b/Sources/EmbeddedSwift/Documentation.docc/UsingEmbeddedSwift/Strings.md index c4d7cdf8..e8b94dca 100644 --- a/Sources/EmbeddedSwift/Documentation.docc/UsingEmbeddedSwift/Strings.md +++ b/Sources/EmbeddedSwift/Documentation.docc/UsingEmbeddedSwift/Strings.md @@ -35,6 +35,33 @@ $ swiftc -target armv6m-none-none-eabi -enable-experimental-feature Emb $ ld ... -o binary output.o $(dirname `which swiftc`)/../lib/swift/embedded/armv6m-none-none-eabi/libswiftUnicodeDataTables.a ``` +Alternatively in a CMake build try something like the below which will check a Swiftly based install. + +Update the `COMPILER_TARGET` variable to the architecture desired. + +```CMake +set(COMPILER_TARGET "riscv32-none-none-eabi") + +find_program(SWIFTLY "swiftly") +IF(SWIFTLY) + execute_process(COMMAND swiftly use --print-location OUTPUT_VARIABLE toolchain_path OUTPUT_STRIP_TRAILING_WHITESPACE) + cmake_path(SET additional_lib_path NORMALIZE "${toolchain_path}/usr/lib/swift/embedded/${COMPILER_TARGET}") +ELSE() + get_filename_component(compiler_bin_dir ${CMAKE_Swift_COMPILER} DIRECTORY) + cmake_path(SET additional_lib_path NORMALIZE "${compiler_bin_dir}/../lib/swift/embedded/${COMPILER_TARGET}") +ENDIF() + +target_link_directories(${COMPONENT_LIB} PUBLIC "${additional_lib_path}") +target_link_libraries(${COMPONENT_LIB} + -Wl,--whole-archive + swiftUnicodeDataTables + -Wl,--no-whole-archive + ) + +## decomment the below line to troubleshoot path issues if needed. +# message(" ----------::: ${additional_lib_path} :::---------- ") +``` + **Unicode data tables are required for (list not exhaustive):** - Comparing String objects for equality