{"id":15382161,"url":"https://github.com/stefnotch/wgsl_linker","last_synced_at":"2025-08-02T11:35:03.249Z","repository":{"id":251110767,"uuid":"835426109","full_name":"stefnotch/wgsl_linker","owner":"stefnotch","description":"WIP: Implements the WGSL linking spec","archived":false,"fork":false,"pushed_at":"2025-02-11T14:21:28.000Z","size":290,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T19:48:16.420Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stefnotch.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-29T20:16:41.000Z","updated_at":"2024-08-29T14:57:13.000Z","dependencies_parsed_at":"2024-08-29T16:25:10.697Z","dependency_job_id":"d6d2a722-f0ac-4b75-b90b-cadaf02432f0","html_url":"https://github.com/stefnotch/wgsl_linker","commit_stats":{"total_commits":45,"total_committers":2,"mean_commits":22.5,"dds":0.0888888888888889,"last_synced_commit":"fbbb3c5586a1eaa721e17b86ba25a5071add117a"},"previous_names":["stefnotch/wgsl_linker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stefnotch/wgsl_linker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefnotch%2Fwgsl_linker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefnotch%2Fwgsl_linker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefnotch%2Fwgsl_linker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefnotch%2Fwgsl_linker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefnotch","download_url":"https://codeload.github.com/stefnotch/wgsl_linker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefnotch%2Fwgsl_linker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268378995,"owners_count":24240916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T14:30:04.223Z","updated_at":"2025-08-02T11:35:03.228Z","avatar_url":"https://github.com/stefnotch.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# WGSL Linker Implementation\n\nSplit your WGSL code into multiple files, and import it!\n\n\nThis is a straightforward implementation of the [WGSL importing specification](https://github.com/wgsl-tooling-wg/wgsl-import-spec/tree/main?tab=readme-ov-file#summary). It grew out of a personal experiment to implement a straightforward WGSL linker.\n\n## Example\n\nWrite WGSL+ code such as\n\n```wgsl\n// common.wgsl\nstruct EncodedPatch { u: u32, v: u32 };\nstruct Patch { min: vec2\u003cf32\u003e, max: vec2\u003cf32\u003e };\n\nfn patch_decode(encoded: EncodedPatch) -\u003e Patch {\n   // implementation ...\n}\n```\n\n```wgsl\n// my_code.wgsl\nimport ./common/{EncodedPatch, patch_decode};\n\n@group(0) @binding(0) var\u003cstorage, read\u003e patches : array\u003cEncodedPatch\u003e;\n\n@compute @workgroup_size(64, 1, 1)\nfn main(@builtin(workgroup_id) workgroup_id : vec3\u003cu32\u003e) {\n    let patch_index: u32 = workgroup_id.x;\n    let quad = patch_decode(patches_from_buffer.patches[patch_index]);\n}\n```\n\nand then point the wgsl_linker at your code!\n\nTODO: How? Example please.\n\n## Running\n\nThis project is heavily test-driven. To run the tests \n```\ncargo test\n```\n\nTo continously run the tests\n\n```\ncargo watch -x test\n```\n\n## Architecture\n\nThe overall idea is to\n1. Parse the WGSL files, and extract the rough structure\n2. Surgically modify the source codes, and link them together.\n\nThis project is split into two main parts: the parser and the linker. The parser is responsible for extracting a minimal AST from the WGSL source code. The linker is responsible for linking files, together with their AST, into a final WGSL module. It tries to implement the bare minimum to achieve this.\n\n1. [Tokenizer](./src/parser/tokenizer.rs): Takes the text and splits it into tokens. Due to the complexity of this (nested comments), we are using a parser library to do this.\n2. [Parser](./src/parser.rs): Does the actual parsing. Handles template lists by joining the two ambiguous parsing paths into one, and reporting which path was the correct one. Avoids the arbitrary lookahead. It produces [a minimal, partial AST](./src/parser/parser_output.rs).\n3. [Linker](./src/linker.rs): Takes the source code, modifies it in memory using the parsed AST, and joins the files together.\n\n\n\n\n## TODO\n\n- Filesystem support\n- Re-exports\n- Source Maps https://github.com/kaleidawave/source-map\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefnotch%2Fwgsl_linker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefnotch%2Fwgsl_linker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefnotch%2Fwgsl_linker/lists"}