Is it possible in Unity 5 to set a script define, wait for a recompile and then create a build from script?

I am currently writing a build script for a project I am on. I have already written a script that, when fired from a menu, builds for all three of our platforms.

I am currently looking for a way to set the script defines before the build. I am using PlayerSettings.SetScriptingDefineSymbolsForGroup to set the defines, but the recompile does not happen immediately, meaning any builds fired afterwards will use the last compiled dll and a recompile only fires after the build is complete.

EditorApplication.isCompiling doesn’t get set to true until after the methods runs. Likewise, subscribing to EditorApplication.update wait for the compile to start seems to delay the start of compilation.

Is there a clean way in Unity 5 to set the script defines, wait for the recompile and continue my script on completion?

Did you solved this problem?