WWDC2003 Session 301

Transcript

Kind: captions
Language: en
so the what we're going to talk about
today is the unix tools there we go okay
now you've heard about Xcode and you've
seen the demos and Xcode is a full tool
suite part of that means the that it
includes command line tools we have a
full set of command line tools of the
traditional sort that the units
community is used to has been using for
a long time we use that to speed reports
we use it to ease maintenance of the
program's once ported and what it really
comes down to is that it's part of
making mac OS 10 a really superior home
for unix applications one of the the
best way to characterize is that things
just work I have a number of
acquaintances including a number of the
enthusiasts of that l system and they
would go to some trouble to run power pc
linux on their tie books they would run
it for a while depending on their level
of dedication and what I've noticed that
they tend to drift back to running OS 10
on them and then what's basically what
they've done or what they've discovered
what they report is that I can get their
DVD player to work the 3d graphics
doesn't result in strange artifacts the
outside the boundaries of the x windows
and other things that that that one
typically happen on a Linux system even
after this many years of development for
it so that's the this really is easy if
the appeal of Mac OS 10 for for unix
development so specific things that
we'll talk about talk about the specific
what tools are delivered we'll talk
about their unique features to go into
porting issues for bringing over new
programs and then we'll go into how to
mix it up with Xcode so you can have
both the command line environment and an
ID environment and have them work well
together so Xcode Xcode Xcode Xcode
Xcode yes that's our big thing but we
it includes command line tools and since
as the audience said they're primarily
UNIX people is that's what we're going
to talk about so what are their
advantages there they're familiar it has
been 30 years of productivity on UNIX
original unix designers were pretty
smart guys they understood about the
composability of tools throughout a
specific example and everybody Snickers
but but the units guys knows that that
these kind of things come up on a daily
basis and take an example of you have
two files you have there some references
to a function that a bug report is
mentioned and you need to find the
references but these are very large
files and disk reppin for who got the
entire files there's too many of them
they take a diff between two versions as
a file and then you grep that for these
couple of function names and this is
something that that unique people do on
a daily basis that's almost a on-the-fly
scripting kind of process and it's very
powerful the UNIX world also because of
the time it's been around has developed
a large number of tools that that are
already out there already in use so we
want to be able to take advantage of
that very large body of tools told me
these things were difficult ok so the
terminal program is the basic way you
get to it and I'm not even going to ask
I'm sure everybody has used the terminal
program here so the but we have to show
you a screenshot for it so I have to
apologize for the graphics the because
you have to get to the terminal program
by clicking somewhere another and so
it's under applications utilities down
there down near the bottom the 'true
terminal aficionado so put this copy in
the dock where it belongs so
so the terminal program it opens up
multiple windows each window runs a
separate shell and you have quite a few
configurability options you have a lot
of the same kind of options you would
see in something like an xterm you can
set the character codes you can set the
colors of the screens do all that kind
of stuff you also have some options that
you won't necessarily see in an X term
for instance set the transparency of the
terminal windows and it's an interesting
thing to see how that comes out style
lights because some people prints they
find that very cluttered and my personal
terminal intend to be opaque other
people they like actually bill to see
what's happening in the terminal windows
that are built in front and in back and
so they'll set all the windows to about
fifty percent the transparency and then
you can see everything that's going on
and then you have to the the trick of
figuring out which which is the
character of streaming buyer from the
front window and which ones are in the
back window so in Panther we also
include a server menu which basically
gives you a shortcut to the various sshs
and RF h's and so forth that you might
want to do to run to two other machines
so that's going to be a very handy
feature okay so let us recite the
catechism so it's a Emacs week at
it this is our code review process being
truly studly programmers we don't bother
with headers or declarations or any of
that kind of stuff we compile it with
with CC we run we add a dash G because
we like the debug and we run it and we
run the dot slash so that we pick up our
a dot out not somebody else's like the
virus and prints out hello but we like
to debug her a lot and so we're going to
run the debugger on this anyway and so
we say fire up the debugger with fire gb
we say break main we run it and we can
step and it still prints hello and all
that kind of stuff so we're actually
done now this is everything you need to
know for programming
nobody's getting up okay you know that
everybody's falling asleep I see a
couple hands falling backwards already I
appreciate everybody coming out this
early in the morning you know it so I
understand that it's a real sacrifice
okay for shells we would you offer a
variety of shells the people use
different shells because they have
different scripting language different
uses usage characteristics so for normal
interactive usage we have tcsh improved
seashell has history and other good
stuff in it and we have also the v sh
and mostly because jordan hubbard like
that i'm told and then we have the bash
which is the new project re
implementation of the bourne shell to
bash being short for the born-again
shell haha so batch also has the
advantage that it's a fairly fast
version of bin sh now for editors we
offer emacs the one true editor
emacs is highly customizable it has its
own programming language so probably the
most widespread use of lists of lists
perhaps even surpassing AutoCAD and it's
used for quite a lot of different things
that people have built newsreaders and
actually built IDEs with emacs quite a
few different kinds of uses for the
customization the Jaguar standard
version is 21.1 the Panther standard
version is we expect to be 21.2 you can
also get X 11 and carbon versions the
one that's built in a system is kind of
a basic TTYL type emacs but we do have X
11 and carbon versions available as well
now because we value diversity hey we
also offer VI oh this is bed I got tough
audience here okay well well I have I
have a good story for V Eisen and well
VI actually last regularly used VI just
about 20 years ago and I used it for
about a year or so and this is back in
the days of bsd 4.1 they may remember
bsd 4.1 okay it's very few clapping okay
well it was a long time ago anyway so I
used VI for about a year and and really
never used too much after that I went a
university environment everybody Max and
I kind of went along with the crowd and
made the transition but when I came back
to apple and VI would show up from time
to time like when you're checking into
CVS and after not using it for 20 years
I still remembered the command I just
like they I didn't know where they came
but I just type the commands right away
so so that's the that's really a point
in its favor I'm not sure anybody would
remember all the Emacs commands after
that length of time now in Panther we've
upgraded to them short for improved VI
and has the more because customization
in configuration and some people
actually think it's too big but that's
okay now we also have a number of other
editors we have Kiko we have said
we have ed and then for the real real
programmers we have cat now how many
people have actually written programs
using just cat yep how many people
written a thousand line program using
cat yeah nobody's raising their hands
now so for language options we provide
the thieves of course we provide both
c90 and see 99 some people call it see
aging I'm but that's wrong it's actually
c90 and we do have see 99 and Panther we
actually provide the library that goes
with it so you now have something
resembling a complete c99 solution we
have the C++ we have objective-c of
course and we have objective c plus plus
which is essentially a combination it's
C++ extended with Objective C features
we offer both the 1.3 and 1.4 versions
of Java we also have an assortment of
scripting languages you get parole
tickle PHP Python and Ruby and so it's
we also have third parties that we have
things like metro works AB soft nag and
so forth you can also download
additional languages for instance g77
for fortran the nap for ADA you got to
get at guys here this time yeah there is
okay yes we have we have these nut cases
that have actually gotten they have
gotten ADA running on running on Mac OS
10 and it really works and there's
actually people doing useful work with
it we offer list so you can or Atari you
can download lips and quite a variety of
other languages so for build tools
there's basically three major options
you knew make as a standard and it's
just the standard the usual you do make
the when you say make that's the one you
get for people that need compatibility
with VSD make and you know who you are
we have bsd make we don't recommend it
however for anything beyond what's
required strictly for compatibility its
features are somewhat different from
what most people are used to and then
finally we have PV build which is used
by Xcode projects and essentially the
command-line interface to Xcode this is
actually very useful in a mixed
environment because you can have
somebody that works in the xcode IDE
build up their project add files and so
forth and then if you say RSS a-qing in
from somewhere else you can type TV
build and build the same project we of
course have the usual collection of
standard UNIX tools the collection is
most similar to what you'll find in
freebsd we have the CVS rtca our CFOs
ccs the trough and all of its little
friends the compiler generators weed
bison and its friends the various object
tool working programs and of the
programming tools in general the total
comes out to about 400 or so scattered
across bin and user bin now if that's
not enough we also have a ports manager
and the port's manager they say allows
you to add to the collection dynamically
not unlike software update so the
mechanism that we're currently using in
Panther are going to be using in Panther
is called Darwin ports and similar to
the Fink and the freebsd ports packages
fact just a couple days ago they think
and Darwin ports guys have actually
started talking about a way to integrate
their two activities about 400 ports
have been done in Darwin ports to date
and it offers both command line and
gooey interfaces so a command line
interfaces port and there's various
commands statue extract etc what it does
to download the sources builds it and
installed it so to actually get a look
at how this works in practice we have
sean fagan is going to give a demo
from my name is sean fagan and I do as I
tell people I do eunuchs Estep all right
first I was going to show you wrong one
thank you I was going to show you the
porch manager application which is the
GUI and there it is as you can see i use
the command line to lunch gooeys because
i prefer the command line the ports
manager application is in applications
utilities on Panther and the first time
you run it it'll tell you it hasn't been
installed you want to install it you of
course say yes it'll ask you for the
admin password and it'll download build
stuff configure it and then you end up
with this and here are all of the
utilities all the categories and as you
can see they're quite a few well there
are but again I like the terminal so I
was going to show you a simple utility
for all those people who need to speak
Swedish okay I've already stretched it
because the with everybody thousands of
people using the network here at get
clients gets kind of bogged down so the
next part is just to build it wow that
was easy is the fast machine next part
is to install it also installed rehashed
because there's of TSH and there's the
message of the day in Swedish wow that
was easy the other thing I like about
our own port is can do this it has by
during the package man it has created an
installable bundle I double click it it
will run the standard installation
program but it's already installed so I
went through that now
the other thing I wanted to show you was
one of the most useful aspects of the
Darwins port system is actually you can
use it not only to install tools and
utilities and libraries and whatnot that
you need but you can also use it to as a
basis to figure out what to do for your
own ports and I had a couple of ports
here let's see that it has an end of it
okay thank you come on out of that
display yeah how about that DJ how's
that
yeah yeah how's that better yes bigger
64 oh wow okay all right sexy right here
this is a sport called open PSP the port
file file called portal has everything
about it and their description and the
part I wanted to show you was the stuff
Marco's configure and that is a series
of commands that are run after the
configure stage in the process and as
you can see this is an example someone
had a sharp pragma implementation in
their source and you don't really want
to have it so that's an example
something you might need to do it's very
long the other example was the consensus
cake the other thing as a in case it
wasn't obvious from that the Darwin
ports by default install things and use
a deport and then for those of you who
are familiar with the freebsd court
systems the structure will be very
familiar except that it uses a port file
instead of a make file and here and on
all those configure argh I've actually
run into I've actually run into a couple
places where I needed to use the XDM
library and I found that it was easier
is easiest to just a grep through the
port files in the Darwin port figure out
the configure arts they needed and I
wanted to show you one last thing as it
is okay one thing that the court
mechanism has that the freebsd ports
mechanism doesn't have is variant and
they're marked by this variant command
as you can see in the middle of the
screen there
this one is how you would build the
carbonized version of a Mac and I had
one thought about building it and
running it off of my little USB key fob
which you can do is it builds will
actually build a bundle but my little
key fob is only 128 megabytes in emacs
won't fit on it
there you go well thank ya one last
thing there will be more discussion
about Darwin court at the open source
session which is fashion 10 to a 1030 ok
[Applause]
now thanks Shawn and I think I hope that
some of you will actually volunteer to
add more stuff to the Darwin port get
the next ok so I'm going to use a moment
and talk about AP is the fundamental API
we have for 40 s tennis is POSIX posix
is we don't have a total complete every
lat last detail passes the conformance
test POSIX what would you have is
essentially as much positive as just
about everybody cares about so if you
find anything that's not conforming and
we want to hear about that because that
means there's at least one person that
cares about that little bit of POSIX we
also have OpenGL and glut4 interface we
have carbon and cocoa for gooeys which
you there's a number of sessions going
into the details of those api's for
doing drivers and kernel extensions we
have something called I oak it
unfortunately this is new to you you're
out of luck because the i/o kit session
was yesterday but you certainly find out
about it an online documentation and so
forth and I okay it is interesting
because it's a c++ framework that allows
you to write drivers without actually
recreating everything that is required
for drivers which uses inheritance and
if you've ever tried to write a linux
device driver or just read the book on
linux device drivers and appreciate it
how much of an advantage that is we
Panther x11 is integrated with the
system so yes
it is one of the big demanded features
that from Jaguar silly-ass owed so
that's good to have we also provide ipv6
via the GF network API and this is such
an important API that actually has its
own session on Friday so if you're
interested in that and go to the session
where is this some more details about
specific API things that are doing
Panther we have pull we have dlopen oh
come on this is another one of the most
requested features in Jaguar yes dlopen
and its friends we also have a number of
new libraries the lib XML we have a wide
wide care library 4c 99 that I referred
to we have a couple libraries for
internationalization as well again the
general in general the API will resemble
what you see in freebsd five-point oh I
have to talk a little bit about
frameworks because that's something that
is unique to OS 10 and a framework is
essentially a shared library okay will
often use the term die lib to refer to
the single file that is the shared
library proper but the way a framework
is structured is that it packages up the
guy lives and the resources and the
headers all into a single place and this
is basically a little bit more
sophisticated design than you'll see in
a something like a standard UNIX type
system where the resources are who knows
where and the headers are mooshed into
user include along with everything else
so the framework packages it all up
gives it a places you can see down at
the bottom of the example where you can
essentially have a separate file for
each language that you wish to translate
the strings that are used in that
framework now use the frameworks just
say include food / food for framework
name foo to link it you add a dash
framework and then the name of the
framework most of the supplied
frameworks you'll find in slack system /
library / frameworks and if you look in
there there's 40 50 60 it's actually
quite a few quick time is a framework
our carbon the whole of carbon is a
single framework and so forth now if you
want to add your own framework you can
drop them into the system library
frameworks or you can put it in your own
place and then direct the compiler to
find them using dash capital f and this
is a again an option that is that is
unique to Apple version of the compiler
and that will it worked a lot like dash
capital I for finding as adding a place
for finding include files now the
traditional UNIX e-type header still
live in user include so you'll see that
sometimes there's a little bit of a
confusing situation because we'll talk
about a system framework and system
framework is ntr term for what would be
called lid see and in Linux land but the
headers are still kept in user include
because if they were actually under
system library frameworks no one would
ever be able to find them so the most
important thing to know about the
compilers compiler is gtc so I think I
think everybody knows that by now a
couple years ago it's a little bit more
of a less well-known so all the usual
GCC options work now we also have a
number of additional compiler options
and there's actually a whole session
that goes into detail on this there's a
couple that are especially interesting
for you to exporting one of them is dash
F altivec to enables altivec types and
built-in functions it is more powerful
and slightly different in behavior than
the dash mne altivec that is an FS fgt
see the details are more complicated
that I can get into here find me
afterwards if you want to talk about it
in depth we also have an option that's
called dash mne dynamic no pic that
recommended for applications and norm
the normal mode of code generation 4g to
generate relocatable code that is by
default everything you have you build
can go into a shared libraries it can be
relocated around the memory space but
the code for this is not quite as
efficient as it could be and so for an
application which is not going to be
relocated you can say dash m dynamic no
pic get a little bit more efficient code
but at the same time still get to
relocatable dilute now to build
libraries you have the traditional
mechanism to build as lib foooo use AR
to build a library use ran lib to build
the table of contents there's a little
bit different than else and else you
don't need to run the ran lid step and
so sometimes programs that you're
porting over won't actually arranged for
the ran lid step and you have to add
that yourself to build the dynamic
library you use CC dash dynamic lib now
most of time you won't actually need to
supply that argument yourself because if
you use libtool libtool already knows
about all this and the versions of
libtool that are out in the world
already have the necessary OS 10 support
it's possible that you'll run into an
older program that has an older copy of
lib tool that's been sucked into it and
those case you'll need to update the lib
tool in the package so to keep track of
versions there's kind of a two there's
two really two layers of the system the
lower layer system was called Darwin it
consists of the open source code there's
no framework the framework support is
there but there's no framework that are
normally shipped with as part of Darwin
there's also no doing so Darla is a real
bare-bones eunuch system the tool
software version SW vers reports the OS
10 verse and that's going to be a 10 to
six or 10 3 or what have you the you
named a shave another unix command
reports the darwin version which is
looks a little bit different and it's
changed somewhat over the fence 10.0 and
so I get provide here a handy little
chart of exactly what happened to it so
the main thing to keep in mind is that a
10 point X you add 4 and you get the get
the Darwin the major Darwin version
numbers
very quickly
that's right okay pardon oh okay so okay
yeah so the the the most unusual thing
about this is that the Darwin numbering
scheme changed partway through 10.1 so I
see that 10.1 oh is 1.4 and then we
change it to be a more consistent
numbering scheme and well I won't
explain why it's more consistent it just
is it it corresponds if you see if you
look in the about box in OS 10 you'll
see down the bottom it says the number
like 7a 179 and the 7 is actually where
the Darwin version number comes from but
it ties in the parts of apples internal
process now most of the time programs
these days are actually most of time but
a large number of programs these days
use the new configure and make and those
programs will almost always just work
they once in awhile it actually was more
true last year than it was this year
that config guess and config dot
subscripts which eventually tell you
what kind of machine you're on they they
needed to be updated that's much less
commonly true nowadays now we do
recommend that if you have to have some
kind of test for system specific
features that don't try to rely on the
predefined macros we have those there's
a double underscore Apple there is a
double underscore Apple CC for a
compiler version there's a double
underscore mock and so forth in practice
it's hard to come up with exactly the
right combination of those that refers
to a specific version of Mac OS 10 so in
general we want you to look at look at
features test for features instead and
if you want to actually set up a whole
bunch of code that if TF 40 s ken
specifically define your own
preprocessor flag mac OS x and set that
up with a dash D and in the make file
and so a configure script adds the
HD mac OS x and on your code test if
there's mac OS x that basically gives
you more control and it also means
you're not as subject to minor changes
that might happen from one compiler or
10 s revision to the next now according
an interface despite the command line
focus we know that there's quite a few
little gooeys of one sort or another on
unix tools the curses just works we use
the ncurses library it's very standard
if you link against that is unlikely
you'll run into any difficulties we have
we have versions of tickle TK and QT max
that are adapted for aqua and in fact
saw a demo of QT Mac yesterday with the
spinning gears in all x11 just works at
x11 applications will actually auto
launch the server so users that may not
even be aware that they are running an
xserve er behind the scenes open glut
OpenGL and glut are standard standard
libraries you will have to translate any
include of gah the under on a unix
system it'll typically be written as g l
/ gah but we have an opengl framework so
called and so we say include opengl /
gah so just briefly to go over some of
the common problems that people run into
the first is the cpp pre comp now cpp
pre comp is gone from 3.3 so this is as
much historical as anything else the 3.1
compiler would use cpp pre comp which is
very useful for things like cocoa but
unix porch generally don't have large
enough header so they don't use large
enough headers to actually need
precompiled headers so it kind of waste
of time and CP pre comp did have some
areas where it wasn't entirely
consistent with the normal new
preprocessor and so the usual advice is
to add an o cpp pre comp it's still good
advice 3.3 we'll just ignore the note
cpp pre comp there are some missing
declarations and functions also
last year there was a bunch of easy
examples 2.2 but all the ones I knew
have had been fixed for Panther so
there's nothing to point to any more but
I'm sure I still some that are out there
you may also run into duplicate
definitions that is the system framework
will have things like get up will be
compiled into it and your program may it
may also link and get off its own
version getopt and then you'll get
complaints now on a on a Linux system
the it will just note that there is a
duplicate definition and we'll go on and
the OS 10 link will actually complain it
will say up multiple eda find you know
that this is an error and we do this
because this is a ties back into the mac
world where multiple definitions of
symbols were hard errors so the way to
deal with this is to add a dash multiple
eda find suppressed and this is
something that's a it's a linker option
but you can hand it in that in this form
to the compiler okay they told me this
was a squirrely so another less common
problems you might run into p thread
functionality soompi thread
functionality is missing even in panther
there's you can run into namespace
conflicts and this has always been a
concern also in practice it doesn't seem
to happen that often and there's an
option called two-level namespace which
is way too complicated to go into here
just read the linker man page and it has
all the gory details as I mentioned
earlier this is this actually happens a
fair amount so it's really not a left
common problem is to remember to run ran
lib that's pretty straightforward you'd
have to remember to do it or add it into
the make file another thing that as a
few people have bumped into is that the
end cursor is a separate live library in
Jaguar and later and previously was
included in the system framework and so
you basically if you want a program that
will run in both pre jaguar and post
jaguar systems you'll have to build them
slightly differently because the lives
of library no longer
being incorporated as part of the system
framework now most of the time for
porting you want to use autocom auto
comp is normally automatically used in
canoe can type configure script and it's
really the best way to test for OS
features on the machine at your building
on and it's basically the process and
actually should have how many people are
not familiar with auto cops okay
basically auto comps will it's horrible
horrible mishmash of scripts and macros
and various kinds of trickery and the
basic concept of our conf is pretty
simple so it will build a tiny program
for instance a tiny program that
includes a unix H which is a
non-standard header and and it will
compile the small program and it will
see if it errors out if it errors out it
says no UNIX dot H not found then it
sets a macro called have UNIX h and then
is 0 so that it says this header has not
been found and then you can use that in
your sources a if if you have UNIX dot H
then include unix dot h otherwise don't
include it so it's a it's a very
powerful mechanism and this is really
the core of how a lot of these programs
can be brought to a new system and just
build the first time and we're lucky and
that there's actually a book now in auto
comp describing it in great detail
written by the people that put a lot of
it together but it has one fatal flaw
which is that it tests the features of
the machine you're building on so if
you're running Jaguar and you want to
build for panther or as i'm sure
everybody's doing now it's all
installation is going on all day
yesterday everybody's running panther
and they want to build for jaguar auto
comps won't do the right thing it'll
it'll build a program that'll work just
fine where panther or may or may not
work on jaguar so we provide an
availability macros h and it's under
user include and what this will do this
will actually have a set of flag to set
of definitions that are used in the OS
10 headers to say whether a particular
feature
is available in Jaguar Panther what have
you and so they actually want to make
those tests when you're using features
that are not available in all versions
of OS 10 so going to a few more caveats
don't abuse root the personal machine
sure why not step on stuff and user bin
and improve the compiler overwrite the
headers we really don't recommend this
because you can easily get into a
situation where the program builds on
your machine or doesn't build on the
machine of the person next to you in
fact I ran into the fifth yesterday
because I had some header files that I
had not moved forward to a new
installation so so be careful about this
kind of thing use user local we have a
full set of user local we keep our own
hands off it so you can fill it up with
your own things the macho object file
format is actually a very different file
format from a out or elf or any other
format and one of the consequence
there's no standard your new binutils
port you often hear people that says
well the first thing I need to do is
build binutils on OS 10 and then I can
continue with my work says well that's
not going to get you very far so if
there's anybody that wants to port
binutils to mock oh you know it's a
please see me afterwards so another
thing to watch out for is white space
and past names they get a standard
installation you have a slash Macintosh
space HD and if you forget to properly
quote your file names bad things can
happen back some of you may remember
there was a bad thing that happened in
something is an apple tool where
somebody forgot the quoting so beware
another thing that happens at least is
often is hfs+ versus uff issues food
Otzi's we've got big seas camel caps foo
all these things are turned into the
same file and this has some interesting
and unfortunate consequences for
instance if somebody has a CVS
repository with files of the same name
differing only in case and CVS just does
not like that at all every time you do a
check out every time you do an update it
says oh this file already exists I've
already checked out this file and then
tries to overwrite it with
file anyway very confused situation
another consequence that I believe Shawn
pointed out to me that I hadn't heard of
before a lot of times people will have a
file named install in all uppercase
that's like to read me about how to
install okay but they also have a make
install action la aufs system make
install what they Okla the install files
air it's perfectly finished and done
there's nothing to do so make install
will has no effect okay couple words
about the debugger there's a whole
session on debugging later on so for the
gory details Mac os10 debugger is EB
currently based on the five point
release 03 release of gdb from the
episode it has a large number of
extensions though there's some objective
c stuff objective-c stuff is going at
FSF gdb but it's not all there yet so we
also have mas de por we have a framework
support we have a number of additional
commands again some of these are making
it into FSF gdb but they're not all
there yet now again there's another
session with all the details on gtc so
I'll just hit the high highlight the
Jaguar system compiler is 3.1 we still
have two point nine five point two and
this is available this is used for
compatibility 10.1 in particular if
you're building text okay the 10.1
earlier cannot run a three point x
compiled text also the reverse is true
the Panther compiler is 3.3 and so it is
so it's already sitting on your systems
as I think Ted mentioned yesterday the
even though the Xcode is still in
preview states the 3.3 compiler is a GM
compiler we've used it for quite a lot
of stuff and in general it's it's been
pretty good quality special features of
3.3 we got even more optimization you
saw the spec numbers are getting better
all the time we get to even better C++
conformant we have a new mechanism
called PCH for precompiled headers
so CP pre-comp is gone PFE is gone PCH
is the only way to go so how do you deal
with all these different GCC versions
well we give them all different names so
2295 compilers always a user bin GC to
the standard version 3 whatever standard
is appropriate for the system is at GCC
3 and then we symlink CC and GCC to one
or the other of these to flip back and
forth if you want to it's very often
convenient just to change the default so
that the make files and folders don't
have to know about this distinction you
can use the script GCC select which is
also unique to OS 10 and it's basically
a labret script that will choose the
compiler that is the default compiler it
knows about setting up to the auxiliary
program the headers and all that stuff
since it's actually affecting user bin
they do need to be route to run it do it
yeah ok so i press it harder it makes it
work better ok now bow dia gerfen will
come up and give us a little demo of
using the xcode ID with open source
project using two different mode cool
thank you very much Sam
I'm afraid of this thing now well good
morning how many of you guys yesterday
went to the open sore the developer
tools overview session just want to get
an idea okay great well this morning I
want to look at three different things
related to our Xcode product I want to
look at two ways that you can take your
existing open source applications and
bring them into the IDE I want to look
at some benefits of each of these two
ways and most importantly I want to give
you a couple of examples because I want
to show you what steps you can take as a
UNIX developer as an open-source
developer to actually start taking
advantage of these of the IDE so to
begin with two types of integration into
the IDE the first type is you can keep
your existing make file you can keep
your make based build system you may
have seen yesterday where Tony TV got on
stage and talked about all the benefits
of the dependency checking that the
xcode IDE provides but if you're already
have a project based on make perhaps
you're doing you're working on an open
source project with another group of
people you don't want to lose all the
work you've put into it you can continue
to do that our IDE will not change your
files it will support your make files
and it just it adds another file in the
directory that allows the IDE to keep
track of files the other thing you can
do is you can you can use xcode native
build system and this is going to mean
going through perhaps your make file
today figuring out your targets figuring
out some of the settings and changing
settings in xcode so we're going to look
at some examples of each of these so to
begin with the benefits of keeping your
existing make file and using it inside
the xcode ide well obviously the big
benefit is you already have it it's
probably already working but why would
you want to bring it into the IDE well
there are some benefits you get a
graphical IDE you get one of the really
nice features that stand pointed out to
me that he likes is the symbol indexing
that you get through the IDE we have a
nice batch find we have source control
integration and of course the
documentation is they're both API
reference and conceptual docs and we
didn't forget about your man page
since you're coming into the IDE we
still let you view the man pages through
that these mr. mantis I like the man
pictures I've spent a lot of time in
them and I don't like Ross she bugged me
every time I don't write what exactly so
to begin with we're going to look at a
demo of using an existing open source
project that make face and I'm going to
show you how to bring it into the xcode
IDE just some simple steps obviously you
know things are going to vary a little
bit but to begin with I always got to
start the app which I was smart enough
to have running already in Xcode just
choose new project and in this case
we're using a make file so we're just
going to choose an empty project and i'm
going to call this one i pick something
nice and big here subversion and I've
got it here in my example source cool so
you need to set a directory if you're if
you're bringing an existing project in
it's probably good to go just like I did
go a directory up so my source code
actually is in I'll show you where it is
an example source there's my source code
so i chose the source directory and then
name the project subversion the same
project name as my existing project that
works with make so when you do this you
just get we chose an empty project so we
get pretty much an empty project window
first thing you want to do is let's
bring in our source code files so under
the project menu we're going to add
files and again i navigate to where my
source files are got to go with column
of you much better alright
so I'm going to add these files in here
it's going to take a little minute first
we need to choose take the default
options you do want to create groups for
any added folders this will let X the
Xcode ide go through all your source
files add it to the index let you find
all the symbols and I've got to wait a
second here and boom we've got all our
we've got our love files now you saw
some of these things yesterday and I
encourage you to go to the later
sessions on the Xcode ide but you get a
lot of benefits so I'm not going to go
into a lot of detail on all the benefits
you get I'm just trying to give you a
starting ground for your your projects
but you notice we have we can now search
on we can choose the project here and
search and we get the nice fast find we
can go through everything we also get
the more enhanced find where we could
look for well I don't know main and
we'll get down here under the find
results we see all the all the
occurrences of main and all our files so
you get a lot of benefits there we also
have let's stop that fine I mentioned
the symbol lookup which is another nice
feature so let's look in here under
subversion it's a nice management system
also you can see client command line I
don't know let's take for example main
notice this this pop-up right here
excuse me it collects the symbols in
that particular file so you can do a
nice quick jump to get to the various
symbols in your file we also have the
documentation look up I mentioned the
man pages and the regular documentation
window so you get a lot of benefits just
and you haven't changed anything you
haven't changed all you've done is
you've added in your source file all
that we've done is we've added this the
TV project there the rest of the things
are just the same so if you have a group
of people that some people want to use
the IDE some people want to use command
line it's okay and at Apple we do that
our engineers are all over the map so
I'm like the IDE some like the command
that's the beauty of it so you can see
here some basic benefits you get it I
guess I should show you at building to
prove that it actually build oh yeah
because we got it forgot an important
step here in our project we've got the
files in the one thing we have to do to
actually build it is add a new target
and in this case we chose new target
from the project menu and we're going to
choose the appropriate Lane named can
you make target and I'm going to call it
something obvious like snake finish and
let's see if this actually worked I'm
going to open the build window so you
can see what's going on behind the
scenes here and I think I touched the
file in there most of them are good we
have one file I touched and so make goes
ahead and redoes it and we were
successful so very minimal work to bring
your projects in that was yeah you saw
it's pretty trivial all you need to do
is make a new project an empty project
is the best then you need to add your
files in and then just add a new target
a new make target so if we can go back
to the slide so that's using an existing
build style a make file with the Xcode
IDE but what if you want to use the
native build system maybe you sat in a
couple sessions yesterday the keynote
the development tools overview and you
saw all those great features their list
with a lot bigger than that list their
list was more like this list what if you
want to take advantage of the zero link
the predictive compilation the
distributed build system the code sense
there's a lot of great features they
showed you now some of those features
are dependent on GCC 3.3 but all of them
are dependent on the native build system
of Xcode so what if you want to take
advantage of those so again a quick
example of that and if we go back to the
demo machine thanks so in this case
we've got I chose a much simpler project
because pretty dang big project there
we've got this little command line tool
called our man and this is actually the
tool we use inside Xcode
item and paid the HTML man pages it's a
very simple tool we only require one
file to actually build it so take the
examples here I understand your projects
are probably going to be a little more
complex again we're going to start with
a new project this time we're going to
do something a little different though
we know what we want to end up with we
know we want to end up with a
command-line tool so I'm going to choose
standard tool and same thing again our
man i'm going to actually that file is
already okay but i'm going to choose the
directory where my project exists i'm
going to give it the same name our man
and you can see their volume to a sample
source our man Oh template files already
exists what's that you always got to
have something fun in a demo alright so
we end up with a project here now this
one's a little different than the other
project the other one was an empty
project this one well actually let me
debug show your love this one actually
does something if we if we build it and
excuse me this one if we build it and
run it it's a simple hello world
application now this isn't the
application we wanted though this is
just a template file when you use one of
the template files in the xcode IDE it
sticks a couple of basic files in there
usually a header file a source file
maybe a man page in this case since it
was a command-line tool and it also sets
up your build settings for you it adds
it sets linker settings it sets the
basic things you need for that type of
project so first thing we got to do in
this one is I'm going to show the target
pain here and I'm going to remove this
main dot C because that's not the file I
want so I'm just going to uncheck it
which removes it from this target and
I'm going to drag in the file I want so
our man dot C of course you could do it
like we did before go to the project
menu and add files but you know it is a
Macintosh drag and drop works so we've
added our source file and things should
just work
ho but life's not that good so if you
look here under this is one of the
features you get by using a native
target you get the integrated error and
warning reporting so over here on the
left you can see if I'm point of the
screen which you guys can't see over
there on the list you can see the errors
and warnings and you notice we have a
couple of errors we have what five
errors and we have a bunch of warnings
we're not going to worry about the
warnings right now it's at least we can
get it to compile but what about those
errors this is the kind of thing you're
going to find if you're importing your
projects into the xcode IDE you'll
notice our errors are all about
variables that are defined and if you
look at it if you look in your source
project I notice that a lot of these
things are defined in my make file so
for example we've got vol list and this
is the call in excuse me let me make
this bigger I realize you can't see it
back there if I look in my make file and
do a find I can see that yeah indeed
they did set this variable in the make
file so how do you get these kind of
things into the xcode IDE this is a very
important thing and this will help you
get your projects into the IDE so we
notice that there's a lot of things
defined in the make file all you need to
do let's go back to our source code all
you need to do is go to this targets tab
here choose the target when we made the
template it automatically added a target
a command line target one of the one of
the features and Xcode is the IDE is
that it uses the inspector a lot for a
lot of your build settings so we
selected the target and we're going to
open the inspector take a look at it and
we see general settings build setting
some rules properties well this is a
variable we want to pass in so under the
build settings we're going to look at
our current setting so I'm going to open
this drawer and look at our current
settings and here you see a nice nice
thing that you might be familiar with
we've got other cflags so in this case I
could add in you know minus the
and whatever that setting was or might
there go and then over here I could
maybe add a new variable definition I
gotta get rid of this it's still scope
there we go and we could add in whatever
our whatever our setting was now I don't
want to go through and make you sit here
there was five of these I don't want to
make you watch me type all that so I'm
going to go ahead and cheat here for the
sake of brevity and open up a pre one
that I've already put all these options
in and just to prove that there's
nothing sneaky going on here we can take
a look at that target again and again we
open we look at the target we open the
inspector we look I'm going to looking
current settings if you want more
details about all these different things
in this drawer here the help has some
information on it and also the sessions
later on give you more details but if
you look here I've set in the options
that i needed having looked at the
makefile I've added in some variable
definitions and let's see if this just
works now so we'll show the build log is
that's slightly interesting and this is
actually a nice feature here this button
right here allows you to see what's
going on we're not doing any magic here
we're still running the same compiler
that Stan talked about earlier this lets
you see what's going on behind the
scenes so if we build this guy who build
succeeded beautiful so all I did was add
it in those settings that i looked at in
the make file and again you can you can
take a look at it in the main project
window and you can see here's our
existing errors we no longer have any
actual errors we've just got some
warnings we can cruise around find
things quickly so best to slide please
you can see that there's a lot of
benefits you can get by using Xcode
native build system you saw how easy it
was to bring your existing make files
into Xcode and acquire some of the
benefits there so I hope this gives you
something to hang on to as you go into
the other sessions and see and realize
that as a UNIX developer as an
open-source developer you can take
advantage of our great Xcode ID so
thanks very much
[Applause]
one of the things that should give you
confidence about the mixed Xcode and and
the command line setup is that is
actually this is what Apple uses itself
to build OS 10 OS 10 consists of some
twelve thirteen hundred projects at
which the colonel is just one and it
uses the many of the projects are set up
to be xcode projects but the the math
bill that is the final build of the
entire system is done with one very very
large script that does a command line
invocation of these projects over and
over so another case where we we do in
fact eat our own dog food a long time
now we actually have a build sleep
they're called of several several
machines ranging eight to twenty
machines just depends on on which group
is doing what kind of build yeah so it's
all distributed around it it is enough
code I think I estimated one time I sort
of did a back of the back of the
envelope thing I came up with some 30
million lines of code in the system as a
whole don't quote me on that as just
that was just my personal estimate so is
it it was enough code that sometimes the
machines actually will be hit by alpha
particles or something like that and
interesting situations anyway so not to
digress to instead just sum up as we see
the Xcode is a complete tool environment
are to being completed including a full
set of command line tools and we have
quite a few command-line tools of
various levels of power shall we say the
standard porting techniques are
sufficient to resolve the API
differences as they are we have a darwin
port system that will ease the
transition the you can either download
the tools they are saying that we didn't
really go into any depth is that you can
also look to see how people have done
Darwin ports to see what how other
people have solved kinds of problems you
might run into and finally we've seen
how you could actually you
is both the xcode ide and you can use
the command line tools and they actually
interoperate in a useful way so that's
the content for more information we have
the number of things online we have the
eunuch sporting guides about porting the
packaging software details of the
compiler and debugging assembler and so
forth we have a mock o runtime
architecture book that's interesting for
the true nerds we also have a technical
note on the reporting of command line
tools which has a lot of things I've
been saying so if you like to be in
printed form and I mentioned getting
configs I guess and convicting heed to
and this is the URL that actually takes
you there to get the latest copy so
additional we have some URLs to pick up
stuff both the official apple's site
developer apple com and the darwin pages
we also have open darwin org which is
where the darwin ports come from and
then pink which is a sourceforge and
then finally we have our contact
addresses we have xcode feedbacks we
have a large collection of mailing lists
i'm on way too many of them myself so if
you want to get hold of me personally
that's one way to do it and then of
course godfrey likes to put his email
address he loves getting email so send
them lot okay well that's that's it for
me thank you very much
[Applause]
you