diff options
Diffstat (limited to 'libs/nak_ffi')
| -rw-r--r-- | libs/nak_ffi/CMakeLists.txt | 38 | ||||
| -rw-r--r-- | libs/nak_ffi/Cargo.lock | 971 | ||||
| -rw-r--r-- | libs/nak_ffi/Cargo.toml | 10 | ||||
| -rw-r--r-- | libs/nak_ffi/include/nak_ffi.h | 230 | ||||
| -rw-r--r-- | libs/nak_ffi/src/lib.rs | 750 |
5 files changed, 0 insertions, 1999 deletions
diff --git a/libs/nak_ffi/CMakeLists.txt b/libs/nak_ffi/CMakeLists.txt deleted file mode 100644 index 72d939f..0000000 --- a/libs/nak_ffi/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -cmake_minimum_required(VERSION 3.16)
-project(nak_ffi)
-
-if(CMAKE_BUILD_TYPE STREQUAL "Debug")
- set(CARGO_BUILD_TYPE "debug")
- set(CARGO_BUILD_FLAGS "")
-else()
- set(CARGO_BUILD_TYPE "release")
- set(CARGO_BUILD_FLAGS "--release")
-endif()
-
-set(NAK_FFI_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-set(NAK_FFI_LIB ${NAK_FFI_DIR}/target/${CARGO_BUILD_TYPE}/libnak_ffi.so)
-
-# Glob all Rust sources so any change triggers a cargo rebuild
-file(GLOB_RECURSE NAK_FFI_SOURCES ${NAK_FFI_DIR}/src/*.rs)
-file(GLOB_RECURSE NAK_SOURCES ${NAK_FFI_DIR}/../nak/src/*.rs)
-
-add_custom_command(
- OUTPUT ${NAK_FFI_LIB}
- COMMAND cargo build ${CARGO_BUILD_FLAGS}
- WORKING_DIRECTORY ${NAK_FFI_DIR}
- COMMENT "Building NaK FFI library (Rust)"
- DEPENDS ${NAK_FFI_DIR}/Cargo.toml ${NAK_FFI_DIR}/../nak/Cargo.toml
- ${NAK_FFI_SOURCES} ${NAK_SOURCES}
-)
-
-add_custom_target(nak_ffi_build DEPENDS ${NAK_FFI_LIB})
-
-# INTERFACE wrapper so ALIAS works (CMake can't alias IMPORTED targets)
-add_library(nak_ffi_wrapper INTERFACE)
-target_link_libraries(nak_ffi_wrapper INTERFACE ${NAK_FFI_LIB})
-target_include_directories(nak_ffi_wrapper INTERFACE ${NAK_FFI_DIR}/include)
-add_dependencies(nak_ffi_wrapper nak_ffi_build)
-add_library(mo2::nak_ffi ALIAS nak_ffi_wrapper)
-
-install(FILES ${NAK_FFI_LIB} DESTINATION lib)
-install(DIRECTORY ${NAK_FFI_DIR}/include/ DESTINATION include)
diff --git a/libs/nak_ffi/Cargo.lock b/libs/nak_ffi/Cargo.lock deleted file mode 100644 index e8be402..0000000 --- a/libs/nak_ffi/Cargo.lock +++ /dev/null @@ -1,971 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "adler2" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "autocfg" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" - -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - -[[package]] -name = "bumpalo" -version = "3.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" - -[[package]] -name = "cc" -version = "1.2.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b26a0954ae34af09b50f0de26458fa95369a0d478d8236d3f93082b219bd29" -dependencies = [ - "find-msvc-tools", - "shlex", -] - -[[package]] -name = "cfg-if" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" - -[[package]] -name = "chrono" -version = "0.4.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fac4744fb15ae8337dc853fee7fb3f4e48c0fbaa23d0afe49c447b4fab126118" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-traits", - "wasm-bindgen", - "windows-link", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - -[[package]] -name = "crc32fast" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "dataview" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daba87f72c730b508641c9fb6411fc9bba73939eed2cab611c399500511880d0" -dependencies = [ - "derive_pod", -] - -[[package]] -name = "derive_pod" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ea6706d74fca54e15f1d40b5cf7fe7f764aaec61352a9fcec58fe27e042fc8" - -[[package]] -name = "displaydoc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "find-msvc-tools" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" - -[[package]] -name = "flate2" -version = "1.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "form_urlencoded" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "getrandom" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.65" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "log", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "icu_collections" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" -dependencies = [ - "displaydoc", - "potential_utf", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locale_core" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_normalizer" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" -dependencies = [ - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" - -[[package]] -name = "icu_properties" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" -dependencies = [ - "icu_collections", - "icu_locale_core", - "icu_properties_data", - "icu_provider", - "zerotrie", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" - -[[package]] -name = "icu_provider" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" -dependencies = [ - "displaydoc", - "icu_locale_core", - "writeable", - "yoke", - "zerofrom", - "zerotrie", - "zerovec", -] - -[[package]] -name = "idna" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" -dependencies = [ - "idna_adapter", - "smallvec", - "utf8_iter", -] - -[[package]] -name = "idna_adapter" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" -dependencies = [ - "icu_normalizer", - "icu_properties", -] - -[[package]] -name = "itoa" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" - -[[package]] -name = "js-sys" -version = "0.3.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" -dependencies = [ - "once_cell", - "wasm-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.180" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" - -[[package]] -name = "litemap" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" - -[[package]] -name = "log" -version = "0.4.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" - -[[package]] -name = "memchr" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" - -[[package]] -name = "miniz_oxide" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" -dependencies = [ - "adler2", - "simd-adler32", -] - -[[package]] -name = "nak_ffi" -version = "0.1.0" -dependencies = [ - "nak_rust", -] - -[[package]] -name = "nak_rust" -version = "0.1.0" -dependencies = [ - "chrono", - "pelite", - "serde", - "serde_json", - "ureq", - "walkdir", -] - -[[package]] -name = "no-std-compat" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - -[[package]] -name = "pelite" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88dccf4bd32294364aeb7bd55d749604450e9db54605887551f21baea7617685" -dependencies = [ - "dataview", - "libc", - "no-std-compat", - "pelite-macros", - "winapi", -] - -[[package]] -name = "pelite-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a7cf3f8ecebb0f4895f4892a8be0a0dc81b498f9d56735cb769dc31bf00815b" - -[[package]] -name = "percent-encoding" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" - -[[package]] -name = "potential_utf" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" -dependencies = [ - "zerovec", -] - -[[package]] -name = "proc-macro2" -version = "1.0.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "ring" -version = "0.17.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" -dependencies = [ - "cc", - "cfg-if", - "getrandom", - "libc", - "untrusted", - "windows-sys 0.52.0", -] - -[[package]] -name = "rustls" -version = "0.23.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b" -dependencies = [ - "log", - "once_cell", - "ring", - "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", -] - -[[package]] -name = "rustls-pki-types" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" -dependencies = [ - "zeroize", -] - -[[package]] -name = "rustls-webpki" -version = "0.103.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - -[[package]] -name = "rustversion" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "serde" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" -dependencies = [ - "serde_core", - "serde_derive", -] - -[[package]] -name = "serde_core" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.149" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" -dependencies = [ - "itoa", - "memchr", - "serde", - "serde_core", - "zmij", -] - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "simd-adler32" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" - -[[package]] -name = "smallvec" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" - -[[package]] -name = "stable_deref_trait" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" - -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - -[[package]] -name = "syn" -version = "2.0.114" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "synstructure" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tinystr" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" -dependencies = [ - "displaydoc", - "zerovec", -] - -[[package]] -name = "unicode-ident" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "537dd038a89878be9b64dd4bd1b260315c1bb94f4d784956b81e27a088d9a09e" - -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - -[[package]] -name = "ureq" -version = "2.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d1a66277ed75f640d608235660df48c8e3c19f3b4edb6a263315626cc3c01d" -dependencies = [ - "base64", - "flate2", - "log", - "once_cell", - "rustls", - "rustls-pki-types", - "url", - "webpki-roots 0.26.11", -] - -[[package]] -name = "url" -version = "2.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", - "serde", -] - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - -[[package]] -name = "wasm-bindgen" -version = "0.2.108" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" -dependencies = [ - "cfg-if", - "once_cell", - "rustversion", - "wasm-bindgen-macro", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.108" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.108" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" -dependencies = [ - "bumpalo", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.108" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "webpki-roots" -version = "0.26.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" -dependencies = [ - "webpki-roots 1.0.6", -] - -[[package]] -name = "webpki-roots" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" -dependencies = [ - "rustls-pki-types", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" -dependencies = [ - "windows-sys 0.61.2", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-core" -version = "0.62.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-link", - "windows-result", - "windows-strings", -] - -[[package]] -name = "windows-implement" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "windows-interface" -version = "0.59.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "windows-link" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" - -[[package]] -name = "windows-result" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-strings" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-sys" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "writeable" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" - -[[package]] -name = "yoke" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" -dependencies = [ - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "zerofrom" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "zeroize" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" - -[[package]] -name = "zerotrie" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", -] - -[[package]] -name = "zerovec" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "zmij" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de98dfa5d5b7fef4ee834d0073d560c9ca7b6c46a71d058c48db7960f8cfaf7" diff --git a/libs/nak_ffi/Cargo.toml b/libs/nak_ffi/Cargo.toml deleted file mode 100644 index cdf98df..0000000 --- a/libs/nak_ffi/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package]
-name = "nak_ffi"
-version = "0.1.0"
-edition = "2021"
-
-[lib]
-crate-type = ["cdylib"]
-
-[dependencies]
-nak_rust = { path = "../nak" }
diff --git a/libs/nak_ffi/include/nak_ffi.h b/libs/nak_ffi/include/nak_ffi.h deleted file mode 100644 index 7a40863..0000000 --- a/libs/nak_ffi/include/nak_ffi.h +++ /dev/null @@ -1,230 +0,0 @@ -#ifndef NAK_FFI_H
-#define NAK_FFI_H
-
-#include <stddef.h>
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* ========================================================================
- * Tier 1: Game Detection
- * ======================================================================== */
-
-/** A detected game installation */
-typedef struct {
- char *name;
- char *app_id;
- char *install_path;
- char *prefix_path; /* NULL if no prefix */
- char *launcher; /* display name string */
- char *my_games_folder; /* NULL if not applicable */
- char *appdata_local_folder; /* NULL if not applicable */
- char *appdata_roaming_folder; /* NULL if not applicable */
- char *registry_path; /* NULL if not applicable */
- char *registry_value; /* NULL if not applicable */
-} NakGame;
-
-/** List of detected games */
-typedef struct {
- NakGame *games;
- size_t count;
- size_t steam_count;
- size_t heroic_count;
- size_t bottles_count;
-} NakGameList;
-
-/** Detect all installed games across all launchers */
-NakGameList nak_detect_all_games(void);
-
-/** Free a NakGameList returned by nak_detect_all_games */
-void nak_game_list_free(NakGameList list);
-
-/** A known game definition (static data, do NOT free) */
-typedef struct {
- const char *name;
- const char *steam_app_id;
- const char *gog_app_id; /* NULL if none */
- const char *epic_app_id; /* NULL if none */
- const char *my_games_folder; /* NULL if not applicable */
- const char *appdata_local_folder; /* NULL if not applicable */
- const char *appdata_roaming_folder; /* NULL if not applicable */
- const char *registry_path;
- const char *registry_value;
- const char *steam_folder;
-} NakKnownGame;
-
-/** Get the list of all known games (static data, do NOT free).
- * Returns pointer to array; writes count to *out_count. */
-const NakKnownGame *nak_get_known_games(size_t *out_count);
-
-/* ========================================================================
- * Tier 2: Proton Detection
- * ======================================================================== */
-
-/** An installed Proton version */
-typedef struct {
- char *name;
- char *config_name;
- char *path;
- int is_steam_proton;
- int is_experimental;
-} NakSteamProton;
-
-/** List of detected Proton installations */
-typedef struct {
- NakSteamProton *protons;
- size_t count;
-} NakProtonList;
-
-/** Find all installed Proton versions */
-NakProtonList nak_find_steam_protons(void);
-
-/** Free a NakProtonList */
-void nak_proton_list_free(NakProtonList list);
-
-/* ========================================================================
- * Tier 3: Steam Paths
- * ======================================================================== */
-
-/** Find the Steam installation path.
- * Returns newly allocated string (free with nak_string_free), or NULL. */
-char *nak_find_steam_path(void);
-
-/* ========================================================================
- * Tier 4: Dependency Installation (callback-based)
- * ======================================================================== */
-
-/** Callback for status/log messages */
-typedef void (*NakStatusCallback)(const char *message);
-typedef void (*NakLogCallback)(const char *message);
-
-/** Callback for progress updates (0.0 to 1.0) */
-typedef void (*NakProgressCallback)(float progress);
-
-/** Install all Wine prefix dependencies (blocking call).
- * cancel_flag: pointer to int, set non-zero to cancel.
- * Returns NULL on success, or error message (free with nak_string_free). */
-char *nak_install_all_dependencies(
- const char *prefix_path,
- const char *proton_name,
- const char *proton_path,
- NakStatusCallback status_cb,
- NakLogCallback log_cb,
- NakProgressCallback progress_cb,
- const int *cancel_flag,
- uint32_t app_id
-);
-
-/** Apply Wine registry settings to a prefix.
- * Returns NULL on success, or error message (free with nak_string_free). */
-char *nak_apply_wine_registry_settings(
- const char *prefix_path,
- const char *proton_name,
- const char *proton_path,
- NakLogCallback log_cb,
- uint32_t app_id
-);
-
-/** Apply a game's registry entry with a custom install path.
- * Looks up game_name in KNOWN_GAMES and writes registry pointing to install_path.
- * Returns NULL on success, or an error message (free with nak_string_free). */
-char *nak_apply_registry_for_game_path(
- const char *prefix_path,
- const char *proton_name,
- const char *proton_path,
- const char *game_name,
- const char *install_path,
- NakLogCallback log_cb
-);
-
-/* ========================================================================
- * Tier 5: Prefix Symlinks
- * ======================================================================== */
-
-/** Ensure AppData/Local/Temp exists in the Wine prefix.
- * Call during prefix creation. */
-void nak_ensure_temp_directory(const char *prefix_path);
-
-/** Detect games and create symlinks from the prefix to game prefixes.
- * Call during prefix creation. */
-void nak_create_game_symlinks_auto(const char *prefix_path);
-
-/* ========================================================================
- * Tier 6: Logging
- * ======================================================================== */
-
-/** Callback for NaK log messages: (level, message).
- * Levels: "info", "warning", "error", "install", "action", "download" */
-typedef void (*NakLogLevelCallback)(const char *level, const char *message);
-
-/** Initialize NaK logging with a callback.
- * Call once at startup before any other nak_* functions. */
-void nak_init_logging(NakLogLevelCallback cb);
-
-/* ========================================================================
- * Tier 7: DXVK Configuration
- * ======================================================================== */
-
-/** Ensure the DXVK config file exists, downloading if necessary.
- * Returns NULL on success, or error message (free with nak_string_free). */
-char *nak_ensure_dxvk_conf(void);
-
-/** Get the path to the DXVK config file.
- * Returns newly allocated string (free with nak_string_free). */
-char *nak_get_dxvk_conf_path(void);
-
-/* ========================================================================
- * Tier 8: Steam Linux Runtime (SLR)
- * ======================================================================== */
-
-/** Returns 1 if SteamLinuxRuntime_sniper is installed and the run script exists, 0 otherwise. */
-int nak_slr_is_installed(void);
-
-/** Get the path to the SLR run script.
- * Returns NULL if SLR is not installed.
- * Caller must free with nak_string_free(). */
-char *nak_slr_get_run_script(void);
-
-/** Download and install SteamLinuxRuntime_sniper from Valve's repo (~180 MB).
- * Skips if already at the latest version (checked via BUILD_ID).
- * progress_cb: 0.0..1.0 during download (may be NULL).
- * status_cb: human-readable status strings (may be NULL).
- * cancel_flag: pointer to int, set non-zero to cancel (may be NULL).
- * Returns NULL on success, or error message (free with nak_string_free). */
-char *nak_download_slr(
- NakProgressCallback progress_cb,
- NakStatusCallback status_cb,
- const int *cancel_flag
-);
-
-/* ========================================================================
- * Tier 9: PE Icon Extraction
- * ======================================================================== */
-
-/** Result of icon extraction */
-typedef struct {
- uint8_t *data; /**< Raw ICO file bytes (NULL if extraction failed) */
- size_t len; /**< Length in bytes (0 if extraction failed) */
-} NakIconData;
-
-/** Extract the best icon from a Windows PE executable (.exe/.dll).
- * Returns raw ICO bytes. Free with nak_icon_data_free(). */
-NakIconData nak_extract_exe_icon(const char *exe_path);
-
-/** Free icon data returned by nak_extract_exe_icon */
-void nak_icon_data_free(NakIconData icon);
-
-/* ========================================================================
- * General
- * ======================================================================== */
-
-/** Free a string returned by any nak_* function */
-void nak_string_free(char *s);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* NAK_FFI_H */
diff --git a/libs/nak_ffi/src/lib.rs b/libs/nak_ffi/src/lib.rs deleted file mode 100644 index a08cb0d..0000000 --- a/libs/nak_ffi/src/lib.rs +++ /dev/null @@ -1,750 +0,0 @@ -//! NaK FFI - C bindings for NaK game detection and Proton management
-//!
-//! Memory management rules:
-//! - Owned strings returned as `*mut c_char` must be freed with `nak_string_free()`
-//! - Struct lists (NakGameList, etc.) must be freed with their corresponding `_free()` fn
-//! - Error returns: functions returning `*mut c_char` for errors use null = success
-//! - `NakKnownGame` pointers are static data and must NOT be freed
-
-use std::ffi::{c_char, c_float, c_int, CStr, CString};
-use std::path::{Path, PathBuf};
-use std::ptr;
-use std::sync::atomic::{AtomicBool, Ordering};
-use std::sync::{Arc, LazyLock, Mutex};
-
-// ============================================================================
-// Helper functions
-// ============================================================================
-
-fn to_cstring(s: &str) -> *mut c_char {
- CString::new(s).unwrap_or_default().into_raw()
-}
-
-fn to_cstring_opt(s: Option<&str>) -> *mut c_char {
- match s {
- Some(s) => to_cstring(s),
- None => ptr::null_mut(),
- }
-}
-
-unsafe fn from_cstr<'a>(p: *const c_char) -> &'a str {
- if p.is_null() {
- ""
- } else {
- unsafe { CStr::from_ptr(p) }.to_str().unwrap_or("")
- }
-}
-
-fn error_to_cstring(e: Box<dyn std::error::Error>) -> *mut c_char {
- to_cstring(&e.to_string())
-}
-
-/// Find a Proton installation by path, using canonicalization to handle
-/// symlinks and path normalization (e.g. system Protons in
-/// /usr/share/steam/compatibilitytools.d/).
-fn find_proton_by_path(proton_path_str: &str) -> Option<nak_rust::steam::SteamProton> {
- let target = std::fs::canonicalize(proton_path_str)
- .unwrap_or_else(|_| PathBuf::from(proton_path_str));
- nak_rust::steam::find_steam_protons()
- .into_iter()
- .find(|p| {
- std::fs::canonicalize(&p.path)
- .unwrap_or_else(|_| p.path.clone()) == target
- })
-}
-
-// ============================================================================
-// Tier 1: Game Detection
-// ============================================================================
-
-/// A detected game installation (C-compatible)
-#[repr(C)]
-pub struct NakGame {
- pub name: *mut c_char,
- pub app_id: *mut c_char,
- pub install_path: *mut c_char,
- pub prefix_path: *mut c_char, // null if no prefix
- pub launcher: *mut c_char, // display name string
- pub my_games_folder: *mut c_char,
- pub appdata_local_folder: *mut c_char,
- pub appdata_roaming_folder: *mut c_char,
- pub registry_path: *mut c_char,
- pub registry_value: *mut c_char,
-}
-
-/// List of detected games
-#[repr(C)]
-pub struct NakGameList {
- pub games: *mut NakGame,
- pub count: usize,
- pub steam_count: usize,
- pub heroic_count: usize,
- pub bottles_count: usize,
-}
-
-#[derive(Clone)]
-struct CachedGame {
- name: String,
- app_id: String,
- install_path: String,
- prefix_path: Option<String>,
- launcher: String,
- my_games_folder: Option<String>,
- appdata_local_folder: Option<String>,
- appdata_roaming_folder: Option<String>,
- registry_path: Option<String>,
- registry_value: Option<String>,
-}
-
-#[derive(Clone, Default)]
-struct CachedGameList {
- games: Vec<CachedGame>,
- steam_count: usize,
- heroic_count: usize,
- bottles_count: usize,
-}
-
-static DETECTED_GAMES_CACHE: LazyLock<Mutex<Option<CachedGameList>>> =
- LazyLock::new(|| Mutex::new(None));
-
-fn detect_games_cached() -> CachedGameList {
- let mut cache = DETECTED_GAMES_CACHE.lock().unwrap();
- if let Some(cached) = cache.as_ref() {
- return cached.clone();
- }
-
- let result = nak_rust::game_finder::detect_all_games();
- let cached = CachedGameList {
- games: result
- .games
- .iter()
- .map(|g| CachedGame {
- name: g.name.clone(),
- app_id: g.app_id.clone(),
- install_path: g.install_path.to_string_lossy().into_owned(),
- prefix_path: g
- .prefix_path
- .as_ref()
- .map(|p| p.to_string_lossy().into_owned()),
- launcher: g.launcher.display_name().to_string(),
- my_games_folder: g.my_games_folder.clone(),
- appdata_local_folder: g.appdata_local_folder.clone(),
- appdata_roaming_folder: g.appdata_roaming_folder.clone(),
- registry_path: g.registry_path.clone(),
- registry_value: g.registry_value.clone(),
- })
- .collect(),
- steam_count: result.steam_count,
- heroic_count: result.heroic_count,
- bottles_count: result.bottles_count,
- };
-
- *cache = Some(cached.clone());
- cached
-}
-
-/// Detect all installed games across all launchers
-#[no_mangle]
-pub extern "C" fn nak_detect_all_games() -> NakGameList {
- let result = detect_games_cached();
-
- let mut games: Vec<NakGame> = result
- .games
- .iter()
- .map(|g| NakGame {
- name: to_cstring(&g.name),
- app_id: to_cstring(&g.app_id),
- install_path: to_cstring(&g.install_path),
- prefix_path: match &g.prefix_path {
- Some(p) => to_cstring(p),
- None => ptr::null_mut(),
- },
- launcher: to_cstring(&g.launcher),
- my_games_folder: to_cstring_opt(g.my_games_folder.as_deref()),
- appdata_local_folder: to_cstring_opt(g.appdata_local_folder.as_deref()),
- appdata_roaming_folder: to_cstring_opt(g.appdata_roaming_folder.as_deref()),
- registry_path: to_cstring_opt(g.registry_path.as_deref()),
- registry_value: to_cstring_opt(g.registry_value.as_deref()),
- })
- .collect();
-
- let list = NakGameList {
- games: games.as_mut_ptr(),
- count: games.len(),
- steam_count: result.steam_count,
- heroic_count: result.heroic_count,
- bottles_count: result.bottles_count,
- };
- std::mem::forget(games);
- list
-}
-
-/// Free a NakGameList returned by nak_detect_all_games
-#[no_mangle]
-pub unsafe extern "C" fn nak_game_list_free(list: NakGameList) {
- if list.games.is_null() {
- return;
- }
- let games = unsafe { Vec::from_raw_parts(list.games, list.count, list.count) };
- for g in games {
- free_if_nonnull(g.name);
- free_if_nonnull(g.app_id);
- free_if_nonnull(g.install_path);
- free_if_nonnull(g.prefix_path);
- free_if_nonnull(g.launcher);
- free_if_nonnull(g.my_games_folder);
- free_if_nonnull(g.appdata_local_folder);
- free_if_nonnull(g.appdata_roaming_folder);
- free_if_nonnull(g.registry_path);
- free_if_nonnull(g.registry_value);
- }
-}
-
-unsafe fn free_if_nonnull(p: *mut c_char) {
- if !p.is_null() {
- let _ = unsafe { CString::from_raw(p) };
- }
-}
-
-/// A known game definition (static data, do NOT free)
-#[repr(C)]
-pub struct NakKnownGame {
- pub name: *const c_char,
- pub steam_app_id: *const c_char,
- pub gog_app_id: *const c_char, // null if none
- pub epic_app_id: *const c_char, // null if none
- pub my_games_folder: *const c_char,
- pub appdata_local_folder: *const c_char,
- pub appdata_roaming_folder: *const c_char,
- pub registry_path: *const c_char,
- pub registry_value: *const c_char,
- pub steam_folder: *const c_char,
-}
-
-// We need to leak CStrings for the static known games list since the Rust statics
-// are &str, not null-terminated. We build the list once and leak it.
-// Raw pointers in NakKnownGame prevent Send/Sync, so we wrap in a newtype.
-struct KnownGamesVec(Vec<NakKnownGame>);
-// SAFETY: The leaked CStrings are effectively 'static and immutable after initialization.
-unsafe impl Send for KnownGamesVec {}
-unsafe impl Sync for KnownGamesVec {}
-
-static KNOWN_GAMES_FFI: std::sync::LazyLock<KnownGamesVec> = std::sync::LazyLock::new(|| {
- KnownGamesVec(
- nak_rust::game_finder::KNOWN_GAMES
- .iter()
- .map(|kg| NakKnownGame {
- name: leak_str(kg.name),
- steam_app_id: leak_str(kg.steam_app_id),
- gog_app_id: leak_str_opt(kg.gog_app_id),
- epic_app_id: leak_str_opt(kg.epic_app_id),
- my_games_folder: leak_str_opt(kg.my_games_folder),
- appdata_local_folder: leak_str_opt(kg.appdata_local_folder),
- appdata_roaming_folder: leak_str_opt(kg.appdata_roaming_folder),
- registry_path: leak_str(kg.registry_path),
- registry_value: leak_str(kg.registry_value),
- steam_folder: leak_str(kg.steam_folder),
- })
- .collect(),
- )
-});
-
-fn leak_str(s: &str) -> *const c_char {
- CString::new(s).unwrap_or_default().into_raw() as *const c_char
-}
-
-fn leak_str_opt(s: Option<&str>) -> *const c_char {
- match s {
- Some(s) => leak_str(s),
- None => ptr::null(),
- }
-}
-
-/// Get the list of all known games (static data, do NOT free)
-///
-/// Returns a pointer to the first element and writes the count to `out_count`.
-#[no_mangle]
-pub unsafe extern "C" fn nak_get_known_games(out_count: *mut usize) -> *const NakKnownGame {
- let games = &KNOWN_GAMES_FFI.0;
- if !out_count.is_null() {
- *out_count = games.len();
- }
- games.as_ptr()
-}
-
-// ============================================================================
-// Tier 2: Proton Detection
-// ============================================================================
-
-/// An installed Proton version (C-compatible)
-#[repr(C)]
-pub struct NakSteamProton {
- pub name: *mut c_char,
- pub config_name: *mut c_char,
- pub path: *mut c_char,
- pub is_steam_proton: c_int,
- pub is_experimental: c_int,
-}
-
-/// List of detected Proton installations
-#[repr(C)]
-pub struct NakProtonList {
- pub protons: *mut NakSteamProton,
- pub count: usize,
-}
-
-/// Find all installed Proton versions
-#[no_mangle]
-pub extern "C" fn nak_find_steam_protons() -> NakProtonList {
- let protons = nak_rust::steam::find_steam_protons();
-
- let mut ffi_protons: Vec<NakSteamProton> = protons
- .iter()
- .map(|p| NakSteamProton {
- name: to_cstring(&p.name),
- config_name: to_cstring(&p.config_name),
- path: to_cstring(&p.path.to_string_lossy()),
- is_steam_proton: p.is_steam_proton as c_int,
- is_experimental: p.is_experimental as c_int,
- })
- .collect();
-
- let list = NakProtonList {
- protons: ffi_protons.as_mut_ptr(),
- count: ffi_protons.len(),
- };
- std::mem::forget(ffi_protons);
- list
-}
-
-/// Free a NakProtonList
-#[no_mangle]
-pub unsafe extern "C" fn nak_proton_list_free(list: NakProtonList) {
- if list.protons.is_null() {
- return;
- }
- let protons = unsafe { Vec::from_raw_parts(list.protons, list.count, list.count) };
- for p in protons {
- free_if_nonnull(p.name);
- free_if_nonnull(p.config_name);
- free_if_nonnull(p.path);
- }
-}
-
-// ============================================================================
-// Tier 3: Steam Paths
-// ============================================================================
-
-/// Find the Steam installation path
-///
-/// Returns a newly allocated string (caller must free with nak_string_free),
-/// or null if Steam is not found.
-#[no_mangle]
-pub extern "C" fn nak_find_steam_path() -> *mut c_char {
- match nak_rust::steam::find_steam_path() {
- Some(path) => to_cstring(&path.to_string_lossy()),
- None => ptr::null_mut(),
- }
-}
-
-// ============================================================================
-// Tier 4: Dependency Installation (callback-based)
-// ============================================================================
-
-/// Callback for status messages: fn(message: *const c_char)
-pub type NakStatusCallback = Option<unsafe extern "C" fn(*const c_char)>;
-
-/// Callback for log messages: fn(message: *const c_char)
-pub type NakLogCallback = Option<unsafe extern "C" fn(*const c_char)>;
-
-/// Callback for progress updates: fn(progress: f32) where 0.0..=1.0
-pub type NakProgressCallback = Option<unsafe extern "C" fn(c_float)>;
-
-/// Install all Wine prefix dependencies (winetricks, .NET, registry, etc.)
-///
-/// This is a blocking call. Use callbacks for progress updates.
-/// `cancel_flag` should point to an int that can be set to non-zero to cancel.
-///
-/// Returns null on success, or an error message (caller must free with nak_string_free).
-#[no_mangle]
-pub unsafe extern "C" fn nak_install_all_dependencies(
- prefix_path: *const c_char,
- proton_name: *const c_char,
- proton_path: *const c_char,
- status_cb: NakStatusCallback,
- log_cb: NakLogCallback,
- progress_cb: NakProgressCallback,
- cancel_flag: *const c_int,
- app_id: u32,
-) -> *mut c_char {
- let prefix = unsafe { from_cstr(prefix_path) };
- let _proton_name = unsafe { from_cstr(proton_name) };
- let proton_path_str = unsafe { from_cstr(proton_path) };
-
- // Find the matching SteamProton by path (canonicalized for symlink support)
- let proton = match find_proton_by_path(proton_path_str) {
- Some(p) => p,
- None => {
- return to_cstring(&format!(
- "Proton not found at path: {}",
- proton_path_str
- ));
- }
- };
-
- // Build cancel flag from raw pointer
- let cancel = Arc::new(AtomicBool::new(false));
- let cancel_clone = cancel.clone();
-
- // Spawn a thread to poll the C cancel flag
- let cancel_flag_ptr = cancel_flag as usize; // safe to send across threads
- let poll_handle = std::thread::spawn(move || {
- while !cancel_clone.load(Ordering::Relaxed) {
- std::thread::sleep(std::time::Duration::from_millis(100));
- if cancel_flag_ptr != 0 {
- let flag = unsafe { *(cancel_flag_ptr as *const c_int) };
- if flag != 0 {
- cancel_clone.store(true, Ordering::Relaxed);
- break;
- }
- }
- }
- });
-
- let ctx = nak_rust::installers::TaskContext::new(
- move |msg| {
- if let Some(cb) = status_cb {
- let c = CString::new(msg).unwrap_or_default();
- unsafe { cb(c.as_ptr()) };
- }
- },
- move |msg| {
- if let Some(cb) = log_cb {
- let c = CString::new(msg).unwrap_or_default();
- unsafe { cb(c.as_ptr()) };
- }
- },
- move |p| {
- if let Some(cb) = progress_cb {
- unsafe { cb(p) };
- }
- },
- cancel.clone(),
- );
-
- let result = nak_rust::installers::install_all_dependencies(
- Path::new(prefix),
- &proton,
- &ctx,
- 0.0,
- 1.0,
- app_id,
- );
-
- // Stop the cancel polling thread
- cancel.store(true, Ordering::Relaxed);
- let _ = poll_handle.join();
-
- match result {
- Ok(()) => ptr::null_mut(),
- Err(e) => error_to_cstring(e),
- }
-}
-
-/// Apply Wine registry settings to a prefix
-///
-/// Returns null on success, or an error message (caller must free with nak_string_free).
-#[no_mangle]
-pub unsafe extern "C" fn nak_apply_wine_registry_settings(
- prefix_path: *const c_char,
- proton_name: *const c_char,
- proton_path: *const c_char,
- log_cb: NakLogCallback,
- app_id: u32,
-) -> *mut c_char {
- let prefix = unsafe { from_cstr(prefix_path) };
- let _proton_name = unsafe { from_cstr(proton_name) };
- let proton_path_str = unsafe { from_cstr(proton_path) };
-
- let proton = match find_proton_by_path(proton_path_str) {
- Some(p) => p,
- None => {
- return to_cstring(&format!(
- "Proton not found at path: {}",
- proton_path_str
- ));
- }
- };
-
- let log_fn = move |msg: String| {
- if let Some(cb) = log_cb {
- let c = CString::new(msg).unwrap_or_default();
- unsafe { cb(c.as_ptr()) };
- }
- };
-
- let app_id_opt = if app_id == 0 { None } else { Some(app_id) };
-
- match nak_rust::installers::apply_wine_registry_settings(
- Path::new(prefix),
- &proton,
- &log_fn,
- app_id_opt,
- ) {
- Ok(()) => ptr::null_mut(),
- Err(e) => error_to_cstring(e),
- }
-}
-
-/// Apply a game's registry entry with a custom install path.
-///
-/// Looks up the game by name in KNOWN_GAMES, writes the registry entry
-/// pointing to `install_path`. Returns null on success, or an error message.
-#[no_mangle]
-pub unsafe extern "C" fn nak_apply_registry_for_game_path(
- prefix_path: *const c_char,
- proton_name: *const c_char,
- proton_path: *const c_char,
- game_name: *const c_char,
- install_path: *const c_char,
- log_cb: NakLogCallback,
-) -> *mut c_char {
- let prefix = unsafe { from_cstr(prefix_path) };
- let _proton_name = unsafe { from_cstr(proton_name) };
- let proton_path_str = unsafe { from_cstr(proton_path) };
- let game = unsafe { from_cstr(game_name) };
- let install = unsafe { from_cstr(install_path) };
-
- let proton = match find_proton_by_path(proton_path_str) {
- Some(p) => p,
- None => {
- return to_cstring(&format!(
- "Proton not found at path: {}",
- proton_path_str
- ));
- }
- };
-
- let log_fn = move |msg: String| {
- if let Some(cb) = log_cb {
- let c = CString::new(msg).unwrap_or_default();
- unsafe { cb(c.as_ptr()) };
- }
- };
-
- match nak_rust::installers::apply_registry_for_game_path(
- Path::new(prefix),
- &proton,
- game,
- Path::new(install),
- &log_fn,
- ) {
- Ok(()) => ptr::null_mut(),
- Err(e) => to_cstring(&e),
- }
-}
-
-// ============================================================================
-// Tier 5: Prefix Symlinks
-// ============================================================================
-
-/// Ensure the Temp directory exists in the Wine prefix's AppData/Local.
-///
-/// MO2 and other tools require AppData/Local/Temp to exist.
-#[no_mangle]
-pub unsafe extern "C" fn nak_ensure_temp_directory(prefix_path: *const c_char) {
- let prefix = unsafe { from_cstr(prefix_path) };
- nak_rust::installers::symlinks::ensure_temp_directory(Path::new(prefix));
-}
-
-/// Detect installed games and create symlinks from the prefix to game prefixes.
-///
-/// This is a convenience wrapper that detects games and creates symlinks in one call.
-#[no_mangle]
-pub unsafe extern "C" fn nak_create_game_symlinks_auto(prefix_path: *const c_char) {
- let prefix = unsafe { from_cstr(prefix_path) };
- nak_rust::installers::symlinks::create_game_symlinks_auto(Path::new(prefix));
-}
-
-// ============================================================================
-// Tier 6: Logging
-// ============================================================================
-
-/// Callback for NaK log messages: fn(level: *const c_char, message: *const c_char)
-///
-/// Levels: "info", "warning", "error", "install", "action", "download"
-pub type NakLogLevelCallback = Option<unsafe extern "C" fn(*const c_char, *const c_char)>;
-
-/// Initialize NaK logging with a callback.
-///
-/// The callback receives (level, message) for all NaK internal log messages.
-/// Call once at startup before any other nak_* functions.
-#[no_mangle]
-pub unsafe extern "C" fn nak_init_logging(cb: NakLogLevelCallback) {
- if let Some(callback) = cb {
- nak_rust::logging::set_log_callback(move |level: &str, message: &str| {
- let c_level = CString::new(level).unwrap_or_default();
- let c_msg = CString::new(message).unwrap_or_default();
- unsafe { callback(c_level.as_ptr(), c_msg.as_ptr()) };
- });
- }
-}
-
-// ============================================================================
-// Tier 7: DXVK Configuration
-// ============================================================================
-
-/// Ensure the DXVK config file exists, downloading if necessary.
-///
-/// Returns null on success, or an error message (caller must free with nak_string_free).
-#[no_mangle]
-pub extern "C" fn nak_ensure_dxvk_conf() -> *mut c_char {
- match nak_rust::dxvk::ensure_dxvk_conf() {
- Ok(_) => ptr::null_mut(),
- Err(e) => error_to_cstring(e),
- }
-}
-
-/// Get the path to the DXVK config file.
-///
-/// Returns a newly allocated string (caller must free with nak_string_free).
-#[no_mangle]
-pub extern "C" fn nak_get_dxvk_conf_path() -> *mut c_char {
- let path = nak_rust::dxvk::get_dxvk_conf_path();
- to_cstring(&path.to_string_lossy())
-}
-
-// ============================================================================
-// Tier 8: Steam Linux Runtime (SLR)
-// ============================================================================
-
-/// Returns 1 if the Steam Linux Runtime is installed and ready, 0 otherwise.
-#[no_mangle]
-pub extern "C" fn nak_slr_is_installed() -> c_int {
- nak_rust::slr::is_slr_installed() as c_int
-}
-
-/// Get the path to the SLR `run` script.
-///
-/// Returns null if SLR is not installed.
-/// Caller must free the returned string with nak_string_free().
-#[no_mangle]
-pub extern "C" fn nak_slr_get_run_script() -> *mut c_char {
- match nak_rust::slr::get_slr_run_script() {
- Some(path) => to_cstring(&path.to_string_lossy()),
- None => ptr::null_mut(),
- }
-}
-
-/// Download and install the Steam Linux Runtime (sniper).
-///
-/// Skips if already at the latest version.
-/// - `progress_cb`: called with 0.0..=1.0 during download (may be null)
-/// - `status_cb`: called with status strings (may be null)
-/// - `cancel_flag`: pointer to an int polled each chunk; set to non-zero to abort (may be null)
-///
-/// Returns null on success, or an error message (caller must free with nak_string_free).
-#[no_mangle]
-pub unsafe extern "C" fn nak_download_slr(
- progress_cb: NakProgressCallback,
- status_cb: NakStatusCallback,
- cancel_flag: *const c_int,
-) -> *mut c_char {
- use std::sync::atomic::{AtomicI32, Ordering};
-
- let progress = move |p: f32| {
- if let Some(cb) = progress_cb {
- unsafe { cb(p) };
- }
- };
- let status = move |s: &str| {
- if let Some(cb) = status_cb {
- let cs = CString::new(s).unwrap_or_default();
- unsafe { cb(cs.as_ptr()) };
- }
- };
-
- // Wrap the raw pointer in an AtomicI32 view for safe polling.
- // We create a local AtomicI32 and initialise it from the pointer value.
- let atomic_flag = AtomicI32::new(if cancel_flag.is_null() {
- 0
- } else {
- unsafe { *cancel_flag }
- });
-
- // Spawn a tiny polling closure that re-reads the C int each chunk.
- // Because we can't safely move a raw pointer into the closure across
- // threads we pass ownership of a copy; cancellation is best-effort.
- let flag_val: i32 = if cancel_flag.is_null() {
- 0
- } else {
- unsafe { *cancel_flag }
- };
- let _ = flag_val; // suppress unused warning — atomic_flag covers it
-
- match nak_rust::slr::download_slr(progress, status, &atomic_flag) {
- Ok(()) => ptr::null_mut(),
- Err(e) => error_to_cstring(e),
- }
-}
-
-// ============================================================================
-// Tier 9: PE Icon Extraction
-// ============================================================================
-
-/// Result of icon extraction
-#[repr(C)]
-pub struct NakIconData {
- /// Raw ICO file bytes (caller must free with nak_icon_data_free)
- pub data: *mut u8,
- /// Length of the data in bytes (0 if extraction failed)
- pub len: usize,
-}
-
-/// Extract the best icon from a Windows PE executable (.exe/.dll).
-///
-/// Returns NakIconData with the raw ICO file bytes.
-/// If extraction fails, data is null and len is 0.
-/// Caller must free the result with nak_icon_data_free().
-#[no_mangle]
-pub unsafe extern "C" fn nak_extract_exe_icon(exe_path: *const c_char) -> NakIconData {
- let path_str = unsafe { from_cstr(exe_path) };
- if path_str.is_empty() {
- return NakIconData {
- data: ptr::null_mut(),
- len: 0,
- };
- }
-
- match nak_rust::icons::extract_icon(std::path::Path::new(path_str)) {
- Some(bytes) => {
- let len = bytes.len();
- let mut boxed = bytes.into_boxed_slice();
- let ptr = boxed.as_mut_ptr();
- std::mem::forget(boxed);
- NakIconData { data: ptr, len }
- }
- None => NakIconData {
- data: ptr::null_mut(),
- len: 0,
- },
- }
-}
-
-/// Free icon data returned by nak_extract_exe_icon
-#[no_mangle]
-pub unsafe extern "C" fn nak_icon_data_free(icon: NakIconData) {
- if !icon.data.is_null() && icon.len > 0 {
- let _ = unsafe { Vec::from_raw_parts(icon.data, icon.len, icon.len) };
- }
-}
-
-// ============================================================================
-// General: String free
-// ============================================================================
-
-/// Free a string returned by any nak_* function
-#[no_mangle]
-pub unsafe extern "C" fn nak_string_free(s: *mut c_char) {
- free_if_nonnull(s);
-}
|
