OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [common/] [common/] [flags.cxx] - Blame information for rev 174

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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