Author Topic: CodeBlocks and contrib projects for MacOSX 10.4  (Read 12374 times)

bnilsson

  • Guest
CodeBlocks and contrib projects for MacOSX 10.4
« on: November 04, 2006, 08:25:48 am »
With some help from Pecan I have adapted a .cbp projects that builds CodeBlocks and contrib plugins on MacOSX 10.4 using CodeBlocks.

What came as a surprise to me was that the frontpage buttons and icons (New project, Open project, Recent projects, etc.) was working instantly on CodeBlocks built by the CodeBlocks-mac104.cbp, while these functions are not working (at least for me) when building CB from command line.

The attached package also contains a modified update script (update-mac) plus a bundle script to make a CodeBlocks.app bundle.

Test it with care, so you don't ruin existing installations.

 

[attachment deleted by admin]

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #1 on: November 04, 2006, 08:33:30 am »
Are these going to be submitted to as patches for CB?  I am starting a project at my university and I have several Mac team members.  It would be a great boon to the project to only have to support one C++ IDE.

takeshimiya

  • Guest
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #2 on: November 03, 2006, 09:27:37 pm »
Hi,

this is nice, it would be even nicer if it could be mantained by someone with commit access over svn,

the unix cbp's are almost the same, with some differences, so you could
a) maintain a set of patches to output -mac.cbp's based on the -unix.cbp's
b) maintain a different set of projects (lot of burden maintenance)
c) maintain a sed script to output -mac.cbp's based on the -unix.cbp's.
d) maintain a set of build scripts (squirrel) for the -unix.cbp's (this is the one I like most)


some things to note in the projects attached:
1) you use
<Option output="devel/libwxscintilla.dylib" prefix_auto="0" extension_auto="0" />
but it is not necessary, the idea is to use prefix_auto="1" and extension_auto="1" so CodeBlocks guesses the prefix and extension automatically,
so here, we cut the "diff" a bit,

2) I can see that you use sometimes <Add option="`wx-config --libs`" /> in both the Projects and the Targets, it is not necessary to be in both, just use one of the two, and leave the same as the -unix.cbp's

3) there is <Add option="-D__WXMAC__" /> usage,
question: doesn't wx-config --cxxflags defines that automatically?

4) I see inclusion of <Add directory="/usr/lib" /> and <Add directory="/usr/local/lib" />,
for which library is this necessary? if for wx, that's not good,
the problem in hard-coding this system path in the project is that, for example, if you want to use the wx from MacPorts (/opt/local/lib) the above path will override it; I think it's better to leave the user to define those system paths in their own linker paths.
linking to /usr/lib/libSystem.dylib directly is rather OK because you don't bring all the paths to the linker

bnilsson

  • Guest
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #3 on: November 03, 2006, 09:34:59 pm »
Thanks for the comment, I will implement the suggested changes.
I got the project from Pecan as being 10.3 compatible, and after I got it to build without errors on 10.4.8, I did not proceed much further.
I will send an updated version as soon as I see that it is working with your suggested changes.
Any further comments will be much appreciated.

bnilsson

  • Guest
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #4 on: November 03, 2006, 11:10:48 pm »
I was able to do away with 3) and 4) but not 1) and 2).
1) libwxscintilla apparently needs to be a .dylib, automatic extension makes it a .so, and this does not link. I did not see auto prefix do anything at all.
2) removing `wx-config -libs`from "sdk" and "src" targets caused link errors against wx.

Major other changes to fix the above I guess would be contraproductive if the issue is to have as little differences as possible vs. -unix.cbp.
But of course, suggestions are welcome.


I will go thru the plugins/contrib projects also to see if I can remove some unnecessary stuff there also.

takeshimiya

  • Guest
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #5 on: November 04, 2006, 12:20:37 am »
1) libwxscintilla apparently needs to be a .dylib, automatic extension makes it a .so, and this does not link. I did not see auto prefix do anything at all.
well then c::b needs a little fix, on Mac autoextension should change it to .dylib, not .so

2) removing `wx-config -libs`from "sdk" and "src" targets caused link errors against wx.
there's probably a linker-order error, I was talking about plugins anyways; let's take an example, codesnippets plugin:

there's this in the Target:
Code: xml
<Linker>
<Add option="`wx-config --libs`" />
<Add directory="../../../devel" />
</Linker>

and you added this in the Project:
Code: xml
<Linker>
<Add option="`wx-config --libs`" />
<Add option="-bundle" />
<Add library="libcodeblocks" />
<Add library="libwxscintilla" />
</Linker>

so the suggestion is to merge all in the Project for example:
Code: xml
<Linker>
<Add option="`wx-config --libs`" />
<Add directory="../../../devel" />
<Add option="-bundle" />
<Add library="codeblocks" />
<Add library="wxscintilla" />
</Linker>

well that's it,

here comes the interesting part, build scripts:
http://wiki.codeblocks.org/index.php?title=Build_scripts

if you can create build scripts instead of new -mac.cbp's it would be a lot nicer,
something like this in the above case:
Code: cpp
function SetBuildOptions(base)
{
    // no PLATFORM_MAC for now, btw the logic in sdk/scripting/bindings/sc_consts.cpp
    // is wrong because there is gtk for mac =P
    if (PLATFORM == PLATFORM_UNKNOWN)
    {
        base.AddLinkerOption(_T("-bundle"));
        base.AddLinkLib(_T("codeblocks"));
        base.AddLinkLib(_T("wxscintilla"));
    }
}

function UnsetBuildOptions(base)
{
    if (PLATFORM == PLATFORM_UNKNOWN)
    {
        base.RemoveLinkerOption(_T("-bundle"));
        base.RemoveLinkLib(_T("codeblocks"));
        base.RemoveLinkLib(_T("wxscintilla"));
    }
}
« Last Edit: November 04, 2006, 12:48:19 am by takeshi miya »

sethjackson

  • Guest
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #6 on: November 04, 2006, 12:42:57 am »
here comes the interesting part, build scripts:
http://wiki.codeblocks.org/index.php?title=Build_scripts

if you can create build scripts instead of new -mac.cbp's it would be a lot nicer,
something like this in the above case:
Code: cpp
function SetBuildOptions(base)
{
    // no PLATFORM_MAC for now, btw the logic in sdk/scripting/bindings/sc_consts.cpp
    // is wrong because there is gtk for mac =P
    if (PLATFORM == PLATFORM_UNKNOWN)
    {
        base.AddLinkerOption(_T("-bundle"));
        base.AddLinkLib(_T("codeblocks"));
        base.AddLinkLib(_T("wxscintilla"));
    }
}

function UnsetBuildOptions(base)
{
    if (PLATFORM == PLATFORM_UNKNOWN)
    {
        base.RemoveLinkerOption(_T("-bundle"));
        base.RemoveLinkLib(_T("codeblocks"));
        base.RemoveLinkLib(_T("wxscintilla"));
    }
}


I agree.

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #7 on: November 04, 2006, 12:46:24 am »
What came as a surprise to me was that the frontpage buttons and icons (New project, Open project, Recent projects, etc.) was working instantly on CodeBlocks built by the CodeBlocks-mac104.cbp, while these functions are not working (at least for me) when building CB from command line.

Interesting, I can see if I can isolate what the bug fix for wxMac turned out to be then...

I've fixed the issues with opening files and with locating the prefix, so will commit those.

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #8 on: November 04, 2006, 01:07:54 am »
FYI: Info.plist for the application will be probably done as codeblocks.plist, generated automatically from codeblocks.plist.in with the current SVN revision, and with support for all of the file types (incl. icons)

See:
http://www.algonet.se/~afb/wx/codeblocks.plist
http://www.algonet.se/~afb/wx/icons48.zip


Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #9 on: November 04, 2006, 01:23:18 am »
Also, with autotools wxscintilla is statically linked (libwxscintilla.a)

takeshimiya

  • Guest
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #10 on: November 04, 2006, 02:08:18 am »
To accomplish d) and 1) fixing C::B itself was needed,
so I've uploaded a little patch for wxMac here: https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1622&group_id=5358

afb, can you check that it works / doesn't overlaps with your patches?

bnilsson

  • Guest
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #11 on: November 04, 2006, 10:50:57 am »
Where should the contents of Icons48 be placed?

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #12 on: November 04, 2006, 11:19:34 am »
Where should the contents of Icons48 be placed?

Sorry, the icons should go next to the other ones in src/src/resources/icons
(in the CodeBlocks.app bundle they should go in the Resources dir, as usual)

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #13 on: November 04, 2006, 11:26:45 am »
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1622&group_id=5358

afb, can you check that it works / doesn't overlaps with your patches?

Seems to apply cleanly, I haven't used Code::Blocks to build itself much.

bnilsson

  • Guest
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #14 on: November 04, 2006, 12:18:15 pm »
takeshi,

Sorry, I had to reverse your patch for pluginmanager, since no plugins loaded when applied.