#!/usr/bin/env python
import os
import os.path
import subprocess
import sys

configuration = eval(open("Configuration.gypi").read())
build_directory = os.path.abspath(os.getcwd())
toplevel_directory = configuration['variables']['toplevel_directory']

# We change to the top-level directory and pass -Goutput_dir so
# that gyp will not generate the makefiles in the source directory
# See https://groups.google.com/forum/?fromgroups#!topic/gyp-developer/UvpraIUYwSs
os.chdir(toplevel_directory)
sys.exit(subprocess.call(['gyp',
                          '--depth=.',
                          '--generator-output=%s' % build_directory,
                          'Source/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCoreGTK.gyp',
                          '-I', os.path.join(build_directory, 'Configuration.gypi')]))
