|
1 | | -import sys |
2 | | -argv = sys.argv[1:] |
3 | | - |
4 | | -print(argv) |
5 | | -exit(1) |
6 | | -try: |
7 | | - library_name = argv[0].replace('-', '_') |
8 | | - cpp_path = argv[1] |
9 | | - h_path = argv[2] |
10 | | - gdext_path = argv[3] |
11 | | -except: |
12 | | - ABOUT = \ |
13 | | -""" |
14 | | -ERROR: Not enough arguments. |
15 | | -Needed arguments (<argument> - example): |
16 | | -
|
17 | | -<library_name> (`my_library_name`) |
18 | | -<cpp_file_path> (`src/register_types.cpp`) |
19 | | -<header_file_path> (`include/register_types.h`) |
20 | | -<gdextension_file_path> (`project/my_library.gdextension`) |
21 | | -""" |
22 | | - print(ABOUT, file=sys.stderr) |
23 | | - exit(1) |
24 | | - |
25 | | -print(f"Configuring '{gdext_path}' ...") |
26 | | -open(gdext_path, 'w').write( |
27 | | - SCRIPTS_GDEXTENSION_IN.replace('@LIBRARY_NAME@', library_name)) |
28 | | - |
29 | | -print(f"Configuring '{cpp_path}' ...") |
30 | | -open(cpp_path, 'w').write( |
31 | | - REGISTER_TYPES_CPP_IN.replace('@LIBRARY_NAME@', library_name)) |
32 | | - |
33 | | -print(f"Configuring '{h_path}' ...") |
34 | | -open(h_path, 'w').write( |
35 | | - REGISTER_TYPES_H_IN.replace('@LIBRARY_NAME@', library_name)) |
36 | | - |
37 | | -print("Files configured.") |
38 | | -exit(0) |
| 1 | + @PY_EMBED_TEMPLATE_FILES@ |
| 2 | +
|
| 3 | + import os, sys |
| 4 | + argv = sys.argv[1:] |
| 5 | + |
| 6 | + try: |
| 7 | + library_name = argv[0].replace('-', '_') |
| 8 | + cpp_path = argv[1] |
| 9 | + h_path = argv[2] |
| 10 | + gdext_path = argv[3] |
| 11 | + except: |
| 12 | + ABOUT = \ |
| 13 | + ''' |
| 14 | + ERROR: Not enough arguments. |
| 15 | + Needed arguments (<argument> - example): |
| 16 | +
|
| 17 | + <library_name> (`my_library_name`) |
| 18 | + <cpp_file_path> (`src/register_types.cpp`) |
| 19 | + <header_file_path> (`include/register_types.h`) |
| 20 | + <gdextension_file_path> (`project/my_library.gdextension`) |
| 21 | + ''' |
| 22 | + print(ABOUT, file=sys.stderr) |
| 23 | + exit(1) |
| 24 | + |
| 25 | + prompt = f'''These files will be affected: |
| 26 | + {'(New) ' if not os.path.exists(gdext_path) else '(Override)'} {gdext_path} |
| 27 | + {'(New) ' if not os.path.exists(cpp_path) else '(Override)'} {cpp_path} |
| 28 | + {'(New) ' if not os.path.exists(h_path) else '(Override)'} {h_path} |
| 29 | + ''' |
| 30 | + print(prompt) |
| 31 | + while True: |
| 32 | + inp = input('Are you sure? (Y/N) ') |
| 33 | + if inp == '': |
| 34 | + continue |
| 35 | + if inp not in 'yY': |
| 36 | + print('No changes, exiting...') |
| 37 | + exit(1) |
| 38 | + break |
| 39 | + |
| 40 | + print(f"Configuring '{gdext_path}' ...") |
| 41 | + open(gdext_path, 'w').write( |
| 42 | + SCRIPTS_GDEXTENSION_IN.replace('@LIBRARY_NAME@', library_name)) |
| 43 | + |
| 44 | + print(f"Configuring '{cpp_path}' ...") |
| 45 | + open(cpp_path, 'w').write( |
| 46 | + REGISTER_TYPES_CPP_IN.replace('@LIBRARY_NAME@', library_name)) |
| 47 | + |
| 48 | + print(f"Configuring '{h_path}' ...") |
| 49 | + open(h_path, 'w').write( |
| 50 | + REGISTER_TYPES_H_IN.replace('@LIBRARY_NAME@', library_name)) |
| 51 | + |
| 52 | + print("Files configured.") |
| 53 | + exit(0) |
0 commit comments