import("//Meta/gn/build/compiled_action.gni")

compiled_action("generate_glapi") {
  tool = "//Meta/Lagom/Tools/CodeGenerators/LibGL:GenerateGLAPIWrapper"
  inputs = [ "GLAPI.json" ]
  outputs = [
    "$target_gen_dir/GL/glapi.h",
    "$target_gen_dir/GLAPI.cpp",
  ]
  args = [
    "-h",
    rebase_path(outputs[0], root_build_dir),
    "-c",
    rebase_path(outputs[1], root_build_dir),
    "-j",
    rebase_path(inputs[0], root_build_dir),
  ]

  # FIXME: install header into $prefix/include/LibGL/GL on serenity
}

config("gl_headers") {
  include_dirs = [ "$target_gen_dir/.." ]
}

shared_library("LibGL") {
  output_name = "gl"
  include_dirs = [ "//Userland/Libraries" ]
  public_configs = [ ":gl_headers" ]
  sources = [
    "Buffer.cpp",
    "Buffer/Buffer.cpp",
    "ClipPlane.cpp",
    "ContextParameter.cpp",
    "GLContext.cpp",
    "Image.cpp",
    "Lighting.cpp",
    "List.cpp",
    "Matrix.cpp",
    "NameAllocator.cpp",
    "Shader.cpp",
    "Shaders/Program.cpp",
    "Shaders/Shader.cpp",
    "Stencil.cpp",
    "Tex/Texture2D.cpp",
    "Texture.cpp",
    "Vertex.cpp",
  ]
  sources += get_target_outputs(":generate_glapi")
  deps = [
    ":generate_glapi",
    "//AK",
    "//Userland/Libraries/LibCore",
    "//Userland/Libraries/LibGLSL",
    "//Userland/Libraries/LibGPU",
    "//Userland/Libraries/LibGfx",
  ]
}
