Semmle 1.20
Skip to end of metadata
Go to start of metadata

This topic describes how to change the locations used to checkout source code or build a project.

Task overview

Each project needs to be able to checkout or update source files and then build these source files. By default, the source files are stored and built in a directory named src stored within each snapshot directory. All checkout and build commands defined in the project file run from this default source location unless specified otherwise. As long as a local checkout and build can be performed in any location, we recommend that you do not change this setting.

In some systems, it may be impossible to build the software from the default src directory. This may be because:

  • checkout process requires a fixed location,
  • build process requires a fixed location, or
  • other issues, such as excessive path length, prevent a build from working properly from arbitrary locations.

In these cases, the source location can be overridden by editing the project file.

Overriding the default source location

You can override the default source location by adding a source-location element and using it to define a detached directory.

To override the default source location
  1.  Edit the project configuration file (stored in odasa/projects/Project_Name or SEMMLE_HOME/projests/Project_Name).
  2. Add a source-location element to the autoupdate section; for example:
    <source-location>/users/example/source_code</source-location>
  3. The directory specified by the source-location element must already exist.
  4. Save the project configuration file.

Note: any files that are not located under the directory specified by the source-location element will not be indexed, regardless of whether or not they are used in the build, so it is important that this directory contains all the files of interest.

Example

For a project file that includes the following checkout and build commands:

Basic <Autoupdate> section of a project file
  <autoupdate>
    <checkout>svn co "http://svn.ruby-lang.org/repos/ruby/trunk" ${src}</checkout>
    <build>make clean</build>
    <build index="true">make</build>
    <build>odasa duplicateCode --ram 2048 --minimum-tokens 100</build>
    <days-between-updates>1</days-between-updates>
  </autoupdate>

You could define a new source location as follows:

Revised <Autoupdate> section of a project file
  <autoupdate>
    <checkout>svn up "http://svn.ruby-lang.org/repos/ruby/trunk" ${src}</checkout>
    <build>make clean</build>
    <build index="true">make</build>
    <build>odasa duplicateCode --ram 2048 --minimum-tokens 100</build>
    <source-location>/home/example/Ruby_source</source-location>
    <days-between-updates>1</days-between-updates>
  </autoupdate>

where /home/example/Ruby_source is the absolute path to the required source location. Notice that the call to the Subversion repository in the revised autoupdate section has also been changed from 'checkout' to 'update'. This change may not be suitable for all systems but can be used in a detached directory to avoid checking out the entirety of a large code base every night - instead, only the changed files are downloaded.

After you define an alternative source location

All newly added snapshots will then use the specified source location. This means that the source files for each new snapshot are checked out/updated in the same source location, and therefore that the source files will be overwritten each night as part of the update process. A copy of the source files is archived as part of the Semmle analysis process but this is available only to the client applications for the display of code violations.

The ${src} variable expands to the actual source location of the snapshot: either the value of the source-location element, if it is defined, or the src directory in the snapshot.

Please see Tutorial: Advanced project creation for an example of a detached directory.

Defining an alternative build location

You can override the default build location for any build command by defining the dir property for the <build> element. The dir property is always defined relative to the source location for the project (${src}).

To override the default build location
  1. Edit the project configuration file (stored in odasa/projects/Project_Name or SEMMLE_HOME/projests/Project_Name).
  2. For each build command that needs to be run from a different directory, define a dir property; for example:
    <build dir="${src}/build" index="true">make</build>
  3. The directory specified by the dir property must already exist.
  4. Save the project configuration file.

Example

For a project file that includes the following checkout and build commands:

Basic <Autoupdate> section of a project file
  <autoupdate>
    <checkout>svn co "http://svn.ruby-lang.org/repos/ruby/trunk" ${src}</checkout>
    <build>make clean</build>
    <build index="true">make</build>
    <build>odasa duplicateCode --ram 2048 --minimum-tokens 100</build>
    <days-between-updates>1</days-between-updates>
  </autoupdate>

You could define a new build location as follows:

Revised <Autoupdate> section of a project file
  <autoupdate>
    <checkout>svn up "http://svn.ruby-lang.org/repos/ruby/trunk" ${src}</checkout>
    <build dir="${src}/build">make clean</build>
    <build dir="${src}/build" index="true">make</build>
    <build dir="${src}/build">odasa duplicateCode --ram 2048 --minimum-tokens 100</build>
    <days-between-updates>1</days-between-updates>
  </autoupdate>

where ./build is the relative path required by the build command. Notice that all three build commands have been updated to include the dir property because they all need to run from the same location. If the project file included build commands that did not need to be run from the build sub-directory then you would omit the dir property from those build elements.