Skip to content

Commit 38910e2

Browse files
Parnassiushfiguiere
authored andcommitted
dotnet: allow specifying the --runtime argument multiple times
When doing so, `dotnet restore` gets executed once for each runtime, creating a file that contains all the required sources.
1 parent 9a48b5e commit 38910e2

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

dotnet/flatpak-dotnet-generator.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def main():
2121
parser = argparse.ArgumentParser()
2222
parser.add_argument('output', help='The output JSON sources file')
2323
parser.add_argument('project', help='The project file')
24-
parser.add_argument('--runtime', '-r', help='The target runtime to restore packages for')
24+
parser.add_argument('--runtime', '-r', nargs='+', default=[None], help='The target runtime to restore packages for')
2525
parser.add_argument('--freedesktop', '-f', help='The target version of the freedesktop sdk to use',
2626
default=freedesktop_default)
2727
parser.add_argument('--dotnet', '-d', help='The target version of dotnet to use',
@@ -34,18 +34,19 @@ def main():
3434
sources = []
3535

3636
with tempfile.TemporaryDirectory(dir=Path()) as tmp:
37-
runtime_args = []
38-
if args.runtime:
39-
runtime_args.extend(('-r', args.runtime))
37+
for runtime in args.runtime:
38+
runtime_args = []
39+
if runtime is not None:
40+
runtime_args.extend(('-r', runtime))
4041

41-
subprocess.run([
42-
'flatpak', 'run',
43-
'--env=DOTNET_CLI_TELEMETRY_OPTOUT=true',
44-
'--env=DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true',
45-
'--command=sh', f'--runtime=org.freedesktop.Sdk//{args.freedesktop}', '--share=network',
46-
'--filesystem=host', f'org.freedesktop.Sdk.Extension.dotnet{args.dotnet}//{args.freedesktop}', '-c',
47-
f'PATH="${{PATH}}:/usr/lib/sdk/dotnet{args.dotnet}/bin" LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/sdk/dotnet{args.dotnet}/lib" exec dotnet restore "$@"',
48-
'--', '--packages', tmp, args.project] + runtime_args)
42+
subprocess.run([
43+
'flatpak', 'run',
44+
'--env=DOTNET_CLI_TELEMETRY_OPTOUT=true',
45+
'--env=DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true',
46+
'--command=sh', f'--runtime=org.freedesktop.Sdk//{args.freedesktop}', '--share=network',
47+
'--filesystem=host', f'org.freedesktop.Sdk.Extension.dotnet{args.dotnet}//{args.freedesktop}', '-c',
48+
f'PATH="${{PATH}}:/usr/lib/sdk/dotnet{args.dotnet}/bin" LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/sdk/dotnet{args.dotnet}/lib" exec dotnet restore "$@"',
49+
'--', '--packages', tmp, args.project] + runtime_args)
4950

5051
for path in Path(tmp).glob('**/*.nupkg.sha512'):
5152
name = path.parent.parent.name

0 commit comments

Comments
 (0)