1 use super::{Diagnostic, PackageId, Target}
;
5 use std
::path
::PathBuf
;
7 /// Profile settings used to determine which compiler flags to use for a
9 #[derive(Debug, Clone, Serialize, Deserialize)]
10 pub struct ArtifactProfile
{
11 /// Optimization level. Possible values are 0-3, s or z.
12 pub opt_level
: String
,
13 /// The amount of debug info. 0 for none, 1 for limited, 2 for full
14 pub debuginfo
: Option
<u32>,
15 /// State of the `cfg(debug_assertions)` directive, enabling macros like
17 pub debug_assertions
: bool
,
18 /// State of the overflow checks.
19 pub overflow_checks
: bool
,
20 /// Whether this profile is a test
24 __do_not_match_exhaustively
: (),
27 /// A compiler-generated file.
28 #[derive(Debug, Clone, Serialize, Deserialize)]
30 /// The package this artifact belongs to
31 pub package_id
: PackageId
,
32 /// The target this artifact was compiled for
34 /// The profile this artifact was compiled with
35 pub profile
: ArtifactProfile
,
36 /// The enabled features for this artifact
37 pub features
: Vec
<String
>,
38 /// The full paths to the generated artifacts
39 /// (e.g. binary file and separate debug info)
40 pub filenames
: Vec
<PathBuf
>,
41 /// Path to the executable file
42 pub executable
: Option
<PathBuf
>,
43 /// If true, then the files were already generated
47 __do_not_match_exhaustively
: (),
50 /// Message left by the compiler
51 // TODO: Better name. This one comes from machine_message.rs
52 #[derive(Debug, Clone, Serialize, Deserialize)]
53 pub struct CompilerMessage
{
54 /// The package this message belongs to
55 pub package_id
: PackageId
,
56 /// The target this message is aimed at
58 /// The message the compiler sent.
59 pub message
: Diagnostic
,
62 __do_not_match_exhaustively
: (),
65 /// Output of a build script execution.
66 #[derive(Debug, Clone, Serialize, Deserialize)]
67 pub struct BuildScript
{
68 /// The package this build script execution belongs to
69 pub package_id
: PackageId
,
71 pub linked_libs
: Vec
<PathBuf
>,
72 /// The paths to search when resolving libs
73 pub linked_paths
: Vec
<PathBuf
>,
74 /// Various `--cfg` flags to pass to the compiler
75 pub cfgs
: Vec
<PathBuf
>,
76 /// The environment variables to add to the compilation
77 pub env
: Vec
<(String
, String
)>,
78 /// The `OUT_DIR` environment variable where this script places its output
80 /// Added in Rust 1.41.
85 __do_not_match_exhaustively
: (),
89 #[derive(Debug, Clone, Serialize, Deserialize)]
90 #[serde(tag = "reason", rename_all = "kebab-case")]
92 /// The compiler generated an artifact
93 CompilerArtifact(Artifact
),
94 /// The compiler wants to display a message
95 CompilerMessage(CompilerMessage
),
96 /// A build script successfully executed.
97 BuildScriptExecuted(BuildScript
),
103 impl fmt
::Display
for CompilerMessage
{
104 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
105 write
!(f
, "{}", self.message
)
109 /// An iterator of Message.
110 type MessageIterator
<R
> =
111 serde_json
::StreamDeserializer
<'
static, serde_json
::de
::IoRead
<R
>, Message
>;
113 /// Creates an iterator of Message from a Read outputting a stream of JSON
114 /// messages. For usage information, look at the top-level documentation.
115 pub fn parse_messages
<R
: Read
>(input
: R
) -> MessageIterator
<R
> {
116 serde_json
::Deserializer
::from_reader(input
).into_iter
::<Message
>()