Skip to content

Commit

Permalink
Support running west lfc outside of the project root.
Browse files Browse the repository at this point in the history
Add docs to the source file
  • Loading branch information
erlingrj committed Oct 23, 2023
1 parent 83e4b47 commit a41c257
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions apps/HelloWorld/src/HelloWorld.lf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/*
* Simple Hello-world. Will work with any Zephyr-supported platform
*/
target C {
platform: "Zephyr",
threading: false
Expand Down
10 changes: 9 additions & 1 deletion apps/NrfBlinky/src/NrfBlinky.lf
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
/*
* This is a Blinky example which blinks the on-board LED0 of the nrf52DK. It
* works with other boards which has a `led0` device tree alias defined.
*/
target C {
platform: "Zephyr",
platform: {
name: "Zephyr",
board: nrf52dk_nrf52832,
},
threading: false
}

preamble {=
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#include <assert.h>
#define LED0_NODE DT_ALIAS(led0)
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
=}
Expand Down
8 changes: 7 additions & 1 deletion apps/NrfBlinky/src/NrfToggleGPIO.lf
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
/*
* This program shows how we can toggle a GPIO pin on the nrf52DK and also
* how we enable the high-precision HFCLK crystal oscillator for better
* timing precision.
*/
target C {
platform: {
name: "Zephyr",
board: nrf52dk_nrf52832,
},
threading: false,
cmake-include: "timer.cmake"
}

preamble {=
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#include <assert.h>

#define PIN 11 // See pin assignments here: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fpin.html&anchor=pin_assign

#define LED0_NODE DT_ALIAS(led0)
Expand Down
5 changes: 1 addition & 4 deletions scripts/lfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ def do_run(self, args, unknown_args):
if "src" not in args.app:
print("ERROR: LF app must be inside a `src` folder")

if not os.path.exists("src") or not os.path.exists("Kconfig") or not os.path.exists("prj.conf") or not os.path.exists("app.overlay"):
print("ERROR: `west lfc` must be called from the root of the application, where it finds `src`, `Kconfig`, `prj.conf` and `app.overlay` in the same directory ")


# Find the path to where lfc will put the sources
appPath, app_ext = os.path.splitext(args.app)
Expand All @@ -60,7 +57,7 @@ def do_run(self, args, unknown_args):
src = os.path.join(rootPath, f)
dst = os.path.join(srcGenPath, f)
if not os.path.exists(src):
print(f"Did not find {f} at {src}")
print(f"Did not find {f} at {src}. Project layout is incorrect")
exit(1)
shutil.copyfile(src, dst)

Expand Down

0 comments on commit a41c257

Please sign in to comment.