Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] MBS cleanCommand for win32

Hi all,

actually, DOS commands are supposed to interpret what's after a
slash as a switch. If you type, into a DOS shell:

del /f /q foo/bar.c

the "del" command will complain about the unknown "/bar.c" switch.

The simplest solution I've found is to let the "make" utility handle 
those changes for you: perhaps it's not the best, but it works fine!

Just edit your IManagedBuilderMakefileGenerator impementation and add 
a "subst" command in the generated makefile, and let it change slashes 
to backslashes. Only, take care to put it in the right place...

usually, the automatically generated makefiles for a managed make 
project follow a rather simple directory-based structure; the CLEAN 
target is placed into the top level makefile, but borrows its 
arguments from the objects.mk file

if you place your substitution code into "objects.mk", it may prevent 
your files to be recognized during the build, because your compiler
wouldn't probably like backslashes in the source objects path!

Hence, the best place to do it is where the CLEAN target is built.

Look below for an example; this code snippet has been taken from the 
method that generates the targets of the "makefile" file: you may 
easily see where the substitution command has been placed.

----snip----
	// add a clean target

	buffer.append("clean:" + NEWLINE);
	String foo = topBuildDir.makeAbsolute().toOSString();
	buffer.append(TAB + NEWLINE); // TODO
	String fool = project.getFullPath().toString();
		
	if(Platform.getOS().equalsIgnoreCase(Platform.OS_WIN32))
	{
		buffer.append(TAB + "-$(RM)" + WHITESPACE + "$(subst " + SEPARATOR + "," + "\\" + "," + "$(OBJS)" + WHITESPACE + "$(DEPS)" + WHITESPACE + outputPrefix + buildTargetName); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
		if (extension.length() > 0) {
			buffer.append(DOT + extension + ")");
		}
		else {
			buffer.append(")");
		}
	}
	else
	{
		buffer.append(TAB + "-$(RM)" + WHITESPACE + "$(OBJS)" + WHITESPACE + "$(DEPS)" + WHITESPACE + outputPrefix + buildTargetName); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
		if (extension.length() > 0) {
			buffer.append(DOT + extension);
		}
	}
	
	buffer.append(NEWLINE + NEWLINE); 
----snip----


as a result, such a kind of make target will be generated:


----snip----
clean:
	
	-$(RM) $(subst /,\,$(OBJS) $(DEPS) myFile.out)
----snip----


Hope this helps!

Ciao,
	Giuseppe

--
"A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila."  (Mitch Radcliffe)
Giuseppe Montalto - STMicroelectronics
HPC / STS / IDTEC / Catania GUI Team  
Giuseppe.Montalto@xxxxxx 



Back to the top