Difference between revisions of "Setting up developer environment"

From MMS Wiki
Jump to: navigation, search
(Mac (incomplete))
Line 116: Line 116:
 
== Mac (incomplete) ==  
 
== Mac (incomplete) ==  
 
* Install XCode
 
* Install XCode
* Install Node (https://nodejs.org/download/)
+
* Install Node (pkg file from https://nodejs.org/download/)
* Install HaXe and OpenFL
+
* Install HaXe
 
* Install Docker Toolbox
 
* Install Docker Toolbox
 
And set up docker machine: https://docs.docker.com/installation/mac/#from-your-shell
 
And set up docker machine: https://docs.docker.com/installation/mac/#from-your-shell
 
NB! that env stuff has to be loaded each time
 
NB! that env stuff has to be loaded each time
* Install homebrew, then
+
* Install Homebrew (http://brew.sh/index.html), then
 
<code>brew install graphicsmagick postgresql libsass</code>
 
<code>brew install graphicsmagick postgresql libsass</code>
 
* Install pip
 
* Install pip
Line 136: Line 136:
  
 
Also, XCode project needs "Build settings" -> "Other linker flags" -> '-stdlib=libc++' for compile to work.
 
Also, XCode project needs "Build settings" -> "Other linker flags" -> '-stdlib=libc++' for compile to work.
 
  
 
== Android Dev ==  
 
== Android Dev ==  

Revision as of 12:03, 29 September 2016

Install packages:

sudo apt-get update
sudo apt-get install -y git-core python2.7-dev curl libfontconfig1-dev libc6 libgc-dev ocaml make xdg-utils libpq-dev postgresql-client libav-tools python-pip fluidsynth graphicsmagick sox libsox-fmt-mp3 s3cmd nodejs npm libjpeg-dev

Install haxe http://www.openfl.org/documentation/setup/install-haxe/

  • Note that if this error occurs ./install-haxe.sh: 21: [: =: unexpected operator that you run install_haxe with command sh install_haxe.sh.

NPM

npm install -g bower grunt-cli cordova

Haxelib stuff

haxelib install hxcpp
# ln -s hxMath.h hxMath.h.h # In the right directory

One last bit of configuration

sudo echo "127.0.0.1 localhost.matchmysound.com" >> /etc/hosts

Docker

sudo apt-get install docker.io
sudo groupadd docker
sudo usermod -aG docker macobo # replace with own username
# log out and in again
docker pull redis
docker pull postgres


Internal setup

Setup: Clone repo:

git clone https://[USERNAME]@bitbucket.org/velochy/guitar-teacher-frontend.git
cd guitar-teacher-frontend
# clone mms-haxe into guitar-teacher-frontend/scripts/haxe/core/
git clone https://[USERNAME]@bitbucket.org/velochy/mms-haxe.git scripts/haxe/core

Install pip packages

sudo pip install -r requirements.txt

Install bower packages

cd client
bower install
npm install

Set up DB (need to have ./manage.py start db running in other terminal)

# ./manage.py start db # in another terminal or with &
./manage.py db:create
./manage.py db:sync

Start up the environment (separate windows)

./manage.py start db redis api celery
./manage.py start client

If client isn't acting up, then `python manage.py` should be sufficient!

If you see ENOSPC error, it is a problem with too many inotify watches. Solution:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

if you see sslwrap error, it is a gevent thing. 1.0.2 fixes it for Python 2.7.9 but if you have 2.7.8 that has the bug backported into it, just go to /usr/local/lib/python2.7/dist-packages/gevent/hub.py and change PYGTE279 to True.


Editor (sublime)

Under Project - edit project, set

   "settings": {
       "expand_tabs_on_save": true,
       "trim_trailing_white_space_on_save": true
   }

Shortcuts:

  • Index project using search in ctrl-shift-p
  • goto definition using ctrl+win+alt+l
  • jump to definition win+ctrl+l

Set user configuration to ignore temporary dirs - Preferences - Package Settings - AngularJS - Settings - User

{
   "exclude_dirs":[
       "client/tmp",
       "client/.tmp",
       "client/node_modules",
   ]
}

Install Anaconda for python linting, goodies

Set user configuration in Anaconda to set max length a bit higher (note that you should still strive for 80)

{
   "pep8_max_line_length": 100
}

Set Anaconda User Key bindings

[
   {"command": "anaconda_goto", "keys": ["super+ctrl+alt+l"]},
   {"command": "anaconda_find_usages", "keys": ["super+alt+d"]},
   {"command": "anaconda_doc", "keys": ["alt+d"]},
   {"command": "anaconda_auto_format", "keys": ["super+a"]},
   {"command": "anaconda_goto", "keys": ["g", "d"],
       "context":
       [
           { "key": "selector", "operator": "equal", "operand": "source.python" },
           { "key": "setting.command_mode", "operand": true },
           { "key": "setting.is_widget", "operand": false }
       ]
   }
]

Shortcuts

  • goto definition using ctrl+win+alt+l
  • show docstring alt+d
  • find usages of function win+alt+d
  • autoformat file win+r (this cleans up a lot of the formatting-related pep8 warnings, good when refactoring and cleaning old code)

Mac (incomplete)

And set up docker machine: https://docs.docker.com/installation/mac/#from-your-shell NB! that env stuff has to be loaded each time

brew install graphicsmagick postgresql libsass

  • Install pip

sudo easy_install pip

Also need to install latest Java JRE and then do: sudo rm /usr/bin/java sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin (http://stackoverflow.com/questions/12757558/installed-java-7-on-mac-os-x-but-terminal-is-still-using-version-6)

haxelib 3,2,81 version needs to have a symlink like "latest" as cordova plugin xml parser has a bug which dies on commas in path name.

Also, XCode project needs "Build settings" -> "Other linker flags" -> '-stdlib=libc++' for compile to work.

Android Dev

HaXe needs to be at least 3.3.0. You also need Android studio (which in turn requires JDK 1.8). Once that is installed, navigate to "Configuration" -> "SDK manager" -> "SDK Tools" and install:

NDK SDK ver 22 SDK build tools ver 22 SDK and Build Tools of <newest>

You will need to set up haxelib

 haxelib dev MMSNativeExtension MMSNativeExtension

Then

 lime setup android

And say n to everything until it starts asking for paths. Then provide them: Android SDK is ~/Android/Sdk NDK is ~/Android/Sdk/ndk-bundle ANT is ~/Android/Sdk/tools Java SDK is /usr/lib/jvm/java-8-openjdk-amd64 (in ubuntu)

You may need to symlink 4.9 to 4.9.x at ~/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/{x86,x86_64}/lib/gcc/arm-linux-androideabi

Also, add this to your .bashrc

 export ANDROID_HOME=/home/velochy/Android/Sdk
 export PATH=$PATH:/home/velochy/Android/Sdk/tools