xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.83k stars 775 forks source link

Prepending toolchain flags or setting tool parameter order #5571

Open ArgoreOfficial opened 1 week ago

ArgoreOfficial commented 1 week ago

Is your feature request related to a problem? Please describe.

A specialized archiver I am working with uses the format ar [mode] -o [outFile] [inputFiles...]
This mode flag has to be the first parameter, and from what I have found you are only able to append flags at the end

Describe the solution you'd like

add_arflags("mode", { prepend = true }) this would yield the following command artool mode -o "outfile.a" "one.o" "two.o" "three.o" ...etc

Describe alternatives you've considered

alternatively some way to directly set the order set_ar_order({ "userflags", "defaultflags", "files", ...etc })

Additional context

No response

ArgoreOfficial commented 1 week ago

for now I've solved this with an intermediate executable that takes the xmake inputs and reformats them for the archiver

having it natively in xmake would be nice though

waruqi commented 1 week ago

Reordering flags is not supported yet, and it's complicated to implement.

if you use specialized archiver, you can call set_toolset("ar@artool mode") to set mode.

or write a shell script to wrap it to ar

or wait for this feature to custom toolchain command and flags. https://github.com/xmake-io/xmake/issues/5554

ArgoreOfficial commented 1 week ago

I tried doing "ar@artool mode" but that failed due to the exec trying to run a file named artool mode.
if I remember correctly the command it called looked something like exec( "\"artool mode\" -o file... ..etc" )

I'll wait for the feature, my workaround does its job for now :)