Browse Source

build: add library versioning and ensure consistent library paths

- Add version suffix to shared library (libusm-0.1.so) to prevent ABI conflicts
- Force --libdir=lib across all meson builds for cross-platform consistency
- Set PKG_CONFIG_PATH when building USM to find bundled Invercargill libraries
- Add LD_LIBRARY_PATH export in shim for runtime library discovery
- Add exit before payload section in compiled installer scripts
clanker 5 ngày trước cách đây
mục cha
commit
b05bb6f93a
4 tập tin đã thay đổi với 22 bổ sung14 xóa
  1. 11 7
      installer/build_config.sh
  2. 3 0
      installer/compile.sh
  3. 7 6
      src/lib/meson.build
  4. 1 1
      src/meson.build

+ 11 - 7
installer/build_config.sh

@@ -44,8 +44,8 @@ build_invercargill() {
     
     pushd "$src_dir" >/dev/null || return 1
     
-    # Configure with meson
-    if ! meson setup src builddir --prefix="$prefix" -Ddefault_library=static >"$output_redirect" 2>&1; then
+    # Configure with meson (force libdir=lib for consistency across platforms)
+    if ! meson setup src builddir --prefix="$prefix" --libdir=lib -Ddefault_library=static >"$output_redirect" 2>&1; then
         log_error "Failed to configure Invercargill"
         [[ "$VERBOSE" != "true" ]] && log_info "Run with --verbose for details"
         popd >/dev/null
@@ -81,8 +81,8 @@ build_invercargill_json() {
     
     pushd "$src_dir" >/dev/null || return 1
     
-    # Configure with meson
-    if ! meson setup src builddir --prefix="$prefix" -Ddefault_library=static >"$output_redirect" 2>&1; then
+    # Configure with meson (force libdir=lib for consistency across platforms)
+    if ! meson setup src builddir --prefix="$prefix" --libdir=lib -Ddefault_library=static >"$output_redirect" 2>&1; then
         log_error "Failed to configure Invercargill-Json"
         [[ "$VERBOSE" != "true" ]] && log_info "Run with --verbose for details"
         popd >/dev/null
@@ -118,8 +118,11 @@ build_usm() {
     
     pushd "$src_dir" >/dev/null || return 1
     
-    # Configure with meson (USM's meson.build is at root, not in src/)
-    if ! meson setup builddir --prefix="$prefix" >"$output_redirect" 2>&1; then
+    # Set PKG_CONFIG_PATH to find bundled Invercargill libraries
+    export PKG_CONFIG_PATH="$prefix/lib/pkgconfig:$prefix/share/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
+    
+    # Configure with meson (USM's meson.build is at root, force libdir=lib for consistency)
+    if ! meson setup builddir --prefix="$prefix" --libdir=lib >"$output_redirect" 2>&1; then
         log_error "Failed to configure USM"
         [[ "$VERBOSE" != "true" ]] && log_info "Run with --verbose for details"
         popd >/dev/null
@@ -183,7 +186,8 @@ install_shim() {
     log_step "Installing shim to $shim_path..."
     
     local shim_content="#!/bin/bash
-exec ${target_dir}/bin/usm \"\$@\"
+export LD_LIBRARY_PATH=\"${target_dir}/lib\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}\"
+exec \"${target_dir}/bin/usm\" \"\$@\"
 "
     
     if [[ -n "$sudo" ]]; then

+ 3 - 0
installer/compile.sh

@@ -131,6 +131,9 @@ process_script() {
     # Add the main call at the very end
     echo "# Run main function"
     echo 'main "$@"'
+    echo ""
+    echo "# Exit before payload"
+    echo "exit 0"
 } > "$COMBINED_FILE"
 
 # Replace version placeholder in combined file

+ 7 - 6
src/lib/meson.build

@@ -39,22 +39,23 @@ dependencies = [
     meson.get_compiler('c').find_library('sodium'),
 ]
 
-usm = shared_library('usm', sources,
+library_version = meson.project_version()
+usm = shared_library('usm-@0@'.format(library_version), sources,
     dependencies: dependencies,
     install: true,
-    vala_gir: 'usm-1.0.gir',
+    vala_gir: 'usm-@0@.gir'.format(library_version),
     install_dir: [true, true, true, true]
 )
 usm_dep = declare_dependency(link_with: usm, include_directories: include_directories('.'))
 
 pkg = import('pkgconfig')
 pkg.generate(usm,
-    version : '0.1',
-    name : 'usm',)
+    version : library_version,
+    name : 'usm-@0@'.format(library_version))
     
 g_ir_compiler = find_program('g-ir-compiler')
-custom_target('usm typelib', command: [g_ir_compiler, '--shared-library=libusm.so', '--output', '@OUTPUT@', meson.current_build_dir() / 'usm-1.0.gir'],
-              output: 'usm-1.0.typelib',
+custom_target('usm typelib', command: [g_ir_compiler, '--shared-library=libusm-@0@.so'.format(library_version), '--output', '@OUTPUT@', meson.current_build_dir() / 'usm-@0@.gir'.format(library_version)],
+              output: 'usm-@0@.typelib'.format(library_version),
               depends: usm,
               install: true,
               install_dir: get_option('libdir') / 'girepository-1.0')

+ 1 - 1
src/meson.build

@@ -1,4 +1,4 @@
-project('Universal Source Manifest', 'vala', 'c')
+project('Universal Source Manifest', 'vala', 'c', version: '0.1')
 vapi_dir = meson.current_source_dir() / 'vapi'
 
 subdir('lib')