OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [common/] [common/] [flags.cxx] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
2
// -------------------------------------------                              
3
// This file is part of the eCos host tools.                                
4
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.            
5
//
6
// This program is free software; you can redistribute it and/or modify     
7
// it under the terms of the GNU General Public License as published by     
8
// the Free Software Foundation; either version 2 or (at your option) any   
9
// later version.                                                           
10
//
11
// This program is distributed in the hope that it will be useful, but      
12
// WITHOUT ANY WARRANTY; without even the implied warranty of               
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
14
// General Public License for more details.                                 
15
//
16
// You should have received a copy of the GNU General Public License        
17
// along with this program; if not, write to the                            
18
// Free Software Foundation, Inc., 51 Franklin Street,                      
19
// Fifth Floor, Boston, MA  02110-1301, USA.                                
20
// -------------------------------------------                              
21
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
22
//==========================================================================
23
//
24
//      flags.cxx
25
//
26
//      The implementation of build flags extraction from CDL data
27
//
28
//==========================================================================
29
//==========================================================================
30
//#####DESCRIPTIONBEGIN####                                             
31
//
32
// Author(s):           jld
33
// Date:                1999-11-08
34
//
35
//####DESCRIPTIONEND####
36
//==========================================================================
37
 
38
#include "flags.hxx"
39
#include <cctype>
40
 
41
static const std::string GLOBAL_FLAGS_PREFIX = "CYGBLD_GLOBAL_";
42
static const std::string ADD_FLAGS_SUFFIX    = "_ADD";
43
static const std::string REMOVE_FLAGS_SUFFIX = "_REMOVE";
44
 
45
// convert a string of space-separated values into a list of strings
46
static void string_to_list (std::string input, std::list <std::string> & output) {
47
        std::string item;
48
        bool space = true;
49
        output.clear ();
50
 
51
        for (unsigned int n = 0; n < input.size (); n++) { // for each char in the string
52
                if (isspace (input [n])) { // if char is a space
53
                        if (! space) { // if previous char not a space
54
                                output.push_back (item); // add item to output list
55
                                item.erase (); // clear item string
56
                                space = true;
57
                        }
58
                } else { // char is not a space
59
                        item += input [n]; // add char to item string
60
                        space = false;
61
                }
62
        }
63
 
64
        if (! space) { // if final char not a space
65
                output.push_back (item); // add final item to output list
66
        }
67
}
68
 
69
// convert a list of strings into a string of space-separated values
70
static std::string list_to_string (std::list <std::string> & input) {
71
        std::string output;
72
 
73
        for (std::list <std::string>::iterator item = input.begin (); item != input.end (); item++) { // for each item in the list
74
                output += * item + " "; // add item to output string followed by a space
75
        }
76
 
77
        if (! output.empty ()) { // if the output string is not empty
78
                output.resize (output.size () - 1); // remove the trailing space
79
        }
80
 
81
        return output;
82
}
83
 
84
// return the build flags of the specified category
85
std::string get_flags (const CdlConfiguration config, const CdlBuildInfo_Loadable * build_info, const std::string flag_category) {
86
        std::list <std::string> flags_list;
87
 
88
        CdlValuable global_flags = dynamic_cast <CdlValuable> (config->lookup (GLOBAL_FLAGS_PREFIX + flag_category));
89
        if (global_flags) { // if there are global flags
90
                string_to_list (global_flags->get_value (), flags_list);
91
        }
92
 
93
        if (build_info) { // if the caller requires flags specific to a particular loadable
94
                // process flags to be removed
95
                CdlValuable remove_flags = dynamic_cast <CdlValuable> (config->lookup (build_info->name + "_" + flag_category + REMOVE_FLAGS_SUFFIX));
96
                if (remove_flags) { // if there are flags to be removed
97
                        std::list <std::string> remove_flags_list;
98
                        string_to_list (remove_flags->get_value (), remove_flags_list);
99
                        for (std::list <std::string>::iterator item = remove_flags_list.begin (); item != remove_flags_list.end (); item++) {
100
                                flags_list.remove (* item); // remove the flag from the list
101
                        }
102
                }
103
 
104
                // process flags to be added
105
                CdlValuable add_flags = dynamic_cast <CdlValuable> (config->lookup (build_info->name + "_" + flag_category + ADD_FLAGS_SUFFIX));
106
                if (add_flags) { // if there are flags to be added
107
                        std::list <std::string> add_flags_list;
108
                        string_to_list (add_flags->get_value (), add_flags_list);
109
                        flags_list.splice (flags_list.end (), add_flags_list); // splice the additional flags onto the end of the list
110
                }
111
        }
112
 
113
        return list_to_string (flags_list);
114
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.