#!/usr/bin/env python

Import("env")

thirdparty_obj = []

if env["platform"] in ["haiku", "osx", "windows", "x11"]:
    # Thirdparty source files
    thirdparty_dir = "#thirdparty/glad/"
    thirdparty_sources = [
        "glad.c",
    ]
    thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

    env.Prepend(CPPPATH=[thirdparty_dir])

    env.Append(CPPDEFINES=["GLAD_ENABLED"])
    env.Append(CPPDEFINES=["GLES_OVER_GL"])

    env_thirdparty = env.Clone()
    env_thirdparty.disable_warnings()
    env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
    env.drivers_sources += thirdparty_obj


# Pandemonium source files

driver_obj = []

env.add_source_files(driver_obj, "*.cpp")
env.drivers_sources += driver_obj

# Needed to force rebuilding the driver files when the thirdparty code is updated.
env.Depends(driver_obj, thirdparty_obj)
