mirror of
https://github.com/mii443/rs-azookey-binding.git
synced 2025-08-23 00:25:44 +00:00
first
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "azookey-binding"
|
||||||
|
version = "0.1.0"
|
5
Cargo.toml
Normal file
5
Cargo.toml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[package]
|
||||||
|
name = "azookey-binding"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
8
azookey-swift/.gitignore
vendored
Normal file
8
azookey-swift/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.DS_Store
|
||||||
|
/.build
|
||||||
|
/Packages
|
||||||
|
xcuserdata/
|
||||||
|
DerivedData/
|
||||||
|
.swiftpm/configuration/registries.json
|
||||||
|
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||||
|
.netrc
|
34
azookey-swift/Package.swift
Normal file
34
azookey-swift/Package.swift
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// swift-tools-version: 6.1
|
||||||
|
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||||
|
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "azookey-swift",
|
||||||
|
products: [
|
||||||
|
// Products define the executables and libraries a package produces, making them visible to other packages.
|
||||||
|
.library(
|
||||||
|
name: "azookey-swift",
|
||||||
|
type: .dynamic,
|
||||||
|
targets: ["azookey-swift"]),
|
||||||
|
.library(
|
||||||
|
name: "ffi",
|
||||||
|
targets: ["azookey-swift"]
|
||||||
|
)
|
||||||
|
],
|
||||||
|
targets: [
|
||||||
|
// Targets are the basic building blocks of a package, defining a module or a test suite.
|
||||||
|
// Targets can depend on other targets in this package and products from dependencies.
|
||||||
|
.target(name: "ffi"),
|
||||||
|
.target(
|
||||||
|
name: "azookey-swift",
|
||||||
|
dependencies: [
|
||||||
|
"ffi"
|
||||||
|
]
|
||||||
|
),
|
||||||
|
.testTarget(
|
||||||
|
name: "azookey-swiftTests",
|
||||||
|
dependencies: ["azookey-swift"]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
7
azookey-swift/Sources/azookey-swift/azookey_swift.swift
Normal file
7
azookey-swift/Sources/azookey-swift/azookey_swift.swift
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import Foundation
|
||||||
|
import ffi
|
||||||
|
|
||||||
|
@_silgen_name("HelloSwift")
|
||||||
|
@MainActor public func hello_swift() {
|
||||||
|
print("hello_swift")
|
||||||
|
}
|
0
azookey-swift/Sources/ffi/ffi.c
Normal file
0
azookey-swift/Sources/ffi/ffi.c
Normal file
7
azookey-swift/Sources/ffi/include/ffi.h
Normal file
7
azookey-swift/Sources/ffi/include/ffi.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef ffi_h
|
||||||
|
#define ffi_h
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
5
azookey-swift/Sources/ffi/module.modulemap
Normal file
5
azookey-swift/Sources/ffi/module.modulemap
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module ffi {
|
||||||
|
header "ffi.h"
|
||||||
|
|
||||||
|
export *
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
import Testing
|
||||||
|
@testable import azookey_swift
|
||||||
|
|
||||||
|
@Test func example() async throws {
|
||||||
|
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
|
||||||
|
}
|
8
build.rs
Normal file
8
build.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fn main() {
|
||||||
|
let project_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-link-search={}/azookey-swift/.build/release/",
|
||||||
|
project_dir
|
||||||
|
);
|
||||||
|
println!("cargo:rustc-link-lib=azookey-swift");
|
||||||
|
}
|
3
src/lib.rs
Normal file
3
src/lib.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
unsafe extern "C" {
|
||||||
|
pub fn HelloSwift();
|
||||||
|
}
|
3
src/main.rs
Normal file
3
src/main.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
unsafe { azookey_binding::HelloSwift() };
|
||||||
|
}
|
Reference in New Issue
Block a user