Modify & Rebuild mongoose library

If you are asking a question, please follow this template:

  1. My goal is:
    [download/modify/rebuild library https://github.com/cesanta/mongoose]
  2. My actions are: [Using “mos build --platform esp8266” to build project]
  3. The result I see is:
    [
    in mos_final.yml
    origin: https://github.com/mongoose-os-libs/mongoose
    location: https://github.com/mongoose-os-libs/mongoose
    name: mongoose
    path: /data/fwbuild-volumes/2.19.1/apps/Http_esp8266/esp8266/build_contexts/build_ctx_338561145/deps/mongoose
    version: “6.16”
    ]
  4. My expectation & question is:
    [
    Is there a doc/procedure explain how to build a library after modified ?
    e.g. I want to have the version: “7.3” of https://github.com/mongoose-os-libs/mongoose
    and add some debug print
    ]

https://github.com/mongoose-os-libs/mongoose is one of the libraries that is close source. You can’t modify it.
mos will stay on 6.x for the foreseeable future.

How about other open-source library ?

Fork the repo, clone, modify, build, etc…

If you want to modify one of the mongoose-os-libs you should build locally.
If you want to build remotely you will most likely end up getting the unmodified library, what I’ve been doing so far (just what I fancy and works for me) is to place a copy on the deps directory and in mos.yml use - name: libname (instead of - origin: https://github.com/mongoose-os-libs/libname). Before each build, erase the deps and build directories and copy your modified libname contents to deps/libname, which is trivial from the command line.
This works also for developing your own lib. Most developers seem to use Docker and build locally.

Yes, that’s the way I do it all the time. And I have lots of common code and libraries which are placed in directories out of the application’s source tree.

sources:
  - src
  - ../common/event-handler-wrapper
  - ../common/rpc-wrapper
  - ../common/ws-client

libs:
  - origin: ../libs/hdc1080-i2c
  - origin: ../libs/hdc20x0-i2c
  - origin: ../libs/json-queue

This layout works for remote builds too, provided the size of the upload is les than ~5MB, I think. There is no need to play with the deps directory and local builds anymore.

LE. Forgot to mention the posibilty to create a private build server. It works for me on Debian buster.

1 Like

I got the code build locally using the Docker now.
Using the Mongoose-OS (2.18.0) and I can see mongoose is (6.18)

If I wan to use newer mongoose (7.2), do I simply add the following ?

libs:
  - origin: https://github.com/mongoose-os-libs/core
  - origin: https://github.com/mongoose-os-libs/boards
  - origin: https://github.com/mongoose-os-libs/ca-bundle
  - origin: https://github.com/mongoose-os-libs/wifi
  - origin: https://github.com/mongoose-os-libs/mjs
  - origin: https://github.com/mongoose-os-libs/dash
  - origin: https://github.com/mongoose-os-libs/fstab
  - origin: c:/mongoose/v7.2/

I read somewhere a response to a similar question. IIRC and my understanding was correct, Mongoose comes bundled with mOS and you can not (easily ?) change to a different release; furthermore, the API in version 7 is different and mOS may not be ported to that API, at least in the near future.

I have followed your format, it works for most of the libs in the project. But it failed in 2 of the libs

libs:
  - origin: https://github.com/mongoose-os-libs/ota-http-server
  - origin: ../libs/core
  - origin: ../libs/boards
  - origin: ../libs/rpc-service-config
  - origin: ../libs/fstab
  - origin: ../libs/wifi
  - origin: ../libs/mjs
  - origin: ../libs/dash

Error: /src/cli/manifest_parser/manifest_parser.go:425: neither sources nor prebuilt binary exists for the lib “dash” (or, if a library doesn’t have any code by design, its mos.yml shouldn’t contain “sources”). Fetch error was: [unable to fetch prebuilt binary for “dash”]

What I have missed ??

dash is a binary only library.

how I should include both binary without building it ??

  • ota-http-server
  • dash

You can’t build dash and/or ota-http-server because they are closed source.

So, that’s mean Mongoose-OS application project can never be built locally without access to below GIT server ? Is my understanding correct ?

As I do want to have my Application build without reply on GIT being available.
My requirement only changing Application and not included library.

You can try something like this.
Leave the github references in mos.yml. Run first, e.g.

mos build --local --deps-dir $DEPS_DIR --binary-libs-dir $LIBS_DIR --platform esp32

After that, run

mos build --local --deps-dir $DEPS_DIR --binary-libs-dir $LIBS_DIR --platform esp32 --no-libs-update

The build process will use all the dependencies and binary libs which were downloaded in the first step.
Don’t change anything in mos.yml.

1 Like