xod icon indicating copy to clipboard operation
xod copied to clipboard

Add `--entry-point` parameter for `xodc transpile`

Open nkrkv opened this issue 5 years ago • 0 comments
trafficstars

Rationale

The code generated by XOD assumes setup and loop will be used as program entry points. This is the case with most Arduino-compatible boards but does not cover all cases. For example, a user might have a board running FreeRTOS and define main himself. See https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/cores/nRF5/main.cpp as an example.

For such cases, it would be handy to have a single-function entry point generated. So that I can trivially call it from my own main or make it a FreeRTOS task.

User story

I run:

xodc transpile my-proj-qux.xodball main --entry-point my_qux_main

And the resulting code, along with the traditional setup and loop contains quite trivial:

// ... the usual code ...

extern void yield();

void my_qux_main(void*) {
    setup();
    while (true) {
        loop();
        yield();
    }
}

Acceptance criteria

  • [ ] The --entry-point argument is taken into account as shown
  • [ ] The value is validated to be a valid C++ identifier. If not, a clear error is shown and xodc exits with non-zero code
  • [ ] Multiple entry points can be be used together without conflicts

Out of scope

  • Providing own yield. It’s up to a user to guarantee its presence. E.g., use the mentioned Adafruit core
  • Providing own main. It’s up to a user to guarantee its presence.

nkrkv avatar Aug 17 '20 13:08 nkrkv