Add minimal support for building non-GUI parts of wxWidgets for Android.

Recognize __ANDROID__ in wx/platform.h and include the appropriate headers
from wx/android.

Also fix a couple of compilation errors (in filename.cpp) and warnings (in
event.h) which only appear when building for Android.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70703 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2012-02-26 20:24:25 +00:00
parent 1eff60811f
commit 1b4bff8262
7 changed files with 1949 additions and 6 deletions

View File

@ -0,0 +1,230 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/android/chkconf.h
// Purpose: Android-specific configuration options checks
// Author: Zsolt Bakcsi
// Modified by:
// Created: 2011-12-08
// RCS-ID:
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ANDROID_CHKCONF_H_
#define _WX_ANDROID_CHKCONF_H_
// ----------------------------------------------------------------------------
// Disable features which don't work (yet) or don't make sense under Android.
// ----------------------------------------------------------------------------
// please keep the list in alphabetic order except for closely related settings
// (e.g. wxUSE_ENH_METAFILE is put immediately after wxUSE_METAFILE)
// ----------------------------------------------------------------------------
// These are disabled because they are TODO. Or to decide whether to do or not.
// ----------------------------------------------------------------------------
#undef wxUSE_CONFIG
#define wxUSE_CONFIG 0
// This compiles, but not yet tested, so:
#undef wxUSE_CONSOLE_EVENTLOOP
#define wxUSE_CONSOLE_EVENTLOOP 0
#undef wxUSE_DEBUGREPORT
#define wxUSE_DEBUGREPORT 0
#undef wxUSE_DIALUP_MANAGER
#define wxUSE_DIALUP_MANAGER 0
#undef wxUSE_DISPLAY
#define wxUSE_DISPLAY 0
#undef wxUSE_DYNAMIC_LOADER
#define wxUSE_DYNAMIC_LOADER 0
#undef wxUSE_DYNLIB_CLASS
#define wxUSE_DYNLIB_CLASS 0
#undef wxUSE_FSVOLUME
#define wxUSE_FSVOLUME 0
// Compile-time errors when last tried (wxHAS_INOTIFY, wxHAS_KQUEUE)
#undef wxUSE_FSWATCHER
#define wxUSE_FSWATCHER 0
// Seems like Android lacks locale support. TODO: check!
// Hint:
// http://groups.google.com/group/android-ndk/browse_thread/thread/ffd012a047ec2392?pli=1
// "Android doesn't provide locale support in its C and C++ runtimes.
// This is handled at a higher-level in the application stack, using ICU
// (which is not exposed by the NDK, since the ABI is very volatile, and the
// set of built-in tables varies from device to device, based on customization
// / size reasons).
// You might want to use a different locale implementation. The STLport and GNU
// libstdc++ do provide then if you're using C++."
#undef wxUSE_INTL
#define wxUSE_INTL 0
#undef wxUSE_XLOCALE
#define wxUSE_XLOCALE 0
#undef wxUSE_IPC
#define wxUSE_IPC 0
#undef wxUSE_MEDIACTRL
#define wxUSE_MEDIACTRL 0
#undef wxUSE_ON_FATAL_EXCEPTION
#define wxUSE_ON_FATAL_EXCEPTION 0
#undef wxUSE_REGEX
#define wxUSE_REGEX 0
#undef wxUSE_STDPATHS
#define wxUSE_STDPATHS 0
#undef wxUSE_STACKWALKER
#define wxUSE_STACKWALKER 0
#undef wxUSE_MIMETYPE
#define wxUSE_MIMETYPE 0
#undef wxUSE_REGEX
#define wxUSE_REGEX 0
#undef wxUSE_REGKEY
#define wxUSE_REGKEY 0
#undef wxUSE_SNGLINST_CHECKER
#define wxUSE_SNGLINST_CHECKER 0
#undef wxUSE_SOUND
#define wxUSE_SOUND 0
#undef wxUSE_SYSTEM_OPTIONS
#define wxUSE_SYSTEM_OPTIONS 0
#undef wxUSE_XRC
#define wxUSE_XRC 0
// ----------------------------------------------------------------------------
// GUI is completely TODO.
// ----------------------------------------------------------------------------
#undef wxUSE_COLOURPICKERCTRL
#define wxUSE_COLOURPICKERCTRL 0
#undef wxUSE_COLOURDLG
#define wxUSE_COLOURDLG 0
#undef wxUSE_FONTENUM
#define wxUSE_FONTENUM 0
#undef wxUSE_FONTMAP
#define wxUSE_FONTMAP 0
#undef wxUSE_HELP
#define wxUSE_HELP 0
#undef wxUSE_HTML
#define wxUSE_HTML 0
#undef wxUSE_LISTBOOK
#define wxUSE_LISTBOOK 0
#undef wxUSE_OWNER_DRAWN
#define wxUSE_OWNER_DRAWN 0
#undef wxUSE_NOTEBOOK
#define wxUSE_NOTEBOOK 0
#undef wxUSE_RICHEDIT
#define wxUSE_RICHEDIT 0
#undef wxUSE_RICHEDIT2
#define wxUSE_RICHEDIT2 0
#undef wxUSE_STATUSBAR
#define wxUSE_STATUSBAR 0
// Are tooltips useful at all on a touch screen?
#undef wxUSE_TOOLTIPS
#define wxUSE_TOOLTIPS 0
#undef wxUSE_WXHTML_HELP
#define wxUSE_WXHTML_HELP 0
// ----------------------------------------------------------------------------
// All image classes are TODO.
// ----------------------------------------------------------------------------
#undef wxUSE_IMAGE
#define wxUSE_IMAGE 0
#undef wxUSE_LIBPNG
#define wxUSE_LIBPNG 0
#undef wxUSE_LIBJPEG
#define wxUSE_LIBJPEG 0
#undef wxUSE_LIBTIFF
#define wxUSE_LIBTIFF 0
#undef wxUSE_TGA
#define wxUSE_TGA 0
#undef wxUSE_GIF
#define wxUSE_GIF 0
#undef wxUSE_PNM
#define wxUSE_PNM 0
#undef wxUSE_PCX
#define wxUSE_PCX 0
#undef wxUSE_IFF
#define wxUSE_IFF 0
#undef wxUSE_XPM
#define wxUSE_XPM 0
#undef wxUSE_ICO_CUR
#define wxUSE_ICO_CUR 0
#undef wxUSE_PALETTE
#define wxUSE_PALETTE 0
// ----------------------------------------------------------------------------
// These are disabled because they don't make sense, are not supported, or
// would require too much effort.
// ----------------------------------------------------------------------------
// Unnecessary under Android, probably it doesn't even compile.
#undef wxUSE_AUI
#define wxUSE_AUI 0
// No command line on Android.
#undef wxUSE_CMDLINE_PARSER
#define wxUSE_CMDLINE_PARSER 0
// No joystick on Android devices.
// (What about using the direction sensor or the accelerometer?)
#undef wxUSE_JOYSTICK
#define wxUSE_JOYSTICK 0
// No MDI under Android. Well, no GUI at all (yet).
#undef wxUSE_MDI
#define wxUSE_MDI 0
#undef wxUSE_MDI_ARCHITECTURE
#define wxUSE_MDI_ARCHITECTURE 0
// No printing support on Android (2011).
// Although 3rd party SDKs may exist (I know of one payware).
#undef wxUSE_PRINTING_ARCHITECTURE
#define wxUSE_PRINTING_ARCHITECTURE 0
#endif // _WX_ANDROID_CHKCONF_H_

View File

@ -0,0 +1,56 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/android/config_android.h
// Purpose: configurations for Android builds
// Author: Zsolt Bakcsi
// Modified by:
// Created: 2011-12-02
// RCS-ID:
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// Please note that most of these settings are based on config_xcode.h and
// 'fine-tuned' on a trial-and-error basis. This means, no in-depth analysis
// of Android docs / source was done.
#define wxUSE_UNIX 1
#define __UNIX__ 1
#define HAVE_NANOSLEEP
#define HAVE_FCNTL 1
#define HAVE_GCC_ATOMIC_BUILTINS
#define HAVE_GETHOSTBYNAME 1
#define HAVE_GETSERVBYNAME 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_GMTIME_R 1
#define HAVE_INET_ADDR 1
#define HAVE_INET_ATON 1
#define HAVE_LOCALTIME_R 1
#define HAVE_PTHREAD_MUTEXATTR_T 1
#define HAVE_PTHREAD_MUTEXATTR_SETTYPE_DECL 1
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
#define HAVE_THREAD_PRIORITY_FUNCTIONS 1
#define HAVE_SSIZE_T 1
#define HAVE_STRCASECMP_IN_STRING_H 1
#define HAVE_WPRINTF 1
#define SIZEOF_INT 4
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define SIZEOF_SIZE_T 4
#define SIZEOF_VOID_P 4
#define SIZEOF_WCHAR_T 4
#define wxHAVE_PTHREAD_CLEANUP 1
#define wxNO_WOSTREAM
#define wxSIZE_T_IS_UINT 1
#define wxWCHAR_T_IS_REAL_TYPE 1
#define wxTYPE_SA_HANDLER int
#define wxUSE_SELECT_DISPATCHER 1
#ifdef HAVE_PTHREAD_CANCEL
// Android doesn't support pthread_cancel().
#undef HAVE_PTHREAD_CANCEL
#endif

1645
include/wx/android/setup.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1219,6 +1219,8 @@
# include "wx/motif/chkconf.h"
#elif defined(__WXX11__)
# include "wx/x11/chkconf.h"
#elif defined(__WXANDROID__)
# include "wx/android/chkconf.h"
#endif
/*

View File

@ -225,10 +225,13 @@ public:
const wxObjectEventFunctor &other =
static_cast< const wxObjectEventFunctor & >( functor );
// FIXME-VC6: amazing but true: replacing "method == NULL" here
// with "!method" makes VC6 crash with an ICE in DLL build (only!)
// FIXME-VC6: amazing but true: replacing "m_method == 0" here
// with "!m_method" makes VC6 crash with an ICE in DLL build (only!)
// Also notice that using "NULL" instead of "0" results in warnings
// about "using NULL in arithmetics" from arm-linux-androideabi-g++
// 4.4.3 used for wxAndroid build.
return ( m_method == other.m_method || other.m_method == NULL ) &&
return ( m_method == other.m_method || other.m_method == 0 ) &&
( m_handler == other.m_handler || other.m_handler == NULL );
}
else

View File

@ -149,6 +149,11 @@
# define __WXHANDHELD__
#endif
#ifdef __ANDROID__
# define __WXANDROID__
# include "wx/android/config_android.h"
#endif
/*
Include wx/setup.h for the Unix platform defines generated by configure and
the library compilation options

View File

@ -2666,12 +2666,14 @@ bool wxFileName::GetTimes(wxDateTime *dtAccess,
wxStructStat stBuf;
if ( wxStat( GetFullPath(), &stBuf) == 0 )
{
// Android defines st_*time fields as unsigned long, but time_t as long,
// hence the static_casts.
if ( dtAccess )
dtAccess->Set(stBuf.st_atime);
dtAccess->Set(static_cast<time_t>(stBuf.st_atime));
if ( dtMod )
dtMod->Set(stBuf.st_mtime);
dtMod->Set(static_cast<time_t>(stBuf.st_mtime));
if ( dtCreate )
dtCreate->Set(stBuf.st_ctime);
dtCreate->Set(static_cast<time_t>(stBuf.st_ctime));
return true;
}