The best approach to this workflow is to create a custom target file which includes a set of rtwoptions allowing the separate specification of standard includes and legacy code includes. This can then be linked to a custom TMF variable which can be used appropriately in the code. You can find a general summary of this workflow in our documentation using the link below:
A summary of the steps which need to be taken are shown below:
1) Define an element in the 'rtwoptions' file to capture the location of the directory
rtwoptions(2).prompt = 'Custom Legacy Code Directory';
rtwoptions(2).type = 'Edit';
rtwoptions(2).enable = 'on';
rtwoptions(2).default = 'C:\LegacyCodeInc';
rtwoptions(2).popupstrings = '';
rtwoptions(2).tlcvariable = 'CustomLegacyCodeDir';
rtwoptions(2).tooltip = '';
rtwoptions(2).callback = '';
rtwoptions(2).opencallback = '';
rtwoptions(2).closecallback = '';
rtwoptions(2).makevariable = 'CUSTOM_LEGACY_CODE_DIR';
2) Modify your TMF in order to expand the CUSTOM_LEGACY_CODE_DIR makevariable
# Additional file include paths
|>START_EXPAND_INCLUDES<|
MATLAB_INCLUDES = $(MATLAB_INCLUDES);|>EXPAND_DIR_NAME<||>END_EXPAND_INCLUDES<|
ADD_LEGACY_INCLUDES = |>CUSTOM_LEGACY_CODE_DIR<|;
INCLUDE = .;$(RELATIVE_PATH_TO_ANCHOR);$(MATLAB_INCLUDES); $(ADD_LEGACY_INCLUDES); $(INCLUDE)
!if "$(SHARED_SRC_DIR)" != ""
INCLUDE = $(INCLUDE);$(SHARED_SRC_DIR)
!endif
After expansion, the code above will appear as the following
# Additional file include paths
MATLAB_INCLUDES = $(MATLAB_INCLUDES);$(START_DIR)\bouncing_ball02302873_legacy_include_rtw
MATLAB_INCLUDES = $(MATLAB_INCLUDES);$(START_DIR)
MATLAB_INCLUDES = $(MATLAB_INCLUDES);$(MATLAB_ROOT)\toolbox\physmod\mech\c
MATLAB_INCLUDES = $(MATLAB_INCLUDES);$(MATLAB_ROOT)\toolbox\physmod\common\foundation\core\c
ADD_LEGACY_INCLUDES = C:\LegacyCodeInc;
INCLUDE = .;$(RELATIVE_PATH_TO_ANCHOR);$(MATLAB_INCLUDES); $(ADD_LEGACY_INCLUDES); $(INCLUDE)
!if "$(SHARED_SRC_DIR)" != ""
INCLUDE = $(INCLUDE);$(SHARED_SRC_DIR)
!endif
Best Answer