buildframework/helium/tools/common/python/lib/atsant.py
changeset 179 d8ac696cc51f
equal deleted inserted replaced
1:be27ed110b50 179:d8ac696cc51f
       
     1 # -*- encoding: latin-1 -*-
       
     2 
       
     3 #============================================================================ 
       
     4 #Name        : atsant.py 
       
     5 #Part of     : Helium 
       
     6 
       
     7 #Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     8 #All rights reserved.
       
     9 #This component and the accompanying materials are made available
       
    10 #under the terms of the License "Eclipse Public License v1.0"
       
    11 #which accompanies this distribution, and is available
       
    12 #at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    13 #
       
    14 #Initial Contributors:
       
    15 #Nokia Corporation - initial contribution.
       
    16 #
       
    17 #Contributors:
       
    18 #
       
    19 #Description:
       
    20 #===============================================================================
       
    21 
       
    22 import re
       
    23 import sysdef.api
       
    24 import os
       
    25 
       
    26 def files_to_test(canonicalsysdeffile, excludetestlayers, idobuildfilter, builddrive):
       
    27     sdf = sysdef.api.SystemDefinition(canonicalsysdeffile)
       
    28     
       
    29     modules = {}
       
    30     paths_list = []
       
    31     for la in sdf.layers:
       
    32         if re.match(r".*_test_layer$", la):
       
    33             try:
       
    34                 if re.search(r"\b%s\b" % la, excludetestlayers):
       
    35                     continue
       
    36             except TypeError, exp:
       
    37                 pass
       
    38 
       
    39             layer = sdf.layers[la]
       
    40             for mod in layer.modules:
       
    41                 if mod.name not in modules:
       
    42                     modules[mod.name] = []
       
    43                 for unit in mod.units:
       
    44                     include_unit = True
       
    45                     if idobuildfilter != None:
       
    46                         if idobuildfilter != "":
       
    47                             include_unit = False
       
    48                             if hasattr(unit, 'filters'):
       
    49                                 if len(unit.filters) > 0:
       
    50                                     for filter in unit.filters:
       
    51                                         if re.search(r"\b%s\b" % filter, idobuildfilter):
       
    52                                             include_unit = True
       
    53                                         else:
       
    54                                             include_unit = False
       
    55                                 elif len(unit.filters) == 0:
       
    56                                     include_unit = True
       
    57                             else:
       
    58                                 include_unit = False
       
    59                         else:
       
    60                             include_unit = False
       
    61                             if hasattr(unit, 'filters'):                            
       
    62                                 if len(unit.filters) == 0:
       
    63                                     include_unit = True
       
    64                     if include_unit:
       
    65                         modules[mod.name].append(os.path.join(builddrive + os.sep, unit.path))
       
    66 
       
    67     return modules