<commit_before>Setting Up the Build Environment
================================

.. warning::

    The following instructions are currently a work in progress.

Create a Workspace
------------------

First, create a directory to be used as your coding directory.

* ``C:\Users\<username>\workspace`` (Vista/Win 7),
* ``C:\Documents and Settings\<username>\workspace`` (XP),
* ``/home/<username>/workspace`` (Linux).

Install Blender
---------------

See :ref:`user docs <user-getblender>`.

Fedora
``````

For Fedora 16 and up, Blender 2.5x is available via yum::

  sudo yum install blender

For Fedora 15, first `setup a development environment
<http://fedoraproject.org/wiki/How_to_create_an_RPM_package>`_::

  sudo yum groupinstall "Development Tools" -y
  sudo yum install rpmdevtools -y
  rpmdev-setuptree

Then, clone the spec file, install the sources, install the build
dependencies, and kick off an rpm build::

  git clone git://pkgs.fedoraproject.org/blender
  cd blender
  cp * ~/rpmbuild/SOURCES/
  wget http://download.blender.org/source/blender-2.60a.tar.gz
  mv blender-2.60a.tar.gz ~/rpmbuild/SOURCES/
  cat blender.spec | grep ^BuildRequires | gawk '{ print $2 }' | xargs sudo yum install -y
  rpmbuild -ba blender.spec

Building blender takes a long time. When the build is finished,
install the rpm::

  sudo yum localinstall ~/rpmbuild/RPMS/x86_64/blender-2.60a-3.fc15.x86_64.rpm

.. warning::

   The package upgrades Blender 2.49b, so if you had it installed
   previously, it will no longer be available. Do::

     sudo yum erase blender
     sudo yum install blender

   to get your old Blender 2.49b back.

Install Python 3.2
------------------

**Windows**

#. Download `Python 3.2 <http://www.python.org/download/releases/3.2.3/>`_.

#. Pick the installer appropriate for your platform, and follow the instructions.

#. Use the default install location.

**Fedora**::

   sudo yum install python3

**Ubuntu**::

   sudo apt-get install python3-minimal

Install Git
-----------

The code is maintained with git. If you are not yet familiar with git, read `progit <http://progit.org/book/>`_.

**Windows**

We use git bash.
Download `msysgit <http://code.google.com/p/msysgit/downloads/list>`_ and follow the installer instructions.

**Fedora**::

   sudo yum install git

**Ubuntu**::

   sudo apt-get install git

Auto CLRF
`````````

* We need to ensure consistancy between end-of-file(EOF) markers.
* This avoids excess commits where the enviroment automatically adds the EOF.
* Git will think that the whole file has been edited.
* Read `EOF <http://en.wikipedia.org/wiki/Newline>`_.
* For Windows-style line endings, use::

    git config --global core.autocrlf true

  For Unix-style line endings, use::

    git config --global core.autocrlf input

  Either option ensures that all commits in the git history
  will be stored using Unix-style endings,
  and that all checkouts (i.e. actual files)
  will have consistent line endings
  according to your operating system.

Create a Github Fork
--------------------

If you intend to work on the Blender nif plugin, first, you should
clone the code on github.

#. If you do not have one yet, `create a github account
   <https://github.com/signup/free>`_.

#. Set up your `git environment
   <http://help.github.com/set-up-git-redirect>`_.

#. `Log in <https://github.com/login>`_ on github.

#. Visit the `blender nif plugin mothership repository
   <https://github.com/niftools/blender_nif_plugin>`_.

#. Click **Fork** (top right corner).

Be sure to read the remaining `github help
pages <http://help.github.com/>`_, particularly the beginner's
guides.

Get the Source Code
-------------------

To get the code, run in a terminal (linux) or in git bash (windows)::

   cd ~/workspace
   git clone --recursive <EMAIL>@github.com:<username>/blender_nif_plugin.git
   cd blender_nif_plugin

Optional remote tracking::

   git remote add neomonkeus git://github.com/neomonkeus/blender_nif_plugin.git
   git remote add aaron git://github.com/Aaron1178/blender_nif_plugin.git
   git remote add ghost git://github.com/Ghostwalker71/blender_nif_plugin.git
   git remote add amorilia git://github.com/amorilia/blender_nif_plugin.git

Install Build Environment Batch Script
--------------------------------------

.. note::

   * The build enviroment is a tool to standardise development for all NifTools application on Windows
   * Its purpose is to initialises a command line window with temporary enviromental setting, avoiding bloating PATH.
   * It will attempt to look for supported build utilities which can also be read from an .ini file 
   * For more information, read the :file:`README.rst` file provided with the repository.

**Windows**

Get the build environment batch script::

   cd workspace
   git clone git://github.com/niftools/buildenv.git

In the repo is a script called create_shortcut.bat.
This creates shortcuts that when generate buildenv console, hooking to their specific ini file.

The following is a sample .ini file for the Blender Nif Plug-in::<commit_msg>Added instructions for pulling submodules and possible errors encountered.<commit_after>Setting Up the Build Environment
================================

.. warning::

    The following instructions are currently a work in progress.

Create a Workspace
------------------

First, create a directory to be used as your coding directory.

* ``C:\Users\<username>\workspace`` (Vista/Win 7),
* ``C:\Documents and Settings\<username>\workspace`` (XP),
* ``/home/<username>/workspace`` (Linux).

Install Blender
---------------

See :ref:`user docs <user-getblender>`.

Fedora
``````

For Fedora 16 and up, Blender 2.5x is available via yum::

  sudo yum install blender

For Fedora 15, first `setup a development environment
<http://fedoraproject.org/wiki/How_to_create_an_RPM_package>`_::

  sudo yum groupinstall "Development Tools" -y
  sudo yum install rpmdevtools -y
  rpmdev-setuptree

Then, clone the spec file, install the sources, install the build
dependencies, and kick off an rpm build::

  git clone git://pkgs.fedoraproject.org/blender
  cd blender
  cp * ~/rpmbuild/SOURCES/
  wget http://download.blender.org/source/blender-2.60a.tar.gz
  mv blender-2.60a.tar.gz ~/rpmbuild/SOURCES/
  cat blender.spec | grep ^BuildRequires | gawk '{ print $2 }' | xargs sudo yum install -y
  rpmbuild -ba blender.spec

Building blender takes a long time. When the build is finished,
install the rpm::

  sudo yum localinstall ~/rpmbuild/RPMS/x86_64/blender-2.60a-3.fc15.x86_64.rpm

.. warning::

   The package upgrades Blender 2.49b, so if you had it installed
   previously, it will no longer be available. Do::

     sudo yum erase blender
     sudo yum install blender

   to get your old Blender 2.49b back.

Install Python 3.2
------------------

**Windows**

#. Download `Python 3.2 <http://www.python.org/download/releases/3.2.3/>`_.

#. Pick the installer appropriate for your platform, and follow the instructions.

#. Use the default install location.

**Fedora**::

   sudo yum install python3

**Ubuntu**::

   sudo apt-get install python3-minimal

Install Git
-----------

The code is maintained with git. If you are not yet familiar with git, read `progit <http://progit.org/book/>`_.

**Windows**

We use git bash.
Download `msysgit <http://code.google.com/p/msysgit/downloads/list>`_ and follow the installer instructions.

**Fedora**::

   sudo yum install git

**Ubuntu**::

   sudo apt-get install git

Auto CLRF
`````````

* We need to ensure consistancy between end-of-file(EOF) markers.
* This avoids excess commits where the enviroment automatically adds the EOF.
* Git will think that the whole file has been edited.
* Read `EOF <http://en.wikipedia.org/wiki/Newline>`_.
* For Windows-style line endings, use::

    git config --global core.autocrlf true

  For Unix-style line endings, use::

    git config --global core.autocrlf input

  Either option ensures that all commits in the git history
  will be stored using Unix-style endings,
  and that all checkouts (i.e. actual files)
  will have consistent line endings
  according to your operating system.

Create a Github Fork
--------------------

If you intend to work on the Blender nif plugin, first, you should
clone the code on github.

#. If you do not have one yet, `create a github account
   <https://github.com/signup/free>`_.

#. Set up your `git environment
   <http://help.github.com/set-up-git-redirect>`_.

#. `Log in <https://github.com/login>`_ on github.

#. Visit the `blender nif plugin mothership repository
   <https://github.com/niftools/blender_nif_plugin>`_.

#. Click **Fork** (top right corner).

Be sure to read the remaining `github help
pages <http://help.github.com/>`_, particularly the beginner's
guides.

Get the Source Code
-------------------

To get the code, run in a terminal (linux) or in git bash (windows)::

   cd ~/workspace
   git clone --recursive <EMAIL>:<username>/blender_nif_plugin.git
   cd blender_nif_plugin

We use submodules to point to the external repository, to avoid having to store & maintain seperate code bases.

Fetching the submodules::
   
   $ git submodule update --init
   
If you get the following error::

   fatal: Needed a single revision 
   Unable to find current revision in submodule path ’pyffi’

Run::
   
   $ rm -rf pyffi   
   $ git submodule update --init

Optional remote tracking::

   git remote add neomonkeus git://github.com/neomonkeus/blender_nif_plugin.git
   git remote add aaron git://github.com/Aaron1178/blender_nif_plugin.git
   git remote add ghost git://github.com/Ghostwalker71/blender_nif_plugin.git
   git remote add amorilia git://github.com/amorilia/blender_nif_plugin.git

Install Build Environment Batch Script
--------------------------------------

.. note::

   * The build enviroment is a tool to standardise development for all NifTools application on Windows
   * Its purpose is to initialises a command line window with temporary enviromental setting, avoiding bloating PATH.
   * It will attempt to look for supported build utilities which can also be read from an .ini file 
   * For more information, read the :file:`README.rst` file provided with the repository.

**Windows**

Get the build environment batch script::

   cd workspace
   git clone git://github.com/niftools/buildenv.git

In the repo is a script called create_shortcut.bat.
This creates shortcuts that when generate buildenv console, hooking to their specific ini file.

The following is a sample .ini file for the Blender Nif Plug-in::
{'fraction_non_alphanumeric': 0.12449114834800719, 'fraction_numerical': 0.00927766732935719, 'mean_word_length': 3.338398357289528, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5907399', 'n_tokens_mistral': 3395, 'n_tokens_neox': 3099, 'n_words': 1210}