2 // Automated Testing Framework (atf)
4 // Copyright (c) 2009 The NetBSD Foundation, Inc.
5 // All rights reserved.
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
10 // 1. Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
16 // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 // CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 // IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 // GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 // IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "atf-c/build.h"
32 #include "atf-c/error.h"
35 #include "atf-c++/build.hpp"
36 #include "atf-c++/exceptions.hpp"
37 #include "atf-c++/process.hpp"
39 namespace impl
= atf::build
;
40 #define IMPL_NAME "atf::build"
42 // ------------------------------------------------------------------------
43 // Auxiliary functions.
44 // ------------------------------------------------------------------------
47 atf::process::argv_array
48 clist_to_argv(const atf_list_t
* l
)
50 std::vector
< const char* > aux
;
52 atf_list_citer_t iter
;
53 atf_list_for_each_c(iter
, l
)
54 aux
.push_back(static_cast< const char* >(atf_list_citer_data(iter
)));
56 return atf::process::argv_array(aux
);
60 atf::process::argv_array
61 clist_to_argv_and_free(atf_list_t
* l
)
64 atf::process::argv_array argv
= clist_to_argv(l
);
73 // ------------------------------------------------------------------------
75 // ------------------------------------------------------------------------
77 atf::process::argv_array
78 impl::c_o(const std::string
& sfile
, const std::string
& ofile
,
79 const process::argv_array
& optargs
)
83 atf_error_t err
= atf_build_c_o(sfile
.c_str(), ofile
.c_str(),
84 optargs
.exec_argv(), &l
);
85 if (atf_is_error(err
))
88 return clist_to_argv_and_free(&l
);
91 atf::process::argv_array
92 impl::cpp(const std::string
& sfile
, const std::string
& ofile
,
93 const process::argv_array
& optargs
)
97 atf_error_t err
= atf_build_cpp(sfile
.c_str(), ofile
.c_str(),
98 optargs
.exec_argv(), &l
);
99 if (atf_is_error(err
))
100 throw_atf_error(err
);
102 return clist_to_argv_and_free(&l
);
105 atf::process::argv_array
106 impl::cxx_o(const std::string
& sfile
, const std::string
& ofile
,
107 const process::argv_array
& optargs
)
111 atf_error_t err
= atf_build_cxx_o(sfile
.c_str(), ofile
.c_str(),
112 optargs
.exec_argv(), &l
);
113 if (atf_is_error(err
))
114 throw_atf_error(err
);
116 return clist_to_argv_and_free(&l
);