Skip to content

Conversation

@t089
Copy link
Owner

@t089 t089 commented Nov 15, 2025

Summary

  • Adds post-install.sh to prepare the environment for Swift VIPS saveable/import changes
  • Adds backwards-compatibility shim for VipsSaveable in CvipsShim.h for libvips 8.17+
  • Extends Swift bindings (VipsSaveable.swift) to map to VipsForeignSaveable flags through the shim
  • Installs required system dependencies via apt-get: gnupg2, libcurl4-openssl-dev, libxml2-dev, libncurses-dev, libz3-dev, pkg-config
  • Uses non-interactive installation to suit CI and local development setups

Changes

New Files

  • post-install.sh: New script that runs apt-get -y install to install the required dependencies

Updated Files

  • Sources/CvipsShim/include/CvipsShim.h: Backwards-compatibility shim for libvips 8.17+ VipsSaveable removal
  • Sources/VIPS/Foreign/Enums/VipsSaveable.swift: Adds compatibility mapping for VipsSaveable alias to new VipsForeignSaveable flags

Dependency Overview

  • Installs: gnupg2, libcurl4-openssl-dev, libxml2-dev, libncurses-dev, libz3-dev, pkg-config

CI/Local Setup

  • Script runs non-interactively to avoid prompts during automated runs

Test plan

  • Run post-install.sh on a Debian/Ubuntu runner to install dependencies
  • Build the Swift VIPS import path and ensure VipsSaveable symbols are accessible
  • Verify mapping of VipsSaveable to VipsForeignSaveable under libvips >= 8.17
  • Run Swift VIPS import tests to ensure no missing dependency errors

🌿 Generated by Terry


ℹ️ Tag @terragon-labs to ask questions and address PR feedback

📎 Task: https://www.terragonlabs.com/task/aa771467-a569-4216-93c5-af2b1872c35a

@t089 t089 changed the title Add post-install.sh to install build deps for Swift VIPS Add post-install.sh and VipsSaveable compatibility shim Nov 15, 2025
t089 and others added 6 commits November 16, 2025 21:32
Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
In libvips 8.17.0, VipsSaveable was removed and replaced with VipsForeignSaveable flags.
This commit adds a compatibility shim in CvipsShim to provide the old VipsSaveable enum
by mapping to the new VipsForeignSaveable flags, ensuring code depending on the old enum
continues to function with libvips 8.17+.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
Changed the shim detection from checking VIPS_TYPE_SAVEABLE (a GObject
type macro that may not be reliable) to checking for VIPS_SAVEABLE_MONO
constant directly. This ensures the shim is properly activated when
VipsSaveable doesn't exist in libvips 8.17.x.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
libvips 8.17.0 removed VipsSaveable and replaced it with VipsForeignSaveable
(a flags enum with different semantics). This creates a compatibility layer:

- CvipsShim defines the old enum values for libvips 8.17+ by mapping to
  VipsForeignSaveable flags
- Swift code uses a typealias to UInt32 that works with both the native
  enum (pre-8.17) and our shim constants (8.17+)
- Provides convenient static properties for all VipsSaveable values

This ensures the wrapper works across libvips versions 8.15 through 8.17+
without breaking changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Swift cannot import C macros that use bitwise OR operators. libvips 8.17.3
added backwards compatibility macros for VipsSaveable, but they use OR
operations which Swift rejects with "structure not supported".

Solution: CvipsShim now provides inline getter functions that:
- Work across all libvips versions (8.15.x through 8.17.x+)
- Return the native enum values for pre-8.17
- Use the backwards compat macros if available in 8.17.3+
- Fall back to VipsForeignSaveable flags for 8.17.0-8.17.2

Swift code simply calls these functions to get the constant values,
avoiding any direct dependency on enums or macros.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@t089 t089 force-pushed the terragon/fix-vips-saveable-import-exz1xp branch from 210616e to b01505d Compare November 16, 2025 20:34
Base automatically changed from refactor to main November 16, 2025 20:49
@t089 t089 closed this Nov 17, 2025
@t089 t089 deleted the terragon/fix-vips-saveable-import-exz1xp branch November 17, 2025 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants