Running a user tool on all files in a directory

Running a user tool on all files in a directory

1029
Power UserPower User
1029

    Oct 21, 2010#1

    Hi,
    I've been searching the forums but haven't found the answer to this. I have my files and directories set up in a number of Projects, and for each project have a number of user tools defined to compile, assemble and link the code. Each tool has a hot key defined, and also an icon on the tool bar, so for individual compiles or assembles I can simply click the relevant icon. However I'd like to be able to do a bulk compile or assemble of all the files in a directory, running the applicable user tool against each one. How do I go about setting this up?

    Running UES 10.20.0.1001, and UE 16.20.0.1001 on Win 7 X64.

    Thanks...

    Frank

    6,603548
    Grand MasterGrand Master
    6,603548

      Oct 21, 2010#2

      Well, that process is named Build process using a makefile. Because UEStudio is an IDE and not just a text editor it has the feature to create on the fly a makefile (batch file) next executed when you execute the command Build or Rebuild from the toolbar, the menu or by hotkey. The command Compile makes only the first step of a build process, it compiles the current file to an object file.

      So instead of your user tools it would be best to create a config file containing all your commands to be able to use the commands Compile, Build and Rebuild. With the config file you define the commands required to compile a file with extension .C using a C/C++ compiler first for example to an assembler file with extension .SRC compiled next with an assembler to an object file. You define in the config file also which commands are necessary to compile a file with extension .ASM to an object file. And so on for every other file type.
      Further you define in the config file which additional commands are necessary to link and locate all the object files together to an application or library. For embedded firmware further commands can be specified for the Build process to create Intel HEX files or files for a debugger/emulator after successful link/locate, or even upload and program the just created firmware into the target device, or start the debugger with the just created output, or whatever you want to do after successfully "building" the output. The build process is smart enough to first check if the object file for a source code file already exists or not and when it exists, if the file date of the object file is newer than the file date of the source code file. If object file for a source code file is present and newer than source code file, then this file must not be compiled again and next project file is evaluated next.
      The Rebuild process is the same as the build process with only 1 difference, all object files are deleted first which results automatically in compiling all source code files again to object files.

      So my first suggestion is to take the time and look into existing config files of UEStudio and help of UES and try to create such a config file using the commands you have already defined as user tools. That makes it later possible to use the commands compile, build and rebuild for all your projects without the need to adapt something all time for your various projects using the same tools.

      But if you want to use your existing project tools to create on the fly your own makefile you have to develop a script (or macro, but script is better). It is possible to call user and project tools from within a script. It is also possible to get a list of project files from within a script using my function GetListOfFiles. So you have the possibility to write a script which first gets a list of project files, and next run your tools on each file depending on your own rules packed as code into the script.

      But there is one big difference between using a config file in UES and its ability to create a makefile for a build process and execute it in comparison to your own makefile using a script: the build process is 1 batch job and all the output to stdout and stderr devices of all the console tools executed within this batch job is captured and displayed in the output window for easy evaluting the result of the build process and fix mistakes in source code. When using a script and calling each project tool from within the script on every project file the output window contains only the output of last called project tool. Also the script interpreter writes by default to the output window. It would be possible to collect all the tool outputs by the script itself because from within a script you have access to content of output window, and as final step write all the collected outputs of the tools at once to the output window. But all that needs a lot of script coding and without knowing your tool chain I think it would be really easier to create a config file and let UES do the job for creating and executing the makefile according to the commands you have defined in the config file.

      I have written here for C/C++ projects with assembler files because I think you are also a programmer. But in general a config file could be used for everything. For example it can be used to define commands to convert with command "compile" the active file with an UE script or UE macro executed in a separate instance of UE/UES, or console application, or vb script or whatever executable from format A to format B. The build process would than do that for all project files. You always have to take into account that a config file is just a set of rules how to build a batch file (script). It is up to you what the batch file named makefile contains and therefore what happens.
      Best regards from an UC/UE/UES for Windows user from Austria

      1029
      Power UserPower User
      1029

        Oct 21, 2010#3

        Mofi, thanks for the detailed response. I'll look into the config file option. The tools I use are the compiler, assembler and pre-linker from Dignus (www.Dignus.com) used to build programs for MVS. The compiler templates supplied with UES I've seen all seem to be targeted at Windows development. There might be something there that I can use as a starting point.

        Cheers...

        Frank

        6,603548
        Grand MasterGrand Master
        6,603548

          Oct 22, 2010#4

          Most of the preinstalled configs are for compilers creating applications or libraries for Windows, but some are also for compilers of controllers used in embedded systems. However, with Cmdx = you define the command(s) used and therefore as I wrote you can do anything you want. I'm quite sure that you will have success to create a working config file for your need.
          Best regards from an UC/UE/UES for Windows user from Austria