makepad_studio/build_manager/
rustc_json.rs

1#![allow(dead_code)]
2use crate::{
3    makepad_micro_serde::*,
4    makepad_code_editor::text::{Length, Position},
5};
6
7// rust compiler output json structs
8#[derive(Clone, DeJson, Debug, Default)]
9pub struct RustcTarget {
10    pub kind: Vec<String>,
11    pub crate_types: Vec<String>,
12    pub name: String,
13    pub src_path: String,
14    pub edition: String,
15    pub doc: Option<bool>,
16    pub doctest: bool,
17    pub test: bool
18}
19
20#[derive(Clone, DeJson, Debug, Default)]
21pub struct RustcText {
22    pub text: String,
23    pub highlight_start: usize,
24    pub highlight_end: usize
25}
26
27#[derive(Clone, DeJson, Debug, Default)]
28pub struct RustcSpan {
29    pub file_name: String,
30    pub byte_start: usize,
31    pub byte_end: usize,
32    pub line_start: usize,
33    pub line_end: usize,
34    pub column_start: usize,
35    pub column_end: usize,
36    pub is_primary: bool,
37    pub text: Vec<RustcText>,
38    pub label: Option<String>,
39    pub suggested_replacement: Option<String>,
40    pub suggestion_applicability: Option<String>,
41    pub expansion: Option<Box<RustcExpansion >>,
42    pub level: Option<String>
43}
44
45impl RustcSpan {
46    pub fn start(&self) -> Position {
47        Position {
48            line_index: self.line_start - 1,
49            byte_index: self.column_start - 1
50        }
51    }
52
53    pub fn end(&self) -> Position {
54        Position {
55            line_index: self.line_end - 1,
56            byte_index: self.column_end - 1
57        }
58    }
59
60    pub fn length(&self) -> Length {
61        self.end() - self.start()
62    }
63}
64
65#[derive(Clone, DeJson, Debug, Default)]
66pub struct RustcExpansion {
67    pub span: Option<RustcSpan>,
68    pub macro_decl_name: String,
69    pub def_site_span: Option<RustcSpan>
70}
71
72#[derive(Clone, DeJson, Debug, Default)]
73pub struct RustcCode {
74    pub code: String,
75    pub explanation: Option<String>
76}
77
78#[derive(Clone, DeJson, Debug, Default)]
79pub struct RustcMessage {
80    pub message: String,
81    //#[remap("$message_type")]
82    pub message_type: Option<String>,
83    pub code: Option<RustcCode>,
84    pub level: String,
85    pub spans: Vec<RustcSpan>,
86    pub children: Vec<RustcMessage>,
87    pub rendered: Option<String>
88}
89
90#[derive(Clone, DeJson, Debug, Default)]
91pub struct RustcProfile {
92    pub opt_level: String,
93    pub debuginfo: Option<usize>,
94    pub debug_assertions: bool,
95    pub overflow_checks: bool,
96    pub test: bool
97}
98
99#[derive(Clone, DeJson, Debug, Default)]
100pub struct RustcCompilerMessage {
101    pub reason: String,
102    pub signal: Option<u64>,
103    pub success: Option<bool>,
104    pub package_id: Option<String>,
105    pub manifest_path: Option<String>,
106    pub linked_libs: Option<Vec<String >>,
107    pub linked_paths: Option<Vec<String >>,
108    pub cfgs: Option<Vec<String >>,
109    pub env: Option<Vec<Vec<String >>>,
110    pub target: Option<RustcTarget>,
111    pub message: Option<RustcMessage>,
112    pub profile: Option<RustcProfile>,
113    pub out_dir: Option<String>,
114    pub features: Option<Vec<String >>,
115    pub filenames: Option<Vec<String >>,
116    pub executable: Option<String>,
117    pub fresh: Option<bool>
118}