#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os

#Run our configuration stuff to setup our build environment (detect platform/arch, find libraries, etc)
SConscript(File('src/SConscript.env'), duplicate=0) 

#Grab some variables, created by SConscript.env, that we'll need to do the rest of the build
#and installation.
Import('env', 'sources', 'flags') 
Import('build_dir', 'platformString')

# Make the main src directory accessible to the SoundSourceM4A, so
# SoundSourceM4A can get at sounddevice.cpp, which it needs to build
# and link properly. This sucks but it's the best way I can find -- bkgood
VariantDir("plugins/soundsourcem4a", "src", duplicate=0)
VariantDir("plugins/soundsourcewv", "src", duplicate=0)
#Build our soundsource plugins
soundsource_plugins = SConscript(File('plugins/SConscript'), build_dir=Dir(build_dir + "/plugins"), duplicate=0, exports=['env', 'flags', 'platformString'])

#Setup and build the "mixxx" executable target. Also sets up our install targets for each platform.
SConscript(File('src/SConscript'), build_dir=Dir(build_dir), duplicate=0, exports=['env', 'sources', 'flags', 'soundsource_plugins']) 


#Conveniece - Copy over the Mixxx executable out of the build directory and into the bottom of the source
#             tree. (That should be the directory where you run "scons".)
#wtf doesn't this work on win32 (works on Linux, OS X):
Command("mixxx", os.path.join(build_dir, "mixxx"), Copy("$TARGET", "$SOURCE"))
#hack for windows:
Copy("mixxx", os.path.join(build_dir, "mixxx"))

#On OS X, if the bundle has been built, copy it up:
#Command("Mixxx.app", os.path.join(build_dir, "Mixxx.app"), Copy("$TARGET", "$SOURCE"))
