module.py 21 KB
Newer Older
1
#!/usr/bin/python
Pawel Szostek's avatar
Pawel Szostek committed
2
# -*- coding: utf-8 -*-
3
#
4
# Copyright (c) 2013, 2014 CERN
Pawel Szostek's avatar
Pawel Szostek committed
5
# Author: Pawel Szostek (pawel.szostek@cern.ch)
6
# Multi-tool support by Javier D. Garcia-Lasheras (javier@garcialasheras.com)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#
# This file is part of Hdlmake.
#
# Hdlmake is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Hdlmake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Hdlmake.  If not, see <http://www.gnu.org/licenses/>.
22

23
from __future__ import print_function
Pawel Szostek's avatar
Pawel Szostek committed
24
import os
25
import sys
26 27 28 29 30 31
import logging

from .manifest_parser import Manifest, ManifestParser
from .util import path as path_mod
from . import global_mod
from . import fetch
32

33

Pawel Szostek's avatar
Pawel Szostek committed
34
class Module(object):
35 36 37
    @property
    def source(self):
        return self._source
Pawel Szostek's avatar
Pawel Szostek committed
38

39
    @source.setter
40
    def source(self, value):
41
        if value not in [fetch.GIT, fetch.SVN, fetch.LOCAL, fetch.GITSUBMODULE]:
42
            raise ValueError("Improper source: " + value)
43
        self._source = value
Pawel Szostek's avatar
Pawel Szostek committed
44

45
    @source.deleter
46
    def source(self):
47
        del self._source
48

49 50
    @property
    def basename(self):
51
        from .util import path
52
        if self.source == fetch.SVN:
Pawel Szostek's avatar
Pawel Szostek committed
53 54 55
            return path.svn_basename(self.url)
        else:
            return path.url_basename(self.url)
56

57
    #PLEASE don't use this constructor. Create all modules with ModulePool.new_module()
58
    def __init__(self, parent, url, source, fetchto, pool):
59 60 61
        assert url is not None
        assert source is not None

62
        self.manifest_dict = None
63
        self.fetchto = fetchto
64
        self.pool = pool
65
        self.source = source
66
        self.parent = parent
67
        self.isparsed = False
Pawel Szostek's avatar
Pawel Szostek committed
68
        self.isprocessed = False
69
        self.include_dirs = None
70 71 72 73 74 75 76 77 78
        self.library = "work"
        self.local = []
        self.git = []
        self.svn = []
        self.target = None
        self.action = None
        self.vmap_opt = None
        self.vlog_opt = None
        self.vcom_opt = None
79
        self.revision = None
80
        self.quartus_preflow = None
81
        self.quartus_postmodule = None
82
        self.quartus_postflow = None
83 84
        self._files = None
        self.manifest = None
85
        self.incl_makefiles = []
86
        self.force_tool = None
Pawel Szostek's avatar
Pawel Szostek committed
87 88 89 90 91
        self.syn_device = None
        self.syn_grade = None
        self.syn_package = None
        self.syn_project = None
        self.syn_top = None
92
        self.syn_tool = None
Pawel Szostek's avatar
Pawel Szostek committed
93
        self.syn_ise_version = None
94 95 96 97
        self.syn_pre_script = None
        self.syn_post_script = None
        self.sim_only_files = None
        self.sim_pre_script = None
98
        self.sim_post_script = None
99
        self.top_module = None
100
        self.commit_id = None
Pawel Szostek's avatar
Pawel Szostek committed
101

Pawel Szostek's avatar
Pawel Szostek committed
102
        self.raw_url = url
103
        if source != fetch.LOCAL:
104
            self.url, self.branch, self.revision = path_mod.url_parse(url)
105 106
        else:
            self.url, self.branch, self.revision = url, None, None
Pawel Szostek's avatar
Pawel Szostek committed
107

108
        if source == fetch.LOCAL and not os.path.exists(url):
109 110
            logging.error("Path to the local module doesn't exist:\n" + url
                          + "\nThis module was instantiated in: " + str(parent))
111
            quit()
Pawel Szostek's avatar
Pawel Szostek committed
112

113
        if source == fetch.LOCAL:
114
            self.path = url
115
            self.isfetched = True
Pawel Szostek's avatar
Pawel Szostek committed
116
        else:
117
            if os.path.exists(os.path.abspath(os.path.join(fetchto, self.basename))) and os.listdir(os.path.abspath(os.path.join(fetchto, self.basename))):
Pawel Szostek's avatar
Pawel Szostek committed
118
                self.path = os.path.abspath(os.path.join(fetchto, self.basename))
119
                self.isfetched = True
120
                logging.debug("Module %s (parent: %s) is fetched." % (url, parent.path))
121
            else:
122 123
                self.path = None
                self.isfetched = False
124
                logging.debug("Module %s (parent: %s) is NOT fetched." % (url, parent.path))
125

126 127 128
        self.manifest = None

        self.git_submodules = []
Pawel Szostek's avatar
Pawel Szostek committed
129

130
    def __str__(self):
Pawel Szostek's avatar
Pawel Szostek committed
131
        return self.raw_url
Pawel Szostek's avatar
Pawel Szostek committed
132

133 134 135 136
    @property
    def is_fetched_to(self):
        return os.path.dirname(self.path)

Pawel Szostek's avatar
Pawel Szostek committed
137
    def submodules(self):
138 139 140 141 142 143
        def __nonull(x):
            if not x:
                return []
            else:
                return x

144
        return __nonull(self.local) + __nonull(self.git) + __nonull(self.svn) + __nonull(self.git_submodules)
Pawel Szostek's avatar
Pawel Szostek committed
145

146
    def _search_for_manifest(self):
Pawel Szostek's avatar
Pawel Szostek committed
147 148 149
        """
        Look for manifest in the given folder
        """
150
        logging.debug("Looking for manifest in " + self.path)
151 152 153
        dir_files = os.listdir(self.path)
        if "manifest.py" in dir_files and "Manifest.py" in dir_files:
            logging.error("Both manifest.py and Manifest.py found in the module directory: %s" % self.path)
154
            sys.exit("\nExiting")
155
        for filename in dir_files:
156 157
            if filename == "manifest.py" or filename == "Manifest.py":
                if not os.path.isdir(filename):
158
                    logging.debug("Found manifest for module %s: %s" % (self.path, filename))
159 160
                    manifest = Manifest(path=os.path.abspath(os.path.join(self.path, filename)))
                    return manifest
Pawel Szostek's avatar
Pawel Szostek committed
161 162
        return None

Pawel Szostek's avatar
Pawel Szostek committed
163
    def _flatten_list(self, sth):
164
        if sth is not None:
165
            if not isinstance(sth, (list, tuple)):
Pawel Szostek's avatar
Pawel Szostek committed
166 167 168 169 170
                sth = [sth]
        else:
            sth = []
        return sth

Pawel Szostek's avatar
Pawel Szostek committed
171
    def remove_dir_from_disk(self):
Pawel Szostek's avatar
Pawel Szostek committed
172 173 174 175 176
        if not self.isfetched:
            return

        import shutil

177
        logging.debug("Removing " + self.path)
Pawel Szostek's avatar
Pawel Szostek committed
178 179 180 181
        shutil.rmtree(self.path)

        while True:
            try:
182 183
                logging.debug("Trying to remove " + os.path.dirname(self.path))
                os.rmdir(os.path.dirname(self.path))
184
            except OSError:  # a catologue is not empty - we are done
Pawel Szostek's avatar
Pawel Szostek committed
185 186
                break

Pawel Szostek's avatar
Pawel Szostek committed
187
    def parse_manifest(self):
188
        if self.manifest_dict:
189
            return
190
        if self.isparsed is True or self.isfetched is False:
Pawel Szostek's avatar
Pawel Szostek committed
191
            return
192
        if self.manifest is None:
193
            self.manifest = self._search_for_manifest()
194
        if self.path is None:
195
            raise RuntimeError()
Pawel Szostek's avatar
Pawel Szostek committed
196

Pawel Szostek's avatar
Pawel Szostek committed
197
        manifest_parser = ManifestParser()
198

Pawel Szostek's avatar
Pawel Szostek committed
199 200
        manifest_parser.add_arbitrary_code(global_mod.options.arbitrary_code)

201
        if self.manifest is None:
202
            logging.debug("No manifest found in module "+str(self))
Pawel Szostek's avatar
Pawel Szostek committed
203
        else:
204
            logging.debug("Parse manifest in: %s" % self.path)
Pawel Szostek's avatar
Pawel Szostek committed
205 206
            manifest_parser.add_manifest(self.manifest)

207
        if self.parent is None:
208
            extra_context = {}
209
        else:
210 211 212 213 214 215 216 217
            extra_context = dict(global_mod.top_module.manifest_dict)  # copy the dictionary
            del extra_context["modules"]
            del extra_context["files"]
            del extra_context["include_dirs"]
            del extra_context["sim_only_files"]
            del extra_context["incl_makefiles"]
            del extra_context["bit_file_targets"]
            del extra_context["library"]
218
        extra_context["__manifest"] = self.path
219

Pawel Szostek's avatar
Pawel Szostek committed
220 221
        opt_map = None
        try:
222
            opt_map = manifest_parser.parse(extra_context=extra_context)
Pawel Szostek's avatar
Pawel Szostek committed
223
        except NameError as ne:
224
            logging.error("Error while parsing {0}:\n{1}: {2}.".format(self.manifest, type(ne), ne))
Pawel Szostek's avatar
Pawel Szostek committed
225
            quit()
226
        self.manifest_dict = opt_map
Pawel Szostek's avatar
Pawel Szostek committed
227

228
    def process_manifest(self):
229
        from .srcfile import TCLFile, VerilogFile, VHDLFile, SourceFileSet
Pawel Szostek's avatar
Pawel Szostek committed
230 231
        if self.isprocessed is True:
            return
232
        if self.manifest_dict is None:
233
            logging.debug("There is no manifest to be processed in: %s" % self.url)
234
            return
235
        logging.debug("Process manifest in: %s" % self.path)
236 237
        if self.manifest_dict["syn_ise_version"] is not None:
            version = self.manifest_dict["syn_ise_version"]
Pawel Szostek's avatar
Pawel Szostek committed
238
            self.syn_ise_version = str(version)
239 240
        if self.manifest_dict["fetchto"] is not None:
            fetchto = path_mod.rel2abs(self.manifest_dict["fetchto"], self.path)
241
            self.fetchto = fetchto
Pawel Szostek's avatar
Pawel Szostek committed
242
        else:
243
            fetchto = self.fetchto
Pawel Szostek's avatar
Pawel Szostek committed
244

245 246
        if "local" in self.manifest_dict["modules"]:
            local_paths = self._flatten_list(self.manifest_dict["modules"]["local"])
247 248
            local_mods = []
            for path in local_paths:
Pawel Szostek's avatar
Pawel Szostek committed
249
                if path_mod.is_abs_path(path):
250 251
                    logging.error("Found an absolute path (" + path + ") in a manifest"
                                  "(" + self.path + ")")
Pawel Szostek's avatar
Pawel Szostek committed
252
                    quit()
253
                path = path_mod.rel2abs(path, self.path)
254 255 256 257
                local_mods.append(self.pool.new_module(parent=self,
                                                       url=path,
                                                       source=fetch.LOCAL,
                                                       fetchto=fetchto))
258 259 260 261
            self.local = local_mods
        else:
            self.local = []

262 263 264 265 266 267
        self.vmap_opt = self.manifest_dict["vmap_opt"]
        self.vcom_opt = self.manifest_dict["vcom_opt"]
        self.vsim_opt = self.manifest_dict["vsim_opt"]
        self.vlog_opt = self.manifest_dict["vlog_opt"]
        self.iverilog_opt = self.manifest_dict["iverilog_opt"]
        self.sim_tool = self.manifest_dict["sim_tool"]
268 269 270 271 272 273
        if self.manifest_dict["force_tool"]:
            ft = self.manifest_dict["force_tool"]
            self.force_tool = ft.split(' ')
            if len(self.force_tool) != 3:
                logging.warning("Incorrect force_tool format %s. Ignoring" % self.force_tool)
                self.force_tool = None
Pawel Szostek's avatar
Pawel Szostek committed
274

275 276
        if "top_module" in self.manifest_dict:
            self.top_module = self.manifest_dict["top_module"]
277

278
        mkFileList = []
279 280
        if isinstance(self.manifest_dict["incl_makefiles"], basestring):
            mkFileList.append(self.manifest_dict["incl_makefiles"])
Pawel Szostek's avatar
Pawel Szostek committed
281
        else:  # list
282
            mkFileList = self.manifest_dict["incl_makefiles"][:]
Pawel Szostek's avatar
Pawel Szostek committed
283 284 285

        makefiles_paths = self._make_list_of_paths(mkFileList)
        self.incl_makefiles.extend(makefiles_paths)
286 287 288 289 290 291 292 293 294 295

        #if self.vlog_opt == "":
        #    self.vlog_opt = global_mod.top_module.vlog_opt
        #if self.vcom_opt == "":
        #    self.vcom_opt = global_mod.top_module.vcom_opt
        #if self.vsim_opt == "":
        #    self.vsim_opt = global_mod.top_module.vsim_opt
       # if self.vmap_opt == "":
        #    self.vmap_opt = global_mod.top_module.vmap_opt

296
        self.library = self.manifest_dict["library"]
297
        self.include_dirs = []
298 299 300 301
        if self.manifest_dict["include_dirs"] is not None:
            if isinstance(self.manifest_dict["include_dirs"], basestring):
#                self.include_dirs.append(self.manifest_dict["include_dirs"])
                ll = os.path.relpath(os.path.abspath(os.path.join(self.path, self.manifest_dict["include_dirs"])))
302
                self.include_dirs.append(ll)
303
            else:
304
#                self.include_dirs.extend(self.manifest_dict["include_dirs"])
305
                ll = map(lambda x: os.path.relpath(os.path.abspath(os.path.join(self.path, x))),
306
                         self.manifest_dict["include_dirs"])
307
                self.include_dirs.extend(ll)
308

309 310 311 312 313
        for dir_ in self.include_dirs:
            if path_mod.is_abs_path(dir_):
                logging.warning("%s contains absolute path to an include directory: %s" % (self.path, dir_))
            if not os.path.exists(dir_):
                logging.warning(self.path + " has an unexisting include directory: " + dir_)
314

315
        if self.manifest_dict["files"] == []:
316
            self.files = SourceFileSet()
317 318 319 320
            try:
                logging.debug("No files in the manifest %s" % self.manifest.path)
            except AttributeError:
                pass
Pawel Szostek's avatar
Pawel Szostek committed
321
        else:
322
            self.manifest_dict["files"] = self._flatten_list(self.manifest_dict["files"])
323
            logging.debug("Files in %s: %s" % (self.path, str(self.manifest_dict["files"])))
324
            paths = self._make_list_of_paths(self.manifest_dict["files"])
Pawel Szostek's avatar
Pawel Szostek committed
325
            self.files = self._create_file_list_from_paths(paths=paths)
326
            for f in self.files:
327 328 329 330
                if isinstance(f, VerilogFile):
                    f.vsim_opt = self.vsim_opt
                elif isinstance(f, VHDLFile):
                    f.vcom_opt = self.vcom_opt
Pawel Szostek's avatar
Pawel Szostek committed
331

332
        if len(self.manifest_dict["sim_only_files"]) == 0:
333 334
            self.sim_only_files = SourceFileSet()
        else:
335 336
            self.manifest_dict["sim_only_files"] = self._flatten_list(self.manifest_dict["sim_only_files"])
            paths = self._make_list_of_paths(self.manifest_dict["sim_only_files"])
Pawel Szostek's avatar
Pawel Szostek committed
337 338
            self.sim_only_files = self._create_file_list_from_paths(paths=paths)

339 340 341 342
        self.syn_pre_cmd = self.manifest_dict["syn_pre_cmd"]
        self.syn_post_cmd = self.manifest_dict["syn_post_cmd"]
        self.sim_pre_cmd = self.manifest_dict["sim_pre_cmd"]
        self.sim_post_cmd = self.manifest_dict["sim_post_cmd"]
343

344
        self.bit_file_targets = SourceFileSet()
345 346
        if len(self.manifest_dict["bit_file_targets"]) != 0:
            paths = self._make_list_of_paths(self.manifest_dict["bit_file_targets"])
Pawel Szostek's avatar
Pawel Szostek committed
347
            self.bit_file_targets = self._create_file_list_from_paths(paths=paths)
348

349 350
        if "svn" in self.manifest_dict["modules"]:
            self.manifest_dict["modules"]["svn"] = self._flatten_list(self.manifest_dict["modules"]["svn"])
351
            svn_mods = []
352
            for url in self.manifest_dict["modules"]["svn"]:
353 354 355 356
                svn_mods.append(self.pool.new_module(parent=self,
                                                     url=url,
                                                     source=fetch.SVN,
                                                     fetchto=fetchto))
357
            self.svn = svn_mods
358 359 360
        else:
            self.svn = []

361 362
        if "git" in self.manifest_dict["modules"]:
            self.manifest_dict["modules"]["git"] = self._flatten_list(self.manifest_dict["modules"]["git"])
363
            git_mods = []
364
            for url in self.manifest_dict["modules"]["git"]:
365 366 367 368
                git_mods.append(self.pool.new_module(parent=self,
                                                     url=url,
                                                     source=fetch.GIT,
                                                     fetchto=fetchto))
369
            self.git = git_mods
370 371
        else:
            self.git = []
Pawel Szostek's avatar
Pawel Szostek committed
372

373 374 375 376 377 378 379
        git_submodule_dict = fetch.Git.get_git_submodules(self)
        git_toplevel = fetch.Git.get_git_toplevel(self)
        for submodule_key in git_submodule_dict.keys():
            url = git_submodule_dict[submodule_key]["url"]
            path = git_submodule_dict[submodule_key]["path"]
            path = os.path.join(git_toplevel, path)
            fetchto = os.path.sep.join(path.split(os.path.sep)[:-1])
380
            self.git_submodules.append(self.pool.new_module(parent=self,
381 382
                                                            url=url,
                                                            fetchto=fetchto,
383
                                                            source=fetch.GITSUBMODULE))
384 385
        self.target = self.manifest_dict["target"].lower()
        self.action = self.manifest_dict["action"].lower()
Pawel Szostek's avatar
Pawel Szostek committed
386

387 388
        if self.manifest_dict["syn_name"] is None and self.manifest_dict["syn_project"] is not None:
            self.syn_name = self.manifest_dict["syn_project"][:-5]  # cut out .xise from the end
Pawel Szostek's avatar
Pawel Szostek committed
389
        else:
390
            self.syn_name = self.manifest_dict["syn_name"]
391
        self.syn_tool = self.manifest_dict["syn_tool"]
392 393 394 395 396
        self.syn_device = self.manifest_dict["syn_device"]
        self.syn_grade = self.manifest_dict["syn_grade"]
        self.syn_package = self.manifest_dict["syn_package"]
        self.syn_project = self.manifest_dict["syn_project"]
        self.syn_top = self.manifest_dict["syn_top"]
Pawel Szostek's avatar
Pawel Szostek committed
397

398 399 400 401 402 403 404 405
        if self.manifest_dict["quartus_preflow"] != None:
            path = path_mod.rel2abs(self.manifest_dict["quartus_preflow"], self.path);
            if not os.path.exists(path):
                p.error("quartus_preflow file listed in " + self.manifest.path + " doesn't exist: "
                        + path + ".\nExiting.")
                quit()
            self.quartus_preflow = TCLFile(path)

406 407 408 409 410 411 412 413
        if self.manifest_dict["quartus_postmodule"] != None:
            path = path_mod.rel2abs(self.manifest_dict["quartus_postmodule"], self.path);
            if not os.path.exists(path):
                p.error("quartus_postmodule file listed in " + self.manifest.path + " doesn't exist: "
                        + path + ".\nExiting.")
                quit()
            self.quartus_postmodule = TCLFile(path)

414 415 416 417 418 419 420 421
        if self.manifest_dict["quartus_postflow"] != None:
            path = path_mod.rel2abs(self.manifest_dict["quartus_postflow"], self.path);
            if not os.path.exists(path):
                p.error("quartus_postflow file listed in " + self.manifest.path + " doesn't exist: "
                        + path + ".\nExiting.")
                quit()
            self.quartus_postflow = TCLFile(path)

Pawel Szostek's avatar
Pawel Szostek committed
422
        self.isparsed = True
Pawel Szostek's avatar
Pawel Szostek committed
423
        self.isprocessed = True
Pawel Szostek's avatar
Pawel Szostek committed
424

425 426
        for m in self.submodules():
            m.parse_manifest()
427
            m.process_manifest()
428

Pawel Szostek's avatar
Pawel Szostek committed
429 430 431 432 433 434 435 436
        if self == global_mod.top_module:
            revision = fetch.Svn.check_revision_number(self.path)
            if revision is None:
                commit = fetch.Git.check_commit_id(self.path)
                self.revision = commit
            else:
                self.revision = revision
        else:
437
            if self.source == fetch.SVN:
Pawel Szostek's avatar
Pawel Szostek committed
438
                self.revision = fetch.Svn.check_revision_number(self.path)
439
            elif self.source == fetch.GIT:
Pawel Szostek's avatar
Pawel Szostek committed
440 441
                self.revision = fetch.Git.check_commit_id(self.path)

Pawel Szostek's avatar
Pawel Szostek committed
442 443 444
    def _make_list_of_paths(self, list_of_paths):
        paths = []
        for filepath in list_of_paths:
445
            if self._check_filepath(filepath):
446
                paths.append(path_mod.rel2abs(filepath, self.path))
Pawel Szostek's avatar
Pawel Szostek committed
447 448 449 450 451 452
        return paths

    def _check_filepath(self, filepath):
        if filepath:
            if path_mod.is_abs_path(filepath):
                logging.warning("Specified path seems to be an absolute path: %s\nOmitting." % filepath)
453 454
                return False
            filepath = os.path.join(self.path, filepath)
455
            if not os.path.exists(filepath):
456
                logging.error("Path specified in manifest in %s doesn't exist: %s" % (self.path, filepath))
457 458 459 460
                sys.exit("Exiting")


            filepath = path_mod.rel2abs(filepath, self.path)
461

462
            if os.path.isdir(filepath):
463
                logging.warning("Path specified in manifest %s is a directory: %s" % (self.path, filepath))
Pawel Szostek's avatar
Pawel Szostek committed
464 465
        return True

466 467 468
    def is_fetched_recursively(self):
        if not self.isfetched:
            return False
469
        for mod in self.submodules():
470
            if mod.is_fetched_recursively() is False:
471 472
                return False
        return True
Pawel Szostek's avatar
Pawel Szostek committed
473 474

    def make_list_of_modules(self):
475
        logging.debug("Making list of modules for " + str(self))
Pawel Szostek's avatar
Pawel Szostek committed
476 477 478 479
        new_modules = [self]
        modules = [self]
        while len(new_modules) > 0:
            cur_module = new_modules.pop()
480

Pawel Szostek's avatar
Pawel Szostek committed
481
            if not cur_module.isfetched:
482
                logging.error("Unfetched module in modules list: " + str(cur_module))
Pawel Szostek's avatar
Pawel Szostek committed
483
                quit()
484
            if cur_module.manifest is None:
485
                logging.debug("No manifest in " + str(cur_module))
Pawel Szostek's avatar
Pawel Szostek committed
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
                continue
            cur_module.parse_manifest()

            for module in cur_module.local:
                modules.append(module)
                new_modules.append(module)

            for module in cur_module.git:
                modules.append(module)
                new_modules.append(module)

            for module in cur_module.svn:
                modules.append(module)
                new_modules.append(module)

        if len(modules) == 0:
502
            logging.debug("No modules were found in " + self.fetchto)
Pawel Szostek's avatar
Pawel Szostek committed
503 504
        return modules

Pawel Szostek's avatar
Pawel Szostek committed
505
    def _create_file_list_from_paths(self, paths):
506
        from .srcfile import SourceFileFactory, SourceFileSet
507 508
        sff = SourceFileFactory()
        srcs = SourceFileSet()
Pawel Szostek's avatar
Pawel Szostek committed
509
        for p in paths:
510
            if os.path.isdir(p):
511 512
                dir_ = os.listdir(p)
                for f_dir in dir_:
513 514
                    f_dir = os.path.join(self.path, p, f_dir)
                    if not os.path.isdir(f_dir):
515 516 517 518 519 520
                        srcs.add(sff.new(path=f_dir,
                                         module=self,
                                         library=self.library,
                                         vcom_opt=self.vcom_opt,
                                         vlog_opt=self.vlog_opt,
                                         include_dirs=self.include_dirs))
521
            else:
522 523 524 525 526 527
                srcs.add(sff.new(path=p,
                                 module=self,
                                 library=self.library,
                                 vcom_opt=self.vcom_opt,
                                 vlog_opt=self.vlog_opt,
                                 include_dirs=self.include_dirs))
Pawel Szostek's avatar
Pawel Szostek committed
528
        return srcs