This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

read a text file while invoking compiler commands through batch

hi,

I  am trying to create a .bat file which tries to invoke the msp430_4.4.5 compiler and builds my project

I have saved the necessary includes for compilation in a separate .txt  file, and I want to use this file while I invoke the compiler command .. in order to successfully compile my project .

would like to know if this is possible and how ...

thanks & regards

  • Maisie Fernandes said:
    I have saved the necessary includes for compilation in a separate .txt  file

    I'm not sure what you mean here.  Describe it in more detail.  Create a very small example that does this.

    Thanks and regards,

    -George

  • okay ,

    So here I am trying to invoke the compiler using the compiler commands through command prompt.

     The compiler used : ti-cgt-msp430_4.4.5 (msp430 compiler)

    an example to compile two source files through command prompt is shown below :

    here it is seen that the command "cl430" is used invoke the compiler ,after which the source files must be specified that  need to be compiled, then the include paths are specified, and lastly the environment variables and the path to place the object file is specified.

    the entire command successfully compiles the sources files and we get the respective object files.

    Now suppose we have a number of source files to be compiled and many includes paths too, it would be cumbersome and the command length would be large. so, I want to write a separate text file which will have all the source files and a separate text file for the include paths and then call these two files in the command line.

    There is a command  " set MSP430_C_DIR "  which can set the variable "MSP430_C_DIR"  with all the include paths which are required to compile the source files.

    used as follows ;

     this is tried successfully .

    Similarly I tried to get all the source files to be stored in a variable and then use it with the cl430 command. but that wouldn't work ...

    Would like to know if there is any other way out ..?

    Thanks and Regards

  • The best solution is to use the option --cmd_file=name_of_text_file .  Read about it in the MSP430 compiler manual.  Once you understand it, I don't think you will continue to use MSP430_C_DIR.  But the manual also describes how to use that environment variable.

    Thanks and regards,

    -George

  • Hi George ,

    Thank you very much for the prompt reply ..

    I tried using it for a simple example where I specified the source file through a .txt and it very well worked.

    However now I need to use three text files 1) one having all the sources files 2) one having the include paths and 3) having the environment options.

    ((For example three text files namely : source.txt ; include.txt ; options.txt))

    I did not very well understand how to use the command , as well as how to mention the paths/options in the text file (particular syntax)

    I get a compilation error when I try to follow the method given by the compiler guide;

    Thanks and Regards

    Maisie

     

  • Hi,
    What I would like to know as well is ....
    I generated text file which includes all the header files that I require to compile my project ..
    I was trying to use this file along the with the "cmd_file" option.... but this doesn't seem to be working .
    Is it necessary to mention only the paths along with the command "--include_path" (eg: --include_path= d:/project/xyz )cant we mention all the header files required (eg: d:/project/xyz/file.h) ??

    Thank you

    Maisie
  • No, you cannot put the header file names on the command line or in a command file. You must include them from a C or C++ source file, or another header file.

    You can use as many compiler command files as you like; the contents of the command file are treated as extra options to the compiler.
  • Hi,
    Thank you very much for the reply..
    Now I know how to use the "--cmd_file" option

    Would like to know if we can use any Variable which stores the contents of the text file (text file containing the source files to be compiled) and use it along with the command "cl430" ?
    I believe the use of the command would further simplify..

    Thank you once again
    Regards
  • Maisie Fernandes said:
    Would like to know if we can use any Variable which stores the contents of the text file (text file containing the source files to be compiled) and use it along with the command "cl430" ?

    Such a feature is not supported by the compiler.  You can do things like that in make files.

    Thanks and regards,

    -George

  • hi,

    I have tried to read the contents of the text file, stored it in a variable and then used that variable in cl430.
    It works fine.

    Thank you so much for the help
    Regards,
    Maisie