I know I'm not the only one who tires of the difficulty of C, the clunkiness and ugliness of C++, and the general limitations of Lua, and desired a better language for PSP development--a language that ironically combines the speed of C, the OOP aspects of C++ or Java, and even some of the cool tricks of Lua, such as automatic garbage collection, anonymous functions, and nested functions. I am referring to the language known as D. I have studied that language for a while now that a stable release, 1.0, has come out, and I thought, I am not returning to PSP development unless I can use that.
So I asked a simple question on D.GNU, the news list for the free software D compiler, about why I couldn't compile gdc along with the c and c++ compilers without errors, and surprisingly I received many answers and GDC was patched to support MIPS. Many others had interest in this and so here are the instructions that someone gave to compile the GNU D compiler (dgcc) with an already working psptoolchain install:
This gives a fully functional psp-gdc compiler and libgphobos.a, which contains the D standard library and runtime. But there are still some minor issues. The PSP_MODULE_INFO macro is a weird thing that expands to inline mips assembly and some strange struct thing, which may or may not be possible to do in D. So a C source file is needed for the "glue" and has PSP_MODULE_INFO. But the rest can be nice, plain D source files (.d).Originally Posted by Kostas
So here is an example of a project that can be compiled with the D compiler in the toolchain: http://rapidshare.com/files/13244035...xample.7z.html
BUT: you must do one of either to get this to compile with make: manually compile the D file with "psp-gdc -c main.d" OR add this in line 201 of the $PSPDEV/psp/sdk/lib/build.mak file:
(yes that is a tab before psp-gdc -c $<). The DFLAGS is an optional macro you could put in each project Makefile that contains d compile flags such as -I.Code:%.o: %.d psp-gdc -c $< $(DFLAGS)
OR just use this file http://rapidshare.com/files/133727628/build.mak.html as your $PSPDEV/psp/sdk/lib/build.mak file. Regardless, I just ask everyone compiling D on the PSP to add "-fversion=Psp" to their compile or DFLAGS options because we need some sort of version set for the PSP since neither version=Windows or version=Linux is set.
I have many plans and ideas of some D programs I want to port, as long as I can either compile libgtango--the alternative, superior standard D library, or remove some tango dependencies from those projects. So far, we haven't had luck getting past running the configure script for trying to compile tango for psptoolchain. But the inferior stdlib Phobos is good enough for what PSP apps generally are (calling mostly sce* functions or using OSLib or SDL).
EDIT: I'm using an archaic style makefile so for 3.xx users you might need to add this to the Makefile in the demo:
But the 1.0 EBOOT worked for me and I am using 3.40 OE.Code:PSP_FW_VERSION=300
To make things easy, I have ported all of the pspsdk headers to D and they should work properly: http://rapidshare.com/files/13513325...psdkD.zip.html
To use them, make sure the extracted pspsdk/ folder is in your psp-gdc include path (paths added with -Ipathname, e.g. -I/usr/local/include/myincludes or just put pspsdk/ in $PSPDEV/include/d/4.1.0/ ) and you need to link your applications to libpspsdkD.a for all functionality to work. To link it, just put the library in your project source folder, add -L. -lpspsdkD to your LIBS macro in the Makefile. or you can just drag and drop libpspsdkD.a into $PSPDEV/lib and use -lpspsdkD.
If you want to use the Lua API with D applications, this package is all you need: http://rapidshare.com/files/133725027/dluaPsp.zip.html it contains both the D headers and a precompiled liblua51.a that makes sure the headers work without linker errors. I was going to port DMDScript but it is too heavily dependent on parts of Phobos that are not yet implemented on the Psp (but could easily be implemented). I had gotten it to compile but it crashed on trying to initialize... oh well, Lua is probably faster and better anyway.