06-10-2022 09:22 AM
Before building the final executable I need to compile some of the source files to build and run some tests over the source code.
I'm going to use one of the existing test frameworks (greates, cpputest, gtest, check, ...).
Only if all the test pass, the build of the executbale can be started.
Is there a document desribing how to use pre-build or post-build actions to get this result?
Or, is there a different approach?
Thanks
06-13-2022 03:05 AM
Hello vix,
there's is a compile.exe utility that comes with CVI. It just compiles the prj file you give it. So you can write scripts around it and make it part of your test framework.
06-13-2022 05:55 AM
Hi @gdardaud
I think you refer to https://www.ni.com/docs/en-US/bundle/labwindows-cvi-2020/page/cvi/usermanual/cmdlineinterface.htm
The problem is that I need to specify the flags to be passed to the compiler because I need to fine tune the behavior of the compiler.
Is there a way to do this?
Thanks
06-13-2022 08:25 AM - edited 06-13-2022 08:25 AM
Yes, that's it.
What do you mean by 'flags' ?
If it's compiler #define, you can pass /Dmydefine=toto
If it's project options, you can possibly grep/replace inside the prj before calling compile.exe
If it's more global compiler options, you can pass a specific ecc file (it's text also) (I think, I've never tried). At a minima you can have multiple configurations.
06-13-2022 08:53 AM
I mean the several command line options supported by the compiler.
As an example, for GCC they're listed here.
I don't understand what you mean with "pass a specific ecc file".
Can you provide a link describing the syntax for this file?
06-13-2022 09:03 AM
CVI doesn't have all the options that gcc (or even the Clang it relies on) has. You can emulate that by having several configurations (or several prj files).
I got the ecc confused with CVI for Linux, the equivalent of compile.exe is cvicc and it uses a global .ecc configration file which is easy to change (you can change compiler, includes, libraries, options, etc in it). I thought compile.exe used the same system but it doesn't appear so. Sorry.
06-13-2022 09:38 AM
I investigated and I saw that if I enable custom build actions, a lot of files are creted under cvibuild.xxxxxx\[Debug|Release|...] folder.
Some of the files are BuildStep.bat, CallCC.bat, ...
Inside them I can see how the compiler is called
@echo Compiling %FileNum% %SrcFileName%
@"c:\program files\national instruments\cvi2015\bin\clang\3.3\clang.exe" -cc1 -nostdsysteminc -fno-builtin-include-notes....
but I don't uderstand if (and how) I can twek this call
Is there a way?
06-14-2022 04:30 AM
Not sure if this can be done in some way.
In the meanwhile I have another need, and I don't find documentation on how to do this:
is there a way to use a pre-build action that checks something, and if the check fails the build step is not executed?
The main project depends on another project which contains a set of tests (built and executed).
If the execution fails, I don't want that the main project is built.
09-16-2024 03:16 AM - edited 09-16-2024 03:16 AM
A lot of time passed by, but I haven't find yet a way to solve this need:
how can I write a custom pre-build script so that it fails the build is not executed?
The build can require a lot of time, and if my pre-build step doesn't succeed, I don't like wasting time waiting for the build to complete.