#!/usr/local/bin/python

import os

header_name = 'sbsmanip.h'
header_source = 'sbsmanip.h-base'

src_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'src')

headers = [f for f in os.listdir(src_dir)
           if os.path.isfile(os.path.join(src_dir, f))
           and f.endswith('.h')
           and f != header_name
           and f != header_source
           and f != 'pch.h']

content = ('//////////////////////////////////////////\n'
           '// This file is automatically generated //\n'
           '//////////////////////////////////////////\n'
           '\n')

with open(os.path.join(src_dir, header_source), 'r') as f:
    for line in f:
        content += line
        if line.endswith('BEGIN GENERATED CONTENT\n'):
            for h in headers:
                content += '#include "%s"\n' % h

with open(os.path.join(src_dir, header_name), 'w') as f:
    f.write(content)

print 'src' + os.path.sep + header_name
