There we are, with part 3 of our grand quest to building Sphere for Mac!
In part 2 we installed Audiere, which was a pain due to its dependencies. Then we configured the build to actually see audiere.h. Then I fixed mercurial for Mavericks and started its download. It is still busy. (That is, 7 minutes after posting my last post). Sigh.
So instead, I will fix the code of Sphere and its build configuration, to skip the examples and include the platform.h. If you are someone trying to reproduce what I do: you don't need to do this. I will update the project on GitHub.
I like where I put the include-flag for Audiere, so I keep it there, but I add a comment line for future maintainers.
Somehow, .o files are not excluded from git. Which is odd, because most often that is the first thing you add to gitignore. So I add a UNIX section and add *.o. Git status tells me that there is data in build/linux/docs. On github, it only has an engine.ini in linux/. Excluding the docs folder.
There seems to be some kind of database file for SCons: adding it do gitignore too.
I have seriously no clue how SCons works, but in the SConscript where I removed 'config', there already is a statement to add a folder in case of a unix build. I add an else clause and put config there. Now config is build on everything but Unix.
If another maintainer can tell me how I can add a clause specially for Mac, please
Now, HG tells me:
added 179880 changesets with 1008534 changes to 155940 files.
It does kind of explain why it took so long. (It is still busy 17 min after my last post).
Great, i accidentally deleted the mozilla directory because I put it in sphere/...
So I forgot to read the SM page, and it tells me: "To avoid downloading the full history, download the tar by clicking on tar at
http://hg.mozilla.org/mozilla-central/file/tip". (Updated part 2)
For me, it is 168MB. Now is hoping that SM has a stable API and Sphere can use the latest version.
WARNING: Scroll below, because Sphere is so extremely outdated that it is not fixable for the newest SpiderMonkey. Below, we try to get an ancient (2009) spidermonkey running.
Untar the directory. I never understand the tar command, so i just open the file using 'open ...tar.gz'.
open *.tar.gz (name is dependent on last commit id)
cd mozilla-central<tab>
cd js/src
Mozilla tells me I can only use 1 specific version of autoconf: 2.13, and nothing later. Of course I have 2.68. Lets try it anyway.
autoconf
And No, it does not work. I think that on this quest, at least one thing has to be wrong with every step...
I must say I am surprised: homebrew tells me there is a 2.13 package for me!
brew install homebrew/versions/autoconf213
There was some link problem: I don't think it is a big trouble-file, so I renamed the standards.info to standards.info_bak.
Now that I have autoconf213, lets try it again.
autoconf213
./configure
What a fun: I have Python 2.7.2 but we need at least 2.7.3 (but not 3). Brew has python 2.7.6, so lets try:
brew install python
brew link python
After running above commands, I had to add the full python 2.7.6 path before ./configure
PYTHON=/usr/local/Cellar/python/2.7.6_1/bin/python2.7 ./configure
Now running
make.
...
I almost can't believe it: no errors! I finished with
make install.
Lets try SCons again on Sphere. Nope, it can't find SM.
Make install installed the headers in /usr/local/include/-/mozjs-31a1/. Lets fix that by moving it to /usr/local/include/mozjs.
When SCons still can't find the headers, I discovered that it looks only in /usr/bin/mozjs and not in /usr/local/bin/mozjs. I added that searchpath too. I also added an error when it can't find the javascript engine.
So, running scons throws some errors (surprise!):
/usr/local/include/mozjs/mozilla/NullPtr.h:17:6: error: "clang version natively supporting nullptr is required."
/usr/local/include/mozjs/js/TypeDecls.h:23:10: fatal error: 'js-config.h' file not found
It also throws a bunch of warnings about C++11. The first error tells me I need to activate C++11 in clang. I added
-std=c++11 to the compiler flags for linux, but again, this should only be done when using Clang. But I have no clue how to do that. Maybe other do.
The c++11 switch dismisses a lot of warnings, and the first error. Now, the second error.
For some reason, make install did not install js-config.h. I am lazy and copy it by hand.
cp mozilla-central/js/src/js/src/js-config.h /usr/local/include/mozjs/
scons
I forgot to platform-erize network.hpp (I will push this to GitHub ofcourse), solving an error.
Now, I am going to cry for a bit: I see a lot of errors coming from the Sphere engine code about missing JS declarations. Three of them:
source/engine/ss_functions.table:6:1: error: unknown type name 'JSBool'
source/particle_engine/ScriptInterface.hpp:87:41: error: use of undeclared identifier 'JS_TRUE'
source/engine/ss_functions.table:16:1: error: unknown type name 'uintN'
It seems JSBool has become bool, JS_TRUE becomes true and JS_FALSE becomes false. That is an easy fix.
The documentation does not say anything about removing uintN: instead, it is noted that uintN is the native unsigned int, and intN is the native int. So I replaced those.
Next problem: JS_AddRoot is gone and made place for more specific functions, as seem
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_AddRoot.Ok, I think I give up on refactoring all of Sphere's javascript code... The documentation does not event seem to match the current code.
I am rolling back the changes I made to the code, and instead am going to try to get the VERY old SpiderMonkey: from 2009. version 1.8.
wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz
tar xvzf js-1.8.0-rc1.tar.gz
cd js/src
make BUILD_OPT=1 -f Makefile.ref
Wow, not even a configure! It also fails. Something about assigning to va_list. I know that clang supports va_copy, so I forced that in the faulting file.
//#ifdef HAVE_VA_COPY
#define VARARGS_ASSIGN(foo, bar) va_copy(foo,bar)
//#elif defined(HAVE_VA_LIST_AS_ARRAY)
//#define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0]
//#else
//#define VARARGS_ASSIGN(foo, bar) (foo) = (bar)
//#endif
There is no make install, so I did the stuff below to make it work:
mkdir /usr/local/include/js
cp js/src/*.{h,tbl} /usr/local/include/js
cp js/src/Darwin_OPT.OBJ/*.h /usr/local/include/js
cp js/src/Darwin_OPT.OBJ/libjs.* /usr/local/lib
Then Sphere built a bit more for me: it now gives me an error on Audiere
In this part I tried to get the most up to date SpiderMonkey to run. I achieved that (try the js command) but sadly, Sphere is so outdated that its API is nearly not convertable: at least not in a couple of hours. Instead, I build and installed-by-hand the ancient SpiderMonkey.
In part 4, I will be fixing more errors and I will probably meet the missing Corona and LibMNG.