how to setup custom error processing only for custom compile command in emacs?
===

I'm using scons to build my c++ projects.  
I'm using next script to correctly process scons's errors:  

    34;;; SCons builds into a 'build' subdir, but we want to find the errors
    35;;; in the regular source dir.  So we remove build/XXX/YYY/{dbg,final}/ from the
    36;;; filenames.
    37(defun process-error-filename (filename)
    38  (let ((case-fold-search t))
    39    (setq f (replace-regexp-in-string
    40             "[Ss]?[Bb]uild[\\/].*\\(final\\|dbg\\)[^\\/]*[\\/]" "" filename))
    41    (cond ((file-exists-p f)
    42           f)
    43          (t filename))))
    44
    45(setq compilation-parse-errors-filename-function 'process-error-filename)  

So. I want to use emacs not only with c++ and scons. But also with java and other languages.   
How to setup emacs to use this "process-error-filename" function only when I'm running the 
 
    M-x compile   
    scons  
command?