Building druntime on MAC OS X

Jacob Carlborg doob at me.com
Sat Nov 23 02:28:59 PST 2013


On Thursday, 21 November 2013 at 11:18:44 UTC, Andrew Edwards 
wrote:

> #!/usr/bin/env /bin/bash

Since this script will only be run on Mac OS X there's no point 
in using the "env" command. Just hardcode the path to Bash.

> ##
> # Author:: Andrew Edwards
> # Version:: Initial created: 2013
> # License:: Public Domain
>
> # Create directories to house generated ouput
> mkdir -p .work  && cd .work
>
> # Fetch source from github
> getdmd="git clone -q --progress -bv$(<~/VERSION) 
> https://github.com/D-Programming-Language";
> $getdmd"/dmd.git";
> $getdmd"/druntime.git";
> $getdmd"/phobos.git";
> $getdmd"/tools.git";
>
> # Build DMD, making changes to dmd.conf as necessary
> cd dmd;
> make -f posix.mak install;
> cat ../install/bin/dmd.conf | sed "s/-L--export-dynamic //g" > 
> ../install/bin/dmd.conf2
> cat ../install/bin/dmd.conf2 | sed "s/-L-lrt//g" > 
> ../install/bin/dmd.conf
> rm  ../install/bin/dmd.conf2

Don't patch dmd.conf. Change the makefile to do the right thing 
from the beginning.

> # Build DRUNTIME
> make -C ../druntime -f posix.mak install DMD=../install/bin/dmd
>
> # Build PHOBOS
> make -C ../phobos -f posix.mak install DMD=../install/bin/dmd
>
> # Build TOOLS
> make -C ../tools -f posix.mak install DMD=../install/bin/dmd
>
> # Move tools to correct location
> mv ../tools/generated/osx/default/catdoc ../install/bin
> mv ../tools/generated/osx/default/changed ../install/bin
> mv ../tools/generated/osx/default/ddemangle ../install/bin
> mv ../tools/generated/osx/default/detab ../install/bin
> mv ../tools/generated/osx/default/dget ../install/bin
> mv ../tools/generated/osx/default/rdmd ../install/bin
> mv ../tools/generated/osx/default/tolf ../install/bin

Not all of these tools are currently shipped with DMD. Don't know 
if we want to include all of these. We should probably start a 
new post about it.

> # Generate zip file
> ditto ../install ~/.dmg/usr/share/dmd
> ditto -jc --keepParent ~/.dmg/usr/share/dmd 
> ~/dmd.$(<~/VERSION).bz2
>
> # Place DMD in path
> mkdir -p ~/.dmg/etc/paths.d
> cat >~/.dmg/etc/paths.d/dmd <<'EOT'
> /usr/share/dmd/bin
> /usr/share/dmd/man/man1
> EOT
>
> # Generate installer
> mkdir -p dmd.$(<~/VERSION)
>
> cat >dmd.$(<~/VERSION)/uninstall.command <<'EOT'
> #!/usr/bin/env bash
>
> sudo -p "Please provide your password to uninstall DMD: " rm 
> -rf /usr/share/dmd
> sudo -p "Please provide your password to uninstall DMD: " rm -f 
> /etc/paths.d/dmd

Don't remove the whole directory like that. Explicitly remove all 
files the installer put there and then remove the directory if 
it's empty. The user could have placed some own files in that 
directory. It happened with the latest Windows installer 
resulting in some angry posts.

> echo "Uninstallation complete!\n"
> EOT
>
> chmod +x dmd.$(<~/VERSION)/uninstall.command
>
> pkgbuild --identifier org.dlang.pkg.app --root ~/.dmg 
> dmd.$(<~/VERSION)/dmd.$(<~/VERSION).pkg
> hdiutil create -ov -srcfolder dmd.$(<~/VERSION) 
> ~/dmd.$(<~/VERSION).dmg

You're not using the dmd2.pmdoc file or corresponding. That will 
result in missing readme, licenses and other information.

> cd ~ && rm -rf .dmg .work
> </end file>

--
/Jacob Carlborg


More information about the Digitalmars-d mailing list