[darwinbuild] A couple of questions

Kevin Van Vechten kevin at opendarwin.org
Wed Nov 2 16:18:54 PST 2005

On Nov 2, 2005, at 3:15 PM, ice wrote:

> 1) How can I specify CFLAGS for use in the built projects? The guide
> just cuts off right where those directions should be...

This can be done on a per-project or per-build basis.  If you're  
interested in setting the CFLAGS for a Darwin project, you'll  
actually want to set the RC_NONARCH_CFLAGS variable.  DarwinBuild  
will take the contents of this variable, and append any necessary - 
arch flags in order to create the RC_CFLAGS variable which is used by  
Darwin projects.

If you've added your own project to a build, and really want to set  
the CFLAGS variable, that's fine too.

Environment variables are contained in a dictionary named  
"environment" in the property list.  You can edit your property lists  
with the following command (substitute your actual build number):

# darwinxref edit 8A428

You should see the following in your editor:

> // All projects for build 8A428
> // !$*UTF8*$!
> {
>         binary_sites = (
>                 "http://darwinsource.opendarwin.org/Roots/8A428",
>         );
>         build = 8A428;
>         darwin = "Darwin 8.0";
>         environment = {
>                 MACOSX_DEPLOYMENT_TARGET = 10.4;
>                 NEXT_ROOT = "";
>                 RC_ARCHS = "ppc i386";
>                 RC_JASPER = YES;
>                 RC_NONARCH_CFLAGS = "-pipe -no-cpp-precomp";
>                 RC_OS = macos;
>                 RC_RELEASE = Tiger;
>                 RC_XBS = YES;
>                 SEPARATE_STRIP = YES;
>                 UNAME_RELEASE = 8.0;
>                 UNAME_SYSNAME = Darwin;
>         };

Simply modify the RC_NONARCH_CLFAGS line (or add in a new CFLAGS  
line).  This will add the cflags change for all projects.  However,  
if you only want to adjust a single project, say xnu, you can do the  

# darwinbuild edit 8A428 xnu

> // Project xnu for build 8A428
> // !$*UTF8*$!
> {
>         dependencies = {
>                 build = (
>                         adv_cmds,
>                         awk,
>                         bash,
>                         bootstrap_cmds,

You can add an environment dictionary here, to set the cflags, e.g:

> // Project xnu for build 8A428
> // !$*UTF8*$!
> {
> 	environment = {
> 		RC_NONARCH_CFLAGS = "-pipe -no-cpp-precomp -Wall";
> 	};
>         dependencies = {
>                 build = (
>                         adv_cmds,
>                         awk,
>                         bash,
>                         bootstrap_cmds,

During the build, DarwinBuild will combine the per-project  
environment variables and the per-build environment variables.  Per- 
project variables take precedence.

I've just now noticed a "bug" where setting the per-build environment  
will mask out the entire environment from an inherited build.   
Therefore if you're using something like 8F46 (which inherits from  
8A428), for now you should either:
a) make your change in 8A428 and rely on inheritance, or
b) copy the entire 8A428 environment dictionary to 8F46, and then  
make your changes there

Expect the behavior to change so that per-build environments are  
merged with inherited environments in the next DarwinBuild release.

> 2) Is there a way to automatically build a large number of projects?
> Should I just write a shell script that goes through the projects I
> want built?

Yes, you can put a list of projects into a text file (one project  
name per line) and use the following script:

# darwinxref version '*' | sed -e 's/-.*//' > projects.txt
# /usr/local/share/darwinbuild/buildlist projects.txt

There's also an experimental script that attempts to inspect the  
dependencies and outputs a list of projects rearranged into an  
optimal order:

# /usr/local/share/darwinbuild/buildorder projects.txt ordered- 

You could then use buildlist on that result.

Hope this helps,

- Kevin

More information about the darwinbuild-dev mailing list