refactor(ffi-linkage): Phase 9.2d — rename foreign_path → runtime_path (coupled .sx↔.zig↔hook)

The JNI/runtime-class path (Decision 5, Runtime* family). Coordinated across the
hook boundary so the BuildOptions accessor + its registered hook string stay in sync:
- src/: RuntimeClassDecl.foreign_path→runtime_path, splitForeignPath→splitRuntimePath,
  foreignPathToJavaName→runtimePathToJavaName, jni_main_foreign_paths→
  jni_main_runtime_paths, hookJniMainForeignPathAt→hookJniMainRuntimePathAt, and the
  hook string 'BuildOptions.jni_main_foreign_path_at'→'…runtime_path_at'.
- library/: build.sx accessor jni_main_foreign_path_at→jni_main_runtime_path_at +
  bundle.sx call sites + the  local var → runtime_path + a comment.
- specs.md: the accessor name + <foreign_path_with_dots> doc refs.
- Regenerated 37 .ir snapshots: every program importing build declares the renamed
  @BuildOptions.jni_main_runtime_path_at hook stub — symbol-name change only (verified
  the .ir diff is ONLY this rename; reverted orthogonal empty-file normalization).
Suite green (646 corpus / 444 unit, 0 failed).
This commit is contained in:
agra
2026-06-15 09:20:30 +03:00
parent a15a868391
commit 8cca3b9dde
53 changed files with 130 additions and 130 deletions

View File

@@ -84,10 +84,10 @@ BuildOptions :: struct #compiler {
// `#jni_main #jni_class("path") { ... }` decls collected during
// lowering. The Android bundler walks `0..jni_main_count()` and
// for each entry writes a `.java` file at
// `<stage>/java/<foreign_path>.java`, compiles via javac + d8, and
// `<stage>/java/<runtime_path>.java`, compiles via javac + d8, and
// bundles the resulting classes.dex into the APK.
jni_main_count :: (self: BuildOptions) -> i64;
jni_main_foreign_path_at :: (self: BuildOptions, i: i64) -> string;
jni_main_runtime_path_at :: (self: BuildOptions, i: i64) -> string;
jni_main_java_source_at :: (self: BuildOptions, i: i64) -> string;
}

View File

@@ -871,11 +871,11 @@ build_android_manifest :: (opts: BuildOptions, package: string, lib_name: string
pkg_esc := xml.escape(package);
lib_esc := xml.escape(lib_name);
if opts.jni_main_count() > 0 {
// First `#jni_main` decl drives the Activity. The foreign_path
// First `#jni_main` decl drives the Activity. The runtime_path
// uses `/` separators; Java fully-qualified class names use
// `.` so we rewrite.
foreign := opts.jni_main_foreign_path_at(0);
cls := slash_to_dot(foreign);
runtime_path := opts.jni_main_runtime_path_at(0);
cls := slash_to_dot(runtime_path);
cls_esc := xml.escape(cls);
return format(#string MANIFEST
<?xml version="1.0" encoding="utf-8"?>
@@ -938,7 +938,7 @@ slash_to_dot :: (path: string) -> string {
}
// Last `/`-separated component of a forward-slash path (used to split
// JNI foreign paths into pkg + class). `co/swipelab/Foo` → `Foo`.
// JNI runtime-class paths into pkg + class). `co/swipelab/Foo` → `Foo`.
// `Foo` → `Foo`. `dir_part` returns the part before the last slash
// (or "" if none).
last_slash_component :: (path: string) -> string {
@@ -990,10 +990,10 @@ compile_jni_main_sources :: (opts: BuildOptions, stage: string, android_jar: str
count := opts.jni_main_count();
i : i64 = 0;
while i < count {
foreign := opts.jni_main_foreign_path_at(i);
runtime_path := opts.jni_main_runtime_path_at(i);
java_source := opts.jni_main_java_source_at(i);
pkg := dir_part(foreign);
cls := last_slash_component(foreign);
pkg := dir_part(runtime_path);
cls := last_slash_component(runtime_path);
pkg_dir := if pkg.len > 0 then path_join(java_root, pkg) else java_root;
if !create_dir_all(str_to_cstr(pkg_dir)) {
@@ -1003,7 +1003,7 @@ compile_jni_main_sources :: (opts: BuildOptions, stage: string, android_jar: str
java_path := path_join(pkg_dir, concat(cls, ".java"));
if !write_file(str_to_cstr(java_path), java_source) {
out("error: apk: cannot write .java for ");
out(foreign);
out(runtime_path);
out("\n");
return false;
}