IFDEFs, Mac OS X Port and general crossplatform development

for UltraStar Deluxe & Plugin developers

IFDEFs, Mac OS X Port and general crossplatform development

Postby eddie on Sun Oct 21, 2007 9:15 am

Hello,

My name is Eddie and I am the new guy. I was invited by Mog to join the USDX team to create an OS X port of UltraStar Deluxe. A few days ago I released a proof-of-concept OS X port of the UltraStar version 0.5.3: http://sourceforge.net/projects/ultrastar-mac/.

I will delete that project, once an official USDX OS X port is available.

Yesterday I downloaded the current trunk, and I have some questions and suggestions. Before I make any changes to the repository I want to discuss, what's the best way to introduce the Mac specific parts.

1. Lazarus vs XCode
A stable build of Lazarus is not available for Mac OS (Intel). Also, Lazarus requires X11 and half a Linux system to be installed through Fink, if I understood the Lazarus for Mac page correctly.
So, I will use XCode for the OS X port. This creates a real native Mac application that uses the installed Frameworks that are available on the Mac (on the mac DLLs are bundled with header files to Frameworks).

2. IFDEFs and switches.inc
For the Mac port we have to change the way compiler defines are used.
The current code uses the define FPC for two things: For FPC specific things like "mode delphi", but also for Linux/Lazarus sepecific code parts. Since the mac port also uses FPC, but not Lazarus this will not work.
For Linux we should use the define "LINUX", and for OS X the define "DARWIN". Both are builtin.

I also found some parts with {$IFDEF FPC} ... {$ELSE} ... {$ENDIF}. This could lead to problems, but I am not 100% sure now, how to do the OS X port. If I use the same way as for the 0.5.3 port, the mac port will define "WIN32" and emulate all missing functions through mac-only wrapper files. But we would have to change FPC to LINUX anyway.

My todo would then be:
a. Add a DARWIN part to swicthes.inc
b. Replace all FPC with LINUX where needed (maybe jaybinks can help me at this point or just do a code review after the change).
c. [optional] Include swicthes.inc in all U*.pas files and move the "MODE DELPHI" to switches.inc

3. General crossplatform development
In the long term, I would prefer that we eliminate all or most platform specific code from the U*.pas files that is duplicated for each platform. For example the resource loading will be implemented seperately for all platforms: The windows port uses Windows resources, the linux port uses Lazarus resources and the mac port will use normal files, because I don't know how to port this resource.
To solve the resources problem we could use MD5 to avoid changes to files or maybe we can embed the resources as Base64 encoded Strings in the source code? Just an idea...

Best regards,
Eddie
eddie
 
Posts: 4
Joined: Fri Oct 19, 2007 9:48 am

Re: IFDEFs, Mac OS X Port and general crossplatform development

Postby jaybinks on Sun Oct 21, 2007 11:00 pm

Im well up for helping..

actually a native Mac Os X port was on my own personal roadmap for
after the linux port.

so Im VERY VERY Glad to see you come on with us and combine resources.

as for 1)... Im not sure... I hav never used XCode and Ill take your word for it being better
than mac lazarus.

I agree with #2.. the reason I have used {$IFDEF FPC} if because I dont think there is a "Lazarus" defined,
but we can do that ourselves ( probably ) and.. Ive been currently maintaining windows build compatibility in
lazarus for windows. you will find I have also done a LOT Of {$ifndef win32} instead of using {$ifdef linux}
ive done this because its code I anticipated to work on macos also.

I agree with your goal of eliminating all platform specific code... but I wouldn't only limit it to U*.pas files.
id like to make it as platform agnostic as possible and have a few plugable units that implement the platform specific code.

as for the resources... you can probably use the lazarus resource.pas unit in XCode that would give you the ability to compile in resources for the mac build... Or ive also considered doing our own resource file type thing for this, since...
lazarus resources dont seem to be compressed... and it would be nice to use the same code on windows..

anyways.... bottom line, Im WELL up for helping as much as I can with the mac os X port..
I might try and get me a mac mini that I Can use to help you, if you can instruct me on how to setup xcode etc.
jaybinks
Developer
 
Posts: 27
Joined: Wed Sep 12, 2007 10:23 am
Location: Brisbane Australia

Re: IFDEFs, Mac OS X Port and general crossplatform development

Postby eddie on Mon Oct 22, 2007 8:32 am

I'm glad to hear that we both have the same ideas and goals :-)

The main problem I have with Lazarus for OS X (Intel) is that there is no stable build. The only available build is an auto-generated daily build. Once there is a stable build we may switch to Lazarus on OS X, too.

On the other hand, XCode is a very mighty IDE. Besides the fact that you can add support for new languages like Pascal, you can define multiple targets per project and multiple configurations per target. You can add custom actions and scripts to any build phase. The only disadvantage is that the debugger only displays the first character of a pascal string.

I'm not 100% sure what's the best way to change the IFDEFs. We could add a custom define LAZARUS and maybe one day, lazarus can compile the project on windows, linux and mac. But that wouldn't work for mac os today, since there is no stable Lazarus.
For the moment I think, it's the best to use the WIN32 define for the mac os build, like I did for the 0.5.3 port, but this is of course very confusing. But I can reuse the wrappers I wrote for the 0.5.3 port and we would see results on OS X early.
I also have to take a look at the {$ifndef win32} parts.
I will read more of the code during the next days and think further about the IFDEF problem.

We should move the code from the dpr/lpr file to the UMain.pas like in the current build of UltraStar 0.5.3. I can't use the dpr/lpr file on Mac OS and we would have 3 versions of the main() function then.

I don't know how the Lazarus resources work, but if we can use this format on all platforms we should do that. I think it's no problem that the resources aren't compressed: the setup is compressed anyway and hard drives are big enough today. We also have to ship so many libraries that a few resources shouldn't be the problem.
eddie
 
Posts: 4
Joined: Fri Oct 19, 2007 9:48 am

Re: IFDEFs, Mac OS X Port and general crossplatform development

Postby eddie on Fri Nov 02, 2007 6:54 pm

Hello jay,

first: sorry for breaking all the files on linux. I didn't know that the mode switch would cause so much trouble. With FreePascal 2.2.0 on the mac it works...

Does the baseunix unit work on linux? We could then remove the oldlinux parts.

Regards,
Eddie
eddie
 
Posts: 4
Joined: Fri Oct 19, 2007 9:48 am

Re: IFDEFs, Mac OS X Port and general crossplatform development

Postby jaybinks on Sat Nov 03, 2007 12:40 am

No probs... Im not yet using FPC 2.2
but might change soon.

and yes Ill try and make that change asap.

be good to catch you on IRC at some point :)
jaybinks
Developer
 
Posts: 27
Joined: Wed Sep 12, 2007 10:23 am
Location: Brisbane Australia

Re: IFDEFs, Mac OS X Port and general crossplatform development

Postby Tothem on Thu Jul 31, 2008 5:51 pm

Hi guys,

First I'd like to thank you for your awesome work!
Then I'd like to know if Ultrastar-dx was meant to be compiled on a PPC architecture.
I installed the prerequisited packages via fink and downloaded ultrastardx code via SVN, and when I tried to compile it, I got the following error:
Classes/TextGL.pas(12,4) Error: Illegal assembler style specified "INTEL"
Classes/TextGL.pas(89,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /sw/bin/ppcppc returned an error exitcode (normal if you did not specify a source file to be compiled)
make: *** [../../UltraStar] Error 1

Can I do something to fix that? Or should I just give up on trying to find a Singstar-like on PPC? ;)

Cheers,
Tothem
 
Posts: 2
Joined: Thu Jul 31, 2008 5:45 pm

Re: IFDEFs, Mac OS X Port and general crossplatform development

Postby mischi on Wed Aug 20, 2008 6:54 am

Hi

the development of USDX is on an Intel-10.5 machine. Most Mac OS X specific things are finished, so that test on 10.4 have started, but there is still a crash. The next step after this will definitely be a try on PowerPC Macs. It will be interesting to see the load on those machines.

After a quick look, that assembler will not be a show stopper.

Btw. Interested in becoming involved in the project? see you on channel #ultrastardx on irc.quakenet.org
Mischi does the Mac OS X port.
mischi
 
Posts: 102
Joined: Sat May 17, 2008 11:27 pm

Re: IFDEFs, Mac OS X Port and general crossplatform development

Postby mischi on Wed Aug 27, 2008 9:11 am

Tothem wrote:Hi guys,

First I'd like to thank you for your awesome work!
Then I'd like to know if Ultrastar-dx was meant to be compiled on a PPC architecture.
I installed the prerequisited packages via fink and downloaded ultrastardx code via SVN, and when I tried to compile it, I got the following error:
Classes/TextGL.pas(12,4) Error: Illegal assembler style specified "INTEL"
Classes/TextGL.pas(89,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /sw/bin/ppcppc returned an error exitcode (normal if you did not specify a source file to be compiled)
make: *** [../../UltraStar] Error 1

Can I do something to fix that? Or should I just give up on trying to find a Singstar-like on PPC? ;)

Cheers,


The error above is fixed and USDX compiles and links on a PowerMac under 10.5. This first try shows problems with graphics and sound; probably big-endian/little-endian related bugs. In summary: There is hope.

You could help by getting the recent sources from svn. Please note, that there was an update about the packages/libraries you need from fink. Can you scan the code for endian related problems?
Mischi does the Mac OS X port.
mischi
 
Posts: 102
Joined: Sat May 17, 2008 11:27 pm

Re: IFDEFs, Mac OS X Port and general crossplatform development

Postby Tothem on Sun Sep 07, 2008 9:35 am

Hi,

Thanks for your answer!
I'm currently selfupgrading fink and then I'll re-try to compile ultrastardx from the source available on the SVN repo.
I'll gladly keep you updated with any relevant issue I'll find.

Cheers,
Tothem
 
Posts: 2
Joined: Thu Jul 31, 2008 5:45 pm

Re: IFDEFs, Mac OS X Port and general crossplatform development

Postby mischi on Sun Sep 28, 2008 2:52 pm

The endian related problems with the Mac OS X PowerPC port are fixed with version 1419. CPU usage on a 867 MHz Dual G4 is 50% with video background on. Looks good enough to give it a try :-)
Mischi does the Mac OS X port.
mischi
 
Posts: 102
Joined: Sat May 17, 2008 11:27 pm

Next

Return to Developers

Who is online

Users browsing this forum: No registered users and 1 guest

cron