Difference between revisions of "STRIDE Extensions for Visual Studio"

From STRIDE Wiki
Jump to: navigation, search
(Prerequisites)
(Introduction)
Line 1: Line 1:
 
== Introduction ==  
 
== Introduction ==  
If you are using the STRIDE desktop Framework for Windows, an alternative to the [[Building_an_Off-Target_Test_App | standard method]] of building test apps (using ''make'') is to use the STRIDE Rules file for Visual Studio.
+
If you are using the STRIDE desktop Framework for Windows, an alternative to the [[Building_an_Off-Target_Test_App | standard method]] of building test apps (using ''make'') is to use the STRIDE Extensions for Visual Studio.
  
 
== Prerequisites ==
 
== Prerequisites ==

Revision as of 16:30, 9 June 2011

Introduction

If you are using the STRIDE desktop Framework for Windows, an alternative to the standard method of building test apps (using make) is to use the STRIDE Extensions for Visual Studio.

Prerequisites

  • Visual Studio 2005 or later (an express distribution is fine)
  • a recent version of the STRIDE Framework installed including a recent version of Perl
  • a static library version of the runtime built using the source files included in the SDK. This is accomplished by just running make on the makefile that we provide in the SDK\Windows\src directory (the default makefile target builds the static runtime library).

Creating Off-Target Test App Projects

The following instructions describe the steps required to create sandbox target applications on windows. You will likely need additional source code and project settings as required to make your specific application code build.

  1. Create a new C/C++ Win32 Console application project. All versions of Visual Studio provide a project wizard to do this. If you are given an option to use precompiled headers in the project, select No.
  2. Assign the stride rules file to this project. Select the Project -> Custom Build Rules... menu item to launch a dialog to import this rules file located at stride\SDK\Windows\settings\stride.rules. After associating the stride rules file with your project, make sure you also enable the rule for your project (typically by selecting the check-box next to its name).
  3. Add your application, test and SCL source code to the project. Any header files that are in the project will be automatically processed by the STRIDE SCL compiler. If there are some header files that contain no SCL statements, then we recommend disabling the build step for these files. This is typically done via the properties dialog for a file by setting the "General" | "Exclude from build" property to "Yes". In order to get an appropriate main function, you will also need to add the stride\SDK\Windows\src\TestApp.c to the project.
  4. Change the C/C++ Properties for the project:
    • Disable detection of 64-bit portability issues [typically found in the General section].
    • set the runtime library to Multi-threaded DLL (/MD) [typically found in the Code Generation section].
    • Add Additional Include Directories to your project [typically found in the General section]:
      $(STRIDE_DIR)\SDK\Runtime
      $(STRIDE_DIR)\SDK\Windows\src
      [path(s) to other application and test source headers]
      
    • Add the following to the preprocessor definitions [typically found in the Preprocessor section]:
      STANDALONE_TESTAPP 
      STRIDE_ENABLED  
      STRIDE_STATIC
      
    • Disable precompiled headers for the project (or selectively disable them for STRIDE-generated files) [typically found in the Precompiled Headers section].
  5. Change the Linker Properties for the project:
    • Add Additional Library Directories [typically found in the General section]:
      $(STRIDE_DIR)\SDK\Windows\out\lib
      
    • Add Additional (linker) Dependency [typically found in the Input section]:
      stride.lib
      ws2_32.lib   
      winmm.lib
      
  6. Set the STRIDE Compile-Instrument properties for the project:
    • Set the Compile Options File to $(STRIDE_DIR)\SDK\Windows\settings\stride.s2scompile. This file provides basic options for windows off-target apps. If you require different or additional parameters to be passed to the STRIDE SCL compiler, then we recommend that you make a local copy of the provided settings file and set this property to your private (and modified) version. The size and alignment settings in the provided file are correct for standard 32 bit Windows platforms.
    • The default Intercept generation assumes STUB settings for all captured functions. If you require different settings for any of your interfaces, you should create a text file containing the additional settings to assign the path to this file for the Intercept Options File property.
    • Add directories to the Include Directory property as needed to allow the STRIDE SCL compiler to process your source code. You can often use the same values here that you have previously set in the C/C++ compiler settings for your project.
    • Add preprocessor defines to the Defines property as needed to allow the STRIDE SCL compiler to process your source code. You can often use the same values here that you have previously set in the C/C++ compiler settings for your project.
  7. Repeat steps 4-6 for all project configurations you want to build (e.g., Debug, Release).
  8. Build your project once to generate the STRIDE intercept module source files. You will get linker errors during this build since you have not yet added the generated STRIDE intercept code.
  9. Add the generated source file - strideIM.cpp - to your project. This file will be located in the $(ProjectDir) directory. If you are using the STRIDE rules file (as described in step 2 above), you also need to add the following generated header files to your project: strideIM.h and strideIMEntry.h. Since these header files are generated, we do not want the STRIDE rule to attempt to process them (rather, they are in the project so that Visual Studio can properly calculate dependencies). As such, you should also set the Excluded from build property on these two header files to yes (this property is accessible by right clicking on the header file in the solution explorer view and selecting Properties)
  10. Rebuild your project and resolve any compiler errors/warnings.
  11. NOTE: As you add more header source files to the project, they will be automatically processed by the stride compiler unless you explicitly exclude them from the build. As you add sources, you will likely also need to add additional include and preprocessor defines to the STRIDE compile-instrument settings in order to successfully build.