Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To replace *.udl with use of Uniffi proc macro initially #261

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[alias]
xcode = ["bin", "cargo-xcode"]
make = ["bin", "cargo-make"]
3 changes: 0 additions & 3 deletions examples/hello_world/shared/build.rs

This file was deleted.

9 changes: 5 additions & 4 deletions examples/hello_world/shared/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
uniffi::setup_scaffolding!();

pub mod app; // not exposed so you can remove this in your project

use lazy_static::lazy_static;
Expand All @@ -7,24 +9,23 @@ pub use crux_core::{bridge::Bridge, Core, Request};

pub use app::*;

// TODO hide this plumbing

uniffi::include_scaffolding!("shared");

lazy_static! {
static ref CORE: Bridge<Effect, Hello> = Bridge::new(Core::new());
}

#[uniffi::export]
#[wasm_bindgen]
pub fn process_event(data: &[u8]) -> Vec<u8> {
CORE.process_event(data)
}

#[uniffi::export]
#[wasm_bindgen]
pub fn handle_response(id: u32, data: &[u8]) -> Vec<u8> {
CORE.handle_response(id, data)
}

#[uniffi::export]
#[wasm_bindgen]
pub fn view() -> Vec<u8> {
CORE.view()
Expand Down
5 changes: 0 additions & 5 deletions examples/hello_world/shared/src/shared.udl

This file was deleted.

21 changes: 8 additions & 13 deletions examples/simple_counter/Android/shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
jvmTarget = '20'
}
sourceSets {
main.java.srcDirs += "${projectDir}/../../shared_types/generated/java"
main.java.srcDirs += "${projectDir}/../../shared/generated/java"
}
}

Expand Down Expand Up @@ -87,27 +87,22 @@ afterEvaluate {
}

tasks.register('bindGen', Exec) {
def outDir = "${projectDir}/../../shared_types/generated/java"
workingDir "../../"
def outDir = "${projectDir}/../../shared/generated/java"
workingDir "../../shared"
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine("cmd", "/c",
"cargo build -p shared && " + "target\\debug\\uniffi-bindgen generate shared\\src\\shared.udl " + "--language kotlin " + "--out-dir " + outDir.replace('/', '\\'))
"cargo make uniffi-gen-java")
} else {
commandLine("sh", "-c",
"""\
cargo build -p shared && \
target/debug/uniffi-bindgen generate shared/src/shared.udl \
--language kotlin \
--out-dir $outDir
""")
"cargo make uniffi-gen-java")
}
}

tasks.register('typesGen', Exec) {
workingDir "../../"
workingDir "../../shared"
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine("cmd", "/c", "cargo build -p shared_types")
commandLine("cmd", "/c", "cargo make generate-types")
} else {
commandLine("sh", "-c", "cargo build -p shared_types")
commandLine("sh", "-c", "cargo make generate-types")
}
}
10 changes: 1 addition & 9 deletions examples/simple_counter/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/simple_counter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["shared", "shared_types", "web-dioxus", "web-leptos", "web-yew"]
members = ["shared", "web-dioxus", "web-leptos", "web-yew"]
resolver = "1"

[workspace.package]
Expand All @@ -17,3 +17,4 @@ serde = "1.0.213"

[workspace.metadata.bin]
cargo-xcode = { version = "=1.7.0" }
cargo-make = { version = "=0.37.14" }
114 changes: 56 additions & 58 deletions examples/simple_counter/iOS/SimpleCounter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,29 @@
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objectVersion = 60;
objects = {

/* Begin PBXBuildFile section */
1989BD3C863A9FB37C889B6D /* SharedTypes in Frameworks */ = {isa = PBXBuildFile; productRef = ADFA4530638891CDAA6FCC5D /* SharedTypes */; };
2AD69AC61D674BB2BC300FC2 /* uniffi-bindgen in Resources */ = {isa = PBXBuildFile; fileRef = E75E53B837C6A0E03FDCEC5A /* uniffi-bindgen */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
401EA3CBD0D2AD8D475C10AF /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842F8D01CC76E9BFCDBD2862 /* ContentView.swift */; };
5776AB3F6BDB21968CE9543A /* shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33C72B2EF6A68B351BB022 /* shared.swift */; };
8291B7EC6C593FA8E5BB4F36 /* sharedFFI.h in Sources */ = {isa = PBXBuildFile; fileRef = 07EC71797B0B95DAD077436C /* sharedFFI.h */; };
94DCD6C97BBC86B89673CA0E /* core.swift in Sources */ = {isa = PBXBuildFile; fileRef = 258EC994D7C693E3141C4563 /* core.swift */; };
A022BC4B1B16254762ED55B3 /* shared.udl in Sources */ = {isa = PBXBuildFile; fileRef = 8B8EC4C63F3ECC2B26BBAEC2 /* shared.udl */; };
ACEED4C684566162EAB9CB48 /* SimpleCounterApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02DCFFA8F642585B6E57DA81 /* SimpleCounterApp.swift */; };
C26A1E5DDAB1ED32518E8F2A /* libshared_static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2EA4D4AAE1A6C4D3400A9A06 /* libshared_static.a */; };
D39A72610E7E3BD191DBDC06 /* SimpleCounterApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF52C000453302D743B48803 /* SimpleCounterApp.swift */; };
C52E639D2187D4C22DDEF776 /* sharedFFI.modulemap in Sources */ = {isa = PBXBuildFile; fileRef = 98924D54C7B6BFCB1E503C2E /* sharedFFI.modulemap */; };
/* End PBXBuildFile section */

/* Begin PBXBuildRule section */
A7015E42CE7FE365402B3A57 /* PBXBuildRule */ = {
isa = PBXBuildRule;
compilerSpec = com.apple.compilers.proxy.script;
filePatterns = "*.udl";
fileType = pattern.proxy;
inputFiles = (
);
isEditable = 1;
name = "Generate FFI";
outputFiles = (
"$(PROJECT_DIR)/generated/$(INPUT_FILE_BASE).swift",
"$(PROJECT_DIR)/generated/$(INPUT_FILE_BASE)FFI.h",
);
outputFilesCompilerFlags = (
);
runOncePerArchitecture = 0;
script = "#!/bin/bash\nset -e\n\n# Skip during indexing phase in XCode 13+\nif [ \"$ACTION\" == \"indexbuild\" ]; then\n echo \"Not building *.udl files during indexing.\"\n exit 0\nfi\n\n# Skip for preview builds\nif [ \"$ENABLE_PREVIEWS\" = \"YES\" ]; then\n echo \"Not building *.udl files during preview builds.\"\n exit 0\nfi\n\ncd \"${INPUT_FILE_DIR}/..\"\n\"${BUILD_DIR}/debug/uniffi-bindgen\" generate \"src/${INPUT_FILE_NAME}\" --language swift --out-dir \"${PROJECT_DIR}/generated\"\n";
};
/* End PBXBuildRule section */

/* Begin PBXContainerItemProxy section */
076D837A2C49634600D2EEF1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 8EA6E09EE87596B896068D0E /* Shared */;
proxyType = 2;
remoteGlobalIDString = CA60D2B4E60D10F7F7FCAC5B;
remoteInfo = "shared-cdylib";
};
4579D0264028B49513DBCDA5 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 8EA6E09EE87596B896068D0E /* Shared */;
Expand All @@ -59,13 +47,6 @@
remoteGlobalIDString = CA607A8B44DC564A772C0BD1;
remoteInfo = "shared-staticlib";
};
CCE0790C2AA1F71400CD4B57 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 8EA6E09EE87596B896068D0E /* Shared */;
proxyType = 2;
remoteGlobalIDString = CA60D2B4E60D10F7F7FCAC5B;
remoteInfo = "shared-cdylib";
};
EC190C8522C4065CF4E41954 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 8EA6E09EE87596B896068D0E /* Shared */;
Expand All @@ -76,14 +57,16 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
02DCFFA8F642585B6E57DA81 /* SimpleCounterApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleCounterApp.swift; sourceTree = "<group>"; };
07EC71797B0B95DAD077436C /* sharedFFI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sharedFFI.h; sourceTree = "<group>"; };
1974E5BC3D6D22A1D5676B40 /* SimpleCounter.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = SimpleCounter.app; sourceTree = BUILT_PRODUCTS_DIR; };
258EC994D7C693E3141C4563 /* core.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = core.swift; sourceTree = "<group>"; };
642CF26F4B57B0FF7348C6BF /* SharedTypes */ = {isa = PBXFileReference; lastKnownFileType = folder; name = SharedTypes; path = ../shared_types/generated/swift/SharedTypes; sourceTree = SOURCE_ROOT; };
642CF26F4B57B0FF7348C6BF /* SharedTypes */ = {isa = PBXFileReference; lastKnownFileType = folder; name = SharedTypes; path = ../shared/generated/swift/SharedTypes; sourceTree = SOURCE_ROOT; };
842F8D01CC76E9BFCDBD2862 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
8B8EC4C63F3ECC2B26BBAEC2 /* shared.udl */ = {isa = PBXFileReference; lastKnownFileType = text; path = shared.udl; sourceTree = "<group>"; };
8EA6E09EE87596B896068D0E /* Shared */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Shared; path = ../shared/shared.xcodeproj; sourceTree = "<group>"; };
BF52C000453302D743B48803 /* SimpleCounterApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleCounterApp.swift; sourceTree = "<group>"; };
98924D54C7B6BFCB1E503C2E /* sharedFFI.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = sharedFFI.modulemap; sourceTree = "<group>"; };
CF5BE0317D54587DCCF48AF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
EA33C72B2EF6A68B351BB022 /* shared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = shared.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -103,30 +86,32 @@
isa = PBXGroup;
children = (
E551F092584A1E0A747C2BEB /* Packages */,
37E66549D321172F287501B5 /* SharedFFI */,
E6F6A75B1B8366C3D868D1E4 /* SimpleCounter */,
A58FEB50EA86B3FEA463FCF0 /* src */,
D4D259F256E0F508B61E0EA9 /* Products */,
B6068D7E9E67CAA3B5F4F827 /* Projects */,
);
sourceTree = "<group>";
};
64DA90BC973EE8B5939308C2 /* Products */ = {
37E66549D321172F287501B5 /* SharedFFI */ = {
isa = PBXGroup;
children = (
2EA4D4AAE1A6C4D3400A9A06 /* libshared_static.a */,
CCE0790D2AA1F71400CD4B57 /* shared.dylib */,
E75E53B837C6A0E03FDCEC5A /* uniffi-bindgen */,
EA33C72B2EF6A68B351BB022 /* shared.swift */,
07EC71797B0B95DAD077436C /* sharedFFI.h */,
98924D54C7B6BFCB1E503C2E /* sharedFFI.modulemap */,
);
name = Products;
name = SharedFFI;
path = ../shared/generated/swift/SharedFFI;
sourceTree = "<group>";
};
A58FEB50EA86B3FEA463FCF0 /* src */ = {
64DA90BC973EE8B5939308C2 /* Products */ = {
isa = PBXGroup;
children = (
8B8EC4C63F3ECC2B26BBAEC2 /* shared.udl */,
2EA4D4AAE1A6C4D3400A9A06 /* libshared_static.a */,
076D837B2C49634600D2EEF1 /* shared.dylib */,
E75E53B837C6A0E03FDCEC5A /* uniffi-bindgen */,
);
name = src;
path = ../shared/src;
name = Products;
sourceTree = "<group>";
};
B6068D7E9E67CAA3B5F4F827 /* Projects */ = {
Expand All @@ -151,15 +136,15 @@
642CF26F4B57B0FF7348C6BF /* SharedTypes */,
);
name = Packages;
sourceTree = SOURCE_ROOT;
sourceTree = "<group>";
};
E6F6A75B1B8366C3D868D1E4 /* SimpleCounter */ = {
isa = PBXGroup;
children = (
842F8D01CC76E9BFCDBD2862 /* ContentView.swift */,
258EC994D7C693E3141C4563 /* core.swift */,
BF52C000453302D743B48803 /* SimpleCounterApp.swift */,
CF5BE0317D54587DCCF48AF4 /* Info.plist */,
02DCFFA8F642585B6E57DA81 /* SimpleCounterApp.swift */,
);
path = SimpleCounter;
sourceTree = "<group>";
Expand All @@ -176,7 +161,6 @@
593C7A3AEAC5E5C614E32E14 /* Frameworks */,
);
buildRules = (
A7015E42CE7FE365402B3A57 /* PBXBuildRule */,
);
dependencies = (
2FF352CA5059B90A12956273 /* PBXTargetDependency */,
Expand Down Expand Up @@ -208,6 +192,9 @@
en,
);
mainGroup = 1B8911D02E90EF25A711F2BE;
packageReferences = (
828D8D7B0DA5553163A5E024 /* XCLocalSwiftPackageReference "../shared/generated/swift/SharedTypes" */,
);
projectDirPath = "";
projectReferences = (
{
Expand All @@ -223,20 +210,20 @@
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
076D837B2C49634600D2EEF1 /* shared.dylib */ = {
isa = PBXReferenceProxy;
fileType = "compiled.mach-o.dylib";
path = shared.dylib;
remoteRef = 076D837A2C49634600D2EEF1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
2EA4D4AAE1A6C4D3400A9A06 /* libshared_static.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libshared_static.a;
remoteRef = 6EC78E6AA13637C891278065 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
CCE0790D2AA1F71400CD4B57 /* shared.dylib */ = {
isa = PBXReferenceProxy;
fileType = "compiled.mach-o.dylib";
path = shared.dylib;
remoteRef = CCE0790C2AA1F71400CD4B57 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
E75E53B837C6A0E03FDCEC5A /* uniffi-bindgen */ = {
isa = PBXReferenceProxy;
fileType = "compiled.mach-o.executable";
Expand All @@ -263,9 +250,11 @@
buildActionMask = 2147483647;
files = (
401EA3CBD0D2AD8D475C10AF /* ContentView.swift in Sources */,
D39A72610E7E3BD191DBDC06 /* SimpleCounterApp.swift in Sources */,
ACEED4C684566162EAB9CB48 /* SimpleCounterApp.swift in Sources */,
94DCD6C97BBC86B89673CA0E /* core.swift in Sources */,
A022BC4B1B16254762ED55B3 /* shared.udl in Sources */,
5776AB3F6BDB21968CE9543A /* shared.swift in Sources */,
8291B7EC6C593FA8E5BB4F36 /* sharedFFI.h in Sources */,
C52E639D2187D4C22DDEF776 /* sharedFFI.modulemap in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -290,6 +279,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = SimpleCounter/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -302,7 +292,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.simple_counter.SimpleCounter;
SDKROOT = iphoneos;
SWIFT_OBJC_BRIDGING_HEADER = generated/sharedFFI.h;
SWIFT_OBJC_BRIDGING_HEADER = ../shared/generated/swift/SharedFFI/sharedFFI.h;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -312,6 +302,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = SimpleCounter/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -324,7 +315,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.simple_counter.SimpleCounter;
SDKROOT = iphoneos;
SWIFT_OBJC_BRIDGING_HEADER = generated/sharedFFI.h;
SWIFT_OBJC_BRIDGING_HEADER = ../shared/generated/swift/SharedFFI/sharedFFI.h;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down Expand Up @@ -469,6 +460,13 @@
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
828D8D7B0DA5553163A5E024 /* XCLocalSwiftPackageReference "../shared/generated/swift/SharedTypes" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../shared/generated/swift/SharedTypes;
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
ADFA4530638891CDAA6FCC5D /* SharedTypes */ = {
isa = XCSwiftPackageProductDependency;
Expand Down
Loading