Getting started programming/lang-ja: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
|source = Getting started programming}} |
|source = Getting started programming}} |
||
{{Ongoing Translation}} |
{{Ongoing Translation}} |
||
{{Translated text| |
|||
Thank you for considering working on the One Laptop Per Child project. This page tries to provide you with the answers you need to get started either by contributing to existing projects or starting your own. See also [[Game Development Newbies]] |
Thank you for considering working on the One Laptop Per Child project. This page tries to provide you with the answers you need to get started either by contributing to existing projects or starting your own. See also [[Game Development Newbies]] |
||
|display = block}} |
|||
<div style="float:right"> |
<div style="float:right"> |
||
Line 12: | Line 15: | ||
== Setting up a Development Environment == |
== Setting up a Development Environment == |
||
{{Translated text| |
|||
The OLPC's software environment is a heavily modified Fedora Core Linux system running a custom [[Sugar|GUI shell]] (Sugar). To develop for the platform you will eventually need access to a platform which runs in a manner substantially similar to the OLPC environment. Luckily there are many available options. |
The OLPC's software environment is a heavily modified Fedora Core Linux system running a custom [[Sugar|GUI shell]] (Sugar). To develop for the platform you will eventually need access to a platform which runs in a manner substantially similar to the OLPC environment. Luckily there are many available options. |
||
|display = block}} |
|||
{{anchor|Option 1 - sugar-jhbuild}} |
{{anchor|Option 1 - sugar-jhbuild}} |
||
=== Option 1 - sugar-jhbuild === |
=== Option 1 - sugar-jhbuild === |
||
{{Translated text| |
|||
Compared with using an Emulated XO, installing sugar takes more time and space to set up, but results in a better environment. This is what the core development team uses. |
Compared with using an Emulated XO, installing sugar takes more time and space to set up, but results in a better environment. This is what the core development team uses. |
||
|display = block}} |
|||
{{anchor|On 32-bit Linux}} |
{{anchor|On 32-bit Linux}} |
||
==== On 32-bit Linux ==== |
==== On 32-bit Linux ==== |
||
{{Translated text| |
|||
[[Sugar with sugar-jhbuild|sugar-jhbuild]] builds a parallel set of the libraries required to run the OLPC software. This approach generally works reasonably well on most modern Linux distributions. On some linuxes (32-bit Ubuntu, 32-bit Fedora(?)), it "just works". Though the build system (jhbuild) can be fragile. On others, you may spend quite some time rebuilding and fixing errors to get a final working system, so consider running |
[[Sugar with sugar-jhbuild|sugar-jhbuild]] builds a parallel set of the libraries required to run the OLPC software. This approach generally works reasonably well on most modern Linux distributions. On some linuxes (32-bit Ubuntu, 32-bit Fedora(?)), it "just works". Though the build system (jhbuild) can be fragile. On others, you may spend quite some time rebuilding and fixing errors to get a final working system, so consider running |
||
a "just works" linux in emulation. |
a "just works" linux in emulation. |
||
|display = block}} |
|||
{{anchor|On Windows/Mac/Linux, w/ virtual Linux}} |
{{anchor|On Windows/Mac/Linux, w/ virtual Linux}} |
||
==== On Windows/Mac/Linux, w/ virtual Linux ==== |
==== On Windows/Mac/Linux, w/ virtual Linux ==== |
||
{{Translated text| |
|||
[[Sugar with sugar-jhbuild|sugar-jhbuild]], on a virtual 32-bit Ubuntu, inside of an emulator (eg, Parallels, qemu, vmware). |
[[Sugar with sugar-jhbuild|sugar-jhbuild]], on a virtual 32-bit Ubuntu, inside of an emulator (eg, Parallels, qemu, vmware). |
||
|display = block}} |
|||
{{anchor|Option 2 - Emulated XO}} |
{{anchor|Option 2 - Emulated XO}} |
||
=== Option 2 - Emulated XO === |
=== Option 2 - Emulated XO === |
||
{{Translated text| |
|||
[[OS images for emulation|Running an XO OS image in emulation]] is, for Unix-friendly developers (those who like using command-line tools via ssh), the simplest way to start developing for the OLPC system. They can be run in one of the popular emulation/virtualisation systems, such as [[QEMU|Qemu]], VMWare or Parallels. These images allow you to run a virtual OLPC-configured machine on your regular development workstation. |
[[OS images for emulation|Running an XO OS image in emulation]] is, for Unix-friendly developers (those who like using command-line tools via ssh), the simplest way to start developing for the OLPC system. They can be run in one of the popular emulation/virtualisation systems, such as [[QEMU|Qemu]], VMWare or Parallels. These images allow you to run a virtual OLPC-configured machine on your regular development workstation. |
||
These official images do not provide GUI IDEs or [[SVG]] graphics editors. They normally would be used either with command-line tools (e.g. VIM) or using NFS (or ssh, or similar) to a workstation on which you will do your actual coding. |
These official images do not provide GUI IDEs or [[SVG]] graphics editors. They normally would be used either with command-line tools (e.g. VIM) or using NFS (or ssh, or similar) to a workstation on which you will do your actual coding. |
||
|display = block}} |
|||
{{anchor|Option 3 - Sugar on Linux, images / LiveCD}} |
{{anchor|Option 3 - Sugar on Linux, images / LiveCD}} |
||
=== Option 3 - Sugar on Linux, images / LiveCD === |
=== Option 3 - Sugar on Linux, images / LiveCD === |
||
{{Translated text| |
|||
[[Developer Images]] are intended to be used as virtual desktop machines. The images have far more software than is installed on the OLPC laptops. They resemble a developer's desktop machine which has been upgraded to support the Sugar environment. They tend to have GUI IDEs, full Gnome desktop installations and the like, which make it easy for developers to work entirely within the emulated environment. |
[[Developer Images]] are intended to be used as virtual desktop machines. The images have far more software than is installed on the OLPC laptops. They resemble a developer's desktop machine which has been upgraded to support the Sugar environment. They tend to have GUI IDEs, full Gnome desktop installations and the like, which make it easy for developers to work entirely within the emulated environment. |
||
Line 49: | Line 63: | ||
::: Might such developers be better off with running sugar-jhbuild on a virtual Ubuntu? [[User:MitchellNCharity|MitchellNCharity]] 09:02, 23 June 2007 (EDT) |
::: Might such developers be better off with running sugar-jhbuild on a virtual Ubuntu? [[User:MitchellNCharity|MitchellNCharity]] 09:02, 23 June 2007 (EDT) |
||
:: May as well reverse this advice. Until such time as we get new developer builds, yes, you probably need to go elsewhere. Getting new developer builds created is becoming a bit of a priority as a result. [[User:Mcfletch|Mcfletch]] 12 Aug 2007 |
:: May as well reverse this advice. Until such time as we get new developer builds, yes, you probably need to go elsewhere. Getting new developer builds created is becoming a bit of a priority as a result. [[User:Mcfletch|Mcfletch]] 12 Aug 2007 |
||
|display = block}} |
|||
{{anchor|Option 4 - Sugar on Linux, upgraded libaries}} |
{{anchor|Option 4 - Sugar on Linux, upgraded libaries}} |
||
=== Option 4 - Sugar on Linux, upgraded libaries === |
=== Option 4 - Sugar on Linux, upgraded libaries === |
||
{{Translated text| |
|||
[[Setting Up a Sugar Development Environment on *IX OSes|Update your Linux operating system]] to such a point that it resembles the OLPC environment. You then need only use the more fragile build system for a tiny fraction of the packages required. You should be aware that such upgrades often will require you to update well beyond the "stable" configurations for your Linux distribution, and as such may make your system unstable. |
[[Setting Up a Sugar Development Environment on *IX OSes|Update your Linux operating system]] to such a point that it resembles the OLPC environment. You then need only use the more fragile build system for a tiny fraction of the packages required. You should be aware that such upgrades often will require you to update well beyond the "stable" configurations for your Linux distribution, and as such may make your system unstable. |
||
: As of 2007-04-08 only Fedora Core 6/7, Gentoo and Ubuntu Feisty Fawn are known to upgrade reasonably well. |
: As of 2007-04-08 only Fedora Core 6/7, Gentoo and Ubuntu Feisty Fawn are known to upgrade reasonably well. |
||
: As of 2007-05-23 it appears this approach is deprecated on Fedora Core, and doesn't work with x86_64. [[User:MitchellNCharity|MitchellNCharity]] 16:54, 23 May 2007 (EDT) |
: As of 2007-05-23 it appears this approach is deprecated on Fedora Core, and doesn't work with x86_64. [[User:MitchellNCharity|MitchellNCharity]] 16:54, 23 May 2007 (EDT) |
||
|display = block}} |
|||
{{anchor|Option 5 - A real XO laptop}} |
{{anchor|Option 5 - A real XO laptop}} |
||
=== Option 5 - A real XO laptop === |
=== Option 5 - A real XO laptop === |
||
{{Translated text| |
|||
Hardware Developer's Program - while there are only a small number of test units being produced, developers can [[Developers_Program#How_to_apply|submit proposals]] to receive one of those units for testing and development. |
Hardware Developer's Program - while there are only a small number of test units being produced, developers can [[Developers_Program#How_to_apply|submit proposals]] to receive one of those units for testing and development. |
||
|display = block}} |
|||
{{anchor|Operating Environment}} |
{{anchor|Operating Environment}} |
||
== Operating Environment == |
== Operating Environment == |
||
{{Translated text| |
|||
Languages: |
Languages: |
||
Line 98: | Line 117: | ||
* To conserve memory or improve performance, consider replacing problematic areas in your Python code with C. For example, a [http://dev.laptop.org/ticket/1303 rewrite of the hardware manager service] in C saved 1.8 megabytes of private dirty memory. On a machine with only 256 megabytes of RAM and no swap space, efficient use of memory can make the difference between a usable system and a system made unreliable by out-of-memory failures. |
* To conserve memory or improve performance, consider replacing problematic areas in your Python code with C. For example, a [http://dev.laptop.org/ticket/1303 rewrite of the hardware manager service] in C saved 1.8 megabytes of private dirty memory. On a machine with only 256 megabytes of RAM and no swap space, efficient use of memory can make the difference between a usable system and a system made unreliable by out-of-memory failures. |
||
*Distribute your source code under the GPL, LGPL or MIT license. |
*Distribute your source code under the GPL, LGPL or MIT license. |
||
|display = block}} |
|||
{{anchor|Operating Environment}} |
{{anchor|Operating Environment}} |
||
== Operating Environment == |
== Operating Environment == |
||
{{Translated text| |
|||
Most developers will probably be working on an Activity for use on the OLPC. This kind of development can normally be done with little interaction with other development groups, save for the core Sugar developers (whose work directly affects activity developers). |
Most developers will probably be working on an Activity for use on the OLPC. This kind of development can normally be done with little interaction with other development groups, save for the core Sugar developers (whose work directly affects activity developers). |
||
|display = block}} |
|||
{{anchor|Communications Channels}} |
{{anchor|Communications Channels}} |
||
=== Communications Channels === |
=== Communications Channels === |
||
{{Translated text| |
|||
Most of the core developers use IRC for instant-messaging-style communications: |
Most of the core developers use IRC for instant-messaging-style communications: |
||
Line 124: | Line 147: | ||
* [http://groups.google.com/group/olpcnepal OLPC Nepal] |
* [http://groups.google.com/group/olpcnepal OLPC Nepal] |
||
* [http://groups.google.com/group/dev-olpcnepal Developers OLPC Nepal] |
* [http://groups.google.com/group/dev-olpcnepal Developers OLPC Nepal] |
||
|display = block}} |
|||
{{anchor|Requests and Ideas for Projects}} |
{{anchor|Requests and Ideas for Projects}} |
||
=== Requests and Ideas for Projects === |
=== Requests and Ideas for Projects === |
||
{{Translated text| |
|||
[[Software ideas]] describes activity and tool types that are currently needed. If you have an idea for an activity, add it to the list in the appropriate category (create a new category if necessary). You can create a new wiki page to describe your idea in more detail. |
[[Software ideas]] describes activity and tool types that are currently needed. If you have an idea for an activity, add it to the list in the appropriate category (create a new category if necessary). You can create a new wiki page to describe your idea in more detail. |
||
|display = block}} |
|||
{{anchor|Existing Projects }} |
{{anchor|Existing Projects }} |
||
=== Existing Projects === |
=== Existing Projects === |
||
{{Translated text| |
|||
[[Software projects]] describes the currently active projects that may need help. Once you have decided on a project, add yourself to the list along with your contact information, homepage (which may be a wiki page on the OLPC wiki), etceteras. In particular, the various [[Activities]] available on the XO may need help as build time draws near; if you're looking for an existing project to get your feet wet with, check there. |
[[Software projects]] describes the currently active projects that may need help. Once you have decided on a project, add yourself to the list along with your contact information, homepage (which may be a wiki page on the OLPC wiki), etceteras. In particular, the various [[Activities]] available on the XO may need help as build time draws near; if you're looking for an existing project to get your feet wet with, check there. |
||
|display = block}} |
|||
{{anchor|Available Resources }} |
{{anchor|Available Resources }} |
||
=== Available Resources === |
=== Available Resources === |
||
{{Translated text| |
|||
The [[Developers Program]] provides general [[Project hosting| project management]] facilities for OLPC projects. |
The [[Developers Program]] provides general [[Project hosting| project management]] facilities for OLPC projects. |
||
|display = block}} |
|||
{{anchor|Documentation}} |
{{anchor|Documentation}} |
||
Line 146: | Line 176: | ||
=== Tutorials === |
=== Tutorials === |
||
{{Translated text| |
|||
* Original [[Sugar Activity Tutorial|HelloWorld Tutorial]] using regular GTK |
* Original [[Sugar Activity Tutorial|HelloWorld Tutorial]] using regular GTK |
||
* Tuquito's [[Hello World!]] using GTK+Glade rather than hand-coded GTK |
* Tuquito's [[Hello World!]] using GTK+Glade rather than hand-coded GTK |
||
Line 152: | Line 183: | ||
** [http://www.redhatmagazine.com/2007/03/26/building-the-xo-the-anatomy-of-an-activity Anatomy of an Activity] Basic Hello World style introduction to creating a new activity |
** [http://www.redhatmagazine.com/2007/03/26/building-the-xo-the-anatomy-of-an-activity Anatomy of an Activity] Basic Hello World style introduction to creating a new activity |
||
** [http://www.redhatmagazine.com/2007/04/05/building-the-xo-porting-a-pygtk-game-to-sugar-part-one Porting a PyGTK Game to the XO] Very involved tutorial describing the [[Block Party]] game distributed with the XO. |
** [http://www.redhatmagazine.com/2007/04/05/building-the-xo-porting-a-pygtk-game-to-sugar-part-one Porting a PyGTK Game to the XO] Very involved tutorial describing the [[Block Party]] game distributed with the XO. |
||
|display = block}} |
|||
{{anchor|References}} |
{{anchor|References}} |
||
=== References === |
=== References === |
||
{{Translated text| |
|||
These documents are frequently referenced during the development process. |
These documents are frequently referenced during the development process. |
||
Line 167: | Line 200: | ||
* [[Understanding sugar code]] provides an overview of how Sugar interacts with activities, including startup and shutdown, useful to understand the environment in which your activity will run |
* [[Understanding sugar code]] provides an overview of how Sugar interacts with activities, including startup and shutdown, useful to understand the environment in which your activity will run |
||
* [[Activity Bundles]] describes the packaging structure |
* [[Activity Bundles]] describes the packaging structure |
||
|display = block}} |
|||
{{anchor|Resources}} |
{{anchor|Resources}} |
||
=== Resources === |
=== Resources === |
||
{{Translated text| |
|||
* The [[:Category:Developers | Developer's Category]] collects everything in the wiki that's been tagged as pertaining to developers (it's a bit hard to navigate) |
* The [[:Category:Developers | Developer's Category]] collects everything in the wiki that's been tagged as pertaining to developers (it's a bit hard to navigate) |
||
* [[Developers Program]] focuses on development for the core system, but with information useful for activity developers as well |
* [[Developers Program]] focuses on development for the core system, but with information useful for activity developers as well |
||
Line 180: | Line 215: | ||
*[http://dev.laptop.org/git.do?p=projects/block-party-activity;a=tree BlockParty] for overall organization of an activity. |
*[http://dev.laptop.org/git.do?p=projects/block-party-activity;a=tree BlockParty] for overall organization of an activity. |
||
*[http://dev.laptop.org/git.do?p=projects/hellomesh;a=tree HelloMesh], [http://dev.laptop.org/git.do?p=projects/connect-activity;a=tree Connect] or [http://dev.laptop.org/git.do?p=projects/write;a=tree Write] for tubes. |
*[http://dev.laptop.org/git.do?p=projects/hellomesh;a=tree HelloMesh], [http://dev.laptop.org/git.do?p=projects/connect-activity;a=tree Connect] or [http://dev.laptop.org/git.do?p=projects/write;a=tree Write] for tubes. |
||
|display = block}} |
|||
{{anchor|Frequently Asked Questions}} |
{{anchor|Frequently Asked Questions}} |
||
Line 186: | Line 222: | ||
{{anchor|How do I do networking in Sugar?}} |
{{anchor|How do I do networking in Sugar?}} |
||
==== How do I do networking in Sugar? ==== |
==== How do I do networking in Sugar? ==== |
||
{{Translated text| |
|||
* Internal (to other laptops) (use Tubes) |
* Internal (to other laptops) (use Tubes) |
||
* External (to the wider internet) |
* External (to the wider internet) |
||
Line 194: | Line 231: | ||
** PyRO (Python remote objects) |
** PyRO (Python remote objects) |
||
** XMLRPC/SOAP |
** XMLRPC/SOAP |
||
|display = block}} |
|||
{{anchor|How do I create a persistent server/service?}} |
{{anchor|How do I create a persistent server/service?}} |
||
==== How do I create a persistent server/service? ==== |
==== How do I create a persistent server/service? ==== |
||
{{Translated text| |
|||
* How do I register for start-time loading? |
* How do I register for start-time loading? |
||
* Is there any dbus event service for loading only on response to messages? That is, not loading until there is an event of a given type, such as a presence event? |
* Is there any dbus event service for loading only on response to messages? That is, not loading until there is an event of a given type, such as a presence event? |
||
** Yes, of a sort, services are defined in .service files, these match a named service to an executable which is to provide that service. Thus one can register to handle requests for a given named service, but you still need to arrange to have that service called by something. |
** Yes, of a sort, services are defined in .service files, these match a named service to an executable which is to provide that service. Thus one can register to handle requests for a given named service, but you still need to arrange to have that service called by something. |
||
|display = block}} |
|||
{{anchor|How do I access the special hardware?}} |
{{anchor|How do I access the special hardware?}} |
||
Line 205: | Line 245: | ||
{{anchor|Camera}} |
{{anchor|Camera}} |
||
===== Camera ===== |
===== Camera ===== |
||
{{Translated text| |
|||
* Have to script v4l2 via gstreamer to capture a single frame from the camera. See sugar/shell/intro/glive.py for sample code |
* Have to script v4l2 via gstreamer to capture a single frame from the camera. See sugar/shell/intro/glive.py for sample code |
||
* Try this from the command line: <tt>gst-launch-0.10 v4l2src ! ffmpegcolorspace ! pngenc ! filesink location=foo.png</tt> |
* Try this from the command line: <tt>gst-launch-0.10 v4l2src ! ffmpegcolorspace ! pngenc ! filesink location=foo.png</tt> |
||
* See also: [[Programming the camera]] |
* See also: [[Programming the camera]] |
||
|display = block}} |
|||
{{anchor|Camera-as-video-camera (v4l2?)}} |
{{anchor|Camera-as-video-camera (v4l2?)}} |
||
===== Camera-as-video-camera (v4l2?) ===== |
===== Camera-as-video-camera (v4l2?) ===== |
||
{{Translated text| |
|||
* Is a regular v4l2 device available via gstreamer (gst module) |
* Is a regular v4l2 device available via gstreamer (gst module) |
||
** If you do not have hardware, you can simulate the camera interactively with an regular v4l2 source (many cheap web-cams provide this type of source) |
** If you do not have hardware, you can simulate the camera interactively with an regular v4l2 source (many cheap web-cams provide this type of source) |
||
Line 216: | Line 259: | ||
* Try this from a terminal in the developer console: <tt>gst-launch-0.10 v4l2src ! ximagesink</tt> (The image will appear <i>behind </i>the developer console window so you'll need to move the window aside.) |
* Try this from a terminal in the developer console: <tt>gst-launch-0.10 v4l2src ! ximagesink</tt> (The image will appear <i>behind </i>the developer console window so you'll need to move the window aside.) |
||
* See also: [[Programming the camera]] |
* See also: [[Programming the camera]] |
||
|display = block}} |
|||
{{anchor|Directional pad/buttons}} |
{{anchor|Directional pad/buttons}} |
||
===== Directional pad/buttons ===== |
===== Directional pad/buttons ===== |
||
{{Translated text| |
|||
* Have their own X key names |
* Have their own X key names |
||
* Currently 4-button set mapped to arrow (cursor) keys |
* Currently 4-button set mapped to arrow (cursor) keys |
||
* Two separate buttons mapped to ??? (pageup/pagedown) |
* Two separate buttons mapped to ??? (pageup/pagedown) |
||
|display = block}} |
|||
{{anchor|Touchpad}} |
{{anchor|Touchpad}} |
||
Line 228: | Line 274: | ||
{{anchor|Drawing pad (stylus pad)}} |
{{anchor|Drawing pad (stylus pad)}} |
||
===== Drawing pad (stylus pad) ===== |
===== Drawing pad (stylus pad) ===== |
||
{{Translated text| |
|||
* How to switch in/out of stylus mode? |
* How to switch in/out of stylus mode? |
||
* How to set interpretation parameters? |
* How to set interpretation parameters? |
||
|display = block}} |
|||
{{anchor|Audio-port probe}} |
{{anchor|Audio-port probe}} |
||
===== Audio-port probe ===== |
===== Audio-port probe ===== |
||
{{Translated text| |
|||
* How to get access? |
* How to get access? |
||
** What's going to come out when I get access (keeping in mind I (the developer) likely won't have the actual hardware available) |
** What's going to come out when I get access (keeping in mind I (the developer) likely won't have the actual hardware available) |
||
|display = block}} |
|||
{{anchor|Mode-switching code for the screen}} |
{{anchor|Mode-switching code for the screen}} |
||
===== Mode-switching code for the screen ===== |
===== Mode-switching code for the screen ===== |
||
{{Translated text| |
|||
* backlight on/off |
* backlight on/off |
||
* backlight brightness |
* backlight brightness |
||
Line 244: | Line 295: | ||
* drop to a lower resolution for performance or ease of porting, such as 600x450 or 400x300 |
* drop to a lower resolution for performance or ease of porting, such as 600x450 or 400x300 |
||
See also [[Display]]. |
See also [[Display]]. |
||
|display = block}} |
|||
{{anchor|How do I create my activity GUI?}} |
{{anchor|How do I create my activity GUI?}} |
||
==== How do I create my activity GUI? ==== |
==== How do I create my activity GUI? ==== |
||
{{Translated text| |
|||
* Can I just use [[Cairo]], [[Pygame]] or [[GTK]] directly? |
* Can I just use [[Cairo]], [[Pygame]] or [[GTK]] directly? |
||
** Sugar's own GUI interface is coded in a GTK derived library (Hippo), using an internal "sugar.graphics" package. This package is currently in flux and you should not likely start new projects using it until the API stabilises. In the meantime please use GTK or PyGame (SDL) for you project's GUI. |
** Sugar's own GUI interface is coded in a GTK derived library (Hippo), using an internal "sugar.graphics" package. This package is currently in flux and you should not likely start new projects using it until the API stabilises. In the meantime please use GTK or PyGame (SDL) for you project's GUI. |
||
Line 265: | Line 318: | ||
*** Usable if you can set up a reasonably-performing emulated system or upgrade your system to support Sugar directly |
*** Usable if you can set up a reasonably-performing emulated system or upgrade your system to support Sugar directly |
||
* How does [[HippoCanvas]] work? |
* How does [[HippoCanvas]] work? |
||
|display = block}} |
|||
{{anchor|How do I package my activity?}} |
{{anchor|How do I package my activity?}} |
||
==== How do I package my activity? ==== |
==== How do I package my activity? ==== |
||
{{Translated text| |
|||
* How do I work from an in-process activity (develop registration)? |
* How do I work from an in-process activity (develop registration)? |
||
** setup.py develop |
** setup.py develop |
||
Line 283: | Line 338: | ||
*** Pygsear or other PyGame extensions |
*** Pygsear or other PyGame extensions |
||
** How do I provide my own base packages on top of which I have written dozens of applications? |
** How do I provide my own base packages on top of which I have written dozens of applications? |
||
|display = block}} |
|||
{{anchor|How do I share files between applications?}} |
{{anchor|How do I share files between applications?}} |
||
==== How do I share files between applications? ==== |
==== How do I share files between applications? ==== |
||
{{Translated text| |
|||
Plan at the moment is to have file-sharing handled by the underlying system. That is, the system will simply notice that you have duplicate files with the same properties and hash and will share them between the two activities. |
Plan at the moment is to have file-sharing handled by the underlying system. That is, the system will simply notice that you have duplicate files with the same properties and hash and will share them between the two activities. |
||
|display = block}} |
|||
{{anchor|How do I test a Sugar activity?}} |
{{anchor|How do I test a Sugar activity?}} |
||
==== How do I test a Sugar activity? ==== |
==== How do I test a Sugar activity? ==== |
||
{{Translated text| |
|||
* Start sugar, start a bash shell, run "sugar-jhbuild shell" to set up the sugar environment variables, then use "sugar-activity YourActivityName" to run the activity with output going to your local shell |
* Start sugar, start a bash shell, run "sugar-jhbuild shell" to set up the sugar environment variables, then use "sugar-activity YourActivityName" to run the activity with output going to your local shell |
||
|display = block}} |
|||
{{anchor|How do I debug a Sugar activity?}} |
{{anchor|How do I debug a Sugar activity?}} |
||
==== How do I debug a Sugar activity? ==== |
==== How do I debug a Sugar activity? ==== |
||
{{Translated text| |
|||
If you start your Sugar activity from the command line, you can insert a standard Python: |
If you start your Sugar activity from the command line, you can insert a standard Python: |
||
Line 302: | Line 363: | ||
command into your activity and then use the Python debugger to step through your activity's behaviour. Note that this will "freeze" your application while you are working, so you may have display issues. |
command into your activity and then use the Python debugger to step through your activity's behaviour. Note that this will "freeze" your application while you are working, so you may have display issues. |
||
|display = block}} |
|||
{{anchor|How do I publish for others to consume?}} |
{{anchor|How do I publish for others to consume?}} |
||
Line 308: | Line 370: | ||
{{anchor|How do I edit with emacs on the laptop?}} |
{{anchor|How do I edit with emacs on the laptop?}} |
||
==== How do I edit with emacs on the laptop? ==== |
==== How do I edit with emacs on the laptop? ==== |
||
{{Translated text| |
|||
* Install [http://www.mtxia.com/fancyIndex/Tools/Editors/MicroEMACS/ MicroEMACS] by copying [http://www.mtxia.com/fancyIndex/Tools/Editors/MicroEMACS/me404linux.bin this file] to the laptop. |
* Install [http://www.mtxia.com/fancyIndex/Tools/Editors/MicroEMACS/ MicroEMACS] by copying [http://www.mtxia.com/fancyIndex/Tools/Editors/MicroEMACS/me404linux.bin this file] to the laptop. |
||
* [http://zile.sourceforge.net/ Zile] may be closer to what you expect from Emacs install this RPM [ftp://rpmfind.net/linux/fedora/extras/6/i386/zile-2.2.19-1.fc6.i386.rpm this rpm file] to get it. |
* [http://zile.sourceforge.net/ Zile] may be closer to what you expect from Emacs install this RPM [ftp://rpmfind.net/linux/fedora/extras/6/i386/zile-2.2.19-1.fc6.i386.rpm this rpm file] to get it. |
||
|display = block}} |
|||
{{anchor|How do I mount a USB drive?}} |
{{anchor|How do I mount a USB drive?}} |
||
==== How do I mount a USB drive? ==== |
==== How do I mount a USB drive? ==== |
||
{{Translated text| |
|||
Normally this is done automatically by the HAL when you plug the USB key into the laptop. It will show up as a directory in the /media folder. If, however, you had the USB key in when you started the machine, or the HAL doesn't recognize the key, you may not get the mount completed. In that case you can try manually mounting the key: |
Normally this is done automatically by the HAL when you plug the USB key into the laptop. It will show up as a directory in the /media folder. If, however, you had the USB key in when you started the machine, or the HAL doesn't recognize the key, you may not get the mount completed. In that case you can try manually mounting the key: |
||
Line 322: | Line 387: | ||
* Don't forget to unmount it before removal: <tt>$ umount /mnt/usb</tt> |
* Don't forget to unmount it before removal: <tt>$ umount /mnt/usb</tt> |
||
* If anything fails you should edit your <tt>/etc/fstab</tt> file to include the mount point, device, and filesystem for the device to mount. |
* If anything fails you should edit your <tt>/etc/fstab</tt> file to include the mount point, device, and filesystem for the device to mount. |
||
|display = block}} |
|||
[[Category:Developers]] |
[[Category:Developers]] |
Revision as of 04:53, 22 August 2007
- This is an on-going translation
Thank you for considering working on the One Laptop Per Child project. This page tries to provide you with the answers you need to get started either by contributing to existing projects or starting your own. See also Game Development Newbies
Setting up a Development Environment
The OLPC's software environment is a heavily modified Fedora Core Linux system running a custom GUI shell (Sugar). To develop for the platform you will eventually need access to a platform which runs in a manner substantially similar to the OLPC environment. Luckily there are many available options.
Option 1 - sugar-jhbuild
Compared with using an Emulated XO, installing sugar takes more time and space to set up, but results in a better environment. This is what the core development team uses.
On 32-bit Linux
sugar-jhbuild builds a parallel set of the libraries required to run the OLPC software. This approach generally works reasonably well on most modern Linux distributions. On some linuxes (32-bit Ubuntu, 32-bit Fedora(?)), it "just works". Though the build system (jhbuild) can be fragile. On others, you may spend quite some time rebuilding and fixing errors to get a final working system, so consider running a "just works" linux in emulation.
On Windows/Mac/Linux, w/ virtual Linux
sugar-jhbuild, on a virtual 32-bit Ubuntu, inside of an emulator (eg, Parallels, qemu, vmware).
Option 2 - Emulated XO
Running an XO OS image in emulation is, for Unix-friendly developers (those who like using command-line tools via ssh), the simplest way to start developing for the OLPC system. They can be run in one of the popular emulation/virtualisation systems, such as Qemu, VMWare or Parallels. These images allow you to run a virtual OLPC-configured machine on your regular development workstation.
These official images do not provide GUI IDEs or SVG graphics editors. They normally would be used either with command-line tools (e.g. VIM) or using NFS (or ssh, or similar) to a workstation on which you will do your actual coding.
Option 3 - Sugar on Linux, images / LiveCD
Developer Images are intended to be used as virtual desktop machines. The images have far more software than is installed on the OLPC laptops. They resemble a developer's desktop machine which has been upgraded to support the Sugar environment. They tend to have GUI IDEs, full Gnome desktop installations and the like, which make it easy for developers to work entirely within the emulated environment.
Developers working on Developer Images should be sure to test their creations on real OLPC Laptops or official images in order to be sure that they do not have dependencies on software not available on the actual laptops.
- As of 2007-May-23, the developer images have not been updated since early April. Is this approach depreciated? MitchellNCharity 18:13, 23 May 2007 (EDT)
- No, it is *not* deprecated. For those who are not Linux developers the developer builds are much more likely to allow for starting to develop on day one. These images are intended to be download-and-start-coding tools for developers who prefer GUI environments for working. Mcfletch 24 May 2007
- Might such developers be better off with running sugar-jhbuild on a virtual Ubuntu? MitchellNCharity 09:02, 23 June 2007 (EDT)
- May as well reverse this advice. Until such time as we get new developer builds, yes, you probably need to go elsewhere. Getting new developer builds created is becoming a bit of a priority as a result. Mcfletch 12 Aug 2007
- No, it is *not* deprecated. For those who are not Linux developers the developer builds are much more likely to allow for starting to develop on day one. These images are intended to be download-and-start-coding tools for developers who prefer GUI environments for working. Mcfletch 24 May 2007
Option 4 - Sugar on Linux, upgraded libaries
Update your Linux operating system to such a point that it resembles the OLPC environment. You then need only use the more fragile build system for a tiny fraction of the packages required. You should be aware that such upgrades often will require you to update well beyond the "stable" configurations for your Linux distribution, and as such may make your system unstable.
- As of 2007-04-08 only Fedora Core 6/7, Gentoo and Ubuntu Feisty Fawn are known to upgrade reasonably well.
- As of 2007-05-23 it appears this approach is deprecated on Fedora Core, and doesn't work with x86_64. MitchellNCharity 16:54, 23 May 2007 (EDT)
Option 5 - A real XO laptop
Hardware Developer's Program - while there are only a small number of test units being produced, developers can submit proposals to receive one of those units for testing and development.
Operating Environment
Languages:
- Technically any language is usable
- Python is strongly encouraged, to have a single language "under the hood" when the curious child looks inside
- C/C++ should be used where Python performance is unacceptable, but try to keep it to a minimum, preferably as standard well-encapsulated and documented components
- Smalltalk-speaking developers may wish to work within the eToys environment
- Javascript can be used in web-based applications (Gecko or Opera engine Javascript implementation)
GUI Environments:
- PyGTK or the PyGTK-derived Sugar system should be used for most "Window, Icon, Mouse, Pointer" type GUIs. Note, however, as of 2007-04-21 that the Sugar "graphics" package is in Flux.
- Pygame SDL-based 2D game environment can be used for "Canvas" graphics using "Sprites".
- (Mozilla) XULRunner can be used to develop Gecko-based activities
Operating Stack:
Libraries/modules:
- Check to see what libraries are included before you begin development. Even some "universally available" libraries, such as OpenGL, are not available!
- Carefully choose support modules to minimize your storage footprint, for instance if you need a database, choose Sqlite rather than MySQL. Or better yet, use dbm.
- If you are unsure what is supported, ask.
Testing/working:
- Test your application in an official image (or a physical laptop) before publishing broadly
- To conserve memory or improve performance, consider replacing problematic areas in your Python code with C. For example, a rewrite of the hardware manager service in C saved 1.8 megabytes of private dirty memory. On a machine with only 256 megabytes of RAM and no swap space, efficient use of memory can make the difference between a usable system and a system made unreliable by out-of-memory failures.
- Distribute your source code under the GPL, LGPL or MIT license.
Operating Environment
Most developers will probably be working on an Activity for use on the OLPC. This kind of development can normally be done with little interaction with other development groups, save for the core Sugar developers (whose work directly affects activity developers).
Communications Channels
Most of the core developers use IRC for instant-messaging-style communications:
irc.freenode.net #sugar
the Sugar mailing list is also used for broader comment and collaboration:
List Information
If you have a large number of developers in a given area and would like to set up a local discussion list, post to the Sugar mailing list with a request for a new discussion list.
Current Active Local Discussion Lists:
Requests and Ideas for Projects
Software ideas describes activity and tool types that are currently needed. If you have an idea for an activity, add it to the list in the appropriate category (create a new category if necessary). You can create a new wiki page to describe your idea in more detail.
Existing Projects
Software projects describes the currently active projects that may need help. Once you have decided on a project, add yourself to the list along with your contact information, homepage (which may be a wiki page on the OLPC wiki), etceteras. In particular, the various Activities available on the XO may need help as build time draws near; if you're looking for an existing project to get your feet wet with, check there.
Available Resources
The Developers Program provides general project management facilities for OLPC projects.
Documentation
Tutorials
- Original HelloWorld Tutorial using regular GTK
- Tuquito's Hello World! using GTK+Glade rather than hand-coded GTK
- Red Hat Magazine
- Introducing Sugar Article describing how to use sugar-jhbuild to set up a development environment
- Anatomy of an Activity Basic Hello World style introduction to creating a new activity
- Porting a PyGTK Game to the XO Very involved tutorial describing the Block Party game distributed with the XO.
References
These documents are frequently referenced during the development process.
- Sugar Architecture covers Sugar APIs and specifications
- Human interaction guidelines (HIG) for Sugar activities
- Bitfrost summary (full spec) the security system which will control activities and their interaction with the system and other users
- Sugar PyDoc just provides the raw API documentation, which is severely lacking in documentation strings (Good familiarisation project might be working with Marco to improve that situation)
- Hippo PyDoc again, just raw API documentation, needs lots of documentation effort
- Software components is a somewhat old document describing the various pieces of software and libraries involved in the system.
- Instructions on using the Sugar user interface
- Understanding sugar code provides an overview of how Sugar interacts with activities, including startup and shutdown, useful to understand the environment in which your activity will run
- Activity Bundles describes the packaging structure
Resources
Frequently Asked Questions
How do I do networking in Sugar?
- Internal (to other laptops) (use Tubes)
- External (to the wider internet)
- Activity Sharing (session establishment)
- Otherwise general Python networking
- Twisted (will this be available on the images?)
- Asyncore
- PyRO (Python remote objects)
- XMLRPC/SOAP
How do I create a persistent server/service?
- How do I register for start-time loading?
- Is there any dbus event service for loading only on response to messages? That is, not loading until there is an event of a given type, such as a presence event?
- Yes, of a sort, services are defined in .service files, these match a named service to an executable which is to provide that service. Thus one can register to handle requests for a given named service, but you still need to arrange to have that service called by something.
How do I access the special hardware?
Camera
Camera-as-video-camera (v4l2?)
- Is a regular v4l2 device available via gstreamer (gst module)
- If you do not have hardware, you can simulate the camera interactively with an regular v4l2 source (many cheap web-cams provide this type of source)
- For test-driven development, you can use any gstreamer source (such as a regular file), hooking up your code to use a file source instead of a v4l2src
- Try this from a terminal in the developer console: gst-launch-0.10 v4l2src ! ximagesink (The image will appear behind the developer console window so you'll need to move the window aside.)
- See also: Programming the camera
Directional pad/buttons
- Have their own X key names
- Currently 4-button set mapped to arrow (cursor) keys
- Two separate buttons mapped to ??? (pageup/pagedown)
Touchpad
Drawing pad (stylus pad)
- How to switch in/out of stylus mode?
- How to set interpretation parameters?
Audio-port probe
- How to get access?
- What's going to come out when I get access (keeping in mind I (the developer) likely won't have the actual hardware available)
Mode-switching code for the screen
- backlight on/off
- backlight brightness
- set all 8 (4 distinct) settings for MODE_MONO_LUMA, MODE_CSWIZZLE, MODE_COL_AA
- query, change, and restrict screen orientation
- drop to a lower resolution for performance or ease of porting, such as 600x450 or 400x300
See also Display.
How do I create my activity GUI?
- Can I just use Cairo, Pygame or GTK directly?
- Sugar's own GUI interface is coded in a GTK derived library (Hippo), using an internal "sugar.graphics" package. This package is currently in flux and you should not likely start new projects using it until the API stabilises. In the meantime please use GTK or PyGame (SDL) for you project's GUI.
- How can a non-GTK (or Qt) app fully interact with Sugar?
- At the moment it cannot do this easily.
- Sugar is using custom dbus messages to communicate with a server that must be present for every activity. That restriction may be relaxed in the future.
- Can be easily "fixed" by creating a wrapper in Python (e.g. the ClassicGnome activity)
- Can write various DBUS services using a GTK event loop to provide the required introspection services (implies that GTK must be loaded by every process, regardless of whether it is needed)
- Can alter your core event loop to cooperate with an embedded GObject event loop (PyGame allows this, for instance), with the small concern that this requires loading GObject into your process' memory space
- How flexible does the GUI need to be?
- Should be able to handle a resize-and-rotate event from the X server
- Should be able to handle internationalisation/localisation, including to right-to-left-written scripts
- What's the best development approach:
- Write outside Sugar, finish and debug, then port?
- For older PowerPC-based Macs, this is likely the best approach
- Write to Sugar, test and debug within the system?
- Usable if you can set up a reasonably-performing emulated system or upgrade your system to support Sugar directly
- Write outside Sugar, finish and debug, then port?
- How does HippoCanvas work?
How do I package my activity?
- How do I work from an in-process activity (develop registration)?
- setup.py develop
- You can use sugar-activity to start the activity, but you have to manually close it (using the Sugar GUI: show the frame, then move to the activity icon on the top bar, hover for a second, then click close (yes, it's really that awkward))
- How do I produce a binary extension?
- How do I make my package available for users to download dynamically?
- How do I tell users about updates to the packages?
- How do I share code between activities?
- How do I use (large, common) Python packages?
- Numpy
- Matplotlib
- MySQL or PostgreSQL client code
- Twisted
- Zope Interfaces
- Pygsear or other PyGame extensions
- How do I provide my own base packages on top of which I have written dozens of applications?
- How do I use (large, common) Python packages?
Plan at the moment is to have file-sharing handled by the underlying system. That is, the system will simply notice that you have duplicate files with the same properties and hash and will share them between the two activities.
How do I test a Sugar activity?
- Start sugar, start a bash shell, run "sugar-jhbuild shell" to set up the sugar environment variables, then use "sugar-activity YourActivityName" to run the activity with output going to your local shell
How do I debug a Sugar activity?
If you start your Sugar activity from the command line, you can insert a standard Python:
import pdb pdb.set_trace()
command into your activity and then use the Python debugger to step through your activity's behaviour. Note that this will "freeze" your application while you are working, so you may have display issues.
How do I publish for others to consume?
How do I edit with emacs on the laptop?
- Install MicroEMACS by copying this file to the laptop.
- Zile may be closer to what you expect from Emacs install this RPM this rpm file to get it.
How do I mount a USB drive?
Normally this is done automatically by the HAL when you plug the USB key into the laptop. It will show up as a directory in the /media folder. If, however, you had the USB key in when you started the machine, or the HAL doesn't recognize the key, you may not get the mount completed. In that case you can try manually mounting the key:
- Enter the linux shell mode
- First become root: $ su
- Then make a place to mount it: $ mkdir /mnt/usb
- Then mount the drive: $ mount /dev/sda1 /mnt/usb
- Don't forget to unmount it before removal: $ umount /mnt/usb
- If anything fails you should edit your /etc/fstab file to include the mount point, device, and filesystem for the device to mount.