-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathappend_target_triple.py
More file actions
35 lines (31 loc) · 863 Bytes
/
append_target_triple.py
File metadata and controls
35 lines (31 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import subprocess
import sys
import os
import asyncio
import re
extension = ''
if sys.platform == 'win32':
extension = '.exe'
async def run_command(cmd):
process = await asyncio.create_subprocess_shell(
cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await process.communicate()
return stdout.decode().strip(), stderr.decode().strip()
async def main():
rust_info, _ = await run_command('rustc -vV')
target_triple = re.search(r'host: (\S+)', rust_info).group(1)
if not target_triple:
print('Failed to determine platform target triple')
return
os.rename(
f'dist/api{extension}',
f'dist/api-{target_triple}{extension}'
)
if __name__ == "__main__":
try:
asyncio.run(main())
except Exception as e:
raise e