Skip to content

Commit cb837cb

Browse files
authored
Fix CMake generation on Windows
On Windows, paths are mixed by os.path.join with different slash directions. This should generally be fine but when using the print function we print "C:\\mypath/myfile.cpp" as "C:\mypath/myfile.cpp" which is unescaped on the backward slash. To fix this I propose to replace "\\" with "/" just before printing it out for CMake usage. I would suggest using pathlib but it is not included by default on python versions <= 3.3 which may still be an issue.
1 parent d7c55b1 commit cb837cb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

binding_generator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ def print_file_list(api_filepath, output_dir, headers=False, sources=False):
2525
header_filename = os.path.join(include_gen_folder, strip_name(_class["name"]) + ".hpp")
2626
source_filename = os.path.join(source_gen_folder, strip_name(_class["name"]) + ".cpp")
2727
if headers:
28-
print(header_filename, end=end)
28+
print(header_filename.replace("\\", "/"), end=end)
2929
if sources:
30-
print(source_filename, end=end)
30+
print(source_filename.replace("\\", "/"), end=end)
3131
icall_header_filename = os.path.join(include_gen_folder, '__icalls.hpp')
3232
register_types_filename = os.path.join(source_gen_folder, '__register_types.cpp')
3333
init_method_bindings_filename = os.path.join(source_gen_folder, '__init_method_bindings.cpp')
3434
if headers:
35-
print(icall_header_filename, end=end)
35+
print(icall_header_filename.replace("\\", "/"), end=end)
3636
if sources:
37-
print(register_types_filename, end=end)
38-
print(init_method_bindings_filename, end=end)
37+
print(register_types_filename.replace("\\", "/"), end=end)
38+
print(init_method_bindings_filename.replace("\\", "/"), end=end)
3939

4040

4141
def generate_bindings(api_filepath, use_template_get_node, output_dir="."):

0 commit comments

Comments
 (0)