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

compiled_action("SQLClientEndpoint") {
  tool = "//Meta/Lagom/Tools/CodeGenerators/IPCCompiler"
  inputs = [ "//Userland/Services/SQLServer/SQLClient.ipc" ]
  outputs = [ "$root_gen_dir/SQLServer/SQLClientEndpoint.h" ]
  args = [
    rebase_path(inputs[0], root_build_dir),
    "-o",
    rebase_path(outputs[0], root_build_dir),
  ]
}

compiled_action("SQLServerEndpoint") {
  tool = "//Meta/Lagom/Tools/CodeGenerators/IPCCompiler"
  inputs = [ "//Userland/Services/SQLServer/SQLServer.ipc" ]
  outputs = [ "$root_gen_dir/SQLServer/SQLServerEndpoint.h" ]
  args = [
    rebase_path(inputs[0], root_build_dir),
    "-o",
    rebase_path(outputs[0], root_build_dir),
  ]
}

shared_library("LibSQL") {
  output_name = "sql"
  include_dirs = [
    "//Userland/Libraries",
    "//Userland",
  ]
  sources = [
    "AST/CreateSchema.cpp",
    "AST/CreateTable.cpp",
    "AST/Delete.cpp",
    "AST/Describe.cpp",
    "AST/Expression.cpp",
    "AST/Insert.cpp",
    "AST/Lexer.cpp",
    "AST/Parser.cpp",
    "AST/Select.cpp",
    "AST/Statement.cpp",
    "AST/SyntaxHighlighter.cpp",
    "AST/Token.cpp",
    "AST/Update.cpp",
    "BTree.cpp",
    "BTreeIterator.cpp",
    "Database.cpp",
    "HashIndex.cpp",
    "Heap.cpp",
    "Index.cpp",
    "Key.cpp",
    "Meta.cpp",
    "Result.cpp",
    "ResultSet.cpp",
    "Row.cpp",
    "SQLClient.cpp",
    "Serializer.cpp",
    "TreeNode.cpp",
    "Tuple.cpp",
    "Value.cpp",
  ]
  sources += get_target_outputs(":SQLClientEndpoint") +
             get_target_outputs(":SQLServerEndpoint")
  deps = [
    ":SQLClientEndpoint",
    ":SQLServerEndpoint",
    "//AK",
    "//Userland/Libraries/LibCore",
    "//Userland/Libraries/LibFileSystem",
    "//Userland/Libraries/LibIPC",
    "//Userland/Libraries/LibRegex",
    "//Userland/Libraries/LibSyntax",
  ]
}
