{
  "id": "emscripten",
  "name": "Emscripten",
  "homepage": "https://emscripten.org",
  "description": "A complete compiler toolchain to WebAssembly, using LLVM, with a special focus on speed, size, and the Web platform.",
  "executables": [
    "emcc",
    "em++",
    "emar",
    "emcmake",
    "emconfigure"
  ],
  "dotfiles": {
    "paths": [
      "~/.emscripten"
    ],
    "secret": [],
    "machine_lines": [
      {
        "file": "~/.emscripten",
        "match": {
          "prefix": [
            "LLVM_ROOT",
            "BINARYEN_ROOT",
            "EMSDK_NODE"
          ]
        },
        "scope": "platform"
      }
    ]
  },
  "commands": {
    "format": 1,
    "label": "Compile with emcc",
    "description": "Compile C/C++ sources to WebAssembly and JavaScript with emcc (em++ takes the same options). Optimization levels are separate switches; pick at most one. Other -s settings and clang options are not covered.",
    "quality": "ai-draft",
    "parser": {
      "end_of_options": "--",
      "interleave": "permute",
      "long_equals": true,
      "short_attached": true,
      "short_bundles": false
    },
    "source": [
      {
        "id": "emcc",
        "kind": "manual",
        "url": "https://emscripten.org/docs/tools_reference/emcc.html",
        "revision": "2026-10-27",
        "evidence": "   emcc [options] file...\n\"-O2\"\n\"-O3\"\n\"-Oz\"\n\"-g\"\n\"--closure 0|1|2\"\n\"--embed-file <file>\"\n\"--preload-file <name>\"\n\"--shell-file <path>\"\n\"--bind\"\n\"-o <target>\"\n\"-c\"\n"
      }
    ],
    "field": [
      {
        "id": "inputs",
        "label": "Source files",
        "type": "path",
        "position": 0,
        "multiple": true,
        "min": 1,
        "path": {
          "kind": "file",
          "role": "input",
          "must_exist": true
        },
        "sources": [
          "emcc"
        ]
      },
      {
        "id": "output",
        "label": "Output file",
        "description": "The extension picks the output type, for example .html, .js or .wasm.",
        "type": "path",
        "option": [
          "-o"
        ],
        "path": {
          "kind": "file",
          "role": "output",
          "must_exist": false
        },
        "effect": "overwrite",
        "sources": [
          "emcc"
        ]
      },
      {
        "id": "compile_only",
        "label": "Compile only",
        "description": "Produce an object file instead of linking.",
        "type": "boolean",
        "option": [
          "-c"
        ],
        "sources": [
          "emcc"
        ]
      },
      {
        "id": "o2",
        "label": "Optimize (-O2)",
        "type": "boolean",
        "option": [
          "-O2"
        ],
        "sources": [
          "emcc"
        ]
      },
      {
        "id": "o3",
        "label": "Optimize more (-O3)",
        "type": "boolean",
        "option": [
          "-O3"
        ],
        "sources": [
          "emcc"
        ]
      },
      {
        "id": "oz",
        "label": "Optimize for size (-Oz)",
        "type": "boolean",
        "option": [
          "-Oz"
        ],
        "sources": [
          "emcc"
        ]
      },
      {
        "id": "debug",
        "label": "Debug info",
        "type": "boolean",
        "option": [
          "-g"
        ],
        "sources": [
          "emcc"
        ]
      },
      {
        "id": "embed_file",
        "label": "Embed file",
        "description": "Embed a file or directory in the generated output.",
        "type": "path",
        "option": [
          "--embed-file"
        ],
        "multiple": true,
        "path": {
          "kind": "any",
          "role": "input",
          "must_exist": true
        },
        "sources": [
          "emcc"
        ]
      },
      {
        "id": "preload_file",
        "label": "Preload file",
        "description": "Package a file or directory to load before the program starts.",
        "type": "path",
        "option": [
          "--preload-file"
        ],
        "multiple": true,
        "path": {
          "kind": "any",
          "role": "input",
          "must_exist": true
        },
        "sources": [
          "emcc"
        ]
      },
      {
        "id": "shell_file",
        "label": "HTML shell file",
        "type": "path",
        "option": [
          "--shell-file"
        ],
        "path": {
          "kind": "file",
          "role": "input",
          "must_exist": true
        },
        "sources": [
          "emcc"
        ]
      },
      {
        "id": "bind",
        "label": "Embind bindings",
        "type": "boolean",
        "option": [
          "--bind"
        ],
        "sources": [
          "emcc"
        ]
      },
      {
        "id": "closure",
        "label": "Closure compiler",
        "type": "enum",
        "option": [
          "--closure"
        ],
        "choices": [
          {
            "value": "0",
            "label": "Off"
          },
          {
            "value": "1",
            "label": "On"
          },
          {
            "value": "2",
            "label": "Aggressive"
          }
        ],
        "sources": [
          "emcc"
        ]
      }
    ],
    "task": [
      {
        "id": "web",
        "label": "Build a web page",
        "fields": [
          "inputs",
          "output",
          "o2",
          "shell_file"
        ],
        "required": [
          "inputs",
          "output"
        ]
      },
      {
        "id": "node",
        "label": "Build a JavaScript module",
        "fields": [
          "inputs",
          "output",
          "o2"
        ],
        "required": [
          "inputs",
          "output"
        ]
      }
    ],
    "group": [
      {
        "id": "basic",
        "label": "Basic",
        "fields": [
          "inputs",
          "output",
          "compile_only",
          "o2",
          "o3",
          "oz",
          "debug"
        ]
      },
      {
        "id": "advanced",
        "label": "Advanced",
        "fields": [
          "embed_file",
          "preload_file",
          "shell_file",
          "bind",
          "closure"
        ]
      }
    ]
  }
}
