Examples

This section contains a few examples of how to use the SNAPbuild command-line tool. See snapbuild:index for more details.

Basic Usage

To build a SNAPpy script named MyTestScript.py for a Synapse SM220UF1 module running SNAPcore firmware version 2.7.2, the command would look like this:

snapbuild -m SM220UF1 -c 2.7.2 MyTestScript.py

This will create a MyTestScript.spy SNAPpy image file and a MyTestScript.map map file in the current directory.

Verbosity

To view more info about the build, a -v (or --verbose) option can be appended:

$ snapbuild -m SM220UF1 -c 2.7.2 MyTestScript.py -v
2016-03-22 22:16:11,211 INFO     __main__ Defaulting platform to `SM220`
2016-03-22 22:16:11,213 INFO     __main__ Building SNAPpy file from: MyTestScript.py
2016-03-22 22:16:11,213 INFO     __main__ SNAP Module Type: SM220UF1
2016-03-22 22:16:11,213 INFO     __main__ User Platform: SM220
2016-03-22 22:16:11,214 INFO     __main__ SNAP Core version: 2.7.2
2016-03-22 22:16:11,233 INFO     __main__ Generated: MyTestScript.spy
2016-03-22 22:16:11,233 INFO     __main__ SNAPpy CRC: 0x6ea4

To view even more verbose information, append additional -v flags:

snapbuild -m SM220UF1 -c 2.7.2 MyTestScript.py -vv

Include Paths

If a SNAPpy script imports from other files that are not in the current directory, those import paths need to be specified using the --Include (-I) option. For example, if MyTestScript.py has the line:

from MyCommonLibrary import *

and MyCommonLibrary can be found at /usr/local/lib/, the SNAPbuild command would need to specify that path:

snapbuild -m SM220UF1 -c 2.7.2 MyTestScript.py --Include /usr/local/lib/

Platform Constant

The platform constant used in SNAPpy scripts for compile-time decision-making is an optional argument. By default, the platform constant will be set based on the module type (the -m or --module-type parameter). If a script needs the platform constant to be something other than the default, it is easily specified using the --platform option:

snapbuild -m SM220UF1 -c 2.7.2 MyTestScript.py --platform XQ550

Output Specification

To save the output files resulting from a build of MyScript.py, but with the names MyScript_v1.0.spy and MyScript_v1.0.map, the following command can be used:

snapbuild MyScript.py -m RF200PF1 -c 2.7.2 -o MyScript_v1.0

If the output files need to be saved in a different directory a command like this might be used:

snapbuild MyScript.py -m RF200PF1 -c 2.7.2 -o compiled/MyScript_v1.0

Disallow Warnings

After adding the -Wall flag, all warnings flagged by SNAPbuild will be treated as errors and will cause the build to fail:

snapbuild -m SM220UF1 -c 2.7.2 MyTestScript.py -Wall