Skip to content

Commit

Permalink
merge last changes from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lrntct committed Feb 22, 2018
2 parents e09a327 + a3d1b58 commit ddfa411
Show file tree
Hide file tree
Showing 149 changed files with 41,492 additions and 3,806 deletions.
172 changes: 100 additions & 72 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,137 @@
# Setting up the development environment
# I. Setting up the development environment (This is a work in progress)

We use the [conda](https://conda.io/docs/user-guide/getting-started.html) as
infrastructure to develop, build and test SWMM. We also use [CMake](https://cmake.org/)
to have a simple way to generate cross platform binaries.
The official windows compiler used for originally building SWMM was Visual Studio 2010 32 bits and as such is the recommended compiler on windows for current development. We are in the process of validating that other compilers on windows for different architecture and different operating systems results in the same results (Regression tests).

Conda is a cross platform package manager written in Python that is part of the
scientific distribution [Anaconda](https://www.continuum.io/what-is-anaconda),
and also provides isolated system environments where one can install several
different packages.
If you are also testing the PySWMM wrapper for development, we advised to use Python 3.4 (32 bits) which uses the same compiler and hence provides full binary compatibility for SWMM

## Step 1: Install conda via Anaconda or Miniconda
## A.) Windows

- Download and install [miniconda](https://conda.io/miniconda.html) or
[anaconda](https://www.continuum.io/downloads)
### Install Dependencies

**Note**: We recommend installing for the current user and avoid `All users`
installations.
- Visual Studio C++ 10. Link to download
- Install CMake >= `<VERSION>` Link to download
- Python 3.4. Link to download
- Install the nrtest dependencies. Links to download

## Step 2: Install conda-build and anaconda-client
### Building
To build SWMM then run:

Open up a **terminal** (on OSX or Linux) or the **Anaconda Prompt**
(on Windows), and install **conda-build** and **anaconda-client** on the
**root** environment.
```
$ cmake -G "Visual Studio <VERSION>" -DCMAKE_INSTALL_PREFIX:PATH=output -DCMAKE_BUILD_TYPE:STRING=Release
```

### Running

```
$ run-swmm --help
```

The **root** environment is the default conda environment that gets installed
with anaconda or miniconda. Conda-build is what allows us to create a conda
package with a recipe. The recipe for SWMM can be found in the
[conda.recipe](https://github.com/OpenWaterAnalytics/Stormwater-Management-Model/tree/develop/conda.recipe)
folder.
## B.) Linux

### Install Dependencies
- Build dependencies... gcc >= libgcc >=
- cmake
- Install the nrtest dependencies..... Links to download

#### On Debian (.deb) based systems you can use
```
$ sudo apt install ...
```

#### On Centos (.rpm) based systems you can use

```
$ conda install conda-build anaconda-client
$ sudo yum install ...
```

## Step 3: create the development enviornment
### Building

So now, lets create a conda environment called **swmm** and install the
development dependencies. We also install **clangdev** from the **conda-forge**
to use the [clang-format](https://clang.llvm.org/docs/ClangFormat.html) tool
to keep the C code tidy and uniform.
```
$ cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE:STRING=Release ..
$ make -j $CPU_COUNT
$ make install
```

### On OSX and Linux:
### Running

```
$ conda create --name swmm cmake gcc libgcc python=3.6
$ conda install --name clangdev --channel conda-forge
$ run-swmm --help
```

### On Windows:
## C.) OSX

### InstallDependencies
- Clang version >= ??? or
- gcc version >= ???
- cmake
- Install python and the nrtest dependencies..... Links to download or commands

#### If using Homebrew
```
$ conda create --name swmm cmake python=3.6
$ conda install --name clangdev --channel conda-forge
$ brew install ...
```

## Step 4: Activating the conda environment
### Building

By default when opening a new Terminal (or Anaconda Prompt) we will get the
**root** environment so everytime we start working we need to make sure that
we do:
```
$ cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE:STRING=Release ..
$ make -j $CPU_COUNT
$ make install
```

### On OSX and Linux:
### Running

```
$ source activate swmm
$ run-swmm --help
```

### On Windows:

# II. If you are developing for PySwmm

If you are developing for PySwmm you need to install these versions to work with [how python is compiled](https://wiki.python.org/moin/WindowsCompilers) on different platforms:

## A.) Windows

### Python 2.7
- Visual Studio C++ 9 for Python 2.7. Link to download
- Python 2.7. Link to download

### Python 3.4
- Visual Studio C++ 10 for Python 3.4. Link to download
- Python 3.4. Link to download.

### Python 3.5 and 3.6
- Visual Studio C++ 14 for Python 3.5 and 3.6. Link to download
- Python 3.5. Link to download
- Python 3.6. Link to download

## B.) Linux

....

## C.) OSX

....


# III. Regression Testing

To execute regression tests run:

```
$ activate swmm
$ python <script...>
```

Now we are ready to do some work!
# IV. Unit tests

To execute unit tests run:

```
$ python <script...>
```


# Contributing to the project
# V. Contributing to the project

## Git and Github

Expand Down Expand Up @@ -117,31 +173,3 @@ $ git push origin fix/some-branch-fix
Once the work is done go to https://github.com/OpenWaterAnalytics/Stormwater-Management-Model
and make a pull request from your created branch.


## Coding guidelines

Coding guidelines are simple, because we use an automatic tool to format the
code after making changes make sure to run the tool on the file that changed
by doing:

```
(swmm) $ python tools/clangformatter.py src/<file-that-was-edited> -i
```


# Building the project for local testing

If you want to build the package for local testing, open the terminal
(or Anaconda prompt) and type:

```
(swmm) $ conda-build conda.recipe
```

After the process has finished you can install and run the locally created
package with:

```
(swmm) $ conda install --name swmm libswmm --use-local
(swmm) $ run-swmm
```
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# Eclipse Stuff
.metadata/
.settings/
.cproject
.project
.pydevproject


# Mac Stuff
.DS_Store
Expand All @@ -15,9 +19,16 @@
/target
*.zip


# Build files
/build/
*.o


*.orig
*.orig
/Debug/

# Testing
performance.json
stderr.log
stdout.log
54 changes: 19 additions & 35 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,25 @@
# https://travis-ci.com/OpenWaterAnalytics/Stormwater-Management-Model/
matrix:
include:
- os: osx
language: generic
env: TRAVIS_PYTHON_VERSION=3.6
language: python

env:
global:
- SWMM_HOME=`pwd`
- BUILD_HOME=build
- TEST_HOME=tests/swmm-nrtestsuite

cache:
directories:
- $HOME/condacache/pkgs
- $HOME/.cache/pip

before_install:
- sudo apt-get -qq update
- sudo apt-get install -y swig

install:
# Use Astropy ci helpers for initial setup
- git clone git://github.com/astropy/ci-helpers.git
- source ci-helpers/travis/setup_conda_$TRAVIS_OS_NAME.sh
# Install dependencies for building with conda (latests versions)
- conda update -n root conda -q --no-pin
- conda install -n root conda-build anaconda-client -q --no-pin
- conda config --add pkgs_dirs ~/condacache/pkgs
- conda create -n format clangdev -c conda-forge
- conda-build conda.recipe
- conda install -n test libswmm --use-local
- pip install --src build/packages -r tools/requirements.txt

script:
# Check file format with clang
- source activate format
- conda info --json
- python tools/clangformatter.py src/
# Test built package
- source activate test
- conda info --json
- run-swmm --help
before_script:
- mkdir -p $BUILD_HOME
- cd $BUILD_HOME
- cmake ..

deploy:
- provider: script
script: "conda-build conda.recipe --user owa --token ${SWWM_CI_UPLOAD_TOKEN} --old-build-string"
on:
branch: develop
script:
- make
- cd $SWMM_HOME
- tools/gen-config.sh $SWMM_HOME/$BUILD_HOME/bin > $TEST_HOME/apps/swmm-$TRAVIS_COMMIT.json
- tools/run-nrtest.sh $TEST_HOME $TRAVIS_COMMIT
4 changes: 2 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Gonzalo Peña-Castellanos <goanpeca@gmail.com>
Katherine Ratliff <ratliff.katherine@epa.gov>
Lew Rossman <LRossman@cinci.rr.com>
Laurent Courty <lrntct@gmail.com>
Abhiram Mullapudi <abhiramm@umich.edu>
EmNet LLC <EmNet.net>


Authors with Contributions in the Public Domain:
Michael Tryby <tryby.michael@epa.gov>
Michael Tryby <tryby.michael@epa.gov>
20 changes: 15 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if(MSVC)
set(CMAKE_C_FLAGS "/fp:fast /fp:except- /Gd /Oy- /Ob2 /Ot /GL")
set(CMAKE_C_FLAGS_DEBUG "/MTd /W4")
set(CMAKE_C_FLAGS_RELEASE "/O2 /MT /W4")

set(CMAKE_CXX_FLAGS "/fp:fast /fp:except- /Gd /Oy- /Ob2 /Ot /GL")
set(CMAKE_CXX_FLAGS_DEBUG "/MTd /W4")
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /MT /W4")
endif(MSVC)

if(UNIX)
set(CMAKE_C_FLAGS "-std=c99 -fopenmp")
set(CMAKE_CXX_FLAGS "-std=c++11 -fopenmp -Wno-write-strings")
Expand All @@ -22,16 +32,17 @@ endif(OPENMP_FOUND)

if(APPLE)
set(CMAKE_INSTALL_NAME_DIR @executable_path)
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
endif(APPLE)

# includes and source files
include_directories(include)
include_directories(src)
file(GLOB_RECURSE SWMM_HEADERS include/*.h src/*.h)
file(GLOB SWMM_SOURCES src/*.c)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

# library
add_library(swmm5 SHARED ${SWMM_SOURCES})
add_library(swmm5 SHARED ${SWMM_SOURCES} ${SWMM_HEADERS})
target_link_libraries(swmm5)

# executable
Expand All @@ -46,5 +57,4 @@ endif(WIN32)

# install
install(TARGETS run-swmm DESTINATION bin)
install(TARGETS swmm5 DESTINATION lib)
install(FILES src/swmm5.h DESTINATION include)
install(TARGETS swmm5 DESTINATION lib)
Loading

0 comments on commit ddfa411

Please sign in to comment.