builders:
  versions:
    import: 'tool/write_versions.dart'
    build_to: cache
    builder_factories: ["writeVersions"]
    build_extensions: {"$package$": ["lib/versions.json"]}
  api_index:
    import: 'package:code_snippets/indexer.dart'
    build_to: cache
    builder_factories: ['DartIndexBuilder.new']
    auto_apply: all_packages
    runs_before: [code_snippets]
    build_extensions: {"lib/lib": ['api.json']}
  code_snippets:
    import: 'tool/snippets.dart'
    build_to: cache
    builder_factories: ["SnippetsBuilder.new"]
    build_extensions: {"": [".excerpt.json"]}
    auto_apply: none
    defaults:
      options:
        release: false
      release_options:
        release: true

targets:
  prepare:
    auto_apply_builders: false
    builders:
      ":versions":
        enabled: true
      drift_dev:preparing_builder:
        enabled: true
    sources:
      - "$package$"
      - "lib/versions.json"
      - "lib/snippets/**"
      - "tool/write_versions.dart"
      - "tool/snippets.dart"
      - "test/generated/**"

  codegen:
    dependencies: [":prepare"]
    auto_apply_builders: false
    builders:
      drift_dev:preparing_builder:
        enabled: false # Runs in prepare target

      # Modular drift generation, suitable for standalone snippets that aren't part of a database
      drift_dev:analyzer:
        enabled: true
        options: &options
          sql:
            dialect: sqlite
            options:
              version: "3.39"
        generate_for:
          include: &modular
            - "lib/snippets/_shared/**"
            - "lib/snippets/modular/**"
            - "lib/snippets/drift_files/custom_queries.*"
      drift_dev:modular:
        enabled: true
        options: *options
        generate_for:
          include: *modular

      # Non-modular drift generation. Used for some "getting started" e2e examples.
      drift_dev:drift_dev:
        enabled: true
        options: *options
        generate_for:
          exclude: *modular
      json_serializable:
        enabled: true
    sources:
     - lib/**
     - test/generated/**

  syntax_highlighting:
    dependencies: [":codegen"]
    builders:
      ":code_snippets":
        enabled: true
        generate_for:
          include:
            - "lib/snippets/**/*.dart"
            - "lib/snippets/**/*.drift"
            - "lib/snippets/*.dart"
          exclude:
            - "**/*.g.dart"
    auto_apply_builders: false
    sources:
      - "$package$"
      - "lib/snippets/**"
      - "tool/snippets.dart"

  worker:
    dependencies: ['$default']
    auto_apply_builders: false
    sources:
      - "web/drift_worker.dart"
    builders:
      build_web_compilers:entrypoint:
        options:
          compiler: dart2js
      build_web_compilers:dart2js_archive_extractor:
        enabled: false

  dart2js_archives:
    auto_apply_builders: false
    dependencies: [":$default", ":worker"]
    builders:
      build_web_compilers:dart2js_archive_extractor:
        enabled: true

  $default:
    dependencies: [":codegen", ":syntax_highlighting"]
    builders:
      built_site:
        release_options:
          environment: "preview"
      build_web_compilers:entrypoint:
        generate_for:
          include:
            - "web/**"
          exclude:
            - "web/drift_worker.dart"
        release_options:
          # Turn of null assertions for release builds, it looks like this
          # makes generated code slightly smaller.
          native_null_assertions: false
          dart2js_args:
            - "-O4"
            - "--csp"
      # These builders should run in the source_gen target
      drift_dev:preparing_builder:
        enabled: false
      drift_dev:drift_dev:
        enabled: false
      source_gen:combining_builder:
        enabled: false
      json_serializable:
        enabled: false
      build_web_compilers:dart2js_archive_extractor:
        enabled: false
    sources:
      include:
        - "lib/**"
        - "pages/**"
        - "templates/**"
        - "web/**"
        - "$package$"
        - "pubspec.yaml"
        - "theme.yaml"
        - "website.yaml"

# Snippets referencing public API members from this package will get dartdoc links
# embedded in them.
global_options:
  ":api_index":
    options:
      packages: ['drift', 'drift_dev', 'sqlite3']

additional_public_assets:
  - "pages/**"
