@@ -25,24 +25,27 @@ fn main() {
25
25
panic ! ( "\n \n Must select exactly one package for linker script generation!\n Choices: 'stm32l0x1' or 'stm32l0x2' or 'stm32l0x3'\n \n " ) ;
26
26
}
27
27
28
- let linker = if cfg ! ( feature = "stm32l0x1" ) {
29
- include_bytes ! ( "memory_l0x1.x" ) . as_ref ( )
30
- } else if cfg ! ( feature = "stm32l0x2" ) {
31
- include_bytes ! ( "memory_l0x2.x" ) . as_ref ( )
32
- } else if cfg ! ( feature = "stm32l0x3" ) {
33
- include_bytes ! ( "memory_l0x3.x" ) . as_ref ( )
34
- } else {
35
- unreachable ! ( ) ;
36
- } ;
37
-
38
- File :: create ( out. join ( "memory.x" ) )
39
- . unwrap ( )
40
- . write_all ( linker)
41
- . unwrap ( ) ;
42
- println ! ( "cargo:rustc-link-search={}" , out. display( ) ) ;
28
+ if !cfg ! ( feature = "disable-linker-script" ) {
29
+ let linker = if cfg ! ( feature = "stm32l0x1" ) {
30
+ include_bytes ! ( "memory_l0x1.x" ) . as_ref ( )
31
+ } else if cfg ! ( feature = "stm32l0x2" ) {
32
+ include_bytes ! ( "memory_l0x2.x" ) . as_ref ( )
33
+ } else if cfg ! ( feature = "stm32l0x3" ) {
34
+ include_bytes ! ( "memory_l0x3.x" ) . as_ref ( )
35
+ } else {
36
+ unreachable ! ( ) ;
37
+ } ;
38
+
39
+ File :: create ( out. join ( "memory.x" ) )
40
+ . unwrap ( )
41
+ . write_all ( linker)
42
+ . unwrap ( ) ;
43
+ println ! ( "cargo:rustc-link-search={}" , out. display( ) ) ;
44
+
45
+ println ! ( "cargo:rerun-if-changed=memory_l0x1.x" ) ;
46
+ println ! ( "cargo:rerun-if-changed=memory_l0x2.x" ) ;
47
+ println ! ( "cargo:rerun-if-changed=memory_l0x3.x" ) ;
48
+ }
43
49
44
50
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
45
- println ! ( "cargo:rerun-if-changed=memory_l0x1.x" ) ;
46
- println ! ( "cargo:rerun-if-changed=memory_l0x2.x" ) ;
47
- println ! ( "cargo:rerun-if-changed=memory_l0x3.x" ) ;
48
51
}
0 commit comments