I would like to set up a build for an embedded system which can either produce a Xilinx MicroBlaze binary or a Windows binary (compiled by Mingw for simulation). I have succeeded in compiling a simple test project under Windows, but I haven’t figured out how to specify the MicroBlaze compiler (mb-g++ instead of g++).
I could resort to tricks such as redirecting the PATH to a g++.bat file which calls mb-g++, but I would still need to declare a “microblaze” processor architecture so that the build would produce the correct variant – and I cannot seem to find how to do that, either.
I took a look at nokee, but aside from providing an additional plugin for compiling JNI modules, it seems very similar to the Gradle 8.1 C++ plugins. The site did mention the deprecated model-based native plugin, though. Since that one supports cross-compilation, I thought I’d give it a try, assuming it won’t be discontinued until the new version reaches feature parity.
Using the build script below, I successfully got Gradle to invoke the mb-gcc compiler, but it looks like the compiler does not accept @option files. Is there a way to get Gradle to specify compiler options directly on the command line?
> Task :compileMainMicroblazeExecutableMainC FAILED
Found all include files for ':compileMainMicroblazeExecutableMainC'
Caching disabled for task ':compileMainMicroblazeExecutableMainC' because:
Build cache is disabled
Task ':compileMainMicroblazeExecutableMainC' is not up-to-date because:
Task has failed previously.
The input changes require a full rebuild for incremental task ':compileMainMicroblazeExecutableMainC'.
See file:///C:/globe/c-application/build/tmp/compileMainMicroblazeExecutableMainC/output.txt for all output for compileMainMicroblazeExecutableMainC.
Starting process 'command 'C:\Xilinx\13.4\ISE_DS\EDK\gnu\microblaze\nt64\bin\mb-gcc.exe''. Working directory: C:\globe\c-application\build\objs\main\microblaze\mainC Command: C:\Xilinx\13.4\ISE_DS\EDK\gnu\microblaze\nt64\bin\mb-gcc.exe @C:\globe\c-application\build\tmp\compileMainMicroblazeExecutableMainC\options.txt C:\globe\c-application\src\main\c\main.c -o C:\globe\c-application\build\objs\main\microblaze\mainC\7ywyobd9l7sopuxey9ya912jy\main.obj
Successfully started process 'command 'C:\Xilinx\13.4\ISE_DS\EDK\gnu\microblaze\nt64\bin\mb-gcc.exe''
mb-gcc.exe: @C:\globe\c-application\build\tmp\compileMainMicroblazeExecutableMainC\options.txt: Invalid argument
What you are experiencing is a limitation of the toolchain declaration in Gradle. Internally, it supports not using command files, and for this, you have to use canUseCommandFile = false under the microblaze configuration action. I hope that help.