From 18c3e7469647d21d9d8fce2764e5bed153b0ad84 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Wed, 22 Jul 2026 20:00:56 +0000
Subject: [PATCH 11/30] minicargo: accept `lib`/`staticlib`/`proc-macro` crate
 types, fix bare-major version reqs

- `crate-type = ["lib", ...]` (gifski 1.34) now maps to rlib;
  staticlib/cdylib entries are accepted and built as rlib when first
  (minicargo only ever consumes Rust dependencies)
- A bare-major version requirement like `chrono = "0"` (vergen 3.2)
  was treated as ^0.0, rejecting 0.4.x; caret/tilde on a lone major now
  expand to [>=X.0.0, <X+1.0.0] matching cargo semantics

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011M9MvswSD3mEeJcBm6S8z7
---
 tools/minicargo/build.cpp    |  3 +++
 tools/minicargo/manifest.cpp | 26 +++++++++++++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/tools/minicargo/build.cpp b/tools/minicargo/build.cpp
index 4ffd6e31..1105e40f 100644
--- a/tools/minicargo/build.cpp
+++ b/tools/minicargo/build.cpp
@@ -858,6 +858,9 @@ bool RunState::outfile_needs_rebuild(const helpers::path& outfile) const
                 outfile /= ::format("lib", target.m_name, crate_suffix, DLLSUF);
                 break;
             }
+        case PackageTarget::CrateType::staticlib:
+        case PackageTarget::CrateType::cdylib:
+            // Only ever consumed as a Rust dependency by minicargo - build as rlib
         case PackageTarget::CrateType::rlib:
             if(crate_type)  *crate_type = "rlib";
             outfile /= ::format("lib", target.m_name, crate_suffix, ".rlib");
diff --git a/tools/minicargo/manifest.cpp b/tools/minicargo/manifest.cpp
index 5e280b05..eced488b 100644
--- a/tools/minicargo/manifest.cpp
+++ b/tools/minicargo/manifest.cpp
@@ -855,7 +855,8 @@ namespace
             for(const auto& sv : kv.value.m_sub_values)
             {
                 const auto& s = sv.as_string();
-                if(s == "rlib") {
+                if(s == "rlib" || s == "lib") {
+                    // NOTE: `lib` is the default library type (seen in e.g. gifski)
                     target.m_crate_types.push_back(PackageTarget::CrateType::rlib);
                 }
                 else if(s == "dylib") {
@@ -864,7 +865,12 @@ namespace
                 else if(s == "cdylib") {
                     target.m_crate_types.push_back(PackageTarget::CrateType::cdylib);
                 }
-                // TODO: Other crate types
+                else if(s == "staticlib") {
+                    target.m_crate_types.push_back(PackageTarget::CrateType::staticlib);
+                }
+                else if(s == "proc-macro") {
+                    target.m_crate_types.push_back(PackageTarget::CrateType::proc_macro);
+                }
                 else {
                     eh.error("Unknown crate type - ", s);
                 }
@@ -1684,12 +1690,22 @@ PackageVersionSpec PackageVersionSpec::from_string(const ::std::string& s)
         }
         else
         {
-            // NOTE: This changes the behaviour of ~ rules to be bounded on the major version instead
-            if( ty == PackageVersionSpec::Bound::Type::MinorCompatible )
-                ty = PackageVersionSpec::Bound::Type::Compatible;
             v.minor = 0;
             v.patch = 0;
             v.patch_set = false;
+            // Bare major version (e.g. `chrono = "0"` in vergen 3.2): caret/tilde semantics for a
+            // lone major are "any version with this major" - `0` matches `0.4.x` (unlike `0.0`)
+            if( ty == PackageVersionSpec::Bound::Type::Compatible || ty == PackageVersionSpec::Bound::Type::MinorCompatible )
+            {
+                rv.m_bounds.push_back(PackageVersionSpec::Bound { PackageVersionSpec::Bound::Type::GreaterEqual, v });
+                rv.m_bounds.push_back(PackageVersionSpec::Bound { PackageVersionSpec::Bound::Type::Less, PackageVersion { v.major + 1 } });
+
+                while( pos < s.size() && isblank(s[pos]) )
+                    pos ++;
+                if(pos == s.size())
+                    break ;
+                continue ;
+            }
         }
 
         rv.m_bounds.push_back(PackageVersionSpec::Bound { ty, v });
-- 
2.43.0

