ffi / ffi-compiler

Apache License 2.0
32 stars 10 forks source link

Stay backwards compatible with `cflags, cxxflags, ldflags` #24

Closed davispuh closed 1 year ago

davispuh commented 1 year ago

5e173ae1de068bea5890c4c2438c5b1e1cdad702 (related to #22) changed API regarding cflags, cxxflags, ldflags

Previously it was expected to be raw and passed as is, thus applications could do either

cflags << "-Wall -Wextra -O3"

cflags << "-Wall" << "-Wextra" << "-O3"

And both would work and do exactly same thing. But 5e173ae1de068bea5890c4c2438c5b1e1cdad702 made that each item is a separate flag thus you couldn't put multiple flags in same string so only 2nd way would work.

I don't think that previous API is good because it's 2 ways to do exactly same thing and you would have to escape it for target shell yourself and it's something that's easy to forget, eg. ldflags << "-L" << libpath - this actually wouldn't work if libpath contained spaces and weren't escaped for shell.

But there's probably a lot of applications that are passing multiple flags in single string so to make life easier for everyone lets just keep API compatibility.

And for new applications they can disable this compatibility with raw = false like this

ldflags.raw = false
ldflags << "-L" << libpath # Now we correctly support `libpath` that contains spaces