Running a Post Operation Script

A post operation script is a script or executable that is executed after the completion of the generation process, irrespective of its success or failure.

You can add a post operation script to all operations, except code reverse.

  1. Create any type of operation configuration (except code reverse). For example, create a C code generation configuration.
  2. From the diagram viewer, double-click a configuration diagram to display the Specification Properties dialog box.

  3. To edit the Post Operation Script, click Edit and then browse for a script.

    Example of a Windows (.bat) script:

    @echo off
    echo MD_GEN_CONF_NAME=%MD_GEN_CONF_NAME%
    echo MD_GEN_CONF_ID=%MD_GEN_CONF_ID%
    echo MD_PROJECT_NAME=%MD_PROJECT_NAME%
    echo MD_OP_EXIT_CODE=%MD_OP_EXIT_CODE%
    echo MD_GEN_LOCAL_PATH=%MD_GEN_LOCAL_PATH%
    echo SOP_LOCAL_WORKSPACE_PATH=%SOP_LOCAL_WORKSPACE_PATH%
    echo MD_INSTALL_ROOT=%MD_INSTALL_ROOT%
    echo MD_PROJECT_DIR=%MD_PROJECT_DIR%
    
    IF %MD_OP_EXIT_CODE% == 0 (
    echo "Operation executed successfully"
    ) ELSE (
    echo "Operation execution failed"
    )
    

  4. Execute your operation; the script is launched after the execution.
    The following environment variables are set during this process:
    Variable Description
    MD_GEN_CONF_NAME Name of the generation configuration
    MD_GEN_CONF_ID Identifier of the generation configuration
    MD_PROJECT_NAME Project name
    MD_OP_EXIT_CODE Exit code returned by the generation execution
    MD_GEN_LOCAL_PATH Path to the folder where the code is generated
    SOP_LOCAL_WORKSPACE_PATH Local workspace path configured in Options > Project > Software Producer
    Notes:
    • The path variables defined in Options > Environment > Path Variables are exposed.
    • Variable names are converted to uppercase, prefixed with MD_, and any dots are replaced with underscores. Examples:
      • install.root → MD_INSTALL_ROOT
      • project.dir → MD_PROJECT_DIR