Introduce the welded comptime `compiler` library (`#library "compiler"` +
`abi(.zig) extern compiler`), per design/comptime-compiler-api.md, and unify
`callconv(...)` into the new `abi(...)` annotation.
abi(...) replaces callconv(...):
- New ABI enum { default, c, zig, pure }; `abi(.c|.zig|.pure)` parses in the
postfix slot before extern/export (and standalone). `kw_callconv` -> `kw_abi`.
- Migrated 52 sx files, the call-convention-mismatch diagnostic, and docs
(readme/specs) from `callconv(.c)` to `abi(.c)`.
Phase 1 — welded compiler library (parse -> registry -> validation -> bridge):
- `abi(.zig) extern compiler` parses on fn decls (carries abi/extern_lib) and
struct decls (StructDecl.abi/extern_lib).
- `#library "compiler"` is the comptime-only internal surface — never dlopen'd.
- src/ir/compiler_lib.zig: the binding registry (the safety boundary). `Field`
welded to StructInfo.Field with layout baked from the real Zig type
(@offsetOf/@sizeOf); `findType`/`findFn`. Welded structs are layout-validated
at registration (field set + total size) as a header checked against the impl.
- Host-call bridge: a `fn abi(.zig) extern compiler` dispatches under the
comptime interp to its registered Zig handler (intern/text_of round-trip),
never dlsym. IR Function.compiler_welded; validated in declareFunction.
- Comptime-only enforcement: a runtime call to a welded fn is a clean
build-gating error (emitCall), not an undefined-symbol link failure.
Phase 2.1 — byte-layout weld foundation:
- Decision: full byte-layout weld (sx struct laid out byte-identically to the
bound Zig type). Registered StructInfo (first non-natural / Zig-reordered
layout). `computeWeldPlan` — pure offset-ordered element plan + padding +
sx-field->LLVM-element remap; unit-tested. Emit/interp wiring is the next
sub-step (2.2+, see current/CHECKPOINT-COMPILER-API.md).
Examples: 0625/0626 (welded struct + fn round-trip), 1183/1184/1185
(layout-mismatch, unexported-fn, runtime-call diagnostics).
59 lines
2.4 KiB
Plaintext
59 lines
2.4 KiB
Plaintext
// iOS *device* end-to-end exercise for `platform.bundle`. Distinct from
|
|
// 121-ios-sim-bundle.sx because the device path adds three steps that
|
|
// don't run on the simulator: provisioning profile embed, entitlements
|
|
// extraction (`security cms` + `plutil` pipeline resolving the
|
|
// wildcard `<TEAM>.*` → `<TEAM>.<bundle_id>`), and codesign with
|
|
// `--entitlements`.
|
|
//
|
|
// Build:
|
|
// sx build --target ios examples/122-ios-device-bundle.sx -o /tmp/SxDeviceProbe
|
|
//
|
|
// Install + launch (requires the device UDID to be on the profile):
|
|
// xcrun devicectl device install app --device <name> /tmp/SxDeviceProbe.app
|
|
// xcrun devicectl device process launch --device <name> co.swipelab.sxprobe
|
|
//
|
|
// The bundle id (`co.swipelab.sxprobe`) and codesign identity below
|
|
// match the test team's wildcard `SwipeS32DevProfile.mobileprovision`.
|
|
// Update the three set_* values to your own identity / profile / id to
|
|
// re-exercise on a different developer account.
|
|
|
|
#import "modules/std.sx";
|
|
#import "modules/ffi/objc.sx";
|
|
|
|
#framework "UIKit";
|
|
|
|
UIApplicationMain :: (argc: i32, argv: *void, principal_class: *NSString, delegate_class: *NSString) -> i32 extern;
|
|
#import "modules/build.sx";
|
|
#import "modules/platform/bundle.sx";
|
|
|
|
configure :: () {
|
|
opts := build_options();
|
|
opts.set_bundle_path("/tmp/SxDeviceProbe.app");
|
|
opts.set_bundle_id("co.swipelab.sxprobe");
|
|
opts.set_codesign_identity("Apple Development: Alexandru Agrapine (DC8VVHJ9W4)");
|
|
opts.set_provisioning_profile("/Users/agra/Downloads/SwipeS32DevProfile.mobileprovision");
|
|
opts.set_post_link_callback(bundle_main);
|
|
}
|
|
#run configure();
|
|
|
|
// IMP for application:didFinishLaunchingWithOptions:
|
|
// Obj-C: -(BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)opts
|
|
// Type encoding: "c@:@@" -- BOOL (signed char), self, _cmd, id, id
|
|
did_finish_launching :: (self: *void, _cmd: *void, app: *void, opts: *void) -> u8 abi(.c) {
|
|
NSLog(xx "[sx-device-probe] launched\n");
|
|
return 1; // YES
|
|
}
|
|
|
|
main :: () -> i32 {
|
|
UIResponder := objc_getClass("UIResponder".ptr);
|
|
SxAppDelegate := objc_allocateClassPair(UIResponder, "SxAppDelegate".ptr, 0);
|
|
|
|
sel := sel_registerName("application:didFinishLaunchingWithOptions:".ptr);
|
|
class_addMethod(SxAppDelegate, sel, xx did_finish_launching, "c@:@@".ptr);
|
|
|
|
objc_registerClassPair(SxAppDelegate);
|
|
|
|
// UIApplicationMain blocks driving iOS's run loop.
|
|
return UIApplicationMain(0, xx 0, xx 0, xx "SxAppDelegate");
|
|
}
|