About Xcode crosscompiling, you are absolutely correct: once you have working target to build a native framework (which is nothing less than a folder containing the binaries of a dynamic lib, the headers, and possibly resources), it is a pretty trivial task to cross compile it for ARM/iOS. So, IMHO the first thing to do is to edit the cake generator template to streamline the Xcode project and add a target for building the framework
I think we're close with the current cross compiling impl.
When cross compiling (i.e - define the CMAKE_TOOLCHAIN_FILE cmd line var) this section of code starts a cross build. Once the cross build needs the
mrblib.ctmp
dep (created by a nativemrbc
) this code fires off a full native build (since it's an unmet dependency) and places the native artifacts inbuild/native
.Effectively, the cross build starts a new native build and uses this code until the native build completes, then switches back to finish cross mode. Check out the 2nd shell example from my cross build post to see what I mean.
The configure phase sets up for a cross build. Make starts in cross mode and runs the first
Scanning dependencies of target mruby_object
in cross mode. When the build reachesScanning dependencies of target mruby-native
, it fires off a complete native build (somrblib.ctmp
is created). Finally, the build switches back to cross mode in the secondScanning dependencies of target mruby_object
and completes.CMake is quite clever in allowing you to this single-pass cross and native build with such clean code and only a single command line invocation. Many CMake examples on the web show cross examples that require users to perform multiple steps. We don't want or need that complexity.
Try cross compiling for Window from your OS X box using this toolchain after downloading a darwin mingw-w64 cross toolchain
mingw-w64
prefix indicates a cross tool for building for 64bit windows, and themingw-32
prefix indicatescross tools for 32bit WindowsThis may seem convoluted, but I believe it's fundamentally what needs to happen to get iOS built from Xcode. The existing cross machinery should work with minimal or no modification, and we just need to create a working iOS toolchain file similar to the google links.
The first priority is to tweak the non-cross part of the CMake recipe so that it creates Xcode project files that cleanly build native OS X code. I hope you and @carsonmcdonald can crack the code on that. I'll keep googling, but I'm handicapped without a Mac :(
@jon: I paste hereafter your last message on GH, not to spam the rest of mruby devels.If I understand correctly what you have in mind, you are planning to use directly cmake to actually build the iOS framework. I think that this could be unnecessarily complicated: we only need to customize the cmake generator in order to create three Xcode targets:
- an external target that uses the official Makefile and provides the native mrbc and mrblib.ctmp
- a native target that builds an OS X framework, having 1. as dependency
- a native target that builds an iOS framework, having 1. as dependency
So that the workflow would be: run cmake -G Xcode .. > open Xcode project > select the desired target (iOS or OS X) > click build > copy the product (mruby.framework) in your project and link it to the code > happy coding.This way, it should all be easier and more robust. But there is a high probability I'm misunderstanding the whole matter... What do you think?
Since I don't have Mac/Xcode and you may not have Windows/Visual Studio, I've created a new repo to hold the different types of CMake generated project files. I push the Visual Studio 10 project files to the `vs10` branch and have created empty `xcode` (for native OS X builds) and `xcode-cross` (for iOS builds) branches.
When you get a moment, would you run `cmake -G Xcode ..` from `build/`, copy all the generated dirs/files (except for the `build/CMakeFiles/CMakeTmp/` tree, and push them to the `xcode` branch? I'd like to review and see how they correspond to the pics you sent.
Got it. Thanks, you're a good teacher. I just built my first Hello World application on MyBrainBook Pro, and it worked ;)
From your first screenshot, why is everything red under the Products folder?
I have TeamViewer, that can be done, absolutely. But first I wanted to tell you the results of what I've found yesterday.
It turns out that the mruby make uses the -MMD switch, which automatically generates the list of include files for each *c and puts it in the *.d counterparts. Now, Apple compilers (Apple LLVM 3.1 and LLVM GCC 4.2) do not support the -MMD switch. And this is a mess, because creating an Xcode native target is impossible, since the source files lack a lot of #include directives. I don't know if there is a workaround, I'm still investigating.
You know, I think that this matter of the "native target" is important, if we want to have mruby easily embeddable in iOS projects. I would be curious to know how Carson built its mruby framework, but I suspect he made it by hand (crafting the framework bundle one file at a time), because both of his project on github include a premade framework, but not an Xcode target to build it. So probably he had my very same problems, and he took a shortcut.