1 //
2 //      aegis - project change supervisor
3 //      Copyright (C) 1999, 2001-2008, 2012 Peter Miller
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
17 //      <http://www.gnu.org/licenses/>.
18 //
19 
20 #include <common/ac/assert.h>
21 
22 #include <common/now.h>
23 #include <common/trace.h>
24 #include <libaegis/change/architecture/find_variant.h>
25 #include <libaegis/change.h>
26 #include <libaegis/uname.h>
27 
28 
29 void
change_build_time_set(change::pointer cp)30 change_build_time_set(change::pointer cp)
31 {
32     size_t          j, k;
33     cstate_architecture_times_ty *tp;
34     cstate_ty       *cstate_data;
35     pconf_ty        *pconf_data;
36 
37     //
38     // set the build_time in the change state.
39     //
40     trace(("change_build_time_set(cp = %p)\n{\n", cp));
41     assert(cp->reference_count >= 1);
42     pconf_data = change_pconf_get(cp, 1);
43     cstate_data = cp->cstate_get();
44     cstate_data->build_time = now();
45     if (pconf_data->build_covers_all_architectures)
46     {
47         //
48         // set the build_time in all of the architecture variant records
49         //
50         for (j = 0; j < cstate_data->architecture->length; ++j)
51         {
52             tp =
53                 change_architecture_times_find
54                 (
55                     cp,
56                     cstate_data->architecture->list[j]
57                 );
58             tp->build_time = now();
59             tp->test_time = 0;
60             tp->test_baseline_time = 0; // XXX
61             tp->regression_test_time = 0;
62             if (tp->node)
63                 str_free(tp->node);
64             tp->node = str_copy(uname_node_get());
65         }
66     }
67     else
68     {
69         //
70         // set the build_time in the architecture variant record
71         //
72         tp = change_find_architecture_variant(cp);
73         tp->build_time = now();
74         tp->test_time = 0;
75         tp->test_baseline_time = 0; // XXX
76         tp->regression_test_time = 0;
77 
78         //
79         // figure the oldest time of all variants.
80         // if one is missing, then is zero.
81         //
82         for (j = 0; j < cstate_data->architecture->length; ++j)
83         {
84             for (k = 0; k < cstate_data->architecture_times->length; ++k)
85             {
86                 tp = cstate_data->architecture_times->list[k];
87                 if
88                 (
89                     str_equal
90                     (
91                         cstate_data->architecture->list[j],
92                         tp->variant
93                     )
94                 )
95                     break;
96             }
97             if (k >= cstate_data->architecture_times->length)
98             {
99                 cstate_data->build_time = 0;
100                 break;
101             }
102             if (tp->build_time < cstate_data->build_time)
103                 cstate_data->build_time = tp->build_time;
104         }
105     }
106     cstate_data->test_time = 0;
107     cstate_data->test_baseline_time = 0; // XXX
108     cstate_data->regression_test_time = 0;
109     trace(("}\n"));
110 }
111 
112 
113 // vim: set ts=8 sw=4 et :
114