metadata generator / build process (Re: CHIMP)

  • 17 Replies
  • 1745 Views
*

Offline reyalp

  • ******
  • 11586
Re: metadata generator / build process (Re: CHIMP)
« Reply #10 on: 17 / June / 2017, 18:36:24 »
Advertisements
@reyalp I managed to port the module metadata code to CHDK (to run as a module).

Question: How do I go about sharing code between tools and modules, e.g. meta_modules.c that needs to be built in both.
Generally speaking, one makefile would reference the .c file from the other directory. Host object or lib files should go in the tools directory. We currently have some cases that share includes (flt, lang and font related) but aside from hostlua and run-ubasic (which is probably broken) I can't think of anything offhand that shares actual code.

If it was shared with a module, I'd probably put the code used by both in the modules directory or under lib.
Don't forget what the H stands for.

Re: metadata generator / build process (Re: CHIMP)
« Reply #11 on: 17 / June / 2017, 18:52:22 »
If it was shared with a module, I'd probably put the code used by both in the modules directory or under lib.

This is currently implemented as a module. So I just put the common code under modules and have the tools makefile build it into tools?
Author of CHIMP, Canon Hack Installation and Management Platform

*

Offline reyalp

  • ******
  • 11586
Re: metadata generator / build process (Re: CHIMP)
« Reply #12 on: 17 / June / 2017, 19:00:33 »
This is currently implemented as a module. So I just put the common code under modules and have the tools makefile build it into tools?
That's probably what I would do. If there are a lot of files involved, you might put them lib instead, like Lua.

I'm not clear on the reason to have this as a module.
Don't forget what the H stands for.

Re: metadata generator / build process (Re: CHIMP)
« Reply #13 on: 17 / June / 2017, 19:05:04 »
I'm not clear on the reason to have this as a module.

The reason is it computes SHA-256 hashes of the modules and reads/writes JSON, which I believe to be too much for core.
Author of CHIMP, Canon Hack Installation and Management Platform


*

Offline philmoz

  • *****
  • 3070
    • Photos
Re: metadata generator / build process (Re: CHIMP)
« Reply #14 on: 17 / June / 2017, 20:26:36 »
Question: How do I go about sharing code between tools and modules, e.g. meta_modules.c that needs to be built in both.


Put the code in the 'modules' folder.
Create a new folder in the 'tools' directory for your meta_module tool, with it's own makefile (see elf2flt or packfi2 for example).
Add a custom build rule in the makefile, e.g.:
Code: [Select]

meta_module$(EXE): $(modules)/meta_module.c
   @echo $< \-\> [email protected]
   $(HOSTCC) $(HOSTCFLAGS) -o [email protected] $^


Note, I have not tested the above so you make need to experiment with the build rule.


Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)

Re: metadata generator / build process (Re: CHIMP)
« Reply #15 on: 18 / June / 2017, 10:24:31 »
Put the code in the 'modules' folder.
Create a new folder in the 'tools' directory for your meta_module tool, with it's own makefile (see elf2flt or packfi2 for example).
Add a custom build rule in the makefile, e.g.:
Code: [Select]

meta_module$(EXE): $(modules)/meta_module.c
   @echo $< \-\> [email protected]
   $(HOSTCC) $(HOSTCFLAGS) -o [email protected] $^


Note, I have not tested the above so you make need to experiment with the build rule.


Phil.

Thanks, I'll try that.

Could you (or any of the moderators) please split this discussion starting from this post? It seems to have strayed pretty far away from CHIMP.
Author of CHIMP, Canon Hack Installation and Management Platform

Re: metadata generator / build process (Re: CHIMP)
« Reply #16 on: 21 / June / 2017, 13:22:58 »
That worked perfectly. I now have both software metadata generator tool and menu metadata generator module using the same JSON writer!
Author of CHIMP, Canon Hack Installation and Management Platform

Re: metadata generator / build process (Re: CHIMP)
« Reply #17 on: 23 / June / 2017, 13:00:21 »
I got the build tool to share some code with the flt tool.

For some reason, if meta_modules_get() from meta_modules.c is called from gen_meta_modules.c, it produces garbage output. In its current form, i.e. copied verbatim (with the name changed) to gen_meta_modules.c, it seems to work.

What am I missing? A buffer overrun perhaps?
Author of CHIMP, Canon Hack Installation and Management Platform