-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install Uapi/shield crate to staging (#10)
- [x] create local registry at startup - [x] remove nigthly cargo - [x] install uapi - [x] install shield - [x] install deps (kconfig, metadata) - [x] install task - [x] relink task
- Loading branch information
Showing
14 changed files
with
402 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
`cargo_config` | ||
============== | ||
|
||
.. argparse:: | ||
:module: outpost.barbican._internals.cargo_config | ||
:func: argument_parser | ||
:prog: barbican --internal cargo_config | ||
|
||
.. seealso:: | ||
|
||
:py:mod:`outpost.barbican._internals.cargo_config` module documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
`cargo_install` | ||
=============== | ||
|
||
.. argparse:: | ||
:module: outpost.barbican._internals.cargo_install | ||
:func: argument_parser | ||
:prog: barbican --internal cargo_install | ||
|
||
.. seealso:: | ||
|
||
:py:mod:`outpost.barbican._internals.cargo_install` module documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# SPDX-FileCopyrightText: 2024 Ledger SAS | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""Generate a .cargo/config.toml per cargo app. | ||
Add target specific and per apps compile flags in a config. | ||
""" | ||
|
||
from argparse import ArgumentParser | ||
from pathlib import Path | ||
import typing as T | ||
|
||
|
||
def run_cargo_config(rustargs: Path, target: Path, extra_args: str, outdir: Path) -> None: | ||
rust_target = target.read_text().splitlines()[0] | ||
rust_flags = rustargs.read_text().splitlines() | ||
rust_flags.extend(extra_args.split(" ")) | ||
linker_args = list(filter(lambda x: x.startswith("-Clinker"), rust_flags)) | ||
linker = linker_args[0].split("=")[1] if len(linker_args) else "is not set" | ||
rust_flags = list(filter(lambda x: not x.startswith("-Clinker"), rust_flags)) | ||
|
||
config = f""" | ||
[build] | ||
target = "{rust_target}" | ||
target-dir = "{str(outdir.resolve())}" | ||
rustflags = {rust_flags} | ||
[target.{rust_target}] | ||
{"#" if not len(linker_args) else ""}linker = "{linker}" | ||
[env] | ||
OUT_DIR = "{str(outdir.resolve())}" | ||
""" | ||
|
||
(outdir / ".cargo" / "config.toml").write_text(config) | ||
|
||
|
||
def argument_parser() -> ArgumentParser: | ||
parser = ArgumentParser() | ||
parser.add_argument("--rustargs-file", type=Path, help="rustargs file path") | ||
parser.add_argument("--target-file", type=Path, help="rust target file path") | ||
parser.add_argument("--extra-args", type=str) | ||
parser.add_argument("outdir", type=Path, help="output directory") | ||
|
||
return parser | ||
|
||
|
||
def run(argv: T.List[str]) -> None: | ||
"""Execute gen crate cargo config command.""" | ||
args = argument_parser().parse_args(argv) | ||
run_cargo_config(args.rustargs_file, args.target_file, args.extra_args, args.outdir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# SPDX-FileCopyrightText: 2024 Ledger SAS | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""Generate a .cargo/config.toml per cargo app. | ||
Add target specific and per apps compile flags in a config. | ||
""" | ||
|
||
from argparse import ArgumentParser | ||
from pathlib import Path | ||
import typing as T | ||
|
||
from .install import run_install, argument_parser as install_argument_parser | ||
|
||
|
||
def argument_parser() -> ArgumentParser: | ||
parser = install_argument_parser() | ||
parser.add_argument( | ||
"--target-file", | ||
type=Path, | ||
help="rust target file", | ||
) | ||
parser.add_argument( | ||
"--profile", | ||
action="store", | ||
type=str, | ||
default="release", | ||
help="cargo build profile", | ||
) | ||
|
||
return parser | ||
|
||
|
||
def run(argv: T.List[str]) -> None: | ||
args = argument_parser().parse_args(argv) | ||
target: str = args.target_file.read_text().splitlines()[0] | ||
from_dir: Path = (args.from_dir / target / args.profile).resolve(strict=True) | ||
run_install(from_dir, args.files, args.suffix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.