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    pub code: Option<RustcCode>,
82    pub level: String,
83    pub spans: Vec<RustcSpan>,
84    pub children: Vec<RustcMessage>,
85    pub rendered: Option<String>
86}
87
88#[derive(Clone, DeJson, Debug, Default)]
89pub struct RustcProfile {
90    pub opt_level: String,
91    pub debuginfo: Option<usize>,
92    pub debug_assertions: bool,
93    pub overflow_checks: bool,
94    pub test: bool
95}
96
97#[derive(Clone, DeJson, Debug, Default)]
98pub struct RustcCompilerMessage {
99    pub reason: String,
100    pub signal: Option<u64>,
101    pub success: Option<bool>,
102    pub package_id: Option<String>,
103    pub manifest_path: Option<String>,
104    pub linked_libs: Option<Vec<String >>,
105    pub linked_paths: Option<Vec<String >>,
106    pub cfgs: Option<Vec<String >>,
107    pub env: Option<Vec<String >>,
108    pub target: Option<RustcTarget>,
109    pub message: Option<RustcMessage>,
110    pub profile: Option<RustcProfile>,
111    pub out_dir: Option<String>,
112    pub features: Option<Vec<String >>,
113    pub filenames: Option<Vec<String >>,
114    pub executable: Option<String>,
115    pub fresh: Option<bool>
116}