Light Style© by Fisana

Jump to content


Android port


  • Please log in to reply
255 replies to this topic

#61 Guest_afeder_*

Guest_afeder_*
  • Guests

Posted 20 January 2012 - 03:29 PM

You should run update-workspaces.sh after setting HOSTTYPE, but before setting PATH or CXX or anything else. That will build the bundled libraries (SpiderMonkey etc) like in a normal non-Android build with the standard x86/amd64 version of GCC - those libraries won't be usable by an Android version of the game but we can deal with that problem later once the game's compile errors are fixed.

Then set PATH and CXX, and run the 'make' command from inside workspaces/gcc/ (like in a normal build of the game, except now it's using the Android compiler).

Yup, that did the trick.
  • 0

#62 Guest_afeder_*

Guest_afeder_*
  • Guests

Posted 22 January 2012 - 10:01 AM

Does the Premake build system override the compiler sysroot somehow? I get errors of this type when running make:

../../../source/lib/external_libraries/opengl.h:40:24: fatal error: GLES2/gl2.h: No such file or directory
Even though the file should exist:

afeder@ubuntu:~/android/0ad/build/workspaces/gcc$ ls `$CXX -print-sysroot`/usr/include/GLES2/gl2.h
/home/afeder/android/toolchain/bin/../sysroot/usr/include/GLES2/gl2.h
Edit: it seems the issue was that the makefile doesn't honor the $CXX environment variable - I had to pass it as a command-line option instead.
Edit2: my bad - I had failed to export the variable. Posted Image

Edited by afeder, 23 January 2012 - 10:06 AM.

  • 0

#63 Guest_afeder_*

Guest_afeder_*
  • Guests

Posted 28 January 2012 - 01:00 PM

I've cross-compiled Boost, SDL, libcurl, libpng and libjpeg under the setup Ykkrosh suggested. My error output now looks like this. As you can see, it's mostly down to graphics and sound (though I haven't dealt with the bundled dependencies yet.)

A few questions:
- What does the game use FAM for and is there some way to disable it (at build time)?
- Does the game use libogg and libvorbis for anything but simple playback of sound and music assets? If not, I suggest porting those parts to OpenSL ES, as it supports this natively, meaning less risk of breakage (it's maintained by Google/handset manufacturers) and better utilization of device-specific features like ARM NEON (i.e. better performance).

Edited by afeder, 28 January 2012 - 02:10 PM.

  • 0

#64 Ykkrosh

Ykkrosh

    Primus Pilus

  • WFG Programming Team
  • 4,921 posts

Posted 28 January 2012 - 03:05 PM

Looks great so far :)

- What does the game use FAM for and is there some way to disable it (at build time)?

It's used for detecting changes to files (so e.g. a modder can edit a texture and immediately see the changes in the game). The game will work fine without it.

We currently have this platform-specific code in source/lib/sysdep/os/. Windows uses the "win" directory, Linux uses "linux" plus "unix" plus "unix/x", OS X uses "osx" plus "unix" plus "unix/x". Android should probably still use the "linux" directory, since it runs the Linux kernel and most of that code is relevant; it's not really a separate OS. (Also it should use "unix" but not "unix/x"). I suppose FAM/Gamin support is technically orthogonal to OS/kernel/etc - currently Gamin is only implemented on Linux but the API could work anywhere - so it's theoretically inappropriate to have it in the "linux" directory, and we theoretically probably ought to arrange things based on feature-detection rather than on detected OS... But that sounds like a lot of effort, so in practice I'll probably add some #define to just cut out the FAM code.

- Does the game use libogg and libvorbis for anything but simple playback of sound and music assets?

Depends what "simple" means, but we only use them for playback. Probably the best thing in the short term is to just #ifdef out all the problematic sound code, since we'll probably redesign most of that code in the future anyway so there's not point porting it yet.

(Incidentally, I'm planning to get an Android phone (Galaxy S II) in the next few days, so this might become of more than hypothetical interest to me :))
  • 0
Philip Taylor [aka Ykkrosh]

Wildfire Games Programmer
Contact me: philip@wildfiregames.com

#65 Ykkrosh

Ykkrosh

    Primus Pilus

  • WFG Programming Team
  • 4,921 posts

Posted 28 January 2012 - 04:43 PM

Committed a few more fixes (with Premake flags --without-fam, --without-audio to disable the offending features for now). Now the only compile errors I get in the 'lowlevel' project are ogl_shader.cpp, plus some because I haven't bothered installing libpng/libjpeg yet. (There's going to be lots of link errors later though.)
  • 0
Philip Taylor [aka Ykkrosh]

Wildfire Games Programmer
Contact me: philip@wildfiregames.com

#66 Guest_afeder_*

Guest_afeder_*
  • Guests

Posted 28 January 2012 - 06:18 PM

(Incidentally, I'm planning to get an Android phone (Galaxy S II) in the next few days, so this might become of more than hypothetical interest to me :))

Great. I'll add it to the 'Target devices' section :)

Committed a few more fixes (with Premake flags --without-fam, --without-audio to disable the offending features for now). Now the only compile errors I get in the 'lowlevel' project are ogl_shader.cpp, plus some because I haven't bothered installing libpng/libjpeg yet. (There's going to be lots of link errors later though.)

What link errors do you foresee (other than the bundled dependencies)? What is not accounted for by the current setup?
  • 0

#67 Ykkrosh

Ykkrosh

    Primus Pilus

  • WFG Programming Team
  • 4,921 posts

Posted 28 January 2012 - 07:51 PM

What link errors do you foresee (other than the bundled dependencies)?

There needs to be some new code added, equivalent to lib/sysdep/os/unix/x/x.cpp (should be mostly trivial), and lib/sysdep/arch/x86_x64/x86_x64.h and lib/sysdep/arch/ia32/ia32.cpp (probably not too hard). I suppose that's not really a lot, and linker errors will point out exactly which functions are missing, so it shouldn't be a big problem.
  • 0
Philip Taylor [aka Ykkrosh]

Wildfire Games Programmer
Contact me: philip@wildfiregames.com

#68 Pureon

Pureon

    Primus Pilus

  • 0 A.D. Art Team
  • 3,537 posts

Posted 28 January 2012 - 09:20 PM

I'm planning to get an Android phone (Galaxy S II) in the next few days

Works flawlessly for me.
  • 0

Pureon
0 A.D. Part time Designer / Texturer / 3D Artist
Contact email:
pureon{@}wildfiregames.com


#69 WhiteTreePaladin

WhiteTreePaladin

    Primus Pilus

  • WFG Retired
  • 1,586 posts

Posted 28 January 2012 - 10:36 PM

Galaxy S III

;)
  • 0

Brian [aka WhiteTreePaladin]

0 A.D. Gameplay and UI Developer


#70 Ykkrosh

Ykkrosh

    Primus Pilus

  • WFG Programming Team
  • 4,921 posts

Posted 28 January 2012 - 11:41 PM

Yeah, anything available now will be totally obsolete within six months :(. But it seems nice enough for now, and relatively good value ('free' with 24/month * 24 month contract, via O2), so I think I'll be adequately happy :)
  • 0
Philip Taylor [aka Ykkrosh]

Wildfire Games Programmer
Contact me: philip@wildfiregames.com

#71 Pureon

Pureon

    Primus Pilus

  • 0 A.D. Art Team
  • 3,537 posts

Posted 29 January 2012 - 01:14 AM

But it seems nice enough for now, and relatively good value ('free' with 24/month * 24 month contract, via O2), so I think I'll be adequately happy :)


That's much better than what I paid/pay for mine btw
  • 0

Pureon
0 A.D. Part time Designer / Texturer / 3D Artist
Contact email:
pureon{@}wildfiregames.com


#72 Guest_afeder_*

Guest_afeder_*
  • Guests

Posted 31 January 2012 - 07:05 PM

I am consistently getting this error when building the game:

In file included from /usr/include/libxml2/libxml/parser.h:807,
 				from /usr/include/libxml2/libxml/hash.h:29,
 				from /usr/include/libxml2/libxml/relaxng.h:14,
 				from ../../../source/ps/XML/RelaxNG.cpp:26:
/usr/include/libxml2/libxml/encoding.h:28:19: error: iconv.h: No such file or directory
In file included from /usr/include/libxml2/libxml/parser.h:807,
 				from /usr/include/libxml2/libxml/hash.h:29,
 				from /usr/include/libxml2/libxml/relaxng.h:14,
 				from ../../../source/ps/XML/RelaxNG.cpp:26:
/usr/include/libxml2/libxml/encoding.h:146: error: 'iconv_t' does not name a type
/usr/include/libxml2/libxml/encoding.h:147: error: 'iconv_t' does not name a type
make[1]: *** [obj/engine_Debug/RelaxNG.o] Error 1
Even though I have built libxml2 without bindings to iconv and hand-edited encoding.h to remove any reference to it:

afeder@ubuntu:~/android/0ad-game/build/workspaces/gcc$ cat $SYSROOT/usr/include/libxml2/libxml/encoding.h | grep iconv
afeder@ubuntu:~/android/0ad-game/build/workspaces/gcc$
I suspect the compiler is loading the encoding.h in my machine's absolute root instead of the $SYSROOT. Any idea why that might be happening? Perhaps there needs to be a --with-sysroot option in update-workspaces.sh? (I see many other packages has this.)

My environment seems right this time:

afeder@ubuntu:~/android/0ad-game/build/workspaces/gcc$ echo $SYSROOT
/home/afeder/android/toolchain/sysroot
afeder@ubuntu:~/android/0ad-game/build/workspaces/gcc$ echo $CXX
arm-linux-androideabi-g++

Edited by afeder, 31 January 2012 - 07:54 PM.

  • 0

#73 historic_bruno

historic_bruno

    Primus Pilus

  • WFG Programming Team
  • 2,385 posts

Posted 31 January 2012 - 10:19 PM

I suspect the compiler is loading the encoding.h in my machine's absolute root instead of the $SYSROOT. Any idea why that might be happening? Perhaps there needs to be a --with-sysroot option in update-workspaces.sh? (I see many other packages has this.)

Premake uses pkg-config to get the include paths for various packages like libxml2. So what's the result of running "pkg-config libxml-2.0 --cflags"? Are the other dependencies that use pkg-config compiling the correct files?
  • 0
Ben Brian [ aka historic_bruno ]

Wildfire Games Programmer
Contact me: ben [at] wildfiregames [dot] com

#74 Guest_afeder_*

Guest_afeder_*
  • Guests

Posted 31 January 2012 - 11:11 PM

Premake uses pkg-config to get the include paths for various packages like libxml2. So what's the result of running "pkg-config libxml-2.0 --cflags"? Are the other dependencies that use pkg-config compiling the correct files?

This is the result:

afeder@ubuntu:~/android/toolchain/sysroot/usr/include/libxml2$ pkg-config libxml-2.0 --cflags
-I/usr/include/libxml2
That should be good enough, if the compiler interprets it relative to $SYSROOT:

afeder@ubuntu:~/android/toolchain/sysroot/usr/include/libxml2$ ls $SYSROOT/usr/include/libxml2
libxml
I can't positively tell whether the other dependencies are included correctly, but at least I have not encountered other errors of this type. And the errors that I did encounter went away when I fixed them in the sysroot - not in the absolute root.

Edited by afeder, 31 January 2012 - 11:23 PM.

  • 0

#75 historic_bruno

historic_bruno

    Primus Pilus

  • WFG Programming Team
  • 2,385 posts

Posted 01 February 2012 - 12:24 AM

That should be good enough, if the compiler interprets it relative to $SYSROOT:

According to your error, it's not :) I've never heard of SYSROOT, if it's something that gets passed to e.g. ./configure, that's a step before the compilation and means the build system is indeed responsible for configuring the path correctly. Apparently there's a variable called "PKG_CONFIG_SYSROOT_DIR" which tells pkg-config to prepend something to its paths, can you try setting that and see what happens? It's listed here under Environment Variables.
  • 0
Ben Brian [ aka historic_bruno ]

Wildfire Games Programmer
Contact me: ben [at] wildfiregames [dot] com

#76 Guest_afeder_*

Guest_afeder_*
  • Guests

Posted 01 February 2012 - 12:39 AM

Yep, that seems right:

afeder@ubuntu:~/android/toolchain/sysroot/usr/include/libxml2$ export PKG_CONFIG_SYSROOT_DIR=$SYSROOT 
afeder@ubuntu:~/android/toolchain/sysroot/usr/include/libxml2$ pkg-config libxml-2.0 --cflags
-I/home/afeder/android/toolchain/sysroot/usr/include/libxml2
Sysroot is a GCC option:

--sysroot=dir
Use dir as the logical root directory for headers and libraries. For example, if the compiler would normally search for headers in /usr/include and libraries in /usr/lib, it will instead searchdir/usr/include and dir/usr/lib.

It is used when cross-compiling to make a local directory the root of a 'virtual' filesystem that corresponds to the filesystem of the target device.

However, some packages (e.g. cURL) do indeed take --with-sysroot=dir as an option of configure.

Edited by afeder, 01 February 2012 - 12:49 AM.

  • 0

#77 Guest_afeder_*

Guest_afeder_*
  • Guests

Posted 01 February 2012 - 12:56 AM

Yep, that fixed the problem. With PKG_CONFIG_SYSROOT_DIR set, I get no error for libxml2 when building the game.

All external dependencies fixed. Posted Image
  • 0

#78 Guest_afeder_*

Guest_afeder_*
  • Guests

Posted 01 February 2012 - 01:08 AM

Behold the beautiful error output.
  • 0

#79 historic_bruno

historic_bruno

    Primus Pilus

  • WFG Programming Team
  • 2,385 posts

Posted 01 February 2012 - 01:25 AM

Have you updated the source code recently? ogl_shader was removed in 10984 and there's been a few more recent changes that might help. That still leaves a lot of errors :(
  • 0
Ben Brian [ aka historic_bruno ]

Wildfire Games Programmer
Contact me: ben [at] wildfiregames [dot] com

#80 Sonarpulse

Sonarpulse

    Sesquiplicarius

  • Community Members
  • PipPip
  • 166 posts

Posted 01 February 2012 - 06:12 AM

Good luck! Hopefully the fixes to those errors will help upstream too.
  • 0
Posted ImagePosted ImagePosted Image