Commit 910c530
authored
Make public app declarations available from root (ZigEmbeddedGroup#775)
Fixes ZigEmbeddedGroup#465.
One of the weaknesses of MicroZig's build system is that packages that
use root declarations for comptime-configuration don't work. We make the
application a package to the real root of an executable, and break out
useful stdlib options (namely logging) through `microzig_options`. This
is also notable because MicroZig changes the defaults for logging
because logging will cause compiler errors from not having an operating
system.
I want to avoid boiler-plate like the following:
```zig
const microzig = @import("microzig");
comptime {
microzig.cpu.export_startup_logic(); // would export startup logic
}
pub fn main() {
// ...
}
```
So this patch creates a code generation step in our build system that
takes the existing `startup.zig` code that currently makes up the root
of the executable and appends the public declarations from the
application. This gives us everything we want, no boiler plate, and
packages will now be able to use comptime-configuration.
The special handling of the Standard Library logging function is
temporary. This needs to be fixed upstream so that the regular logging
function is a no-op on freestanding targets.1 parent 81681fa commit 910c530
File tree
4 files changed
+80
-12
lines changed- core/src
- examples/raspberrypi/rp2xxx/src/rp2040_only
4 files changed
+80
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
561 | 576 | | |
562 | 577 | | |
563 | 578 | | |
| |||
567 | 582 | | |
568 | 583 | | |
569 | 584 | | |
570 | | - | |
| 585 | + | |
571 | 586 | | |
572 | 587 | | |
573 | 588 | | |
| |||
588 | 603 | | |
589 | 604 | | |
590 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
591 | 609 | | |
592 | 610 | | |
593 | 611 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
17 | 36 | | |
18 | 37 | | |
19 | 38 | | |
| |||
40 | 59 | | |
41 | 60 | | |
42 | 61 | | |
43 | | - | |
44 | | - | |
| 62 | + | |
| 63 | + | |
45 | 64 | | |
46 | 65 | | |
47 | 66 | | |
| |||
62 | 81 | | |
63 | 82 | | |
64 | 83 | | |
65 | | - | |
| 84 | + | |
66 | 85 | | |
67 | 86 | | |
68 | 87 | | |
| |||
90 | 109 | | |
91 | 110 | | |
92 | 111 | | |
93 | | - | |
| 112 | + | |
94 | 113 | | |
95 | 114 | | |
96 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
0 commit comments