#!/usr/bin/env python
import os

root = Dir("#").abspath
cpp = os.path.join(root, "godot-cpp")

for header in (
    "godot_cpp/core/class_db.hpp",
    "godot_cpp/core/memory.hpp",
    "godot_cpp/classes/editor_plugin_registration.hpp",
):
    full_path = os.path.join(cpp, "include", header)
    if not os.path.isfile(full_path):
        print("Missing extracted header: " + full_path)
        print("Re-extract the full project ZIP into a new folder.")
        Exit(1)

# Supply absolute include paths before godot-cpp creates its compile targets.
env = Environment(tools=["default"], PLATFORM="")
env.AppendUnique(CPPPATH=[
    os.path.join(cpp, "include"),
    os.path.join(cpp, "gen", "include"),
    os.path.join(root, "src"),
])
env = SConscript("godot-cpp/SConstruct", exports={
    "env": env,
    "api_version": "4.7",
})

library = env.SharedLibrary(
    "bin/libhawktober{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
    source=Glob("src/*.cpp"),
)
env.NoCache(library)
Default(library)
