Skip to content

Commit

Permalink
Initial import of XobotOS into the public repo
Browse files Browse the repository at this point in the history
  • Loading branch information
migueldeicaza committed Apr 30, 2012
0 parents commit f20db62
Show file tree
Hide file tree
Showing 20,992 changed files with 5,956,527 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/Debug
/build
/bin
/upstream
/ipch/
/*.pidb
/*.suo
/*.sdf
/*.opensdf
/*.userprefs
12 changes: 12 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Mon Oct 24 21:46:34 CEST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
118 changes: 118 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
XobotOS project
===============

XobotOS is a Xamarin research project that explored porting Android
4.0 from Java/Dalvik to C# to explore the performance and memory
footprint benefits of C#.

XobotOS is a semi-automated port of the Android 4.0 source code from
Java to C#. The automated parts were ported using an improved version
of Sharpen that can compile more advanced Java constructs and supports
generics. Most of the manual bits of code fall in two categories (a)
code to integrate with the host operating system and (b) replace the
Java JNI code used to call into C, with the ECMA CLI P/Invoke
functionality.

License
=======

The various components of XobotOS are licensed under the same license
as their upstream providers. The C# versions of Android is licensed
under the terms of the Apache 2 license, while the improved version of
Sharpen is licensed under the GPL.

XobotOS Source Code
===================

XobotOS is made up of the following sources:

sharpen:

* Our updated version of Sharpen, see below for changes.

android/generated:

* Fully translated Java to C# code, classes that have been
translated in this way contain the attribute [Sharpen.Sharpened]

* Empty C# stubs based on the Java declaration: these are
needed as intermediate steps to get things to build in the
new C# world. Classes with empty stubs are decorated with
the [Sharpen.NakedStub] attribute

android/extra-sources:

* Custom written code that either fine tunes the port,
provides an alternative optimized version to a class or
provides a runtime facility.

android/api:

* XML files that describe the translation process from Java to C#.

android/upstream:

* Google's Android 4.0 source code.

libxobotos:

* Glue code to integrate with various Android C++ libraries as
well as the Linux X11 host that sets up the toplevel window
and the optional OpenGL context.

* Mostly calls into Skia, Jpeg, OpenGL and ICU libraries.

binaries:

* Libraries to get you started without requiring you to build Skia,
and other native Android tools.

* Screenshots, videos, and some basic precompiled samples.

monodevelop:

* Add-in to build native XobotOS applications with MonoDevelop

samples:

* Ported samples to C# using XobotOS

external:

* Native libraries needed to build the unmanaged libxobotos C library

Sharpen
=======

The outcome of this project is a vastly improved Sharpen tool that is
able to port very sophisticated and advanced Java codebases from Java
to C#. This code lives in the "sharpen" directory.

This modified version of Sharpen can cope with the following enhancements:

* Java generics

* XML-driven translation process

* Type remapping for native Java types to C# types, and supports
for custom type mappings.

* Support for translating code that does native interop

* Support for generating C's .c and .h files for native glue
(to assist in P/Invoke support)

* Add attribute-supported translations

* Improved incremental compilation

Documentation on the improved Sharpen engine will be posted in the
future so other developers can more easily port Java code to C#.

Support
=======

This code is provided as-is, and we do not offer support for any bits
of code here, nor does Xamarin plan on continuing evolving XobotOS at
this point.

140 changes: 140 additions & 0 deletions README.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
PREREQUISITES:
==============

(*) Do not attempt to run this on OpenSuSE 12.1.

If you do have OpenSuSE 12.1, then start Eclipse, create a simple "Hello World"
in Java, compile and run it - if that works for you without crashing, then you
may be lucky.

They did something in their glibc that's causing random crashes in Sun's JVM,
this has made Eclipse so unstable that I had to downgrade to OpenSuSE 11.4

(*) Prior to building, you need to increase memory size in Eclipse
(http://wiki.oseems.com/application/eclipse/fix-gc-overhead-limit-exceeded)

I'm using -Xms2048m and -Xmx4096m.

(*) To get Fonts working on Linux, you must follow these instructions:
http://code.google.com/p/chromium/wiki/LinuxOpenSuseBuildInstructions
(creating all these symlinks is required).

SETTING THINGS UP:
==================

You need to create to separate Eclipse workspaces for this and checkout the
XobotOS module in each of these. I'm using /work/workspace and /work/test.

If you start Eclipse for the first time, then it'll ask you for the workspace
directory. Once it created that, checkout XobotOS in it.

In Eclipse, do File / Import / General / Existing Projects into Workspace,
select /work/workspace/XobotOS as root directory, then it should offer you to
import 5 projects. Select sharpen.core and sharpen.xobotos (sharpen.feature
and sharpen.site are not used at the moment, and you do not want 'android' in
this workspace). Make sure _not_ to copy them into the workspace, that checkbox
must not be checked.

When imported, you should see the 'sharpen.core' and 'sharpen.xobotos' projects.

Select Project / Build automatically.

Open sharpen.xobotos/plugin.xml. At the top of the "Overview" tab, you should
see four buttons, the leftmost of these is "Launch an Eclipse application".
Click it, and another instance of Eclipse will start.

The first time this inferior instance of Eclipse starts up, it will ask you for
a workspace directory. Checkout XobotOS inside that directory, then do the import
as described above, but only select the 'android' module.

You are now ready :-)

You only need to follow the instructions in this section the first time that you're
running this in Eclipse. Eclipse remembers which projects you had open and your last
run configuration, so when you come back, you can simply start Eclipse, then do
Run / Run (or Run / Debug to debug it).

RUNNING THE BUILDER:
====================

Well, that's easy.

Simply do Project / Build, then get some coffee or take a walk ....

Current time for a full build is about 10 minutes on my machine.

When done, all the generated sources are placed in the output/ directory and
XobotOS-debug.csproj is automatically updated.

BUILDING THE C# SOURCES:
========================

There is a XobotOS-debug.sln file in the top level directory (/work/test/XobotOS/XobotOS-debug.sln),
simply open this in MonoDevelop or use xbuild.

It is highly recommended to close the solution in MonoDevelop before doing a full build.

BUILDING THE C# SOURCES FROM GITHUB:
====================================

You can also directly compile the C# sources from github:

After checking out or updating, simply open XobotOS.sln in MonoDevelop.

Note that there are two solutions:

* XobotOS.sln uses the sources from github.

* XobotOS-debug.sln uses the freshly convereted files from the android/output
directory.

BUILDING THE SAMPLES:
=====================

This is a little bit complicated and still unstable, but here's how it should work:

First, check http://code.google.com/p/skia/wiki/GettingStartedOnLinux or
http://code.google.com/p/skia/wiki/GettingStartedOnWindows and install all the
prerequisites listed in there.

On Linux, you also need to follow these instructions:
http://code.google.com/p/chromium/wiki/LinuxOpenSuseBuildInstructions.

Create a directory called 'build' if it doesn't already exist, cd into that directory,
then run

(cd .. && python gyp_xobotos)

This will generate a Makefile in the build/ directory, running 'make' will
build all the native Skia and Android code.

The output gets placed in build/Debug/lib.target. You either have to add that
directory to your LD_LIBRARY_PATH or manually copy the libxobotos.so.

Open XobotOS.sln or XobotOS-debug.sln in MonoDevelop (depending on whether you
want to use the sources from github or the newly converted ones, see above)
and build the solution.

SAMPLE ARCHITECTURE:
====================

There's a class called XobotOS.Runtime.ActivityManager which is responsible
for running a sample Activity.

We use a modified version of Android's 'aapt' tool called 'xorpt', which compiles
the AndroidManifest.xml and the resources into a '<assembly>-res.zip' and also
creates a R.cs.

TestActivity.csproj has a pre-build rule which automatically runs xorpt:

<CustomCommands>
<CustomCommands>
<Command type="BeforeBuild" command="${TargetDir}/xorpt p -f -S res -F TestActivity-res.zip -J . -M AndroidManifest.xml -I ${SolutionDir}/android/system-root/framework/framework-res.apk" workingdir="${ProjectDir}" pauseExternalConsole="true" />
</CustomCommands>
</CustomCommands>

On startup, ActivityManager uses android.content.pm.PackageParser to parse the
resource file and get the startup activity from the AndroidManifest.xml.

We already support constructing a view from XML.

14 changes: 14 additions & 0 deletions README.devices
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
XobotOS now has experimental multi-device support.

See http://developer.android.com/guide/practices/screens_support.html and
http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

XobotOS.exe now takes an optional '--device=handheld' or '--device=tablet'
argument to run with a different screen size. This must be given as first
argument, before the assembly:

$ mono --debug ../build/Debug/XobotOS.exe --device=tablet ../build/Debug/Fragments.dll

samples/Fragments demonstrate an app that looks and behaves differently on a
handheld and a tablet.

Loading

0 comments on commit f20db62

Please sign in to comment.