This is an automated email from the ASF dual-hosted git repository. leginee pushed a commit to branch bazel-migration in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 1e005ed755b89fb7267a548a30c086252a5d522b Author: Peter <[email protected]> AuthorDate: Thu Oct 8 10:28:01 2026 +0200 build(odk): loader classes, unowinreg.dll, unoapploader.exe, uno_loader_classes.zip What odk compiles (source/), mirroring prj/build.lst. Both native targets link the static CRT as upstream does: they run inside a client's java.exe or launcher before any office has been found. An empty _SNPRINTF_DLLIMPORT keeps sal's snprintf.h from declaring the CRT's _snprintf dllimport, which against libcmt is C2375. unowinreg exports the undecorated Java_* names through a DEF made from unowinreg.dxp. javac_classes now roots -d at the class-path root, so packaged classes land at their declared com/sun/.../X.class paths; the existing default-package use (jvmfwk's JREProperties.class) is unchanged. cppuhelper exports findsofficepath.c for unoapploader. Co-Authored-By: Claude Opus 5.5 <[email protected]> --- build/rules/java_pipeline.bzl | 8 ++- main/cppuhelper/BUILD.bazel | 4 ++ main/odk/BUILD.bazel | 123 ++++++++++++++++++++++++++++++++++++++++++ main/odk/util/unowinreg.def | 11 ++++ 4 files changed, 144 insertions(+), 2 deletions(-) diff --git a/build/rules/java_pipeline.bzl b/build/rules/java_pipeline.bzl index 7db66cd14c..0f13a5dbc0 100644 --- a/build/rules/java_pipeline.bzl +++ b/build/rules/java_pipeline.bzl @@ -301,7 +301,11 @@ def _javac_classes_impl(ctx): fail("javac_classes: could not locate javac(.exe) in the JDK runtime") outs = [ctx.actions.declare_file(n) for n in ctx.attr.outs] - out_dir = outs[0].dirname + + # javac -d takes the CLASS-PATH ROOT and adds package directories below + # it, so the root is the output path minus the declared name, which for a + # packaged class carries those directories ("com/sun/.../X.class"). + out_dir = outs[0].path[:-len(ctx.attr.outs[0]) - 1] ctx.actions.run( executable = javac.path, @@ -327,7 +331,7 @@ javac_classes = rule( ), "outs": attr.string_list( mandatory = True, - doc = "Every .class file javac will emit, e.g. [\"JREProperties.class\"].", + doc = "Every .class file javac will emit, relative to the class-path root, e.g. [\"JREProperties.class\"] or [\"com/sun/star/lib/loader/Loader.class\"].", ), "release": attr.string( default = "8", diff --git a/main/cppuhelper/BUILD.bazel b/main/cppuhelper/BUILD.bazel index 17c07c2871..9dbde7843b 100644 --- a/main/cppuhelper/BUILD.bazel +++ b/main/cppuhelper/BUILD.bazel @@ -9,6 +9,10 @@ load("//build:jre.bzl", "jre_home_env") load("//build/rules:gtest_test.bzl", "gtest_test") load("//main/postprocess:postprocess.bzl", "services_rdb") +# findsofficepath.c is also compiled into //main/odk:unoapploader -- upstream +# delivers its .obj on its own for exactly that (Package_findsofficepath.mk). +exports_files(["source/findsofficepath.c"]) + _COPTS = [ "/Zm500", "/Zc:forScope", "/GR", "/nologo", "/Gs", "/EHsc", diff --git a/main/odk/BUILD.bazel b/main/odk/BUILD.bazel new file mode 100644 index 0000000000..ce8670860b --- /dev/null +++ b/main/odk/BUILD.bazel @@ -0,0 +1,123 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") +load("//build/rules:extension.bzl", "ext_files", "oxt_package") +load("//build/rules:java_pipeline.bzl", "javac_classes") + +# odk — the Office Development Kit (SDK). Mirrors prj/build.lst. +# +# This file so far holds the three things odk COMPILES (source/); the SDK tree +# itself (pack/copying: tools, import libs, headers, IDL, settings, examples, +# docs) and the generated reference (pack/gendocu, needs autodoc) are not yet +# migrated. See readme.md. + +_DEFINES = [ + "WNT", + "WIN32", +] + +# Both native targets link the STATIC CRT. sal/config.h pulls in +# systools/win32/snprintf.h, which declares snprintf -- renamed _snprintf by +# the VC9 toolchain's crt_defines -- as __declspec(dllimport), matching only +# the DLL CRT; against libcmt's plain declaration that is C2375. An empty +# _SNPRINTF_DLLIMPORT is the header's own switch for that. +_STATIC_CRT_DEFINES = _DEFINES + ["_SNPRINTF_DLLIMPORT="] + +# ── com.sun.star.lib.loader — source/com/sun/star/lib/loader ───────────────── +# The class loader an SDK client application ships inside its own jar: it finds +# an office installation (registry via unowinreg.dll, or UNO_PATH) and puts its +# UNO jars on a custom class loader. Loose classes, not a jar: the SDK copies +# them into a client's jar under com/sun/star/lib/loader/. +# +# --release 8: these run inside the CLIENT's JRE, not the build JDK. +javac_classes( + name = "loader_classes", + srcs = glob(["source/com/sun/star/lib/loader/*.java"]), + outs = ["com/sun/star/lib/loader/" + c + ".class" for c in [ + "InstallationFinder", + "InstallationFinder$StreamGobbler", + "Loader", + "Loader$CustomURLClassLoader", + "Loader$Drain", + "WinRegKey", + "WinRegKeyException", + ]], + visibility = ["//visibility:public"], +) + +# ── unowinreg.dll — source/unowinreg/win ───────────────────────────────────── +# The JNI half of WinRegKey above. Loaded by the CLIENT's java.exe, never by +# the office, so it links the static CRT (upstream: STDSHL= + LIBCMT) and needs +# no manifest at all. Exports are the undecorated Java_* names; the .def is +# unowinreg.dxp as a DEF (same trick as jurt's jpipe.def -- on x86 link.exe +# binds each name to its __stdcall _Java_...@N symbol). +cc_binary( + name = "unowinreg", + srcs = ["source/unowinreg/win/unowinreg.cxx"], + copts = [ + "/EHsc", + "/Imain/odk/inc/pch", + ], + defines = _STATIC_CRT_DEFINES, + features = ["static_link_msvcrt"], + linkshared = True, + win_def_file = "util/unowinreg.def", + deps = ["@rules_java//toolchains:jni"], + linkopts = [ + "advapi32.lib", + "/MANIFEST:NO", + ], + visibility = ["//visibility:public"], +) + +# ── unoapploader.exe — source/unoapploader/win ─────────────────────────────── +# Copied by an SDK client next to its own exe under the client's name; finds +# the office (findsofficepath.c, shared with cppuhelper), puts it on PATH and +# starts the client's real exe. Static CRT (upstream DYNAMIC_CRT= is empty), +# so it runs before any office -- and any VC runtime -- has been found. +cc_binary( + name = "unoapploader", + srcs = [ + "source/unoapploader/win/unoapploader.c", + "//main/cppuhelper:source/findsofficepath.c", + ], + copts = ["/TC"], + defines = _STATIC_CRT_DEFINES, + features = ["static_link_msvcrt"], + deps = [ + "//main/cppuhelper:cppuhelper_headers", + "//main/sal:sal_headers", + ], + linkopts = [ + "advapi32.lib", + "/SUBSYSTEM:WINDOWS", + "/MANIFEST:NO", + ], + visibility = ["//visibility:public"], +) + +# ── uno_loader_classes.zip ──────────────────────────────────────────────────── +# Upstream pack/copying: zip -r of the SDK's classes/ dir, "com/* win/*" -- the +# loader classes plus win/unowinreg.dll, the layout InstallationFinder expects +# when it loads the DLL from beside the classes. Delivered to solver bin/ by +# prj/d.lst. oxt_package is a plain zip-by-archive-path; nothing about it is +# extension-specific. +ext_files( + name = "_loader_zip_classes", + srcs = [":loader_classes"], + strip_prefix = "main/odk", +) + +ext_files( + name = "_loader_zip_win", + srcs = [":unowinreg"], + dest = "win", +) + +oxt_package( + name = "uno_loader_classes", + out = "uno_loader_classes.zip", + contents = [ + ":_loader_zip_classes", + ":_loader_zip_win", + ], + visibility = ["//visibility:public"], +) diff --git a/main/odk/util/unowinreg.def b/main/odk/util/unowinreg.def new file mode 100644 index 0000000000..e84d417a6a --- /dev/null +++ b/main/odk/util/unowinreg.def @@ -0,0 +1,11 @@ +LIBRARY unowinreg +EXPORTS + Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenClassesRoot + Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenCurrentConfig + Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenCurrentUser + Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenLocalMachine + Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenUsers + Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegOpenKeyEx + Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegCloseKey + Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegQueryValueEx + Java_com_sun_star_lib_loader_WinRegKey_winreg_1RegQueryInfoKey
