Fix Windows path handling

This commit is contained in:
Luke Street 2024-03-04 08:20:58 -07:00
parent 4225743e34
commit 8950d9c77d
3 changed files with 43 additions and 30 deletions

View file

@ -21,6 +21,7 @@ use Python.
import re
import textwrap
import os
from io import StringIO
from pathlib import Path
from typing import Dict, List, Match, Optional, Tuple, Union
@ -215,7 +216,12 @@ class Writer(object):
def serialize_path(input: Optional[NinjaPath]) -> str:
return str(input).replace("\\", "/") if input else ""
if not input:
return ""
if isinstance(input, Path):
return str(input).replace("/", os.sep)
else:
return str(input)
def serialize_paths(input: Optional[NinjaPathOrPaths]) -> List[str]: