[riot-notifications] [RIOT-OS/RIOT] make: add blob utility header (#11870)

Juan I Carrano notifications at github.com
Fri Sep 13 11:56:32 CEST 2019


I'll summarize a discussion we had AFK with @emmanuelsearch. Sorry for the long comment, and I don't mean to bash this PR- **I feel that many of the ideas expressed here apply equally to other instances where we may be wanting to "abstract away" common functionality.**

All this would achieve is remove the need for the following snippet to exist in the application's makefile:

```make
JS_PATH = $(BINDIR)/js/$(MODULE)

# add directory of generated *.js.h files to include path
CFLAGS += -I$(JS_PATH)

# generate .js.h header files of .js files
JS = $(wildcard *.js)
JS_H = $(JS:%.js=$(JS_PATH)/%.js.h)

BUILDDEPS += $(JS_H) $(JS_PATH)/

include $(RIOTBASE)/Makefile.include

$(JS_PATH)/:
	$(Q)mkdir -p $@

$(JS_H): $(JS_PATH)/%.js.h: %.js | $(JS_PATH)/
	$(Q)xxd -i $< | sed 's/^unsigned/const unsigned/g' > $@
```

That was taken from the jerryscript package. Lua has something similar. Note that header files will end up in a js-specific path.

The propose module removes the need for this code, at the price of:

- Reduced flexibility.
  - User cannot have different paths for different file types.
  - The datatype (const unsigned) is fixed.
    - In fact, the whole output template is fixed.
- The code is now "officially" part of the RIOT build system, which means people will depend on in and each change is an API change.

The reduced flexibility means that any deviation from the assumption that this new module does would require reverting back to the above snippet.

Now, there are some very real problems which are not being solved by this or by anything currently in use. Many of these are actually limitations of our build system, unrelated to this PR.

- Making files into arrays is easy, but the interesting part is _indexing_ them (i.e. putting them into some sort of structure or table)
  - I have come to believe that this is best done in an application specific way.
- We still have to come up with a way to generate _just_ the required dependencies. 
  - `$(OBJC) $(OBJCXX): $(BLOB_H)` (or builddeps...) is overkill, but we currently know no better way
- What if I want to generate an object instead of a header.
  - Needed, for example, to properly integrate stuff like vendor supplied binaries/ bootloaders /etc.
  - Compiling a generated C file and  is tricky.
  - #11497 does that, but I did not insist too much on that because the rest of the complaints in this PR apply to it as well (my justification for that PR was that it is something tricky to get right).

In conclusion, I'm against too much convenience functions, since these have to be maintained too.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11870#issuecomment-531177233
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190913/0fb474de/attachment.htm>


More information about the notifications mailing list