How can I use different c compiler/linker options on a per-file basis using rebar?
I've got re开发者_运维技巧bar set up to build an erlang module which uses two different c files.
I set c compilation options in my rebar.config
using (for example):
{port_env, [{"DRV_CFLAGS", "$DRV_CFLAGS -Wall -Wextra"}]}.
Is it possible to set different options for each c source file? I'd like different compiler and linker flags for each.
If not, what's the most common alternative/workaround? I guess that creating a Makefile and moving the c compilation to there would work, it just seems a shame to have to do when rebar takes care of the rest so nicely.
Crazy idea: You can use pre_hooks
and post_hooks
to execute shell scripts. Maybe you could run your own shell script to compile the file with your desired compiler and flags, after rebar already has done it's job.
For an example of preprocessing, check out Steve Vinoskis NIF implementation of the SHA-2 standard. See his rebar.config and c_src/config.sh
精彩评论