Closed dennis4lora closed 3 weeks ago
Hi @dennis4lora ,
which file is used when you compile the project? For me it is main.c
, I can safely delete lora_pkt_fwd.c
Hi, @danielkucera :
there are a few app_main()
defined in the main/test/ folder for testing purpose, and can't co-exist with lora_pkt_fwd.c
or each other, but I think they could be useful. So in my design, I only include a main.c
but soft-link it to whichever app_main()
we want, and the default file is lora_pkt_fwd.c
.
It works well until we want to support it under Windows, so I use hard-link instead of soft-link (that's why you can safely remove lora_pkt_fwd.c
). I thought it works, until today, I just realized that recent commits only updates main.c
, while lora_pkt_fwd.c
has not been updated.
So I guess a better solution is removing the duplication and don't keep main.c
at all. Then one way to choose which app_main
been used is by controlling the main/CMakeLists.txt directly. However, this way feels a little ugly... :laughing:
I see. Can you potentially create one generic main which will call other apps? So they all get compiled and only the one(s) being called will get linked.
In fact, in the future, I'll collect all of the test programs together and all are available from a mini-shell command line (as partly done in dev
branch https://github.com/lora-gateway/esxp1302/blob/dev/main/libloragw-test/cli4test.c).
Then there will only have 2 app_main
left (one for pkt_fwd and one for the tests); then the user can decide which app_main
they want and choose it by set a MACRO flag or from command line, and this issue will be closed. :smile:
There is no main.c
anymore, and this issue can be closed now.
To choose whether to use main/packet_forwarder/lora_pkt_fwd.c
or main/libloragw-test/cli4test.clibloragw-test/cli4test.c
to provide main()
, just control the value of MACRO CONFIG_LIBLORAGW_TEST
(default is 0).
Currently in run_me.sh
, it sets as this:
idf.py -DCONFIG_LIBLORAGW_TEST=0 app
Currently, main.c is a hard link to lora_pkt_fwd.c (per commit: change soft link to hard link to support Windows PlatformIO compile).
However, the content of them doesn't match any more after a few commits.
This issue needs to be addressed. One solution is only keep one of them to avoid duplication...