@@ -13,12 +13,12 @@ use tokio::fs;
13
13
use spin_common:: { ui:: quoted_path, url:: parse_file_url} ;
14
14
15
15
/// Compilation status of all components of a Spin application
16
- pub enum CompilationStatus {
16
+ pub enum AotCompilationStatus {
17
+ /// No components are ahead of time (AOT) compiled.
18
+ Disabled ,
17
19
#[ cfg( feature = "unsafe-aot-compilation" ) ]
18
20
/// All components are componentized and ahead of time (AOT) compiled to cwasm.
19
- AllAotComponents ,
20
- /// No components are ahead of time (AOT) compiled.
21
- NoneAot ,
21
+ Enabled ,
22
22
}
23
23
24
24
/// Loader for the Spin runtime
@@ -28,15 +28,15 @@ pub struct TriggerLoader {
28
28
/// Set the static assets of the components in the temporary directory as writable.
29
29
allow_transient_write : bool ,
30
30
/// Declares the compilation status of all components of a Spin application.
31
- compilation_status : CompilationStatus ,
31
+ aot_compilation_status : AotCompilationStatus ,
32
32
}
33
33
34
34
impl TriggerLoader {
35
35
pub fn new ( working_dir : impl Into < PathBuf > , allow_transient_write : bool ) -> Self {
36
36
Self {
37
37
working_dir : working_dir. into ( ) ,
38
38
allow_transient_write,
39
- compilation_status : CompilationStatus :: NoneAot ,
39
+ aot_compilation_status : AotCompilationStatus :: Disabled ,
40
40
}
41
41
}
42
42
@@ -69,7 +69,7 @@ impl TriggerLoader {
69
69
/// from untrusted sources.**
70
70
#[ cfg( feature = "unsafe-aot-compilation" ) ]
71
71
pub unsafe fn enable_loading_aot_compiled_components ( & mut self ) {
72
- self . compilation_status = CompilationStatus :: AllAotComponents ;
72
+ self . aot_compilation_status = AotCompilationStatus :: Enabled ;
73
73
}
74
74
}
75
75
@@ -95,9 +95,9 @@ impl Loader for TriggerLoader {
95
95
. as_ref ( )
96
96
. context ( "LockedComponentSource missing source field" ) ?;
97
97
let path = parse_file_url ( source) ?;
98
- match self . compilation_status {
98
+ match self . aot_compilation_status {
99
99
#[ cfg( feature = "unsafe-aot-compilation" ) ]
100
- CompilationStatus :: AllAotComponents => {
100
+ AotCompilationStatus :: Enabled => {
101
101
match engine. detect_precompiled_file ( & path) ?{
102
102
Some ( wasmtime:: Precompiled :: Component ) => {
103
103
unsafe {
@@ -110,17 +110,17 @@ impl Loader for TriggerLoader {
110
110
anyhow:: bail!( "Spin loader is configured to load only AOT compiled components, but {} is not precompiled" , quoted_path( & path) )
111
111
}
112
112
}
113
- } ,
114
- CompilationStatus :: NoneAot => {
113
+ }
114
+ AotCompilationStatus :: Disabled => {
115
115
let bytes = fs:: read ( & path) . await . with_context ( || {
116
- format ! (
117
- "failed to read component source from disk at path {}" ,
118
- quoted_path( & path)
119
- )
120
- } ) ?;
121
- let component = spin_componentize:: componentize_if_necessary ( & bytes) ?;
122
- spin_core:: Component :: new ( engine, component. as_ref ( ) )
123
- . with_context ( || format ! ( "loading module {}" , quoted_path( & path) ) )
116
+ format ! (
117
+ "failed to read component source from disk at path {}" ,
118
+ quoted_path( & path)
119
+ )
120
+ } ) ?;
121
+ let component = spin_componentize:: componentize_if_necessary ( & bytes) ?;
122
+ spin_core:: Component :: new ( engine, component. as_ref ( ) )
123
+ . with_context ( || format ! ( "loading module {}" , quoted_path( & path) ) )
124
124
}
125
125
}
126
126
}
0 commit comments