const__pageData=JSON.parse('{"title":"QMK Compiler Development Guide","description":"","frontmatter":{},"headers":[],"relativePath":"api_development_overview.md","filePath":"api_development_overview.md"}');
const_hoisted_1=/* @__PURE__ */createStaticVNode('<h1id="qmk-compiler-development-guide"tabindex="-1">QMKCompilerDevelopmentGuide<aclass="header-anchor"href="#qmk-compiler-development-guide"aria-label="Permalink to "QMK Compiler Development Guide""></a></h1><p>ThispageattemptstointroducedeveloperstotheQMKCompiler.Itdoesnotgointonittygrittydetails-forthatyoushouldreadcode.Whatthiswillgiveyouisaframeworktohangyourunderstandingonasyoureadthecode.</p><h1id="overview"tabindex="-1">Overview<aclass="header-anchor"href="#overview"aria-label="Permalinkto"Overview""></a></h1><p>TheQMKCompileAPIconsistsofafewmovingsparts:</p><p><imgsrc="https://raw.githubusercontent.com/qmk/qmk_api/master/docs/architecture.svg"alt="ArchitectureDiagram"></p><p>APIClientsinteractexclusivelywiththeAPIservice.Thisiswheretheysubmitjobs,checkstatus,anddownloadresults.TheAPIserviceinsertscompilejobsinto<ahref="https://python-rq.org"target="_blank"rel="noreferrer">RedisQueue</a>andchecksbothRQandS3fortheresultsofthosejobs.</p><p>WorkersfetchnewcompilejobsfromRQ,compilethem,andthenuploadthesourceandthebinarytoanS3compatiblestorageengine.</p><h1id="workers"tabindex="-1">Workers<aclass="header-anchor"href="#workers"aria-label="Permalinkto"Workers""></a></h1><p>QMKCompilerWorkersareresponsiblefordoingtheactualbuilding.WhenaworkerpullsajobfromRQitdoesseveralthingstocompletethatjob:</p><ul><li>Makeafreshqmk_firmwarecheckout</li><li>Usethesuppliedlayersandkeyboardmetadatatobuilda<code>keymap.c</code></li><li>Buildthefirmware</li><li>Zipacopyofthesource</li><li>Uploadthefirmware,sourcezip,andametadatafiletoS3.</li><li>ReportthestatusofthejobtoRQ</li></ul><h1id="api-service"tabindex="-1">APIService<aclass="header-anchor"href="#api-service"aria-label="Permalinkto"APIService""></a></h1><p>TheAPIserviceisarelativelysimpleFlaskapplication.Thereareafewmainviewsyoushouldunderstand.</p><h2id="app-route-v1-compile-methods-post"tabindex="-1">@app.route('/v1/compile',methods=['POST'])<aclass="header-anchor"href="#app-route-v1-compile-methods-post"aria-label="Permalinkto"@app.route('/v1/compile',methods=['POST'])""></a></h2><p>ThisisthemainentrypointfortheAPI.Aclient'sinteractionstartshere.TheclientPOST'saJSONdocumentdescribingtheirkeyboard,andtheAPIdoessome(very)basicvalidationofthatJSONbeforesubmittingthecompilejob.</p><h2id="app-route-v1-compile-string-job-id-methods-get"tabindex="-1">@app.route('/v1/compile/<string:job_id>',methods=['GET'])<aclass="header-anchor"href="#app-route-v1-compile-string-job-id-methods-get"aria-label="Permalinkto"@app.route('/v1/compile/&lt;string:job_id&gt;',methods=['GET'])""></a></h2><p>Thisisthemostfrequentlycalledendpoint.Itpullsthejobdetailsfromredis,ifthey'restillavailable,orthecachedjobdetailsonS3ifthey'renot.</p><h2id="app-route-v1-compile-string-job-id-download-methods-get"tabindex="-1">@app.route('/v1/compile/<string:job_id>/download',methods=['GET'])<aclass="header-anchor"href="#app-route-v1-compile-string-job-id-download-methods-get"aria-label="Permalinkto"@app.route('/v1/compile/&lt;string:job_id&gt;/download',methods=['GET'])""></a></h2><p>Thismethodallowsuserstodownloadthecompiledfirmwarefile.</p><h2id="app-route-v1-compile-string-job-id-source-methods-get"tabindex="-1">@app.route('/v1/compile/<string:job_id>/source',methods=['GET'])<aclass="header-anchor"href="#app-route-v1-compile-string-job-id-source-methods-get"aria-label="Permalinkto"@app.route('/v1/compile/&lt;string:job_id&gt;/source',methods=['GET'])&qu