How can I compile automatically generated C files in pre-build?

I have an Eclipse project that I need to auto-generate some files before compiling it. I don’t want to put these automatically generated files into my repository, so every time I compile projetct, I pre-compile to automatically create these files.

The problem is that these automatically generated files are * .c and * .h files, and the first time I compile a project, the following happens (in that order):

  • pre-build: auto-generate some * .c and * .h
  • build: eclipse will not create these automatically generated files

If I compile again, these files will be compiled. Perhaps this is due to the process of detecting which eclipse files will be compiled. Before starting the compilation, we do not have these automatically generated * .c and * .h files.

The second time we compile, we already have these automatically generated files, so these files are compiled.

+6
source share
2 answers

If you want full control over how the custom build step is performed, what files need to be updated after it, the environment, the working directory, etc. Do not specify it as a simple pre-assembly step. Go to project properties β†’ Builders β†’ Create ... and select "Program".

In the dialog box that appears, you greatly control the execution of your tool. For example, you can run your tool when the XML file is saved, and you can say that eclipse updates all automatically generated files whenever it runs.

+5
source

If I understand your question correctly, it seems that creating your project for the first time will automatically generate the necessary * .c and * .h source files, but the project will not be completely created because these source files were not found immediately. After a short delay, Eclipse recognizes that new files have been added to the project, and you can build a second time and everything will work fine. Does this sound right?

Assuming this is the case, I thought that I needed to write some kind of script or makefile so that all these actions could be performed in the correct order with a single action. Depending on how dirty you want to get it, here is the link :)

http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.cdt.doc.user/concepts/cdt_c_makefile.htm

0
source

Source: https://habr.com/ru/post/893512/


All Articles