Cannot properly add LwGPS library to espressif32 project

Hi all,

After adding GPS library LwGPS:

[env:ttgo-t-beam]
platform = espressif32
board = ttgo-t-beam
framework = espidf

lib_deps =
    ; name-based (built-in library in framework)
    majerle/LwGPS@^2.2.0

I’ve faced that I cannot incliude headers from it:

#include "lwgps/lwgps.h"
#include "lwrb/lwrb.h"

But adding:

include_directories(
        <ProjectName>
        ${CMAKE_SOURCE_DIR}/.pio/libdeps/ttgo-t-beam/LwGPS/lwgps/src/include
        ${CMAKE_SOURCE_DIR}/.pio/libdeps/ttgo-t-beam/LwGPS/lwgps/src/include/lwgps
)

Also do not help, because there is template header that is available only after library was built …
How properly add library to espressif32 project ?
Is an aded library built during build of main project ?
Maybe I need somehow to add artifacts to project CMakeList.txt file ?

1 Like

Hi @redradist, there was a flaw in the manifest file for the LwGPS v2.2.0 library which is fixed in the development branch, so I’d recommend installing the library directly from the repository:

[env:ttgo-t-beam]
platform = espressif32
board = ttgo-t-beam
framework = espidf
lib_deps =
    https://github.com/MaJerle/lwgps.git#f1f5d32

Unfortunattly on this commit f1f5d32 I have the same issue:
fatal error: lwgps_opts.h: No such file or directory

I see, unfortunately, CMake scripts are not executed when PlatformIO builds third-party libraries. The author of that library also haven’t implemented a proper integration with PlatformIO, so you’ll need to do it on your side. Fortunately, it’s not that hard, just create an extra script that will handle the same logic as in the CMake file:

[env:ttgo-t-beam]
platform = espressif32
board = ttgo-t-beam
framework = espidf
lib_deps =
    https://github.com/MaJerle/lwgps.git#f1f5d32

; A special workaround for the dynamic generation of the
; "lwgps_opts.h" config file for LwGPS
extra_scripts = 
    generate_lwgps_config_file.py

Where generate_lwgps_config_file.py: is something like this

import os
import shutil

Import("env")

lwgps_lib_path = env.subst(os.path.join("$PROJECT_LIBDEPS_DIR", "$PIOENV", "LwGPS"))
lwgps_config_file = os.path.join(
    lwgps_lib_path, "lwgps", "src", "include", "lwgps", "lwgps_opts.h"
) 

if not os.path.isfile(lwgps_config_file):
    print(
        "Warning! `lwgps_opts.h` file was not found. A new one will be created from `lwgps_opts_template.h`!"
    )
    template_config = lwgps_config_file.replace("lwgps_opts.h", "lwgps_opts_template.h")
    assert os.path.isfile(
        template_config
    ), "Error: missing the template configuration file `lwgps_opts_template.h`!"

    shutil.copyfile(template_config, lwgps_config_file)
    assert os.path.isfile(lwgps_config_file), "Error: `lwgps_opts.h` was not copied!"
2 Likes

Thanks, it is working !!

But based on what was said I’ve a couple new questions:

  1. How this library passed CI during registration on PlatformIO Registry ??

    For example, everything that goes in conan-center-index is passing CI, that is how central repo can guarantee that library is working properly

  2. Why some symbols are not defined in native python for script generate_lwgps_config_file.py ?

    Is it some trick parts of Scons ?
    Because I expect that file with .py extension would be a valid python file, but Import is undefined, env is imported not by proper python mechanism, but using Import … too strange for me …

How this library passed CI during registration on PlatformIO Registry ??

Currently, PlatformIO Registry doesn’t run any CI checks, it’s maintainer’s responsibility to make sure the library is working as expected.

Why some symbols are not defined in native python for script generate_lwgps_config_file.py ? Is it some trick parts of Scons ?

That’s true, though you can still consider it as a generic Python script that’s executed in a special way with access to the SCons build environment.

Do you conside adding CI in future ?
Also if your PlatformIO registry is located on GitHub then Travis CI for open-source projects provide free continuous integration

Do you conside adding CI in future ?

There is always room for improvements, but the CI/CD feature is not the priority at the moment.

I see on this page PlatformIO Registry that you have on Community Plan as well as bunch of proprietary registry …

I suggest to move Community Registry on GitHub, as it was done for conan-center-index.
It could be done by providing all link to public repositories as submodules and new library registration as pull-request that will be merged automatically by bot after CI is passed

Because without CI I do not completely understand what problem solves PlaltfomrIO Registry if nothing is checked on it …

As customer I expect that if library available on Registry than it should work on claimed platforms and frameworks

Thanks for the hint, we’ll think about it.

1 Like