mirror of
https://github.com/projectPiki/pikmin2.git
synced 2024-11-23 21:39:44 +00:00
97c07eda27
* Add dep tracking & use WiBo in CI * Create empty tools/mwcc_compiler * Disable UPDATE_README in CI
57 lines
1.5 KiB
Python
Executable File
57 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import argparse
|
|
import os
|
|
|
|
wineprefix = os.path.join(os.environ['HOME'], '.wine')
|
|
if 'WINEPREFIX' in os.environ:
|
|
wineprefix = os.environ['WINEPREFIX']
|
|
winedevices = os.path.join(wineprefix, 'dosdevices')
|
|
|
|
def import_d_file(in_file) -> str:
|
|
out_text = ''
|
|
|
|
with open(in_file) as file:
|
|
for idx, line in enumerate(file):
|
|
if idx == 0:
|
|
if line.endswith(' \\\n'):
|
|
out_text += line[:-3].replace('\\', '/') + " \\\n"
|
|
else:
|
|
out_text += line.replace('\\', '/')
|
|
else:
|
|
suffix = ''
|
|
if line.endswith(' \\\n'):
|
|
suffix = ' \\'
|
|
path = line.lstrip()[:-3]
|
|
else:
|
|
path = line.strip()
|
|
# lowercase drive letter
|
|
path = path[0].lower() + path[1:]
|
|
# use $WINEPREFIX/dosdevices to resolve path
|
|
path = os.path.realpath(os.path.join(winedevices, path.replace('\\', '/')))
|
|
out_text += "\t" + path + suffix + "\n"
|
|
|
|
return out_text
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
description="""Transform a .d file from Wine paths to normal paths"""
|
|
)
|
|
parser.add_argument(
|
|
"d_file",
|
|
help="""Dependency file in""",
|
|
)
|
|
parser.add_argument(
|
|
"d_file_out",
|
|
help="""Dependency file out""",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
output = import_d_file(args.d_file)
|
|
|
|
with open(args.d_file_out, "w", encoding="UTF-8") as f:
|
|
f.write(output)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|