source: libi4uc/i4ucbuilderdevicetype.vala @ 6e9e55b4c06d6ff5ffa577ade54d8fa719940394

Revision 6e9e55b4c06d6ff5ffa577ade54d8fa719940394, 3.2 KB checked in by Matias De la Puente <mfpuente.ar@…>, 3 years ago (diff)

Builder: Add support for 'post build command'

This command is executed after the build command

  • Property mode set to 100644
Line 
1/* i4ucbuilderdevicetype.vala
2 *
3 * Copyright (C) 2010  Matias De la Puente
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author:
19 *      Matias De la Puente <mfpuente.ar@gmail.com>
20 */
21using Gee;
22
23public class I4uc.BuilderDeviceType : GLib.Object
24{
25        private ArrayList<string> _clean_types = new ArrayList<string> ();
26        private ArrayList<string> _devices = new ArrayList<string> ();
27        private HashMap<string, BuilderSourceType> _source_types = new HashMap<string, BuilderSourceType> ();
28       
29        public string device_type { set; get; }
30        public string build_command { set; get; }
31        public Gee.List<string> clean_types { get { return _clean_types; } }
32        public Gee.List<string> devices { get { return _devices; } }
33        public Gee.Map<string, BuilderSourceType> source_types { get { return _source_types; } }
34        public bool has_post_build_command { set; get; }
35        public string post_build_command { set; get; }
36       
37        public BuilderDeviceType.from_key_file (KeyFile key_file, string group) throws GLib.Error, GLib.KeyFileError
38        {
39                _device_type = key_file.get_string (group, "device_type");
40                _build_command = key_file.get_string (group, "build_command");
41                _has_post_build_command = key_file.has_key (group, "post_build_command");
42                if (_has_post_build_command)
43                        _post_build_command = key_file.get_string (group, "post_build_command");
44                foreach (var clean_type in key_file.get_string_list (group, "clean_types"))
45                        _clean_types.add (clean_type);
46                foreach (var device in key_file.get_string_list (group, "devices"))
47                        _devices.add (device);
48                foreach (var source_type in key_file.get_string_list (group, "source_types"))
49                        if (key_file.has_group (@"$_device_type $source_type source type"))
50                                _source_types[source_type] =  new BuilderSourceType.from_key_file (key_file, @"$_device_type $source_type source type");
51        }
52       
53        public void to_key_file (KeyFile key_file, string group)
54        {
55                key_file.set_string (group, "device_type", _device_type);
56                key_file.set_string (group, "build_command", _build_command);
57                if (_has_post_build_command)
58                        key_file.set_string (group, "post_build_command", _post_build_command);
59                key_file.set_string_list (group, "clean_types", _clean_types.to_array ());
60                key_file.set_string_list (group, "devices", _devices.to_array ());
61                key_file.set_string_list (group, "source_types", _source_types.keys.to_array ());
62               
63                foreach (var source_type in _source_types.values)
64                        source_type.to_key_file (key_file, @"$_device_type $(source_type.source_type) source type");
65        }
66       
67        public BuilderSourceType? get_source_type_from_filename (string filename)
68        {
69                foreach (var source_type in _source_types.values)
70                        if (filename.has_suffix (source_type.source_type))
71                                return source_type;
72                return null;
73        }
74}
Note: See TracBrowser for help on using the repository browser.