Using Eclipse 4.5 (Mars) on Windows 7: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
Line 315: Line 315:


  'Run' -> 'Run'
  'Run' -> 'Run'
Output from the run will be displayed in the 'Console' window.
Change the run focus.
  'Run'
  Click on 'Run configurations...'.
  Select a configured script under 'Python Run'.
  'Run'


Output from the run will be displayed in the 'Console' window.
Output from the run will be displayed in the 'Console' window.

Revision as of 01:54, 29 August 2015

Introduction

After completing these installation instructions, you will have an IDE for GRASS that will allow you to perform that following development tasks:

Workbench

  • Switch between C/C++, Python, Debug and SVN perspectives

Browsing

  • Navigate the GRASS source code trunk
  • Edit source code
  • Select a symbol and go to to its declaration

Building

  • Build the entire GRASS system
  • Build an individual GRASS module

Running

  • Run GRASS modules and Python scripts

Debugging

  • Set breakpoints
  • Single step through source code
  • View variables and memory values

Versioning

  • Commit source code to the SVN repository
  • Update source code from the SVN repository

Install TortoiseSVN

Download and install from the TortoiseSVN Website.

During installation, include the "entire command line tools" so that "svn up" can be run from a Windows Command Prompt or MSYS shell.

The following path should have been added to PATH:

C:\Program Files\TortoiseSVN\bin

From Command Prompt, enter the following command:

>where svn

To run "svn up" from a Command Prompt, enter the following commands:

>cd C:\OSGeo4W\src\grass7_trunk
>svn up

To run "svn up" from a MSYS shell, enter the following commands:

$ export PATH=$PATH:/c/"Program Files"/TortoiseSVN/bin
$ cd /c/OSGeo4W/src/grass7_trunk
$ svn up

Install OSGeo4W Runtime and Development Framework

Download and install the 32bit version from the OSGeo4W Website.

It will be installed in this directory:

C:\OSGeo4W

Checkout GRASS Source Code and Make Debug Build

Checkout the GRASS development branch using the SVN command from the GRASS Download Website.

Open a MSYS shell.

$ cd /c/OSGeo4W/src
$ export PATH=$PATH:/c/"Program Files"/TortoiseSVN/bin
$ which svn
$ svn checkout https://svn.osgeo.org/grass/grass/trunk grass7_trunk

Run a 'debug' build.

$ cd /c/OSGeo4W/src/grass7_trunk
$ export CFLAGS='-g -Wall'
$ ./mswindows/osgeo4w/package.sh

This will take some time to complete.

Build activity is logged to this file:

C:\OSGeo4W\src\grass7_trunk\mswindows\osgeo4w\package.log

Install Doxygen and Make Documentation

Install latest Doxygen binary distribution for Windows.
Download and install from the | Doxygen Website.

Install latest Graphviz binary distribution for windows.
Download and install from the | Graphviz Website.

Install latest basic TeX/LaTeX system for Windows.
Download and install from the | MikTeX Website.

After the TeX/LaTeX system is installed, and during the first time "make pdfdocs" is run, expect to be prompted for additional packages that must be installed to complete the TeX/LaTex system.

Open a MSYS shell.

$ export PATH=$PATH:/c/"Program Files"/doxygen/bin
$ export PATH=$PATH:/c/graphviz-2.38/release/bin
$ export PATH=$PATH:/c/"Program Files (x86)"/"MiKTeX 2.9"/miktex/bin
$ echo $PATH
$ cd /c/OSGeo4W/src/grass7_trunk/
$ make htmldocs
$ make pdfdocs

Open the HTML formatted documentation using a web browser:

file:///C:/OSGeo4W/src/grass7_trunk/html/index.html

Install Eclipse Mars

Download and install the 32bit version of Java SE Runtime Environment (JRE) from the Java Download Website
Download and install the 32bit version of Eclipse IDE for C/C++ Developers from the Eclipse Mars Download Website

Install PyDev Plug-In

Start Eclipse.

Help -> Install New Software...
Select "Add..".
Enter "PyDev" in the "Name: field.
Enter "http://pydev.org/updates/" in the Location" field.
"OK"
Check the "PyDev" option.
"Next"
"Next"
Accept the license agreement.
"Finish"

Restart Eclipse.

Install SVN Plug-In

Start Eclipse.

Install SVN plug-in.

Help -> Install New Software...
Set "Work with:" to "Mars - http://download.eclipse.org/releases/mars".
Expand "Collaboration".
Scroll down and put a check mark in the "Subversive SVN Team Provider option.
"Next"
"Next"
Accept the license agreement.
"Finish"

Restart Eclipse.

When "Subversive Connector Discovery" prompts you for a selection, check "SVN Kit 1.8.10".
"Finish"
"Next"
"Next"
Accept the license agreement.
"Finish"
"OK" to the "security Warning".

Restart Eclipse.

Make SVN visible.

Window → Perspective → Customize Perspective...
Select the "Action Set Availability" tab.
Check the "SVN" option under "Available action sets".
"OK"
Window → Perspective → Customize Perspective...
Select the "Shortcuts" tab.
Check the "SVN" option under "Shortcut Categories".
Select the "Menu Visibility" tab.
Check the "SVN" option under "Menu Structure".
Select the "Tool Bar Visibility" tab.
Check the "SVN" option under "Tool Bar Structure".
"OK"

You should now see "SVN" on the main tool bar and the SVN tool bar available under the main toolbar.

Configure Eclipse Settings

Enable C/C++ Perspective

Window -> Perspective -> Open Perspective
Select 'Other...'
Select 'C/C++'
'OK'

Enable Python Perspective

Window -> Perspective -> Open Perspective
Select 'Other...'
Select 'PyDev'
'OK'

Enable Debug Perspective

Window -> Perspective -> Open Perspective
Select 'Other...'
Select 'Debug'
'OK'

Enable SVN Perspective

Window -> Perspective -> Open Perspective
Select 'Other...'
Select 'SVN Repository Exploring'
'OK'

Insert Spaces for Tabs

Window -> Preferences -> General -> Editors -> Text Editors
Set 'Displayed tab width' to 4.
Check 'Insert spaces for tabs'.
'Apply'
'OK'
Window -> Preferences -> C/C++ -> Code Style -> Formatter
Select the 'New' button to create a new profile.
Enter 'GRASS' in the 'Profile name' field.
Select 'OK'.
Select the 'Indentation' tab.
Under 'General settings', set Tab policy to 'Spaces only'.
'OK'

Uncheck Build Automatically

'Project' -> 'Build Automatically' to uncheck this option.

Change Color of Python Comments

Window -> Preferences
Expand 'PyDev'.
Select 'Editor'.
In the 'Appearance color options' window:
  Scroll down to 'Comments' and select.
  Click on the 'Color' button to bring up options.
  Select the green color that is located in the 3rd column from the left and 4th row from the top.
'OK'
'Apply'
'OK'

Create C/C++ Project

Create a C++, Makefile, Empty project

"File" -> "New" -> "Project..."
Expand "C/C++" option.
Select "C++ Project"
"Next"
Uncheck 'Use default location'.
Browse to 'C:\OSGeo4W\src\grass7_trunk'.
'OK'
Enter 'grass7_trunk' in the "Project name" field.
Expand 'Makefile project' under 'Project type'.
Select 'Empty Project' under 'Project type'.
Select 'MinGW GCC' under 'Toolchains'.
"Next"
Click on 'Advanced settings...'
Click on 'C/C++ Build'.
Click on the 'Behavior' tab.
Leave 'Build (Incremental Build)' Checked.
Enter 'default' in the text box next to 'Build (Incremental Build)' replacing any text that is already there (e.g., 'all').
'Apply'
'OK'
'Finish'

The 'grass7_trunk' project will appear in the 'Project Explorer' view.

The 'C/C++ Indexer' operation will take some time. Its progress can be monitored in the lower right-hand corner of the screen. Click on the rectangles in the corner to display progress details.

Create Top-Level Make Targets

 Right-click on 'grass7_trunk' in the 'Windows Explorer' view.
 Select "Make Targets"
 Select "Create..."
 Enter 'default' in the 'Target name' field.
 'OK'

Do the same for each of the following targets:

install
clean
distclean
libs
libsclean
cleandistdirs
cleanscriptstrings
manifests

Run a GRASS Python Module

Open Project.

Right-click on 'grass7_trunk' in the 'Windows Explorer' view.
Click on 'Open Project'.
The Indexer and SVN cache updates will take a moment to complete.

Configure Script.

Click on 'Run' on the main task bar.
Hover over 'Run As' and select 'Run configurations...' from the pop-up list.
Right-click on 'Python Run' and select 'New'.
Enter 'm.proj.py' in the 'Name' field.
Click the 'Project' 'Browse...' button.
Select 'grass7_trunk'.
'OK'
Click the 'Main Module' 'Browse...' button.
Scroll down and enter the 'scripts' -> 'm.proj' folder and select 'm.proj.py'.
'OK'
Select the 'Arguments' tab.
Enter the following string in the 'Program arguments' window:
coordinates=-111d30,45d15.551666667N proj_out="+proj=utm +zone=10 +datum=NAD27" proj_in="+proj=latlong +datum=NAD83" --v
'Apply'
'Run'

Output from the run will be displayed in the 'Console' window.

Run Script.

'Run' -> 'Run'

Output from the run will be displayed in the 'Console' window.

Change the run focus.

 'Run'
 Click on 'Run configurations...'.
 Select a configured script under 'Python Run'.
 'Run'

Output from the run will be displayed in the 'Console' window.

Run a GRASS C Module

Open Project.

Right-click on 'grass7_trunk' in the 'Windows Explorer' view.
Click on 'Open Project'.
The Indexer and SVN cache updates will take a moment to complete.

Configure Application.

Click on 'Run' on the main task bar.
Select 'Run configurations...' from the pop-up list.
Right-click on 'C/C++ Application' and select 'New'.
Enter 'r.univar' in the 'Name' field.
Click the 'Project' 'Browse...' button.
Select 'grass7_trunk'.
'OK'
Click the 'C/C++ Applications' 'Search Project...' button.
Scroll down and select 'r.univar.exe'.
'OK'
'Apply'
Select the 'Arguments' tab.
Enter the following string in the 'Program arguments' window:
map=aspect@PERMANENT
'Apply'
'Run'

Output from the run will be displayed in the 'Console' window.

Run Application.

'Run' -> 'Run'

Output from the run will be displayed in the 'Console' window.

Change the run focus.

 'Run'
 Click on 'Run configurations...'.
 Select a configured application under 'C/C++ Application'.
 'Run'

Output from the run will be displayed in the 'Console' window.