intercept/lib.rs
1/* Copyright (C) 2012-2018 by László Nagy
2 This file is part of Bear.
3
4 Bear is a tool to generate compilation database for clang tooling.
5
6 Bear 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 3 of the License, or
9 (at your option) any later version.
10
11 Bear is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU 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, see <http://www.gnu.org/licenses/>.
18 */
19
20extern crate libc;
21extern crate serde;
22extern crate serde_json;
23#[macro_use] extern crate serde_derive;
24//#[macro_use] extern crate log;
25extern crate tempdir;
26
27
28pub mod trace;
29pub mod parameters;
30pub mod database;
31pub mod compilation;
32
33
34use std::result;
35
36#[derive(Debug)]
37pub enum Error {
38 Io(std::io::Error),
39 Env(std::env::VarError),
40 Json(serde_json::Error),
41 RuntimeError(String),
42}
43
44impl From<std::io::Error> for Error {
45 fn from(err: std::io::Error) -> Error {
46 Error::Io(err)
47 }
48}
49
50impl From<serde_json::Error> for Error {
51 fn from(err: serde_json::Error) -> Error {
52 Error::Json(err)
53 }
54}
55
56impl From<std::env::VarError> for Error {
57 fn from(err: std::env::VarError) -> Error {
58 Error::Env(err)
59 }
60}
61
62type Result<T> = result::Result<T, Error>;