Difference between revisions of "Setting Up A Development Environment"

From LinuxMCE
Jump to: navigation, search
(Helpful Tools and Hints)
(Helpful Tools and Hints)
Line 96: Line 96:
 
  wget http://svn.linuxmce.com/pluto/trunk/src/CM11A/devicepoll.cpp
 
  wget http://svn.linuxmce.com/pluto/trunk/src/CM11A/devicepoll.cpp
 
This ends up getting the most recent changes that have been committed to that file so that I know that I am working on a current version of the file.
 
This ends up getting the most recent changes that have been committed to that file so that I know that I am working on a current version of the file.
 +
 +
  
 
'''Compiling changes and where to put them on the core'''
 
'''Compiling changes and where to put them on the core'''
Line 101: Line 103:
 
As stated above, I am not sure if there is a golden rule to this, but depending on what you are trying to compile, you will have to use one of the following:
 
As stated above, I am not sure if there is a golden rule to this, but depending on what you are trying to compile, you will have to use one of the following:
 
  make
 
  make
 +
 +
 
  make bin
 
  make bin
 
  make so
 
  make so
Line 125: Line 129:
 
(There are other tools available to take full recorded screencasts of these VNC sessions, but I've never used one)
 
(There are other tools available to take full recorded screencasts of these VNC sessions, but I've never used one)
 
Also note, that the VNC playback is not at full framerate - this is normal.
 
Also note, that the VNC playback is not at full framerate - this is normal.
 +
 +
  
  
Line 140: Line 146:
  
 
You will now have a network folder on your desktop that you can access files with - without having to use the command line. (the first time you will be prompted for a password, which of course is 'linuxmce'. Double clicking files will now open them in your preferred desktop editor!
 
You will now have a network folder on your desktop that you can access files with - without having to use the command line. (the first time you will be prompted for a password, which of course is 'linuxmce'. Double clicking files will now open them in your preferred desktop editor!
 +
 +
  
 
'''SSH-ing into a Media Director'''
 
'''SSH-ing into a Media Director'''

Revision as of 12:22, 21 March 2008


Introduction

See also: Building_From_Source

I have seen a lot of questions on how to set up a development environment for LMCE. As a person with limited programming experience in c++, I can tell you that you don't have to be a master-level programmer to get your feet wet and examine the source code, and even make changes that add new features or fix existing bugs. It just takes a little patience, some help from experienced members, and a willingness to learn. There is a lot of information and help available in the forums, the wiki, and the linuxmce channel on IRC freenode servers.

That being said, dev work can also be risky business. You can seriously damage your installation compiling and testing changes, so USE THIS INFORMATION AT YOUR OWN RISK! If you really want to get started developing, the best advice I can give is to get a separate computer to set up as a development machine, so you don't damage your existing LinuxMCE installation accidentally! That way, if you make a change that LMCE really doesn't like, you won't trash your personally installation. (Too bad I don't follow my own advice, as I've done this before!)



The following tutorial represents my experiences only, and may not necessarily be the best or correct way to do things - though it has worked very well for me.

As I am a linux user, I am going to describe this process as I set up a development environment on my core from a computer running Ubuntu linux. Other linux variants will be very similar, if not the same. For Windows users, there is equivalent software that you can use, though I can't name any off of the top of my head - you will have to do your own research on that one.

Be sure to set aside a free evening to set up your development environment, as it can take several hours to complete!



Preface

The first thing I found surprising when I went to set up my first development environment is that it must be set up on your core. To my knowledge, you can't just make changes to the source on your desktop computer, compile them on your desktop computer, then upload them to the core. Everything must reside on the core, and you can have access to the source on your normal desktop over SSH (covered later). For those that aren't keen with working with a command line over ssh, this will take some getting used to (as was my case). But, once you get used to it, its not a bad development environment, and it even got me more familiar with the command line, and linux commands, which is something I've been meaning to do anyways. Lets get started...


Setting Up the Development Environment

Once you have a LinuxMCE Core up and running, the first thing we have to do is learn how to connect to it from our Desktop computer. On my Ubuntu desktop, I open a terminal via Applications->Accessories->Terminal. We will now use SSH to connect to out core - enter the following into the terminal:

ssh linuxmce@192.168.80.1

When prompted for a password, enter "linuxmce". (You may be prompted for a password several times during the setup of your development environment - this will always be "linuxmce")


Congratulations! You are now logged into the core over SSH from a remote computer! Now its time to install some packages needed for development. In the terminal, type:

sudo apt-get install subversion build-essential

This will install Subversion (SVN), which is needed to keep your local copy of the source code in sync with the latest changes, and well as some development libraries.


For my development environment, I decided to keep everything in my Home directory. The source can actually go many places, but I prefer using the Home directory. Lets go there now...

cd ~/


At this time, the source code is located at Charon Media (though it is supposed to be eventually hosted at svn.linuxmce.com). To download the most recent snapshot of the sourcecode that I know of, run the following:

wget http://www.charonmedia.org/lmce-1465.tbz

Once it downloads, test the checksum to make sure it didn't get corrupted during the download

md5sum lmce-1465.tbz

The checksum should be b3d4b3f6b33ff5e6c4641390f2314095

Now lets extract the source code:

tar xfj lmce-1465.tbz

And finally, lets download any changes that have been made since this snapshot was taken (this syncronizes your local copy of the source code with the most recent committed changes)

cd lmce
svn update

GREAT! You now have the most recent version of the source code available to you! You can run svn update at any time from within the lmce directory to get the latest changes that have been committed to SVN.


Now, before we can compile our own changes, lets build the most recent SVN version (this will not alter your current installation)

./configure
make

Note that you may get some warnings and errors, but they have never adversely affected me.

Once this is finished, you are now ready to compile changes in the source code, then copy the resulting file to the appropriate place in the core.

Since I am familiar with the CM11A source, I will use it as an example... First i cd into the CM11A directory

cd ~/lmce/src/CM11A

Next I make changes to devicepoll.cpp.. Now I want to compile my changes.. But first I have found it good practice to delete any old object files etc. before compiling, so I usually run

rm *.o
rmCM11A

This removes the last resulting CM11A binary if present, as well as the object files that might be present from my last compile. Next I compile the changes..

make bin

Once it is finished compiling, I have a new CM11A binary that just needs moved to the right place in the core.. In this instance it is /usr/pluto/bin/ (/usr/pluto/lib/ is another hot-spot to check, usually for .so files)

sudo rm /usr/pluto/bin/CM11A

then I copy my newly compiled binary over..

sudo cp CM11A /usr/pluto/bin/CM11A

Now with a "quick reload router" from one of my orbiters, my changes will be in effect!

A quick note - if "make bin" does not work, you may need to run "make so" for some sources that end up being library files, and yet others require just "make". I'm not sure if there is a golden rule to all of this, but I just try each of them until one of them works. Then, for the most part, you can search /usr/pluto/bin and /usr/pluto/lib to see where the resulting compiled file should go. Also, I have noticed that a "Full reload router" is necessary if you replace a library file (*.so)

Helpful Tools and Hints

Getting latest svn.linuxmce.com changes

As of the time of this writing, svn.linuxmce.com is not quite ready for use. However, it is kept up to date by the devs and is the best place to grab the most recent changes from. I have found no easy way to do this, other than manually getting the new file directly from the web svn, one file at a time for the files that you want to work on.

For example, if I plan to work on src/CM11A/devicepoll.cpp, I would would first either delete or rename my current devicepoll.cpp file on my core, then from the CM11A directory, run

wget http://svn.linuxmce.com/pluto/trunk/src/CM11A/devicepoll.cpp

This ends up getting the most recent changes that have been committed to that file so that I know that I am working on a current version of the file.


Compiling changes and where to put them on the core

As stated above, I am not sure if there is a golden rule to this, but depending on what you are trying to compile, you will have to use one of the following:

make


make bin
make so

For the most part, you should be able to search through /usr/pluto/bin and /usr/pluto/lib to see where the resulting file should go.


Using VNC to remotely view the on-screen orbiter

As an Ubuntu user, I will explain it from how I do it from Ubuntu.

First, ssh to the core.

ssh linuxmce@192.168.80.1Now lets install VNC
sudo apt-get install vncx11

Ok, once it is installed, run the VNC Server from the core

x11vnc

Now that you have a VNC server running on the core, lets start the client on our Ubuntu desktop: First, open another terminal on your desktop now run the following command (in the new terminal, not the terminal that is SSH'd into the core!)

vncviewer 192.168.80.1:0

Now you can take professional developer-grade screenshots of our on-screen orbiters! (There are other tools available to take full recorded screencasts of these VNC sessions, but I've never used one) Also note, that the VNC playback is not at full framerate - this is normal.



Navigating the core remotely with GUI

Unless you like editing source code in a terminal with vim, you will want to make things easier on yourself, and set things up so you can graphically browse the directory tree on the core, and edit source code files with gedit or a similar editor... In ubuntu, go to Places->Connect To Server A "Connect Tto Server" window will appear. Fill it out as follows: Service Type - SSH Server - 192.168.80.1 Port - 22 Folder - / User Name - linuxmce Name to use for connection - <anything you want> (I use Access Core Files)

You will now have a network folder on your desktop that you can access files with - without having to use the command line. (the first time you will be prompted for a password, which of course is 'linuxmce'. Double clicking files will now open them in your preferred desktop editor!


SSH-ing into a Media Director

I'm sure there is a better way, but here is what I do: 1)ssh into the core

ssh linuxmce@192.168.80.1

..enter password 'linuxmce'

2) navigate to /usr/pluto/diskless

cd /usr/pluto/diskless

3) get the "moon numbers" of the media directors

dir

note that each media director has a unique 3-digit number.. you will need this number in the following steps..

4) change over to the root user:

sudo su

...enter password 'linuxmce'

5) ssh into one of the media directors

ssh moonxxx

(xxx is the 3-digit number of one of the media directors)

You are now in the Media Director's file system, be careful, as you are root!