9 ProxyMakefile::ProxyMakefile ( const Project
& project
)
14 ProxyMakefile::~ProxyMakefile ()
19 ProxyMakefile::GenerateProxyMakefiles ( bool verbose
)
21 for ( size_t i
= 0; i
< project
.modules
.size (); i
++ )
23 GenerateProxyMakefileForModule ( *project
.modules
[i
],
29 ProxyMakefile::GeneratePathToParentDirectory ( int numberOfParentDirectories
)
32 for ( int i
= 0; i
< numberOfParentDirectories
; i
++ )
42 ProxyMakefile::GetPathToTopDirectory ( Module
& module
)
44 int numberOfDirectories
= 1;
45 string basePath
= NormalizeFilename ( module
.GetBasePath () );
46 for ( size_t i
= 0; i
< basePath
.length (); i
++ )
48 if ( basePath
[i
] == CSEP
)
49 numberOfDirectories
++;
51 return GeneratePathToParentDirectory ( numberOfDirectories
);
55 ProxyMakefile::GenerateProxyMakefileForModule ( Module
& module
,
63 printf ( "\nGenerating proxy makefile for %s",
64 module
.name
.c_str () );
67 string proxyMakefile
= NormalizeFilename ( module
.GetBasePath () + SSEP
"makefile" );
68 string pathToTopDirectory
= GetPathToTopDirectory ( module
);
69 string defaultTarget
= module
.name
;
71 buf
= (char*) malloc ( 10*1024 );
73 throw OutOfMemoryException ();
76 s
= s
+ sprintf ( s
, "# This file is automatically generated.\n" );
77 s
= s
+ sprintf ( s
, "\n" );
78 s
= s
+ sprintf ( s
, "TOP = %s\n", pathToTopDirectory
.c_str () );
79 s
= s
+ sprintf ( s
, "DEFAULT = %s\n", defaultTarget
.c_str () );
80 s
= s
+ sprintf ( s
, "include $(TOP)/proxy.mak\n" );
82 FileSupportCode::WriteIfChanged ( buf
, proxyMakefile
);