|
1 | 1 | #
|
2 |
| -# Copyright (C) 2019-2024 PyFPGA Project |
| 2 | +# Copyright (C) 2019-2025 PyFPGA Project |
3 | 3 | #
|
4 | 4 | # SPDX-License-Identifier: GPL-3.0-or-later
|
5 | 5 | #
|
@@ -73,17 +73,17 @@ def add_include(self, path):
|
73 | 73 | :raises NotADirectoryError: if path is not a directory
|
74 | 74 | """
|
75 | 75 | self.logger.debug('Executing add_include: %s', path)
|
76 |
| - path = Path(path).resolve() |
77 |
| - if not path.is_dir(): |
| 76 | + path = self._get_absolute(path, self.conf['make_ext']) |
| 77 | + if not Path(path).is_dir(): |
78 | 78 | raise NotADirectoryError(path)
|
79 |
| - self.data.setdefault('includes', []).append(path.as_posix()) |
| 79 | + self.data.setdefault('includes', []).append(path) |
80 | 80 |
|
81 | 81 | def _add_file(self, pathname, hdl=None, lib=None):
|
82 | 82 | files = glob.glob(pathname, recursive=True)
|
83 | 83 | if len(files) == 0:
|
84 | 84 | raise FileNotFoundError(pathname)
|
85 | 85 | for file in files:
|
86 |
| - path = Path(file).resolve().as_posix() |
| 86 | + path = self._get_absolute(file, self.conf['make_ext']) |
87 | 87 | attr = {}
|
88 | 88 | if hdl:
|
89 | 89 | attr['hdl'] = hdl
|
@@ -134,11 +134,11 @@ def add_cons(self, path):
|
134 | 134 | :raises FileNotFoundError: if path is not found
|
135 | 135 | """
|
136 | 136 | self.logger.debug('Executing add_cons: %s', path)
|
137 |
| - path = Path(path).resolve() |
138 |
| - if not path.is_file(): |
| 137 | + path = self._get_absolute(path, self.conf['make_ext']) |
| 138 | + if not Path(path).is_file(): |
139 | 139 | raise FileNotFoundError(path)
|
140 | 140 | attr = {}
|
141 |
| - self.data.setdefault('constraints', {})[path.as_posix()] = attr |
| 141 | + self.data.setdefault('constraints', {})[path] = attr |
142 | 142 |
|
143 | 143 | def add_param(self, name, value):
|
144 | 144 | """Add a Parameter/Generic Value.
|
@@ -170,7 +170,7 @@ def add_fileset(self, pathname):
|
170 | 170 | :raises FileNotFoundError: when pathname is not found
|
171 | 171 | """
|
172 | 172 | self.logger.debug('Executing add_fileset: %s', pathname)
|
173 |
| - if not os.path.exists(pathname): |
| 173 | + if not Path(pathname).is_file(): |
174 | 174 | raise FileNotFoundError(pathname)
|
175 | 175 | raise NotImplementedError()
|
176 | 176 |
|
@@ -255,13 +255,12 @@ def prog(self, bitstream=None, position=1):
|
255 | 255 | if not bitstream:
|
256 | 256 | for ext in self.conf['prog_bit']:
|
257 | 257 | candidate = Path(self.odir) / f'{self.data["project"]}.{ext}'
|
258 |
| - if candidate.exists(): |
259 |
| - bitstream = candidate.resolve() |
| 258 | + if candidate.is_file(): |
| 259 | + bitstream = candidate |
260 | 260 | break
|
261 |
| - else: |
262 |
| - bitstream = Path(bitstream).resolve() |
263 |
| - if not bitstream or not bitstream.exists(): |
| 261 | + if not bitstream or not Path(bitstream).is_file(): |
264 | 262 | raise FileNotFoundError(bitstream)
|
| 263 | + bitstream = self._get_absolute(bitstream, self.conf['prog_ext']) |
265 | 264 | self.data['bitstream'] = bitstream
|
266 | 265 | self._prog_custom()
|
267 | 266 | self._create_file(f'{self.conf["tool"]}-prog', self.conf['prog_ext'])
|
@@ -322,3 +321,11 @@ def _run(self, command, logname):
|
322 | 321 | )
|
323 | 322 | if error:
|
324 | 323 | raise RuntimeError('Problem with the underlying tool')
|
| 324 | + |
| 325 | + @staticmethod |
| 326 | + def _get_absolute(path, ext): |
| 327 | + path = Path(path).resolve() |
| 328 | + if ext == 'tcl': |
| 329 | + return path.as_posix() |
| 330 | + else: |
| 331 | + return path |
0 commit comments