Skip to content

Add --entry-point parameter for xodc transpile #2020

@nkrkv

Description

@nkrkv

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions