Skip to content

Commit

Permalink
cargo: Embed resolved manifest
Browse files Browse the repository at this point in the history
Cargo with `inherit-workspace` feature requires workspace packages
Cargo.toml's to be resolved when using vendored sources, because
the workspace manifest won't be available when building them.
  • Loading branch information
gasinvein committed Feb 13, 2023
1 parent aa29dab commit d684bd7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cargo/flatpak-cargo-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from urllib.parse import urlparse, ParseResult, parse_qs
import os
import contextlib
import copy
import glob
import subprocess
import argparse
Expand Down Expand Up @@ -121,6 +122,20 @@ class _GitPackage(NamedTuple):
package: _TomlType
workspace: Optional[_TomlType]

@property
def normalized(self) -> _TomlType:
package = copy.deepcopy(self.package)
if self.workspace is None:
return package
for section_key, section in package.items():
for key, value in section.items():
if not isinstance(value, dict):
continue
if not value.get('workspace'):
continue
package[section_key][key] = self.workspace[section_key][key]
return package


_GitPackagesType = Dict[str, _GitPackage]

Expand Down Expand Up @@ -293,6 +308,12 @@ async def get_git_package_sources(
f'cp -r --reflink=auto "{pkg_repo_dir}" "{CARGO_CRATES}/{name}"'
],
},
{
'type': 'inline',
'contents': toml.dumps(git_pkg.normalized),
'dest': f'{CARGO_CRATES}/{name}', #-{version}',
'dest-filename': 'Cargo.toml',
},
{
'type': 'inline',
'contents': json.dumps({'package': None, 'files': {}}),
Expand Down

0 comments on commit d684bd7

Please sign in to comment.