Scope development procedures
Here you can find short procedures for common processes developers need to know about when working with scopes.
Creating a scope
In the Ubuntu SDK, simply create a new project using the Unity Scope Template.
File > New File or Project > Unity Scope Template
Tip: During project creation the build kit wizard page displays. Note that when you build the scope, the generated build is placed by default in the parent directory in a directory that starts with ‘build-’ and completes with the project name followed by ‘-Desktop-Default’. For example, if your scope project is named ‘myscope’, your build directory is ../build-my-scope-Desktop-Default.
Tip: For help installing the Ubuntu SDK and creating projects, see Ubuntu SDK Tutorials.
Opening a scope SDK project
Scope projects use CMake for building. CMake projects have a CMakeLists.txt file in the root directory (and in many other project directories).
You can open scope projects from the Ubuntu SDK with the Ctrl + O shortcut and then navigating to and selecting the CMakeLists.txt file in the project’s root directory.
Opening a scope branch in the SDK as a project
If you have a branch or directory that is a scope source tree that is not an already an SDK project, you can open it and create an SDK project from it, as follows:
- Ctrl + O to open a file or project (or use the File > Open File and Project menu).
- Navigate to and select the CMakeLists.txt file in the source tree, then click the Open button.
- In the Configure Project dialog that displays, click the the Configure Project button.
Building a scope
In the Ubuntu SDK, simply select Build > Build Project MYSCOPE. (You can also use Ctrl + B) This creates the build directory, which by default is next to the scope project directory and starts with ‘build-’, as described above.
You can also build from the terminal. Move to the build directory (after it is created by building at least once from the SDK) and run: cmake && make
Successful builds generate the following important files in the separate build directory:
- BUILDDIR/src/llibMYSCOPE.so: the scope’s shared object used by clients that call the scope
- BUILDDIR/src/llibMYSCOPE.ini: the file used to launch the scope, as discussed next.
Running a scope
You can run your scope locally from your build directory (even if your Desktop uses Unity 7).
You need the unity-scope-tool and unity8-fake-env debian packages installed:
$ sudo apt-get install unity-scope-tool unity8-fake-env
Tip: There are plans to install this package automatically with the SDK by a dependency soon, so it may already be installed for you. Running the above command is not a problem in either case.
To run a scope from terminal, simply use the unity-scope-tool followed by the path to your scope .ini file (which is in src/):
$ unity-scope-tool src/myscope.ini
Tip: There are plans to allow running the scope from the SDK with Ctrl + R.
This runs the scope in a window with the scope’s search results displayed on the left and some development features on the right.
Here’s a screenshot of a scope run from the unity-scope-tool.
- The scope name displayed in the header is derived from the .ini file
- The left half of the run window is the scope. (Only this displays during execution of a deployed scope.)
- The right half is provided by the unity-scopes-tool for development purposes. It allows you to modify the scope in various ways. For example, you can click Override category to edit a Category template that controls how results are displayed. You can from “grid” to “carousel”, although this has no visible effect when there is only a single result (as with the a new default scope project) . But try it later when your scope generates lots of results.