Building with GCC on android
I've been trying to get the lua plugin built on android with gcc although i'm getting this...
Compile++ thumb : RocketLua <= Colourb.cpp
In file included from jni/../Source/Core/Lua/Colourb.cpp:29:0:
jni/../Source/Core/Lua/Colourb.h:64:1: error: explicit qualification in declaration of 'char const* Rocket::Core::Lua::GetTClassName()'
jni/../Source/Core/Lua/Colourb.h:64:1: error: explicit qualification in declaration of 'Rocket::Core::Lua::RegType<Rocket::Core::Colour<unsigned char, 255> >* Rocket::Core::Lua::GetMethodTable()'
jni/../Source/Core/Lua/Colourb.h:64:1: error: explicit qualification in declaration of 'luaL_Reg* Rocket::Core::Lua::GetAttrTable()'
jni/../Source/Core/Lua/Colourb.h:64:1: error: explicit qualification in declaration of 'luaL_Reg* Rocket::Core::Lua::SetAttrTable()'
jni/../Source/Core/Lua/Colourb.h:64:1: error: explicit qualification in declaration of 'bool Rocket::Core::Lua::IsReferenceCounted()'
jni/../Source/Core/Lua/Colourb.cpp:235:1: error: explicit qualification in declaration of 'char const* Rocket::Core::Lua::GetTClassName()'
jni/../Source/Core/Lua/Colourb.cpp:235:1: error: explicit qualification in declaration of 'Rocket::Core::Lua::RegType<Rocket::Core::Colour<unsigned char, 255> >* Rocket::Core::Lua::GetMethodTable()'
jni/../Source/Core/Lua/Colourb.cpp:235:1: error: explicit qualification in declaration of 'luaL_Reg* Rocket::Core::Lua::GetAttrTable()'
jni/../Source/Core/Lua/Colourb.cpp:235:1: error: explicit qualification in declaration of 'luaL_Reg* Rocket::Core::Lua::SetAttrTable()'
jni/../Source/Core/Lua/Colourb.cpp:235:1: error: explicit qualification in declaration of 'bool Rocket::Core::Lua::IsReferenceCounted()'
make: *** [obj/local/armeabi-v7a/objs/RocketLua/__/Source/Core/Lua/Colourb.o] Error 1
and here's the Android.mk script i'm using with the latest NKD (r9). This needs to be placed in the jni/ directory along with lua and freetype
you'll end up with... jni/ Android.mk liblua/ freetype/
jni/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := freetype
LOCAL_SRC_FILES := freetype/libs/$(TARGET_ARCH)/usr/lib/libfreetype.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Rocket
LOCAL_SRC_FILES :=\
../Source/Controls/Clipboard.cpp \
../Source/Controls/Controls.cpp \
../Source/Controls/DataFormatter.cpp \
../Source/Controls/DataQuery.cpp \
../Source/Controls/DataSource.cpp \
../Source/Controls/DataSourceListener.cpp \
../Source/Controls/ElementDataGridCell.cpp \
../Source/Controls/ElementDataGrid.cpp \
../Source/Controls/ElementDataGridExpandButton.cpp \
../Source/Controls/ElementDataGridRow.cpp \
../Source/Controls/ElementFormControl.cpp \
../Source/Controls/ElementFormControlDataSelect.cpp \
../Source/Controls/ElementFormControlInput.cpp \
../Source/Controls/ElementFormControlSelect.cpp \
../Source/Controls/ElementFormControlTextArea.cpp \
../Source/Controls/ElementForm.cpp \
../Source/Controls/ElementTabSet.cpp \
../Source/Controls/ElementTextSelection.cpp \
../Source/Controls/InputTypeButton.cpp \
../Source/Controls/InputTypeCheckbox.cpp \
../Source/Controls/InputType.cpp \
../Source/Controls/InputTypeRadio.cpp \
../Source/Controls/InputTypeRange.cpp \
../Source/Controls/InputTypeSubmit.cpp \
../Source/Controls/InputTypeText.cpp \
../Source/Controls/SelectOption.cpp \
../Source/Controls/WidgetDropDown.cpp \
../Source/Controls/WidgetSlider.cpp \
../Source/Controls/WidgetSliderInput.cpp \
../Source/Controls/WidgetTextInput.cpp \
../Source/Controls/WidgetTextInputMultiLine.cpp \
../Source/Controls/WidgetTextInputSingleLine.cpp \
../Source/Controls/WidgetTextInputSingleLinePassword.cpp \
../Source/Controls/XMLNodeHandlerDataGrid.cpp \
../Source/Controls/XMLNodeHandlerTabSet.cpp \
../Source/Controls/XMLNodeHandlerTextArea.cpp \
../Source/Core/BaseXMLParser.cpp \
../Source/Core/Box.cpp \
../Source/Core/Clock.cpp \
../Source/Core/Context.cpp \
../Source/Core/ContextInstancer.cpp \
../Source/Core/ContextInstancerDefault.cpp \
../Source/Core/ConvolutionFilter.cpp \
../Source/Core/Core.cpp \
../Source/Core/Decorator.cpp \
../Source/Core/DecoratorInstancer.cpp \
../Source/Core/DecoratorNone.cpp \
../Source/Core/DecoratorNoneInstancer.cpp \
../Source/Core/DecoratorTiledBox.cpp \
../Source/Core/DecoratorTiledBoxInstancer.cpp \
../Source/Core/DecoratorTiled.cpp \
../Source/Core/DecoratorTiledHorizontal.cpp \
../Source/Core/DecoratorTiledHorizontalInstancer.cpp \
../Source/Core/DecoratorTiledImage.cpp \
../Source/Core/DecoratorTiledImageInstancer.cpp \
../Source/Core/DecoratorTiledInstancer.cpp \
../Source/Core/DecoratorTiledVertical.cpp \
../Source/Core/DecoratorTiledVerticalInstancer.cpp \
../Source/Core/Dictionary.cpp \
../Source/Core/DocumentHeader.cpp \
../Source/Core/ElementBackground.cpp \
../Source/Core/ElementBorder.cpp \
../Source/Core/Element.cpp \
../Source/Core/ElementDecoration.cpp \
../Source/Core/ElementDefinition.cpp \
../Source/Core/ElementDocument.cpp \
../Source/Core/ElementHandle.cpp \
../Source/Core/ElementImage.cpp \
../Source/Core/ElementInstancer.cpp \
../Source/Core/ElementReference.cpp \
../Source/Core/ElementScroll.cpp \
../Source/Core/ElementStyle.cpp \
../Source/Core/ElementText.cpp \
../Source/Core/ElementTextDefault.cpp \
../Source/Core/ElementUtilities.cpp \
../Source/Core/Event.cpp \
../Source/Core/EventDispatcher.cpp \
../Source/Core/EventInstancer.cpp \
../Source/Core/EventInstancerDefault.cpp \
../Source/Core/EventListenerInstancer.cpp \
../Source/Core/Factory.cpp \
../Source/Core/FileInterface.cpp \
../Source/Core/FileInterfaceDefault.cpp \
../Source/Core/FontDatabase.cpp \
../Source/Core/FontEffect.cpp \
../Source/Core/FontEffectInstancer.cpp \
../Source/Core/FontEffectNone.cpp \
../Source/Core/FontEffectNoneInstancer.cpp \
../Source/Core/FontEffectOutline.cpp \
../Source/Core/FontEffectOutlineInstancer.cpp \
../Source/Core/FontEffectShadow.cpp \
../Source/Core/FontEffectShadowInstancer.cpp \
../Source/Core/FontFace.cpp \
../Source/Core/FontFaceHandle.cpp \
../Source/Core/FontFaceLayer.cpp \
../Source/Core/FontFamily.cpp \
../Source/Core/Geometry.cpp \
../Source/Core/GeometryDatabase.cpp \
../Source/Core/GeometryUtilities.cpp \
../Source/Core/LayoutBlockBox.cpp \
../Source/Core/LayoutBlockBoxSpace.cpp \
../Source/Core/LayoutEngine.cpp \
../Source/Core/LayoutInlineBox.cpp \
../Source/Core/LayoutInlineBoxText.cpp \
../Source/Core/LayoutLineBox.cpp \
../Source/Core/Log.cpp \
../Source/Core/Math.cpp \
../Source/Core/Plugin.cpp \
../Source/Core/PluginRegistry.cpp \
../Source/Core/precompiled.cpp \
../Source/Core/Property.cpp \
../Source/Core/PropertyDefinition.cpp \
../Source/Core/PropertyDictionary.cpp \
../Source/Core/PropertyParserColour.cpp \
../Source/Core/PropertyParserKeyword.cpp \
../Source/Core/PropertyParserNumber.cpp \
../Source/Core/PropertyParserString.cpp \
../Source/Core/PropertySpecification.cpp \
../Source/Core/ReferenceCountable.cpp \
../Source/Core/RenderInterface.cpp \
../Source/Core/Stream.cpp \
../Source/Core/StreamFile.cpp \
../Source/Core/StreamMemory.cpp \
../Source/Core/StringCache.cpp \
../Source/Core/String.cpp \
../Source/Core/StringStorage.cpp \
../Source/Core/StringUtilities.cpp \
../Source/Core/StyleSheet.cpp \
../Source/Core/StyleSheetFactory.cpp \
../Source/Core/StyleSheetNode.cpp \
../Source/Core/StyleSheetNodeSelector.cpp \
../Source/Core/StyleSheetNodeSelectorEmpty.cpp \
../Source/Core/StyleSheetNodeSelectorFirstChild.cpp \
../Source/Core/StyleSheetNodeSelectorFirstOfType.cpp \
../Source/Core/StyleSheetNodeSelectorLastChild.cpp \
../Source/Core/StyleSheetNodeSelectorLastOfType.cpp \
../Source/Core/StyleSheetNodeSelectorNthChild.cpp \
../Source/Core/StyleSheetNodeSelectorNthLastChild.cpp \
../Source/Core/StyleSheetNodeSelectorNthLastOfType.cpp \
../Source/Core/StyleSheetNodeSelectorNthOfType.cpp \
../Source/Core/StyleSheetNodeSelectorOnlyChild.cpp \
../Source/Core/StyleSheetNodeSelectorOnlyOfType.cpp \
../Source/Core/StyleSheetParser.cpp \
../Source/Core/StyleSheetSpecification.cpp \
../Source/Core/SystemInterface.cpp \
../Source/Core/TemplateCache.cpp \
../Source/Core/Template.cpp \
../Source/Core/Texture.cpp \
../Source/Core/TextureDatabase.cpp \
../Source/Core/TextureLayout.cpp \
../Source/Core/TextureLayoutRectangle.cpp \
../Source/Core/TextureLayoutRow.cpp \
../Source/Core/TextureLayoutTexture.cpp \
../Source/Core/TextureResource.cpp \
../Source/Core/UnicodeRange.cpp \
../Source/Core/URL.cpp \
../Source/Core/Variant.cpp \
../Source/Core/Vector2.cpp \
../Source/Core/WidgetSlider.cpp \
../Source/Core/WidgetSliderScroll.cpp \
../Source/Core/WString.cpp \
../Source/Core/XMLNodeHandlerBody.cpp \
../Source/Core/XMLNodeHandler.cpp \
../Source/Core/XMLNodeHandlerDefault.cpp \
../Source/Core/XMLNodeHandlerHead.cpp \
../Source/Core/XMLNodeHandlerTemplate.cpp \
../Source/Core/XMLParser.cpp \
../Source/Core/XMLParseTools.cpp \
../Source/Debugger/Debugger.cpp \
../Source/Debugger/ElementContextHook.cpp \
../Source/Debugger/ElementInfo.cpp \
../Source/Debugger/ElementLog.cpp \
../Source/Debugger/Geometry.cpp \
../Source/Debugger/Plugin.cpp \
../Source/Debugger/SystemInterface.cpp
LOCAL_STATIC_LIBRARIES := freetype
LOCAL_C_INCLUDES := $(LOCAL_PATH)/freetype/include $(LOCAL_PATH)/../Include
include $(BUILD_STATIC_LIBRARY)
#lua
include $(CLEAR_VARS)
LOCAL_MODULE := Lua
LOCAL_SRC_FILES := liblua/lapi.c \
liblua/lauxlib.c \
liblua/lbaselib.c \
liblua/lcode.c \
liblua/ldblib.c \
liblua/ldebug.c \
liblua/ldo.c \
liblua/ldump.c \
liblua/lfunc.c \
liblua/lgc.c \
liblua/linit.c \
liblua/liolib.c \
liblua/llex.c \
liblua/lmathlib.c \
liblua/lmem.c \
liblua/loadlib.c \
liblua/lobject.c \
liblua/lopcodes.c \
liblua/loslib.c \
liblua/lparser.c \
liblua/lstate.c \
liblua/lstring.c \
liblua/lstrlib.c \
liblua/ltable.c \
liblua/ltablib.c \
liblua/ltm.c \
liblua/lundump.c \
liblua/lvm.c \
liblua/lzio.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/liblua
LOCAL_CFLAGS :=-ffast-math -O3 -funroll-loops
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := RocketLua
LOCAL_SRC_FILES :=\
../Source/Core/Lua/Colourb.cpp \
../Source/Core/Lua/Colourf.cpp \
../Source/Core/Lua/Context.cpp \
../Source/Core/Lua/ContextDocumentsProxy.cpp \
../Source/Core/Lua/Document.cpp \
../Source/Core/Lua/ElementAttributesProxy.cpp \
../Source/Core/Lua/ElementChildNodesProxy.cpp \
../Source/Core/Lua/Element.cpp \
../Source/Core/Lua/ElementInstancer.cpp \
../Source/Core/Lua/ElementStyle.cpp \
../Source/Core/Lua/ElementText.cpp \
../Source/Core/Lua/Event.cpp \
../Source/Core/Lua/EventParametersProxy.cpp \
../Source/Core/Lua/GlobalLuaFunctions.cpp \
../Source/Core/Lua/Interpreter.cpp \
../Source/Core/Lua/Log.cpp \
../Source/Core/Lua/LuaDocument.cpp \
../Source/Core/Lua/LuaDocumentElementInstancer.cpp \
../Source/Core/Lua/LuaElementInstancer.cpp \
../Source/Core/Lua/LuaEventListener.cpp \
../Source/Core/Lua/LuaEventListenerInstancer.cpp \
../Source/Core/Lua/precompiled.cpp \
../Source/Core/Lua/RocketContextsProxy.cpp \
../Source/Core/Lua/Rocket.cpp \
../Source/Core/Lua/Utilities.cpp \
../Source/Core/Lua/Vector2f.cpp \
../Source/Core/Lua/Vector2i.cpp \
../Source/Controls/Lua/Controls.cpp \
../Source/Controls/Lua/DataFormatter.cpp \
../Source/Controls/Lua/DataSource.cpp \
../Source/Controls/Lua/ElementDataGrid.cpp \
../Source/Controls/Lua/ElementDataGridRow.cpp \
../Source/Controls/Lua/ElementFormControl.cpp \
../Source/Controls/Lua/ElementFormControlDataSelect.cpp \
../Source/Controls/Lua/ElementFormControlInput.cpp \
../Source/Controls/Lua/ElementFormControlSelect.cpp \
../Source/Controls/Lua/ElementFormControlTextArea.cpp \
../Source/Controls/Lua/ElementForm.cpp \
../Source/Controls/Lua/ElementTabSet.cpp \
../Source/Controls/Lua/LuaDataFormatter.cpp \
../Source/Controls/Lua/LuaDataSource.cpp \
../Source/Controls/Lua/SelectOptionsProxy.cpp
LOCAL_STATIC_LIBRARIES := Rocket Lua
LOCAL_C_INCLUDES := $(LOCAL_PATH)/freetype/include $(LOCAL_PATH)/../Include $(LOCAL_PATH)/liblua
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Rocket_phony
LOCAL_SRC_FILES := test.cpp
LOCAL_STATIC_LIBRARIES := Rocket RocketLua freetype
include $(BUILD_SHARED_LIBRARY)
include $(call all-subdir-makefiles)
compile with ndk-build from the project root. binaries will be output into obj/local/{arch}.
Rocket builds fine (I've been using it for several months now on android), I just need to get the Lua/RML scripting portion working.
I can't reproduce this issue. I whipped up a quick set of android build scripts, which you can get from the 'android' branch, and it built successfully for all architectures. I did it with ndk-r9 and the 4.8 toolchain.
I also had to make some modifications to llex.c to get android to build Lua 5.1.5, which was just removing the lconv->decimal_point line, and defaulting that variable to " . ". I'll probably throw in my LuaJIT build scripts as well.
Thanks, didn't notice the android branch.
Where do I find the Linux build scripts? The cmake files that came with master don't include the lua plugin and i'm having similar issues.
--- Original Message ---
From: "Gambini" [email protected] Sent: 15 September 2013 20:25 To: "Gambini/libRocket" [email protected] Cc: "originalred" [email protected] Subject: Re: [libRocket] Building with GCC on android (#2)
I can't reproduce this issue. I whipped up a quick set of android build scripts, which you can get from the 'android' branch, and it built successfully for all architectures. I did it with ndk-r9 and the 4.8 toolchain.
Reply to this email directly or view it on GitHub: https://github.com/Gambini/libRocket/issues/2#issuecomment-24478088
I made the android branch when you opened this issue, which is why you didn't notice.
Did you read https://github.com/Gambini/libRocket/blob/android/Build/android/AndroidBuilding.md under Build/android/ ? I'll go ahead and put in my LuaJIT build scripts as well, since those don't require modifying the source code to build on Android.
aha, makes sense now. FYI: the android branch will also build on Linux (the master won't due to similar issues). Linking static libs on linux is a bit of an art - link RocketCoreLua and RocketControlsLua before RocketCore and RocketControls.
Now, this'll get you thinking...
I've got a bit of a complex app going - I've got a main script and several AI scripts, each running in their own lua_State (actually, the AIs share a state, but that's a bit irrelevant). I want the embedded code in the RML to be able to call methods from the main script - so I've grabbed the lua_State from the Interpreter and I've built on that, registering my lua calls and loading my script into it.
Is this the best way? It seems to work so far - I ask as there may be an instancing issue down the line somewhere (running 2 or more instances of the app).
/Source/Core/PluginRegistry.cpp#L36 <- Right there, all of the plugins are static. The Lua::Interpreter class has no reason to not keep around at least a static lua_State do execute scripts on. However, that doesn't mean that I can't add the ability to have those scripts also registered on user-supplied lua_States. Would that be useful?
I am not sure how usable that is, since without some sort of messaging system, those functions would be called all on the same thread. Is it safe to assume that you are using multiple lua_States for multi-threading? If so, then any lua_State that is not on the main thread will have its stack superbly messed up when I try calling a function on it. So, if multi-threading is your goal, it would be a better idea to use the rml scripting for pure visual manipulation, and keep the logic in such a way that the AI's (or anything else's) interaction with the UI has been abstracted out and can be queried by Lua rather than pushed to Lua.
But if multithreading is not your goal, and you are fine with having all of the UI called on one thread and you need them to be called on separate lua_States, then I will implement that feature (it shouldn't be too hard).
To answer your instancing question: two static variables when two of the same shared libraries are loaded should not interfere with each other, if my googling was correct. And it will not interfere if you are linking statically.
As long as whatever you register on the lua_State of this plugin does not clash with any of the Rocket type names, then you have used that function in the way it is intended.
Yes, I am using multiple lua_States for multithreading (and a single state for the main script, which is called from 2 threads with a mutex on the script). The only thing I was worried about is if 2 (or more) apps use the same lua_State and both put code into the same state, which you've answered satisfactorily. My AIs have a messaging system that is supplied by the engine (state a calls messaging func, which gets passed to state b) and is quite thread safe.
Well, so far it's stable, so no need to do anything else to it
I did have some similar rocket functionality for basic usage, but it doesn't seem to clash.