From 19ce26d18aaee977d1ec5272d302200b75ea00f6 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 3 Nov 2020 09:00:48 -0800 Subject: [PATCH 01/73] [honk] initial commit? --- .cargo/config.toml | 5 + .vscode/settings.json | 3 + Cargo.toml | 1 + honk/Cargo.lock | 1134 +++++++++++++++++++++++++++++++++++++++++ honk/Cargo.toml | 21 + honk/README.md | 3 + honk/src/lib.rs | 22 + honk/src/main.rs | 18 + workspace.honk | 1 + 9 files changed, 1208 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 honk/Cargo.lock create mode 100644 honk/Cargo.toml create mode 100644 honk/README.md create mode 100644 honk/src/lib.rs create mode 100644 honk/src/main.rs create mode 100644 workspace.honk diff --git a/.cargo/config.toml b/.cargo/config.toml index 1edba4192..00a7b742b 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -126,3 +126,8 @@ ofl-fmt-project = "ofl fmt" clippy-ofl = "clippy --manifest-path ofl/Cargo.toml --workspace" test-ofl = "test --manifest-path ofl/Cargo.toml --workspace" docs-ofl = "doc --manifest-path ofl/Cargo.toml --workspace --no-deps" + +#################################################################################################### +# honk + +honk = "run --manifest-path honk/Cargo.toml --" diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..de288e1ea --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.formatting.provider": "black" +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index b29b63fbb..fb5b85b2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,6 +52,7 @@ members = [ "topo/macro", ] exclude = [ + "honk", "ofl", ] diff --git a/honk/Cargo.lock b/honk/Cargo.lock new file mode 100644 index 000000000..3707c6256 --- /dev/null +++ b/honk/Cargo.lock @@ -0,0 +1,1134 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "addr2line" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" + +[[package]] +name = "aho-corasick" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b476ce7103678b0c6d3d395dbbae31d48ff910bd28be979ba5d48c6351131d0d" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "argh" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91792f088f87cdc7a2cfb1d617fa5ea18d7f1dc22ef0e1b5f82f3157cdc522be" +dependencies = [ + "argh_derive", + "argh_shared", +] + +[[package]] +name = "argh_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4eb0c0c120ad477412dc95a4ce31e38f2113e46bd13511253f79196ca68b067" +dependencies = [ + "argh_shared", + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "argh_shared" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "781f336cc9826dbaddb9754cb5db61e64cab4f69668bd19dcc4a0394a86f4cb1" + +[[package]] +name = "ascii-canvas" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b385d69402821a1c254533a011a312531cbcc0e3e24f19bbb4747a5a2daf37e2" +dependencies = [ + "term", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "backtrace" +version = "0.3.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2baad346b2d4e94a24347adeee9c7a93f412ee94b9cc26e5b59dea23848e9f28" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bit-set" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" + +[[package]] +name = "cc" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "time", + "winapi 0.3.9", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "codemap" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e769b5c8c8283982a987c6e948e540254f1058d5a74b8794914d4ef5fc2a24" + +[[package]] +name = "codemap-diagnostic" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ba0e6be8e2774e750f9e90625b490249715bece38a12f9d09e82477caba5028" +dependencies = [ + "atty", + "codemap", + "termcolor", +] + +[[package]] +name = "color-eyre" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2a5123db5af8349c41c43ed0e5dca1cd56c911ea0c4ce6e6ff30f159fa5d27e" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a99aa4aa18448eef4c7d3f86d2720d2d8cad5c860fe9ff9b279293efdc8f5be" +dependencies = [ + "ansi_term 0.11.0", + "tracing-core", + "tracing-error", +] + +[[package]] +name = "diff" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "docopt" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f525a586d310c87df72ebcd98009e57f1cc030c8c268305287a476beb653969" +dependencies = [ + "lazy_static", + "regex", + "serde", + "strsim", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "ena" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00" +dependencies = [ + "log", +] + +[[package]] +name = "eyre" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534ce924bff9118be8b28b24ede6bf7e96a00b53e4ded25050aa7b526e051e1a" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fixedbitset" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + +[[package]] +name = "generator" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cdc09201b2e8ca1b19290cf7e65de2246b8e91fb6874279722189c4de7b94dc" +dependencies = [ + "cc", + "libc", + "log", + "rustc_version", + "winapi 0.3.9", +] + +[[package]] +name = "generic-array" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +dependencies = [ + "typenum", +] + +[[package]] +name = "gimli" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" + +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +dependencies = [ + "libc", +] + +[[package]] +name = "honk" +version = "7.0.0" +dependencies = [ + "argh", + "color-eyre", + "starlark", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "indenter" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0bd112d44d9d870a6819eb505d04dd92b5e4d94bb8c304924a0872ae7016fb5" + +[[package]] +name = "itertools" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "lalrpop" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e2e80bee40b22bca46665b4ef1f3cd88ed0fb043c971407eac17a0712c02572" +dependencies = [ + "ascii-canvas", + "atty", + "bit-set", + "diff", + "docopt", + "ena", + "itertools", + "lalrpop-util", + "petgraph", + "regex", + "regex-syntax", + "serde", + "serde_derive", + "sha2", + "string_cache", + "term", + "unicode-xid 0.1.0", +] + +[[package]] +name = "lalrpop-util" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b27d8490dbe1f9704b0088d61e8d46edc10d5673a8829836c6ded26a9912c7" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" + +[[package]] +name = "linked-hash-map" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" + +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "loom" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0e8460f2f2121162705187214720353c517b97bdfb3494c0b1e33d83ebe4bed" +dependencies = [ + "cfg-if 0.1.10", + "generator", + "scoped-tls", + "serde", + "serde_json", +] + +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "miniz_oxide" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +dependencies = [ + "adler", + "autocfg 1.0.1", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg 1.0.1", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg 1.0.1", +] + +[[package]] +name = "object" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" + +[[package]] +name = "once_cell" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "ordermap" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" + +[[package]] +name = "owo-colors" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a1250cdd103eef6bd542b5ae82989f931fc00a41a27f60377338241594410f3" + +[[package]] +name = "petgraph" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" +dependencies = [ + "fixedbitset", + "ordermap", +] + +[[package]] +name = "phf_generator" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_shared" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid 0.2.1", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +dependencies = [ + "autocfg 0.1.7", + "libc", + "rand_chacha", + "rand_core 0.4.2", + "rand_hc", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg", + "rand_xorshift", + "winapi 0.3.9", +] + +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.3.1", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi 0.3.9", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi 0.3.9", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.4.2", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "regex" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-automata" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" + +[[package]] +name = "rustc-demangle" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", +] + +[[package]] +name = "sharded-slab" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4921be914e16899a80adefb821f8ddb7974e3f1250223575a44ed994882127" +dependencies = [ + "lazy_static", + "loom", +] + +[[package]] +name = "siphasher" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" + +[[package]] +name = "smallvec" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" + +[[package]] +name = "starlark" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48390a8b2d8db3a5165ec70d803570582d801823a2b112c203cf72f66b1652c4" +dependencies = [ + "codemap", + "codemap-diagnostic", + "lalrpop", + "lalrpop-util", + "linked-hash-map", +] + +[[package]] +name = "string_cache" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89c058a82f9fd69b1becf8c274f412281038877c553182f1d02eb027045a2d67" +dependencies = [ + "lazy_static", + "new_debug_unreachable", + "phf_shared", + "precomputed-hash", + "serde", + "string_cache_codegen", + "string_cache_shared", +] + +[[package]] +name = "string_cache_codegen" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "string_cache_shared", +] + +[[package]] +name = "string_cache_shared" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc" + +[[package]] +name = "strsim" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" + +[[package]] +name = "syn" +version = "1.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid 0.2.1", +] + +[[package]] +name = "term" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" +dependencies = [ + "kernel32-sys", + "winapi 0.2.8", +] + +[[package]] +name = "termcolor" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi", + "winapi 0.3.9", +] + +[[package]] +name = "tracing" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" +dependencies = [ + "cfg-if 0.1.10", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tracing-error" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4d7c0b83d4a500748fa5879461652b361edf5c9d51ede2a2ac03875ca185e24" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-log" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1fa8f0c8f4c594e4fc9debc1990deab13238077271ba84dd853d54902ee3401" +dependencies = [ + "ansi_term 0.12.1", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "typenum" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" + +[[package]] +name = "unicode-segmentation" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/honk/Cargo.toml b/honk/Cargo.toml new file mode 100644 index 000000000..76eed9d16 --- /dev/null +++ b/honk/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "honk" +version = "7.0.0" +description = "An awful billed system." +categories = [] +keywords = ["build", "task", "cargo", "make"] +readme = "README.md" + +# update here, update everywhere! +license = "MIT/Apache-2.0" +homepage = "https://moxie.rs" +repository = "https://github.com/anp/moxie.git" +authors = ["Adam Perry "] +edition = "2018" + +[dependencies] +argh = "0.1.4" +color-eyre = "0.5.6" +starlark = "0.3.1" +tracing = "0.1.21" +tracing-subscriber = { version = "0.2.15", features = ["fmt"] } diff --git a/honk/README.md b/honk/README.md new file mode 100644 index 000000000..376a145c2 --- /dev/null +++ b/honk/README.md @@ -0,0 +1,3 @@ +# honk + +An awful billed system. Experimental. diff --git a/honk/src/lib.rs b/honk/src/lib.rs new file mode 100644 index 000000000..5891e48ec --- /dev/null +++ b/honk/src/lib.rs @@ -0,0 +1,22 @@ +use color_eyre::eyre::Result; +use std::path::{Path, PathBuf}; +use tracing::info; + +#[derive(Debug)] +pub struct Workspace { + /// Root directory of the workspace. + root: PathBuf, +} + +impl Workspace { + pub fn open(root: impl AsRef) -> Result { + let root = root.as_ref().to_path_buf(); + info!(root = %root.display(), "Opening."); + Ok(Self { root }) + } + + pub fn run(self) -> Result<()> { + info!(root = %self.root.display(), "Running."); + Ok(()) + } +} diff --git a/honk/src/main.rs b/honk/src/main.rs new file mode 100644 index 000000000..4e5964c35 --- /dev/null +++ b/honk/src/main.rs @@ -0,0 +1,18 @@ +use argh::FromArgs; +use honk::Workspace; +use std::path::PathBuf; + +/// An awful billed system. +#[derive(Debug, FromArgs)] +struct HonkCli { + /// path to the workspace root. + #[argh(option, default = "std::env::current_dir().unwrap()")] + workspace: PathBuf, +} + +fn main() -> color_eyre::eyre::Result<()> { + tracing_subscriber::fmt::init(); + color_eyre::install()?; + let HonkCli { workspace } = argh::from_env(); + Workspace::open(workspace)?.run() +} diff --git a/workspace.honk b/workspace.honk new file mode 100644 index 000000000..6cab60a8b --- /dev/null +++ b/workspace.honk @@ -0,0 +1 @@ +cargo_workspace(manifest="./Cargo.toml") From 10f7dd112bf70dbac209d8545d7d499ea88f4257 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 3 Nov 2020 12:28:47 -0800 Subject: [PATCH 02/73] [honk] stub out maintain/converge distinction --- honk/src/lib.rs | 30 ++++++++++++++++++++++-------- honk/src/main.rs | 12 ++++++++---- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 5891e48ec..489a64a5a 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,22 +1,36 @@ use color_eyre::eyre::Result; use std::path::{Path, PathBuf}; -use tracing::info; +use tracing::{info, instrument, warn}; #[derive(Debug)] pub struct Workspace { - /// Root directory of the workspace. + /// Path to `workspace.honk`. root: PathBuf, } impl Workspace { - pub fn open(root: impl AsRef) -> Result { - let root = root.as_ref().to_path_buf(); - info!(root = %root.display(), "Opening."); - Ok(Self { root }) + pub fn new(root: impl AsRef) -> Self { + Self { root: root.as_ref().to_path_buf() } } - pub fn run(self) -> Result<()> { - info!(root = %self.root.display(), "Running."); + pub fn maintain(self) -> Result<()> { + info!("maintaining workspace"); + loop { + self.converge()?; + warn!("TODO wait for changes to inputs"); + std::thread::sleep(std::time::Duration::from_secs(10)); + } + } + + #[instrument(level = "info", skip(self), fields(root = %self.root.display()))] + fn converge(&self) -> Result<()> { + info!("reading workspace file"); + + warn!("TODO get workspace file contents"); + warn!("TODO evaluate workspace file"); + warn!("TODO run formatters"); + warn!("TODO run build/test"); + Ok(()) } } diff --git a/honk/src/main.rs b/honk/src/main.rs index 4e5964c35..1be99cbc5 100644 --- a/honk/src/main.rs +++ b/honk/src/main.rs @@ -5,14 +5,18 @@ use std::path::PathBuf; /// An awful billed system. #[derive(Debug, FromArgs)] struct HonkCli { - /// path to the workspace root. - #[argh(option, default = "std::env::current_dir().unwrap()")] + /// path to `workspace.honk`. + #[argh(option, default = "default_workspace_path()")] workspace: PathBuf, } +fn default_workspace_path() -> PathBuf { + std::env::current_dir().unwrap().join("workspace.honk") +} + fn main() -> color_eyre::eyre::Result<()> { - tracing_subscriber::fmt::init(); + tracing_subscriber::fmt::fmt().pretty().init(); color_eyre::install()?; let HonkCli { workspace } = argh::from_env(); - Workspace::open(workspace)?.run() + Workspace::new(workspace).maintain() } From d12537f8d401a5bb2516bfd266650f6350e2bac8 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 3 Nov 2020 16:03:17 -0800 Subject: [PATCH 03/73] [honk] stub out root module loading --- honk/Cargo.lock | 264 ++++++++++++++++++++++++++++++++++++++++++++++++ honk/Cargo.toml | 3 + honk/src/lib.rs | 51 ++++++++-- honk/src/vfs.rs | 36 +++++++ 4 files changed, 347 insertions(+), 7 deletions(-) create mode 100644 honk/src/vfs.rs diff --git a/honk/Cargo.lock b/honk/Cargo.lock index 3707c6256..93a6adc95 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -254,6 +254,27 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "crossbeam-channel" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" +dependencies = [ + "crossbeam-utils", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg 1.0.1", + "cfg-if 0.1.10", + "lazy_static", +] + [[package]] name = "diff" version = "0.1.12" @@ -312,18 +333,71 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +[[package]] +name = "filetime" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "redox_syscall", + "winapi 0.3.9", +] + [[package]] name = "fixedbitset" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" +[[package]] +name = "fs-err" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcd1163ae48bda72a20ae26d66a04d3094135cadab911cff418ae5e33f253431" + +[[package]] +name = "fsevent" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6" +dependencies = [ + "bitflags", + "fsevent-sys", +] + +[[package]] +name = "fsevent-sys" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0" +dependencies = [ + "libc", +] + [[package]] name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + [[package]] name = "generator" version = "0.6.23" @@ -375,8 +449,11 @@ name = "honk" version = "7.0.0" dependencies = [ "argh", + "codemap-diagnostic", "color-eyre", + "memofs", "starlark", + "thiserror", "tracing", "tracing-subscriber", ] @@ -387,6 +464,35 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0bd112d44d9d870a6819eb505d04dd92b5e4d94bb8c304924a0872ae7016fb5" +[[package]] +name = "inotify" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f" +dependencies = [ + "bitflags", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" +dependencies = [ + "libc", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + [[package]] name = "itertools" version = "0.8.2" @@ -449,6 +555,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.80" @@ -492,12 +604,30 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + [[package]] name = "memchr" version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +[[package]] +name = "memofs" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "575ca842746f6079cdd96c2412ed1e3954a8a8b1983d962989482970c406c27b" +dependencies = [ + "crossbeam-channel", + "fs-err", + "notify", + "serde", +] + [[package]] name = "miniz_oxide" version = "0.4.3" @@ -508,12 +638,84 @@ dependencies = [ "autocfg 1.0.1", ] +[[package]] +name = "mio" +version = "0.6.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +dependencies = [ + "cfg-if 0.1.10", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio-extras" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" +dependencies = [ + "lazycell", + "log", + "mio", + "slab", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "net2" +version = "0.2.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.9", +] + [[package]] name = "new_debug_unreachable" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "notify" +version = "4.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd" +dependencies = [ + "bitflags", + "filetime", + "fsevent", + "fsevent-sys", + "inotify", + "libc", + "mio", + "mio-extras", + "walkdir", + "winapi 0.3.9", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -737,6 +939,12 @@ dependencies = [ "rand_core 0.3.1", ] +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + [[package]] name = "regex" version = "1.4.2" @@ -786,6 +994,15 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scoped-tls" version = "1.0.0" @@ -866,6 +1083,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + [[package]] name = "smallvec" version = "1.4.2" @@ -955,6 +1178,26 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "thiserror" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "318234ffa22e0920fe9a40d7b8369b5f649d490980cf7aadcf1eb91594869b42" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae2447b6282786c3493999f40a9be2a6ad20cb8bd268b0a0dbf5a065535c0ab" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thread_local" version = "1.0.1" @@ -1084,6 +1327,17 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "walkdir" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +dependencies = [ + "same-file", + "winapi 0.3.9", + "winapi-util", +] + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" @@ -1132,3 +1386,13 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] diff --git a/honk/Cargo.toml b/honk/Cargo.toml index 76eed9d16..cd29a6578 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -15,7 +15,10 @@ edition = "2018" [dependencies] argh = "0.1.4" +codemap-diagnostic = "0.1.1" color-eyre = "0.5.6" +memofs = "0.1.2" starlark = "0.3.1" +thiserror = "1.0.21" tracing = "0.1.21" tracing-subscriber = { version = "0.2.15", features = ["fmt"] } diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 489a64a5a..ec12aa7df 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,36 +1,73 @@ use color_eyre::eyre::Result; +use starlark::eval::eval as eval_starlark; use std::path::{Path, PathBuf}; -use tracing::{info, instrument, warn}; +use thiserror::Error; +use tracing::{error, info, instrument, warn}; + +mod vfs; + +use vfs::Vfs; -#[derive(Debug)] pub struct Workspace { /// Path to `workspace.honk`. root: PathBuf, + + /// Tracks changes to files which we've read. + vfs: Vfs, } impl Workspace { pub fn new(root: impl AsRef) -> Self { - Self { root: root.as_ref().to_path_buf() } + Self { root: root.as_ref().to_path_buf(), vfs: Vfs::default() } } pub fn maintain(self) -> Result<()> { info!("maintaining workspace"); loop { - self.converge()?; + if let Err(error) = self.converge() { + error!(%error, "couldn't converge current workspace revision"); + } warn!("TODO wait for changes to inputs"); std::thread::sleep(std::time::Duration::from_secs(10)); } } #[instrument(level = "info", skip(self), fields(root = %self.root.display()))] - fn converge(&self) -> Result<()> { + fn converge(&self) -> Result<(), HonkError> { info!("reading workspace file"); + let root_contents = self.vfs.read(&self.root)?; + let root_contents = std::str::from_utf8(&*root_contents) + .map_err(|source| HonkError::ScriptEncoding { source, file: self.root.clone() })?; + + eval_starlark( + todo!(), + &self.root.to_string_lossy(), + &root_contents, + todo!(), + todo!(), + todo!(), + &self.vfs, + ) + .map_err(HonkError::Eval)?; - warn!("TODO get workspace file contents"); - warn!("TODO evaluate workspace file"); warn!("TODO run formatters"); warn!("TODO run build/test"); Ok(()) } } + +#[derive(Debug, Error)] +enum HonkError { + #[error("evaluation error: TODO print it here")] + Eval(codemap_diagnostic::Diagnostic), + + #[error("i/o error")] + Io { + #[from] + source: std::io::Error, + }, + + #[error("non utf-8 *.honk script encountered at {}", file.display())] + ScriptEncoding { source: std::str::Utf8Error, file: PathBuf }, +} diff --git a/honk/src/vfs.rs b/honk/src/vfs.rs new file mode 100644 index 000000000..0b4175611 --- /dev/null +++ b/honk/src/vfs.rs @@ -0,0 +1,36 @@ +use starlark::{ + environment::{Environment, TypeValues}, + eval::{noload::NoLoadFileLoader, EvalException, FileLoader}, +}; +use std::ops::{Deref, DerefMut}; + +pub struct Vfs { + inner: memofs::Vfs, +} + +impl FileLoader for Vfs { + fn load(&self, path: &str, type_values: &TypeValues) -> Result { + // TODO load from the vfs! + NoLoadFileLoader.load(path, type_values) + } +} + +impl Default for Vfs { + fn default() -> Self { + Vfs { inner: memofs::Vfs::new_default() } + } +} + +impl Deref for Vfs { + type Target = memofs::Vfs; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl DerefMut for Vfs { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } +} From b7be115998effbd2bb28be66277b8d2c0bdf62d2 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 3 Nov 2020 16:10:34 -0800 Subject: [PATCH 04/73] [honk] actually evaluate! yay! it does not work --- honk/Cargo.lock | 1 + honk/Cargo.toml | 1 + honk/src/lib.rs | 25 +++++++++++++++++++------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/honk/Cargo.lock b/honk/Cargo.lock index 93a6adc95..8d4e7c888 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -449,6 +449,7 @@ name = "honk" version = "7.0.0" dependencies = [ "argh", + "codemap", "codemap-diagnostic", "color-eyre", "memofs", diff --git a/honk/Cargo.toml b/honk/Cargo.toml index cd29a6578..7660550c6 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -15,6 +15,7 @@ edition = "2018" [dependencies] argh = "0.1.4" +codemap = "0.1.3" codemap-diagnostic = "0.1.1" color-eyre = "0.5.6" memofs = "0.1.2" diff --git a/honk/src/lib.rs b/honk/src/lib.rs index ec12aa7df..3ceff3b4f 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,6 +1,13 @@ +use codemap::CodeMap; use color_eyre::eyre::Result; -use starlark::eval::eval as eval_starlark; -use std::path::{Path, PathBuf}; +use starlark::{ + environment::{Environment, TypeValues}, + eval::eval as eval_starlark, +}; +use std::{ + path::{Path, PathBuf}, + sync::{Arc, Mutex}, +}; use thiserror::Error; use tracing::{error, info, instrument, warn}; @@ -39,13 +46,19 @@ impl Workspace { let root_contents = std::str::from_utf8(&*root_contents) .map_err(|source| HonkError::ScriptEncoding { source, file: self.root.clone() })?; + let map = Arc::new(Mutex::new(CodeMap::new())); + let types = TypeValues::default(); + let mut env = Environment::new("honk"); + + info!("evaluating workspace file"); eval_starlark( - todo!(), + &map, &self.root.to_string_lossy(), &root_contents, - todo!(), - todo!(), - todo!(), + // TODO figure out if this is the right dialect? + starlark::syntax::dialect::Dialect::Bzl, + &mut env, + &types, &self.vfs, ) .map_err(HonkError::Eval)?; From 19ab92704035aa29e7d310f0f755311a1e86e336 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 3 Nov 2020 16:12:45 -0800 Subject: [PATCH 05/73] [honk] store codemap with eval errors --- honk/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 3ceff3b4f..7f8eb9503 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -61,7 +61,7 @@ impl Workspace { &types, &self.vfs, ) - .map_err(HonkError::Eval)?; + .map_err(|diagnostic| HonkError::Eval { diagnostic, map: map.clone() })?; warn!("TODO run formatters"); warn!("TODO run build/test"); @@ -73,7 +73,7 @@ impl Workspace { #[derive(Debug, Error)] enum HonkError { #[error("evaluation error: TODO print it here")] - Eval(codemap_diagnostic::Diagnostic), + Eval { diagnostic: codemap_diagnostic::Diagnostic, map: Arc> }, #[error("i/o error")] Io { From 32dc13a79a29c23b49cee1729ff8d998ed54e6fe Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 3 Nov 2020 16:13:36 -0800 Subject: [PATCH 06/73] [honk] remove import alias --- honk/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 7f8eb9503..cd57238c7 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,9 +1,6 @@ use codemap::CodeMap; use color_eyre::eyre::Result; -use starlark::{ - environment::{Environment, TypeValues}, - eval::eval as eval_starlark, -}; +use starlark::environment::{Environment, TypeValues}; use std::{ path::{Path, PathBuf}, sync::{Arc, Mutex}, @@ -51,7 +48,7 @@ impl Workspace { let mut env = Environment::new("honk"); info!("evaluating workspace file"); - eval_starlark( + starlark::eval::eval( &map, &self.root.to_string_lossy(), &root_contents, From cb41bd8cb1fba2f25ed3783c6bcab08f84639408 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Wed, 4 Nov 2020 08:41:23 -0800 Subject: [PATCH 07/73] [honk] print starlark errors --- honk/src/lib.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index cd57238c7..9d65a42d5 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,4 +1,5 @@ use codemap::CodeMap; +use codemap_diagnostic::{ColorConfig, Emitter}; use color_eyre::eyre::Result; use starlark::environment::{Environment, TypeValues}; use std::{ @@ -48,7 +49,7 @@ impl Workspace { let mut env = Environment::new("honk"); info!("evaluating workspace file"); - starlark::eval::eval( + match starlark::eval::eval( &map, &self.root.to_string_lossy(), &root_contents, @@ -57,8 +58,16 @@ impl Workspace { &mut env, &types, &self.vfs, - ) - .map_err(|diagnostic| HonkError::Eval { diagnostic, map: map.clone() })?; + ) { + Ok(_output) => todo!(), + Err(diagnostic) => { + // TODO reconcile this stderr reporting with other mechanisms like HTTP + let map = map.lock().unwrap(); + let mut emitter = Emitter::stderr(ColorConfig::Auto, Some(&*map)); + emitter.emit(&[diagnostic]); + return Err(HonkError::Eval); + } + } warn!("TODO run formatters"); warn!("TODO run build/test"); @@ -69,8 +78,8 @@ impl Workspace { #[derive(Debug, Error)] enum HonkError { - #[error("evaluation error: TODO print it here")] - Eval { diagnostic: codemap_diagnostic::Diagnostic, map: Arc> }, + #[error("evaluation error")] + Eval, #[error("i/o error")] Io { From fd08bc137e028d84f2f2cad95ef8b5efcb59aebc Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Wed, 4 Nov 2020 10:46:18 -0800 Subject: [PATCH 08/73] [honk] move environment creation to loader --- honk/src/error.rs | 16 +++++++++++ honk/src/lib.rs | 70 ++++++++--------------------------------------- honk/src/vfs.rs | 68 ++++++++++++++++++++++++++++++++------------- 3 files changed, 76 insertions(+), 78 deletions(-) create mode 100644 honk/src/error.rs diff --git a/honk/src/error.rs b/honk/src/error.rs new file mode 100644 index 000000000..45501cb38 --- /dev/null +++ b/honk/src/error.rs @@ -0,0 +1,16 @@ +use std::{path::PathBuf, str::Utf8Error}; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("evaluation error")] + Eval, + + #[error("i/o error")] + Io { + #[from] + source: std::io::Error, + }, + + #[error("non utf-8 *.honk script encountered at {}", file.display())] + ScriptEncoding { source: Utf8Error, file: PathBuf }, +} diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 9d65a42d5..f07591ad9 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,29 +1,25 @@ -use codemap::CodeMap; -use codemap_diagnostic::{ColorConfig, Emitter}; use color_eyre::eyre::Result; -use starlark::environment::{Environment, TypeValues}; -use std::{ - path::{Path, PathBuf}, - sync::{Arc, Mutex}, -}; -use thiserror::Error; +use std::path::{Path, PathBuf}; use tracing::{error, info, instrument, warn}; +mod error; mod vfs; -use vfs::Vfs; +use error::Error; +use vfs::VfsLoader; pub struct Workspace { /// Path to `workspace.honk`. root: PathBuf, - /// Tracks changes to files which we've read. - vfs: Vfs, + /// Services starlark calls to `load()` and tracks changes to files we've + /// read. + loader: VfsLoader, } impl Workspace { pub fn new(root: impl AsRef) -> Self { - Self { root: root.as_ref().to_path_buf(), vfs: Vfs::default() } + Self { root: root.as_ref().to_path_buf(), loader: Default::default() } } pub fn maintain(self) -> Result<()> { @@ -38,55 +34,11 @@ impl Workspace { } #[instrument(level = "info", skip(self), fields(root = %self.root.display()))] - fn converge(&self) -> Result<(), HonkError> { - info!("reading workspace file"); - let root_contents = self.vfs.read(&self.root)?; - let root_contents = std::str::from_utf8(&*root_contents) - .map_err(|source| HonkError::ScriptEncoding { source, file: self.root.clone() })?; + fn converge(&self) -> Result<(), Error> { + let mut env = self.loader.load_workspace_env(&self.root)?; - let map = Arc::new(Mutex::new(CodeMap::new())); - let types = TypeValues::default(); - let mut env = Environment::new("honk"); - - info!("evaluating workspace file"); - match starlark::eval::eval( - &map, - &self.root.to_string_lossy(), - &root_contents, - // TODO figure out if this is the right dialect? - starlark::syntax::dialect::Dialect::Bzl, - &mut env, - &types, - &self.vfs, - ) { - Ok(_output) => todo!(), - Err(diagnostic) => { - // TODO reconcile this stderr reporting with other mechanisms like HTTP - let map = map.lock().unwrap(); - let mut emitter = Emitter::stderr(ColorConfig::Auto, Some(&*map)); - emitter.emit(&[diagnostic]); - return Err(HonkError::Eval); - } - } - - warn!("TODO run formatters"); - warn!("TODO run build/test"); + warn!("TODO display discovered targets"); Ok(()) } } - -#[derive(Debug, Error)] -enum HonkError { - #[error("evaluation error")] - Eval, - - #[error("i/o error")] - Io { - #[from] - source: std::io::Error, - }, - - #[error("non utf-8 *.honk script encountered at {}", file.display())] - ScriptEncoding { source: std::str::Utf8Error, file: PathBuf }, -} diff --git a/honk/src/vfs.rs b/honk/src/vfs.rs index 0b4175611..0415e5212 100644 --- a/honk/src/vfs.rs +++ b/honk/src/vfs.rs @@ -1,36 +1,66 @@ +use crate::error::Error; +use codemap::CodeMap; +use codemap_diagnostic::{ColorConfig, Emitter}; use starlark::{ environment::{Environment, TypeValues}, eval::{noload::NoLoadFileLoader, EvalException, FileLoader}, }; -use std::ops::{Deref, DerefMut}; +use std::{ + path::Path, + sync::{Arc, Mutex}, +}; +use tracing::{info, instrument}; -pub struct Vfs { - inner: memofs::Vfs, +pub struct VfsLoader { + vfs: memofs::Vfs, } -impl FileLoader for Vfs { - fn load(&self, path: &str, type_values: &TypeValues) -> Result { - // TODO load from the vfs! - NoLoadFileLoader.load(path, type_values) - } -} - -impl Default for Vfs { +impl Default for VfsLoader { fn default() -> Self { - Vfs { inner: memofs::Vfs::new_default() } + Self { vfs: memofs::Vfs::new_default() } } } -impl Deref for Vfs { - type Target = memofs::Vfs; +impl VfsLoader { + pub fn load_workspace_env(&self, root: impl AsRef) -> Result { + let root = root.as_ref(); + info!("reading workspace file"); + let root_contents = self.vfs.read(root)?; + let root_contents = std::str::from_utf8(&*root_contents) + .map_err(|source| Error::ScriptEncoding { source, file: root.to_path_buf() })?; + + let map = Arc::new(Mutex::new(CodeMap::new())); + let types = TypeValues::default(); + let mut env = Environment::new("honk"); - fn deref(&self) -> &Self::Target { - &self.inner + info!("evaluating workspace file"); + match starlark::eval::eval( + &map, + &root.to_string_lossy(), + &root_contents, + // TODO figure out if this is the right dialect? + starlark::syntax::dialect::Dialect::Bzl, + &mut env, + &types, + self, + ) { + Ok(_output) => Ok(env), + Err(diagnostic) => { + // TODO reconcile this stderr reporting with other mechanisms like HTTP + let map = map.lock().unwrap(); + let mut emitter = Emitter::stderr(ColorConfig::Auto, Some(&*map)); + emitter.emit(&[diagnostic]); + Err(Error::Eval) + } + } } } -impl DerefMut for Vfs { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.inner +impl FileLoader for VfsLoader { + #[instrument(skip(self))] + fn load(&self, path: &str, type_values: &TypeValues) -> Result { + info!("loading file"); + // TODO load from the vfs! + NoLoadFileLoader.load(path, type_values) } } From e502647e549fd819e52d48bb49e5ffd161b28aee Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Wed, 4 Nov 2020 11:12:33 -0800 Subject: [PATCH 09/73] [honk] wait for file changes we care about instead of a timer --- honk/Cargo.lock | 1 + honk/Cargo.toml | 1 + honk/src/lib.rs | 4 ++-- honk/src/vfs.rs | 30 +++++++++++++++++++++++++++--- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/honk/Cargo.lock b/honk/Cargo.lock index 8d4e7c888..7e39bc4b2 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -452,6 +452,7 @@ dependencies = [ "codemap", "codemap-diagnostic", "color-eyre", + "crossbeam-channel", "memofs", "starlark", "thiserror", diff --git a/honk/Cargo.toml b/honk/Cargo.toml index 7660550c6..81c9ca32f 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -18,6 +18,7 @@ argh = "0.1.4" codemap = "0.1.3" codemap-diagnostic = "0.1.1" color-eyre = "0.5.6" +crossbeam-channel = "0.4.0" memofs = "0.1.2" starlark = "0.3.1" thiserror = "1.0.21" diff --git a/honk/src/lib.rs b/honk/src/lib.rs index f07591ad9..2ad3b6185 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -28,8 +28,7 @@ impl Workspace { if let Err(error) = self.converge() { error!(%error, "couldn't converge current workspace revision"); } - warn!("TODO wait for changes to inputs"); - std::thread::sleep(std::time::Duration::from_secs(10)); + self.loader.wait_for_changes(); } } @@ -39,6 +38,7 @@ impl Workspace { warn!("TODO display discovered targets"); + info!("finished"); Ok(()) } } diff --git a/honk/src/vfs.rs b/honk/src/vfs.rs index 0415e5212..b80ebb7dd 100644 --- a/honk/src/vfs.rs +++ b/honk/src/vfs.rs @@ -1,6 +1,8 @@ use crate::error::Error; use codemap::CodeMap; use codemap_diagnostic::{ColorConfig, Emitter}; +use crossbeam_channel::TryRecvError; +use memofs::{Vfs, VfsEvent}; use starlark::{ environment::{Environment, TypeValues}, eval::{noload::NoLoadFileLoader, EvalException, FileLoader}, @@ -9,19 +11,41 @@ use std::{ path::Path, sync::{Arc, Mutex}, }; -use tracing::{info, instrument}; +use tracing::{debug, info, instrument, trace}; pub struct VfsLoader { - vfs: memofs::Vfs, + vfs: Vfs, } impl Default for VfsLoader { fn default() -> Self { - Self { vfs: memofs::Vfs::new_default() } + Self { vfs: Vfs::new_default() } } } impl VfsLoader { + pub fn wait_for_changes(&self) { + let changes = self.vfs.event_receiver(); + match changes.recv().unwrap() { + VfsEvent::Create(created) => info!(created = %created.display()), + VfsEvent::Write(modified) => info!(modified = %modified.display()), + VfsEvent::Remove(removed) => info!(removed = %removed.display()), + _ => unimplemented!("unrecognized filesystem event"), + } + + // TODO figure out how much memofs debounces, make sure its enough or we do some + debug!("draining other fs events until quiescent"); + loop { + match changes.try_recv() { + Ok(event) => trace!(?event, "discarding"), + Err(TryRecvError::Empty) => break, + Err(TryRecvError::Disconnected) => { + unreachable!("other end is kept alive by ourselves") + } + } + } + } + pub fn load_workspace_env(&self, root: impl AsRef) -> Result { let root = root.as_ref(); info!("reading workspace file"); From 4a55c6d93112acd20a1f04ed80d1a49cbfc15057 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 7 Nov 2020 17:21:49 -0800 Subject: [PATCH 10/73] [honk] support loading files --- honk/rules/rust.honk | 3 ++ honk/src/error.rs | 50 +++++++++++++++++++++++++++--- honk/src/lib.rs | 68 ++++++++++++++++++++++++++++++++++------ honk/src/main.rs | 8 ++--- honk/src/vfs.rs | 74 ++++++++++---------------------------------- workspace.honk | 2 ++ 6 files changed, 129 insertions(+), 76 deletions(-) create mode 100644 honk/rules/rust.honk diff --git a/honk/rules/rust.honk b/honk/rules/rust.honk new file mode 100644 index 000000000..00566080a --- /dev/null +++ b/honk/rules/rust.honk @@ -0,0 +1,3 @@ +# Discovers targets from a Cargo workspace, defined by the path to its root manifest. +def cargo_workspace(manifest): + pass \ No newline at end of file diff --git a/honk/src/error.rs b/honk/src/error.rs index 45501cb38..27c6cf515 100644 --- a/honk/src/error.rs +++ b/honk/src/error.rs @@ -1,16 +1,58 @@ -use std::{path::PathBuf, str::Utf8Error}; +use codemap::CodeMap; +use codemap_diagnostic::{ColorConfig, Emitter}; +use std::{ + fmt::{Debug, Display, Formatter, Result as FmtResult}, + path::PathBuf, + str::Utf8Error, + sync::{Arc, Mutex}, +}; #[derive(Debug, thiserror::Error)] pub enum Error { - #[error("evaluation error")] - Eval, + #[error("evaluation error: {source}")] + Eval { + #[from] + source: EvalError, + }, - #[error("i/o error")] + #[error("i/o error: {source}")] Io { #[from] source: std::io::Error, }, + #[allow(unused)] #[error("non utf-8 *.honk script encountered at {}", file.display())] ScriptEncoding { source: Utf8Error, file: PathBuf }, } + +#[derive(thiserror::Error)] +pub struct EvalError { + pub map: Arc>, + pub diagnostic: codemap_diagnostic::Diagnostic, +} + +impl EvalError { + pub fn from_exception(except: starlark::eval::EvalException, map: Arc>) -> Self { + Self { diagnostic: except.into(), map } + } + + fn emit(&self) { + let map = self.map.lock().unwrap(); + let mut emitter = Emitter::stderr(ColorConfig::Auto, Some(&*map)); + emitter.emit(&[self.diagnostic.clone()]); + } +} + +impl Debug for EvalError { + fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { + self.diagnostic.fmt(f) + } +} + +impl Display for EvalError { + fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { + self.emit(); + f.debug_struct("EvalError").finish() + } +} diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 2ad3b6185..c09145a67 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,25 +1,44 @@ +use codemap::CodeMap; use color_eyre::eyre::Result; -use std::path::{Path, PathBuf}; +use starlark::{ + environment::{Environment, TypeValues}, + eval::{EvalException, FileLoader}, +}; +use std::{ + path::{Path, PathBuf}, + sync::{Arc, Mutex}, +}; use tracing::{error, info, instrument, warn}; mod error; mod vfs; -use error::Error; -use vfs::VfsLoader; +use error::{Error, EvalError}; +use vfs::Vfs; pub struct Workspace { /// Path to `workspace.honk`. root: PathBuf, - /// Services starlark calls to `load()` and tracks changes to files we've - /// read. - loader: VfsLoader, + /// Tracks changes to files we've read. + vfs: Vfs, + + codemap: Arc>, + type_values: TypeValues, } impl Workspace { + /// The asset path used to resolve the root of a honk workspace. + const ASSET_PATH: &'static str = "//workspace.honk"; + pub fn new(root: impl AsRef) -> Self { - Self { root: root.as_ref().to_path_buf(), loader: Default::default() } + let codemap = Arc::new(Mutex::new(CodeMap::new())); + Self { + root: root.as_ref().to_path_buf(), + vfs: Vfs::new(), + codemap, + type_values: Default::default(), + } } pub fn maintain(self) -> Result<()> { @@ -28,13 +47,15 @@ impl Workspace { if let Err(error) = self.converge() { error!(%error, "couldn't converge current workspace revision"); } - self.loader.wait_for_changes(); + self.vfs.wait_for_changes(); } } #[instrument(level = "info", skip(self), fields(root = %self.root.display()))] fn converge(&self) -> Result<(), Error> { - let mut env = self.loader.load_workspace_env(&self.root)?; + let _env = self + .load(Self::ASSET_PATH, &self.type_values) + .map_err(|e| EvalError::from_exception(e, self.codemap.clone()))?; warn!("TODO display discovered targets"); @@ -42,3 +63,32 @@ impl Workspace { Ok(()) } } + +impl FileLoader for Workspace { + #[instrument(skip(self, type_values))] + fn load(&self, path: &str, type_values: &TypeValues) -> Result { + // TODO smarter way to resolve assets etc + let file = self.root.join(path.strip_prefix("//").unwrap_or(path)); + info!(file = %file.display(), "loading"); + + let root_contents = self.vfs.read(&file).expect("TODO pass errors back correctly here"); + let root_contents = + std::str::from_utf8(&*root_contents).expect("TODO pass errors back correctly here"); + + let mut env = Environment::new("honk"); + + info!("evaluating"); + starlark::eval::eval( + &self.codemap, + &file.to_string_lossy(), + &root_contents, + // TODO do we ever want to restrict function definitions? + starlark::syntax::dialect::Dialect::Bzl, + &mut env, + type_values, + self, + )?; + + Ok(env) + } +} diff --git a/honk/src/main.rs b/honk/src/main.rs index 1be99cbc5..18275df8b 100644 --- a/honk/src/main.rs +++ b/honk/src/main.rs @@ -5,15 +5,11 @@ use std::path::PathBuf; /// An awful billed system. #[derive(Debug, FromArgs)] struct HonkCli { - /// path to `workspace.honk`. - #[argh(option, default = "default_workspace_path()")] + /// path to directory containing `workspace.honk`. + #[argh(option, default = "std::env::current_dir().unwrap()")] workspace: PathBuf, } -fn default_workspace_path() -> PathBuf { - std::env::current_dir().unwrap().join("workspace.honk") -} - fn main() -> color_eyre::eyre::Result<()> { tracing_subscriber::fmt::fmt().pretty().init(); color_eyre::install()?; diff --git a/honk/src/vfs.rs b/honk/src/vfs.rs index b80ebb7dd..ededd183f 100644 --- a/honk/src/vfs.rs +++ b/honk/src/vfs.rs @@ -1,31 +1,19 @@ -use crate::error::Error; -use codemap::CodeMap; -use codemap_diagnostic::{ColorConfig, Emitter}; use crossbeam_channel::TryRecvError; -use memofs::{Vfs, VfsEvent}; -use starlark::{ - environment::{Environment, TypeValues}, - eval::{noload::NoLoadFileLoader, EvalException, FileLoader}, -}; -use std::{ - path::Path, - sync::{Arc, Mutex}, -}; -use tracing::{debug, info, instrument, trace}; +use memofs::{Vfs as MemoVfs, VfsEvent}; +use std::ops::{Deref, DerefMut}; +use tracing::{debug, info, trace}; -pub struct VfsLoader { - vfs: Vfs, +pub struct Vfs { + inner: MemoVfs, } -impl Default for VfsLoader { - fn default() -> Self { - Self { vfs: Vfs::new_default() } +impl Vfs { + pub fn new() -> Self { + Self { inner: MemoVfs::new_default() } } -} -impl VfsLoader { pub fn wait_for_changes(&self) { - let changes = self.vfs.event_receiver(); + let changes = self.inner.event_receiver(); match changes.recv().unwrap() { VfsEvent::Create(created) => info!(created = %created.display()), VfsEvent::Write(modified) => info!(modified = %modified.display()), @@ -45,46 +33,18 @@ impl VfsLoader { } } } +} - pub fn load_workspace_env(&self, root: impl AsRef) -> Result { - let root = root.as_ref(); - info!("reading workspace file"); - let root_contents = self.vfs.read(root)?; - let root_contents = std::str::from_utf8(&*root_contents) - .map_err(|source| Error::ScriptEncoding { source, file: root.to_path_buf() })?; - - let map = Arc::new(Mutex::new(CodeMap::new())); - let types = TypeValues::default(); - let mut env = Environment::new("honk"); +impl Deref for Vfs { + type Target = MemoVfs; - info!("evaluating workspace file"); - match starlark::eval::eval( - &map, - &root.to_string_lossy(), - &root_contents, - // TODO figure out if this is the right dialect? - starlark::syntax::dialect::Dialect::Bzl, - &mut env, - &types, - self, - ) { - Ok(_output) => Ok(env), - Err(diagnostic) => { - // TODO reconcile this stderr reporting with other mechanisms like HTTP - let map = map.lock().unwrap(); - let mut emitter = Emitter::stderr(ColorConfig::Auto, Some(&*map)); - emitter.emit(&[diagnostic]); - Err(Error::Eval) - } - } + fn deref(&self) -> &Self::Target { + &self.inner } } -impl FileLoader for VfsLoader { - #[instrument(skip(self))] - fn load(&self, path: &str, type_values: &TypeValues) -> Result { - info!("loading file"); - // TODO load from the vfs! - NoLoadFileLoader.load(path, type_values) +impl DerefMut for Vfs { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner } } diff --git a/workspace.honk b/workspace.honk index 6cab60a8b..fa74648ec 100644 --- a/workspace.honk +++ b/workspace.honk @@ -1 +1,3 @@ +load("//honk/rules/rust.honk", "cargo_workspace") + cargo_workspace(manifest="./Cargo.toml") From 3836fe1725b90c66e2a51f0c94d15560f6c17ca0 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 8 Nov 2020 12:07:26 -0800 Subject: [PATCH 11/73] [honk] expose command() function to environment allows running shell commands during configuration (muahaha) this will require a lot of effort to make efficient later. --- honk/rules/rust.honk | 19 ++++++++++++- honk/src/command.rs | 68 ++++++++++++++++++++++++++++++++++++++++++++ honk/src/error.rs | 7 +++++ honk/src/lib.rs | 21 ++++++++------ 4 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 honk/src/command.rs diff --git a/honk/rules/rust.honk b/honk/rules/rust.honk index 00566080a..7b5865ce0 100644 --- a/honk/rules/rust.honk +++ b/honk/rules/rust.honk @@ -1,3 +1,20 @@ +def cargo_metadata(manifest): + output = command( + "cargo", + [ + "metadata", + "--no-deps", # remove this when we're ready to run rustc ourselves + "--format-version", + "1", # only valid value at time of writing + "--manifest-path", + manifest, + ], + ).run() + # TODO parse stdout as json + return output + + # Discovers targets from a Cargo workspace, defined by the path to its root manifest. def cargo_workspace(manifest): - pass \ No newline at end of file + metadata = cargo_metadata(manifest) + # TODO register discovered targets diff --git a/honk/src/command.rs b/honk/src/command.rs new file mode 100644 index 000000000..7673be52c --- /dev/null +++ b/honk/src/command.rs @@ -0,0 +1,68 @@ +use crate::error::Error; +use starlark::{ + starlark_module, + values::{TypedValue, Value}, +}; +use tracing::instrument; + +// TODO submit an upstream patch to use $crate in all these macros +use starlark::{ + starlark_fun, starlark_parse_param_type, starlark_signature, starlark_signature_extraction, + starlark_signatures, +}; + +starlark_module! { register_commands => + command(command: String, args: Vec) { + Ok(Value::new(Command::new(command, args))) + } + + Command.run(this: Command) { + Ok(Value::new(this.run()?)) + } +} + +#[derive(Clone, Debug)] +pub struct Command { + command: String, + args: Vec, +} + +impl Command { + pub fn new(command: String, args: Vec) -> Self { + Self { command, args } + } + + #[instrument] + pub fn run(self) -> Result { + // TODO set working dir + // TODO set environment + let inner = std::process::Command::new(self.command).args(self.args).output()?; + Ok(Output { inner }) + } +} + +impl TypedValue for Command { + type Holder = starlark::values::Immutable; + + const TYPE: &'static str = "Command"; + + fn values_for_descendant_check_and_freeze(&self) -> Box + '_> { + Box::new(std::iter::empty()) + } +} + +#[derive(Clone)] +pub struct Output { + // TODO + inner: std::process::Output, +} + +impl TypedValue for Output { + type Holder = starlark::values::Immutable; + + const TYPE: &'static str = "Output"; + + fn values_for_descendant_check_and_freeze(&self) -> Box + '_> { + Box::new(std::iter::empty()) + } +} diff --git a/honk/src/error.rs b/honk/src/error.rs index 27c6cf515..9db9025b1 100644 --- a/honk/src/error.rs +++ b/honk/src/error.rs @@ -1,5 +1,6 @@ use codemap::CodeMap; use codemap_diagnostic::{ColorConfig, Emitter}; +use starlark::values::error::ValueError; use std::{ fmt::{Debug, Display, Formatter, Result as FmtResult}, path::PathBuf, @@ -26,6 +27,12 @@ pub enum Error { ScriptEncoding { source: Utf8Error, file: PathBuf }, } +impl From for ValueError { + fn from(e: Error) -> Self { + todo!("uh do this conversion properly: {:?}", e); + } +} + #[derive(thiserror::Error)] pub struct EvalError { pub map: Arc>, diff --git a/honk/src/lib.rs b/honk/src/lib.rs index c09145a67..c0a7a4489 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -10,9 +10,11 @@ use std::{ }; use tracing::{error, info, instrument, warn}; +mod command; mod error; mod vfs; +use command::register_commands; use error::{Error, EvalError}; use vfs::Vfs; @@ -33,12 +35,13 @@ impl Workspace { pub fn new(root: impl AsRef) -> Self { let codemap = Arc::new(Mutex::new(CodeMap::new())); - Self { - root: root.as_ref().to_path_buf(), - vfs: Vfs::new(), - codemap, - type_values: Default::default(), - } + + let (mut throwaway_env, mut type_values) = + starlark::stdlib::global_environment_with_extensions(); + // TODO figure out how to do this once instead of here *and* below in `load()`? + register_commands(&mut throwaway_env, &mut type_values); + + Self { root: root.as_ref().to_path_buf(), vfs: Vfs::new(), codemap, type_values } } pub fn maintain(self) -> Result<()> { @@ -53,7 +56,7 @@ impl Workspace { #[instrument(level = "info", skip(self), fields(root = %self.root.display()))] fn converge(&self) -> Result<(), Error> { - let _env = self + let _workspace_env = self .load(Self::ASSET_PATH, &self.type_values) .map_err(|e| EvalError::from_exception(e, self.codemap.clone()))?; @@ -75,7 +78,9 @@ impl FileLoader for Workspace { let root_contents = std::str::from_utf8(&*root_contents).expect("TODO pass errors back correctly here"); - let mut env = Environment::new("honk"); + let (mut env, mut throwaway_tvs) = starlark::stdlib::global_environment_with_extensions(); + // TODO figure out how to do this once instead of here *and* above in `new()`? + register_commands(&mut env, &mut throwaway_tvs); info!("evaluating"); starlark::eval::eval( From 1a2eb5ae1fd4ad9631f362ea37c1e07974621e52 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 8 Nov 2020 12:58:16 -0800 Subject: [PATCH 12/73] [honk] refactor command builtins to a submodule --- honk/src/builtins.rs | 24 ++++++++++++++++++++++++ honk/src/{ => builtins}/command.rs | 13 ++----------- honk/src/lib.rs | 7 +++---- 3 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 honk/src/builtins.rs rename honk/src/{ => builtins}/command.rs (80%) diff --git a/honk/src/builtins.rs b/honk/src/builtins.rs new file mode 100644 index 000000000..93b9885c1 --- /dev/null +++ b/honk/src/builtins.rs @@ -0,0 +1,24 @@ +use starlark::environment::{Environment, TypeValues}; + +// TODO delete this +macro_rules! starlark_module { + ($($tok:tt)+) => { + // TODO submit an upstream patch to use $crate in all these macros + use starlark::{ + starlark_fun, + starlark_module as raw_starlark_module, + starlark_parse_param_type, + starlark_signature, + starlark_signature_extraction, + starlark_signatures, + }; + + raw_starlark_module! {$($tok)+} + }; +} + +mod command; + +pub fn register(env: &mut Environment, tvs: &mut TypeValues) { + command::globals(env, tvs); +} diff --git a/honk/src/command.rs b/honk/src/builtins/command.rs similarity index 80% rename from honk/src/command.rs rename to honk/src/builtins/command.rs index 7673be52c..a81b0353c 100644 --- a/honk/src/command.rs +++ b/honk/src/builtins/command.rs @@ -1,17 +1,8 @@ use crate::error::Error; -use starlark::{ - starlark_module, - values::{TypedValue, Value}, -}; +use starlark::values::{TypedValue, Value}; use tracing::instrument; -// TODO submit an upstream patch to use $crate in all these macros -use starlark::{ - starlark_fun, starlark_parse_param_type, starlark_signature, starlark_signature_extraction, - starlark_signatures, -}; - -starlark_module! { register_commands => +starlark_module! { globals => command(command: String, args: Vec) { Ok(Value::new(Command::new(command, args))) } diff --git a/honk/src/lib.rs b/honk/src/lib.rs index c0a7a4489..f6397a672 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -10,11 +10,10 @@ use std::{ }; use tracing::{error, info, instrument, warn}; -mod command; +mod builtins; mod error; mod vfs; -use command::register_commands; use error::{Error, EvalError}; use vfs::Vfs; @@ -39,7 +38,7 @@ impl Workspace { let (mut throwaway_env, mut type_values) = starlark::stdlib::global_environment_with_extensions(); // TODO figure out how to do this once instead of here *and* below in `load()`? - register_commands(&mut throwaway_env, &mut type_values); + builtins::register(&mut throwaway_env, &mut type_values); Self { root: root.as_ref().to_path_buf(), vfs: Vfs::new(), codemap, type_values } } @@ -80,7 +79,7 @@ impl FileLoader for Workspace { let (mut env, mut throwaway_tvs) = starlark::stdlib::global_environment_with_extensions(); // TODO figure out how to do this once instead of here *and* above in `new()`? - register_commands(&mut env, &mut throwaway_tvs); + builtins::register(&mut env, &mut throwaway_tvs); info!("evaluating"); starlark::eval::eval( From 0ce2b0fa1cfb415f5114a104b27942a579b36e96 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 8 Nov 2020 13:33:55 -0800 Subject: [PATCH 13/73] [honk] require commands to succeed by default (there is no option to allow them to fail yet) --- honk/rules/rust.honk | 2 +- honk/src/builtins/command.rs | 26 ++++++++++++++++++++------ honk/src/error.rs | 8 ++++++++ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/honk/rules/rust.honk b/honk/rules/rust.honk index 7b5865ce0..6f3b3cdb4 100644 --- a/honk/rules/rust.honk +++ b/honk/rules/rust.honk @@ -11,7 +11,7 @@ def cargo_metadata(manifest): ], ).run() # TODO parse stdout as json - return output + return output.stdout() # Discovers targets from a Cargo workspace, defined by the path to its root manifest. diff --git a/honk/src/builtins/command.rs b/honk/src/builtins/command.rs index a81b0353c..de50a84fd 100644 --- a/honk/src/builtins/command.rs +++ b/honk/src/builtins/command.rs @@ -10,6 +10,10 @@ starlark_module! { globals => Command.run(this: Command) { Ok(Value::new(this.run()?)) } + + Output.stdout(this: Output) { + Ok(Value::new(this.stdout()?)) + } } #[derive(Clone, Debug)] @@ -25,10 +29,13 @@ impl Command { #[instrument] pub fn run(self) -> Result { - // TODO set working dir - // TODO set environment - let inner = std::process::Command::new(self.command).args(self.args).output()?; - Ok(Output { inner }) + let output = Output { + // TODO set working dir + // TODO set environment + inner: std::process::Command::new(&self.command).args(&self.args).output()?, + command: self, + }; + if output.inner.status.success() { Ok(output) } else { Err(Error::CommandFailed(output)) } } } @@ -42,12 +49,19 @@ impl TypedValue for Command { } } -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct Output { - // TODO + command: Command, inner: std::process::Output, } +impl Output { + fn stdout(&self) -> Result { + Ok(String::from_utf8(self.inner.stdout.clone()) + .map_err(|source| Error::StdoutEncoding { source, command: self.command.clone() })?) + } +} + impl TypedValue for Output { type Holder = starlark::values::Immutable; diff --git a/honk/src/error.rs b/honk/src/error.rs index 9db9025b1..fec8a0992 100644 --- a/honk/src/error.rs +++ b/honk/src/error.rs @@ -1,3 +1,4 @@ +use crate::builtins::command::{Command, Output}; use codemap::CodeMap; use codemap_diagnostic::{ColorConfig, Emitter}; use starlark::values::error::ValueError; @@ -5,6 +6,7 @@ use std::{ fmt::{Debug, Display, Formatter, Result as FmtResult}, path::PathBuf, str::Utf8Error, + string::FromUtf8Error, sync::{Arc, Mutex}, }; @@ -22,6 +24,12 @@ pub enum Error { source: std::io::Error, }, + #[error("failed to run command: {0:#?}")] + CommandFailed(Output), + + #[error("`{command:?}` returned non utf-8: {source}")] + StdoutEncoding { source: FromUtf8Error, command: Command }, + #[allow(unused)] #[error("non utf-8 *.honk script encountered at {}", file.display())] ScriptEncoding { source: Utf8Error, file: PathBuf }, From 38ee294e0a7398ebacf3324e5494927aa34304b4 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 8 Nov 2020 14:51:14 -0800 Subject: [PATCH 14/73] [honk] implement json parsing, get cargo metadata with it --- honk/Cargo.lock | 1 + honk/Cargo.toml | 1 + honk/rules/rust.honk | 30 +++++++++++++++------------- honk/src/builtins.rs | 4 +++- honk/src/builtins/json.rs | 41 +++++++++++++++++++++++++++++++++++++++ honk/src/error.rs | 6 ++++++ 6 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 honk/src/builtins/json.rs diff --git a/honk/Cargo.lock b/honk/Cargo.lock index 7e39bc4b2..faf0e0095 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -454,6 +454,7 @@ dependencies = [ "color-eyre", "crossbeam-channel", "memofs", + "serde_json", "starlark", "thiserror", "tracing", diff --git a/honk/Cargo.toml b/honk/Cargo.toml index 81c9ca32f..6926edbaf 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -20,6 +20,7 @@ codemap-diagnostic = "0.1.1" color-eyre = "0.5.6" crossbeam-channel = "0.4.0" memofs = "0.1.2" +serde_json = "1.0.59" starlark = "0.3.1" thiserror = "1.0.21" tracing = "0.1.21" diff --git a/honk/rules/rust.honk b/honk/rules/rust.honk index 6f3b3cdb4..56de62299 100644 --- a/honk/rules/rust.honk +++ b/honk/rules/rust.honk @@ -1,20 +1,22 @@ def cargo_metadata(manifest): - output = command( - "cargo", - [ - "metadata", - "--no-deps", # remove this when we're ready to run rustc ourselves - "--format-version", - "1", # only valid value at time of writing - "--manifest-path", - manifest, - ], - ).run() - # TODO parse stdout as json - return output.stdout() + return json_decode( # TODO json.decode from starlark spec + command( + "cargo", + [ + "metadata", + "--no-deps", # remove this when we're ready to run rustc ourselves + "--format-version", + "1", # only valid value at time of writing + "--manifest-path", + manifest, + ], + ) + .run() + .stdout() + ) # Discovers targets from a Cargo workspace, defined by the path to its root manifest. def cargo_workspace(manifest): - metadata = cargo_metadata(manifest) + return cargo_metadata(manifest) # TODO register discovered targets diff --git a/honk/src/builtins.rs b/honk/src/builtins.rs index 93b9885c1..9fee97a6e 100644 --- a/honk/src/builtins.rs +++ b/honk/src/builtins.rs @@ -17,8 +17,10 @@ macro_rules! starlark_module { }; } -mod command; +pub mod command; +pub mod json; pub fn register(env: &mut Environment, tvs: &mut TypeValues) { command::globals(env, tvs); + json::globals(env, tvs); } diff --git a/honk/src/builtins/json.rs b/honk/src/builtins/json.rs new file mode 100644 index 000000000..ee9d14e50 --- /dev/null +++ b/honk/src/builtins/json.rs @@ -0,0 +1,41 @@ +use crate::error::Error; +use serde_json::Value as JsonValue; +use starlark::values::{dict::Dictionary, list::List, none::NoneType, Value}; + +starlark_module! { globals => + // TODO make this work with the dotted syntax from the spec!!! + json_decode(x: String) { + Ok(decode_json(&x)?) + } +} + +fn decode_json(x: &str) -> Result { + Ok(json_to_starlark(serde_json::from_str(x)?)) +} + +fn json_to_starlark(value: JsonValue) -> Value { + match value { + JsonValue::Null => Value::new(NoneType::None), + JsonValue::Bool(b) => Value::new(b), + JsonValue::Number(n) => Value::new(n.as_i64().expect("TODO support floats")), + JsonValue::String(s) => Value::new(s), + JsonValue::Array(a) => { + let mut list = List::default(); + + for value in a { + list.push(json_to_starlark(value)).unwrap(); + } + + Value::new(list) + } + JsonValue::Object(o) => { + let mut dict = Dictionary::default(); + + for (key, value) in o { + dict.insert(Value::new(key), json_to_starlark(value)).unwrap(); + } + + Value::new(dict) + } + } +} diff --git a/honk/src/error.rs b/honk/src/error.rs index fec8a0992..42c128a3c 100644 --- a/honk/src/error.rs +++ b/honk/src/error.rs @@ -30,6 +30,12 @@ pub enum Error { #[error("`{command:?}` returned non utf-8: {source}")] StdoutEncoding { source: FromUtf8Error, command: Command }, + #[error("error handling JSON: {source}")] + JsonError { + #[from] + source: serde_json::Error, + }, + #[allow(unused)] #[error("non utf-8 *.honk script encountered at {}", file.display())] ScriptEncoding { source: Utf8Error, file: PathBuf }, From 2a61eb6852eac57c2c2d132e05b041b3ead58099 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 8 Nov 2020 15:10:53 -0800 Subject: [PATCH 15/73] [honk] accept non-string args to commands --- honk/src/builtins/command.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/honk/src/builtins/command.rs b/honk/src/builtins/command.rs index de50a84fd..b2f154058 100644 --- a/honk/src/builtins/command.rs +++ b/honk/src/builtins/command.rs @@ -3,7 +3,8 @@ use starlark::values::{TypedValue, Value}; use tracing::instrument; starlark_module! { globals => - command(command: String, args: Vec) { + command(command: String, args: Vec) { + let args = args.iter().map(Value::to_str).collect(); Ok(Value::new(Command::new(command, args))) } From df1a369e8d72ce9f57985671a4c573c91ea97d9c Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 8 Nov 2020 15:11:25 -0800 Subject: [PATCH 16/73] [honk] verify metadata version we get from cargo --- honk/rules/rust.honk | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/honk/rules/rust.honk b/honk/rules/rust.honk index 56de62299..61ab13568 100644 --- a/honk/rules/rust.honk +++ b/honk/rules/rust.honk @@ -1,12 +1,13 @@ def cargo_metadata(manifest): - return json_decode( # TODO json.decode from starlark spec + requested_version = 1 # only valid value at time of writing + metadata = json_decode( # TODO json.decode from starlark spec command( "cargo", [ "metadata", "--no-deps", # remove this when we're ready to run rustc ourselves "--format-version", - "1", # only valid value at time of writing + requested_version, "--manifest-path", manifest, ], @@ -15,6 +16,12 @@ def cargo_metadata(manifest): .stdout() ) + version = metadata["version"] + if version != requested_version: + fail(msg="Got metadata v" + version + ", expected v" + requested_version) + + return metadata + # Discovers targets from a Cargo workspace, defined by the path to its root manifest. def cargo_workspace(manifest): From 1f30650c7d6d18aefb2b89b366b54f69f3d3fbed Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 8 Nov 2020 16:16:13 -0800 Subject: [PATCH 17/73] [honk] extract cargo metadata function to separate file --- honk/rules/rust.honk | 31 ++--------- honk/rules/rust/metadata.honk | 97 +++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 26 deletions(-) create mode 100644 honk/rules/rust/metadata.honk diff --git a/honk/rules/rust.honk b/honk/rules/rust.honk index 61ab13568..d960f244a 100644 --- a/honk/rules/rust.honk +++ b/honk/rules/rust.honk @@ -1,29 +1,8 @@ -def cargo_metadata(manifest): - requested_version = 1 # only valid value at time of writing - metadata = json_decode( # TODO json.decode from starlark spec - command( - "cargo", - [ - "metadata", - "--no-deps", # remove this when we're ready to run rustc ourselves - "--format-version", - requested_version, - "--manifest-path", - manifest, - ], - ) - .run() - .stdout() - ) - - version = metadata["version"] - if version != requested_version: - fail(msg="Got metadata v" + version + ", expected v" + requested_version) - - return metadata - +load("//honk/rules/rust/metadata.honk", "cargo_metadata") # Discovers targets from a Cargo workspace, defined by the path to its root manifest. def cargo_workspace(manifest): - return cargo_metadata(manifest) - # TODO register discovered targets + metadata = cargo_metadata(manifest) + + for id in metadata.member_ids: + fail(msg=id) diff --git a/honk/rules/rust/metadata.honk b/honk/rules/rust/metadata.honk new file mode 100644 index 000000000..4beb76767 --- /dev/null +++ b/honk/rules/rust/metadata.honk @@ -0,0 +1,97 @@ +# Functions to handle https://doc.rust-lang.org/cargo/commands/cargo-metadata.html#output-format. + + +def _dependency_dict_to_struct(dep): + return struct( + name=dep["name"], + source=dep["source"], + req=dep["req"], + kind=dep["kind"], + rename=dep["rename"], + optional=dep["optional"], + uses_default_features=dep["uses_default_features"], + features=dep["features"], + target=dep["target"], + registry=dep["registry"], + ) + + +def _target_dict_to_struct(target): + return struct( + kind=target["kind"], + crate_types=target["crate_types"], + name=target["name"], + src_path=target["src_path"], + edition=target["edition"], + required_features=target.get("required-features"), + doctest=target["doctest"], + test=target.get("test"), + ) + + +def _package_dict_to_struct(package): + dependencies = [_dependency_dict_to_struct(dep) for dep in package["dependencies"]] + targets = [_target_dict_to_struct(target) for target in package["targets"]] + + return struct( + name=package["name"], + version=package["version"], + id=package["id"], + license=package["license"], + license_file=package["license_file"], + description=package["description"], + source=package["source"], + dependencies=dependencies, + targets=targets, + features=package["features"], + manifest_path=package["manifest_path"], + metadata=package["metadata"], + publish=package["publish"], + authors=package["authors"], + categories=package["categories"], + keywords=package["keywords"], + readme=package["readme"], + repository=package["repository"], + edition=package["edition"], + links=package["links"], + ) + + +def _metadata_dict_to_struct(metadata): + packages = dict() + for raw_package in metadata["packages"]: + package = _package_dict_to_struct(raw_package) + packages[package.id] = package + + return struct( + version=metadata["version"], + root=metadata["workspace_root"], + target_dir=metadata["target_directory"], + member_ids=metadata["workspace_members"], + packages=packages, + ) + + +def cargo_metadata(manifest): + requested_version = 1 # only valid value at time of writing + metadata = _metadata_dict_to_struct( + json_decode( # TODO json.decode from starlark spec + command( + "cargo", # TODO get this from a specified toolchain + [ + "metadata", + "--format-version", + requested_version, + "--manifest-path", + manifest, + ], + ) + .run() + .stdout() + ) + ) + + if metadata.version != requested_version: + fail(msg="Got metadata v" + version + ", expected v" + requested_version) + + return metadata From 459dc0155e825384d13c1899d03f930606edf828 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 8 Nov 2020 16:31:54 -0800 Subject: [PATCH 18/73] [honk] reorder target fields to improve readability --- honk/rules/rust/metadata.honk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/honk/rules/rust/metadata.honk b/honk/rules/rust/metadata.honk index 4beb76767..00e90cc66 100644 --- a/honk/rules/rust/metadata.honk +++ b/honk/rules/rust/metadata.honk @@ -18,9 +18,9 @@ def _dependency_dict_to_struct(dep): def _target_dict_to_struct(target): return struct( + name=target["name"], kind=target["kind"], crate_types=target["crate_types"], - name=target["name"], src_path=target["src_path"], edition=target["edition"], required_features=target.get("required-features"), From ee3dee7b0a4f739675d64c17dcf84bfbfb395e83 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 14 Nov 2020 11:03:05 -0800 Subject: [PATCH 19/73] [honk] stub out cargo target discovery --- honk/rules/rust.honk | 45 +++++++++++++++++++++++++++++++--- honk/rules/rust/clippy.honk | 5 ++++ honk/rules/rust/rustfmt.honk | 6 +++++ honk/rules/rust/wasm-pack.honk | 11 +++++++++ 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 honk/rules/rust/clippy.honk create mode 100644 honk/rules/rust/rustfmt.honk create mode 100644 honk/rules/rust/wasm-pack.honk diff --git a/honk/rules/rust.honk b/honk/rules/rust.honk index d960f244a..45611b571 100644 --- a/honk/rules/rust.honk +++ b/honk/rules/rust.honk @@ -1,8 +1,47 @@ +load("//honk/rules/rust/clippy.honk", "lint_crate") load("//honk/rules/rust/metadata.honk", "cargo_metadata") +load("//honk/rules/rust/rustfmt.honk", "format_crate") +load("//honk/rules/rust/wasm-pack.honk", "maybe_wasm_crate") + + +def test_crate(package): + """ + Run `cargo test --all-targets -p ${package}`. + """ + fail(msg="TODO define tests") + + +def doctest_crate(package): + """ + Run `cargo test --doc -p ${package}`. + """ + fail(msg="TODO define doctests") + + +def document_crate(package): + """ + Run `cargo doc --no-deps -p ${package}`. + """ + fail(msg="TODO define documentation") + -# Discovers targets from a Cargo workspace, defined by the path to its root manifest. def cargo_workspace(manifest): + """ + Discovers targets from a Cargo workspace, defined by the path to its root ${manifest}. + """ metadata = cargo_metadata(manifest) - for id in metadata.member_ids: - fail(msg=id) + package = metadata.packages[id] + + # mutators + format_crate(package) + + # assets + # TODO discover binary targets for `honk run` + maybe_wasm_crate(package) + document_crate(package) + + # "tests" + test_crate(package) + doctest_crate(package) + lint_crate(package) diff --git a/honk/rules/rust/clippy.honk b/honk/rules/rust/clippy.honk new file mode 100644 index 000000000..965feecd8 --- /dev/null +++ b/honk/rules/rust/clippy.honk @@ -0,0 +1,5 @@ +def lint_crate(package): + """ + Run clippy on ${package}. + """ + fail(msg="TODO define clippy") diff --git a/honk/rules/rust/rustfmt.honk b/honk/rules/rust/rustfmt.honk new file mode 100644 index 000000000..6603d6e7d --- /dev/null +++ b/honk/rules/rust/rustfmt.honk @@ -0,0 +1,6 @@ +def format_crate(package, check=False): + """ + Runs `rustfmt --edition ${package.edition} [--check] ${target.src_path}` for each target + in ${package}. + """ + fail(msg="TODO define rustfmt") diff --git a/honk/rules/rust/wasm-pack.honk b/honk/rules/rust/wasm-pack.honk new file mode 100644 index 000000000..11665e36e --- /dev/null +++ b/honk/rules/rust/wasm-pack.honk @@ -0,0 +1,11 @@ +def has_wasm_tests(package): + fail(msg="TODO check for wasm-bindgen-test") + + +def wasm_bindgen_test(package): + fail(msg="TODO define wasm-pack testing") + + +def maybe_wasm_crate(package): + if has_wasm_tests(package): + wasm_bindgen_test(package) From a1b661b47f039ce9c8de58012ba3031004bd82d8 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 22 Nov 2020 08:55:54 -0800 Subject: [PATCH 20/73] [honk] move noisy logs to debug --- honk/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index f6397a672..6dd628e1f 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -8,7 +8,7 @@ use std::{ path::{Path, PathBuf}, sync::{Arc, Mutex}, }; -use tracing::{error, info, instrument, warn}; +use tracing::{debug, error, info, instrument, warn}; mod builtins; mod error; @@ -71,7 +71,7 @@ impl FileLoader for Workspace { fn load(&self, path: &str, type_values: &TypeValues) -> Result { // TODO smarter way to resolve assets etc let file = self.root.join(path.strip_prefix("//").unwrap_or(path)); - info!(file = %file.display(), "loading"); + debug!(file = %file.display(), "loading"); let root_contents = self.vfs.read(&file).expect("TODO pass errors back correctly here"); let root_contents = @@ -81,7 +81,7 @@ impl FileLoader for Workspace { // TODO figure out how to do this once instead of here *and* above in `new()`? builtins::register(&mut env, &mut throwaway_tvs); - info!("evaluating"); + debug!("evaluating"); starlark::eval::eval( &self.codemap, &file.to_string_lossy(), From 5e5fe7a95e67eb7372ffa63dd923893f5c54a838 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 22 Nov 2020 08:56:36 -0800 Subject: [PATCH 21/73] [honk] add todo --- workspace.honk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/workspace.honk b/workspace.honk index fa74648ec..65960e858 100644 --- a/workspace.honk +++ b/workspace.honk @@ -1,3 +1,5 @@ load("//honk/rules/rust.honk", "cargo_workspace") cargo_workspace(manifest="./Cargo.toml") + +# TODO specify website construction & HTTP server From 64275024312873f8b34de230127d1aaed04db642 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 22 Nov 2020 08:57:31 -0800 Subject: [PATCH 22/73] [honk] stub out formatting --- honk/rules/rust/metadata.honk | 8 ++++++++ honk/rules/rust/rustfmt.honk | 15 ++++++++++++++- honk/src/builtins.rs | 2 ++ honk/src/builtins/formatter.rs | 8 ++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 honk/src/builtins/formatter.rs diff --git a/honk/rules/rust/metadata.honk b/honk/rules/rust/metadata.honk index 00e90cc66..51d3b766a 100644 --- a/honk/rules/rust/metadata.honk +++ b/honk/rules/rust/metadata.honk @@ -29,6 +29,14 @@ def _target_dict_to_struct(target): ) +def rust_files_in_target(manifest_path, target): + files = set() + + # TODO glob the files + + return files + + def _package_dict_to_struct(package): dependencies = [_dependency_dict_to_struct(dep) for dep in package["dependencies"]] targets = [_target_dict_to_struct(target) for target in package["targets"]] diff --git a/honk/rules/rust/rustfmt.honk b/honk/rules/rust/rustfmt.honk index 6603d6e7d..4a38ca8be 100644 --- a/honk/rules/rust/rustfmt.honk +++ b/honk/rules/rust/rustfmt.honk @@ -1,6 +1,19 @@ +load("//honk/rules/rust/metadata.honk", "rust_files_in_target") + + def format_crate(package, check=False): """ Runs `rustfmt --edition ${package.edition} [--check] ${target.src_path}` for each target in ${package}. """ - fail(msg="TODO define rustfmt") + + args = ["--edition", package.edition] + if check: + args += "--check" + + for target in package.targets: + formatter( + name="format-" + package.name + "-" + target.name, + command=command("rustfmt", args + [target.src_path]), + affected=rust_files_in_target(package.manifest_path, target), + ) diff --git a/honk/src/builtins.rs b/honk/src/builtins.rs index 9fee97a6e..0c8b0770e 100644 --- a/honk/src/builtins.rs +++ b/honk/src/builtins.rs @@ -18,9 +18,11 @@ macro_rules! starlark_module { } pub mod command; +pub mod formatter; pub mod json; pub fn register(env: &mut Environment, tvs: &mut TypeValues) { command::globals(env, tvs); + formatter::globals(env, tvs); json::globals(env, tvs); } diff --git a/honk/src/builtins/formatter.rs b/honk/src/builtins/formatter.rs new file mode 100644 index 000000000..2895c8a58 --- /dev/null +++ b/honk/src/builtins/formatter.rs @@ -0,0 +1,8 @@ +use crate::builtins::command::Command; +use starlark::values::Value; + +starlark_module! { globals => + formatter(name: String, command: Command, affected: Value) { + todo!() + } +} From aa60394739224d80160116b91db7e96fa3ea730e Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 22 Nov 2020 12:12:28 -0800 Subject: [PATCH 23/73] [honk] capture spantraces --- honk/Cargo.lock | 1 + honk/Cargo.toml | 1 + honk/src/main.rs | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/honk/Cargo.lock b/honk/Cargo.lock index faf0e0095..c57ba9491 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -458,6 +458,7 @@ dependencies = [ "starlark", "thiserror", "tracing", + "tracing-error", "tracing-subscriber", ] diff --git a/honk/Cargo.toml b/honk/Cargo.toml index 6926edbaf..5f4b530ff 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -24,4 +24,5 @@ serde_json = "1.0.59" starlark = "0.3.1" thiserror = "1.0.21" tracing = "0.1.21" +tracing-error = "0.1.2" tracing-subscriber = { version = "0.2.15", features = ["fmt"] } diff --git a/honk/src/main.rs b/honk/src/main.rs index 18275df8b..50aabf1b3 100644 --- a/honk/src/main.rs +++ b/honk/src/main.rs @@ -1,6 +1,7 @@ use argh::FromArgs; use honk::Workspace; use std::path::PathBuf; +use tracing_subscriber::Layer; /// An awful billed system. #[derive(Debug, FromArgs)] @@ -11,7 +12,9 @@ struct HonkCli { } fn main() -> color_eyre::eyre::Result<()> { - tracing_subscriber::fmt::fmt().pretty().init(); + let subscriber = tracing_error::ErrorLayer::default() + .with_subscriber(tracing_subscriber::fmt::fmt().pretty().finish()); + tracing::subscriber::set_global_default(subscriber)?; color_eyre::install()?; let HonkCli { workspace } = argh::from_env(); Workspace::new(workspace).maintain() From 848271603712deab3b1a460b99c46bbf8e6169c8 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Thu, 26 Nov 2020 07:38:14 -0800 Subject: [PATCH 24/73] [honk] refactor cargo_metadata function --- honk/rules/rust/metadata.honk | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/honk/rules/rust/metadata.honk b/honk/rules/rust/metadata.honk index 51d3b766a..2bd136934 100644 --- a/honk/rules/rust/metadata.honk +++ b/honk/rules/rust/metadata.honk @@ -82,22 +82,20 @@ def _metadata_dict_to_struct(metadata): def cargo_metadata(manifest): requested_version = 1 # only valid value at time of writing - metadata = _metadata_dict_to_struct( - json_decode( # TODO json.decode from starlark spec - command( - "cargo", # TODO get this from a specified toolchain - [ - "metadata", - "--format-version", - requested_version, - "--manifest-path", - manifest, - ], - ) - .run() - .stdout() - ) + metadata_command = command( + "cargo", # TODO get this from a specified toolchain + [ + "metadata", + "--format-version", + requested_version, + "--manifest-path", + manifest, + ], ) + command_output = metadata_command.run().stdout() + # TODO json.decode from starlark spec + decoded = json_decode(command_output) + metadata = _metadata_dict_to_struct(decoded) if metadata.version != requested_version: fail(msg="Got metadata v" + version + ", expected v" + requested_version) From 50c37d713b3c3c1e6832ee94e78dc71bdd3e24c9 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Thu, 26 Nov 2020 07:59:05 -0800 Subject: [PATCH 25/73] [honk] change formatter panic stub to warning stub --- honk/src/builtins/formatter.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/honk/src/builtins/formatter.rs b/honk/src/builtins/formatter.rs index 2895c8a58..06b255835 100644 --- a/honk/src/builtins/formatter.rs +++ b/honk/src/builtins/formatter.rs @@ -1,8 +1,9 @@ use crate::builtins::command::Command; -use starlark::values::Value; +use starlark::values::{none::NoneType, Value}; starlark_module! { globals => formatter(name: String, command: Command, affected: Value) { - todo!() + tracing::warn!(%name, ?command, "TODO implement formatters"); + Ok(Value::new(NoneType::None)) } } From d88ea4766840a3248dae56f54e898adda7ba55a9 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Thu, 26 Nov 2020 08:00:02 -0800 Subject: [PATCH 26/73] [honk] stub out input tracking for commands --- honk/rules/rust/metadata.honk | 7 ++++++- honk/src/builtins/command.rs | 13 +++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/honk/rules/rust/metadata.honk b/honk/rules/rust/metadata.honk index 2bd136934..0ef141447 100644 --- a/honk/rules/rust/metadata.honk +++ b/honk/rules/rust/metadata.honk @@ -82,15 +82,20 @@ def _metadata_dict_to_struct(metadata): def cargo_metadata(manifest): requested_version = 1 # only valid value at time of writing + + metadata_inputs = [] + # TODO glob for Cargo.toml and all auto-target files + metadata_command = command( "cargo", # TODO get this from a specified toolchain - [ + args=[ "metadata", "--format-version", requested_version, "--manifest-path", manifest, ], + inputs=metadata_inputs, ) command_output = metadata_command.run().stdout() # TODO json.decode from starlark spec diff --git a/honk/src/builtins/command.rs b/honk/src/builtins/command.rs index b2f154058..5b032f253 100644 --- a/honk/src/builtins/command.rs +++ b/honk/src/builtins/command.rs @@ -2,10 +2,13 @@ use crate::error::Error; use starlark::values::{TypedValue, Value}; use tracing::instrument; +// TODO define an actual asset type that can be linked to vfs +type Asset = Value; + starlark_module! { globals => - command(command: String, args: Vec) { + command(command: String, args: Vec, inputs: Vec = vec![]) { let args = args.iter().map(Value::to_str).collect(); - Ok(Value::new(Command::new(command, args))) + Ok(Value::new(Command::new(command, args, inputs))) } Command.run(this: Command) { @@ -21,15 +24,17 @@ starlark_module! { globals => pub struct Command { command: String, args: Vec, + inputs: Vec, } impl Command { - pub fn new(command: String, args: Vec) -> Self { - Self { command, args } + pub fn new(command: String, args: Vec, inputs: Vec) -> Self { + Self { command, args, inputs } } #[instrument] pub fn run(self) -> Result { + // TODO read file metadata for inputs from vfs let output = Output { // TODO set working dir // TODO set environment From a48d32ff212186a87cc475b2806caa033d414b1e Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Thu, 26 Nov 2020 08:03:17 -0800 Subject: [PATCH 27/73] [honk] s/rust rules/cargo rules/ --- honk/rules/{rust => cargo}/clippy.honk | 0 honk/rules/{rust => cargo}/metadata.honk | 0 honk/rules/{rust => cargo}/rustfmt.honk | 2 +- honk/rules/{rust => cargo}/wasm-pack.honk | 0 honk/rules/{rust.honk => cargo/workspace.honk} | 8 ++++---- honk/src/lib.rs | 1 + workspace.honk | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) rename honk/rules/{rust => cargo}/clippy.honk (100%) rename honk/rules/{rust => cargo}/metadata.honk (100%) rename honk/rules/{rust => cargo}/rustfmt.honk (88%) rename honk/rules/{rust => cargo}/wasm-pack.honk (100%) rename honk/rules/{rust.honk => cargo/workspace.honk} (80%) diff --git a/honk/rules/rust/clippy.honk b/honk/rules/cargo/clippy.honk similarity index 100% rename from honk/rules/rust/clippy.honk rename to honk/rules/cargo/clippy.honk diff --git a/honk/rules/rust/metadata.honk b/honk/rules/cargo/metadata.honk similarity index 100% rename from honk/rules/rust/metadata.honk rename to honk/rules/cargo/metadata.honk diff --git a/honk/rules/rust/rustfmt.honk b/honk/rules/cargo/rustfmt.honk similarity index 88% rename from honk/rules/rust/rustfmt.honk rename to honk/rules/cargo/rustfmt.honk index 4a38ca8be..cc2e12cd7 100644 --- a/honk/rules/rust/rustfmt.honk +++ b/honk/rules/cargo/rustfmt.honk @@ -1,4 +1,4 @@ -load("//honk/rules/rust/metadata.honk", "rust_files_in_target") +load("//honk/rules/cargo/metadata.honk", "rust_files_in_target") def format_crate(package, check=False): diff --git a/honk/rules/rust/wasm-pack.honk b/honk/rules/cargo/wasm-pack.honk similarity index 100% rename from honk/rules/rust/wasm-pack.honk rename to honk/rules/cargo/wasm-pack.honk diff --git a/honk/rules/rust.honk b/honk/rules/cargo/workspace.honk similarity index 80% rename from honk/rules/rust.honk rename to honk/rules/cargo/workspace.honk index 45611b571..96fb3b192 100644 --- a/honk/rules/rust.honk +++ b/honk/rules/cargo/workspace.honk @@ -1,7 +1,7 @@ -load("//honk/rules/rust/clippy.honk", "lint_crate") -load("//honk/rules/rust/metadata.honk", "cargo_metadata") -load("//honk/rules/rust/rustfmt.honk", "format_crate") -load("//honk/rules/rust/wasm-pack.honk", "maybe_wasm_crate") +load("//honk/rules/cargo/clippy.honk", "lint_crate") +load("//honk/rules/cargo/metadata.honk", "cargo_metadata") +load("//honk/rules/cargo/rustfmt.honk", "format_crate") +load("//honk/rules/cargo/wasm-pack.honk", "maybe_wasm_crate") def test_crate(package): diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 6dd628e1f..be5f1e86a 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -70,6 +70,7 @@ impl FileLoader for Workspace { #[instrument(skip(self, type_values))] fn load(&self, path: &str, type_values: &TypeValues) -> Result { // TODO smarter way to resolve assets etc + // TODO handle relative paths somehow? let file = self.root.join(path.strip_prefix("//").unwrap_or(path)); debug!(file = %file.display(), "loading"); diff --git a/workspace.honk b/workspace.honk index 65960e858..03a22b762 100644 --- a/workspace.honk +++ b/workspace.honk @@ -1,4 +1,4 @@ -load("//honk/rules/rust.honk", "cargo_workspace") +load("//honk/rules/cargo/workspace.honk", "cargo_workspace") cargo_workspace(manifest="./Cargo.toml") From 7427c7323dd5c232bb64f7a89136b43d90520626 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Fri, 27 Nov 2020 08:51:50 -0800 Subject: [PATCH 28/73] [honk] stub out browser-tests metadata --- dom/Cargo.toml | 3 +++ dom/augdom/Cargo.toml | 3 +++ dom/examples/drivertest/Cargo.toml | 3 +++ dom/examples/hacking/Cargo.toml | 3 +++ dom/examples/todo/Cargo.toml | 3 +++ dom/prettiest/Cargo.toml | 3 +++ honk/rules/cargo/metadata.honk | 14 ++++++++++++++ honk/rules/cargo/wasm-pack.honk | 12 ++---------- 8 files changed, 34 insertions(+), 10 deletions(-) diff --git a/dom/Cargo.toml b/dom/Cargo.toml index 9bbbfc0c2..f5e6e14c1 100644 --- a/dom/Cargo.toml +++ b/dom/Cargo.toml @@ -17,6 +17,9 @@ edition = "2018" default-target = "wasm32-unknown-unknown" all-features = true +[package.metadata.honk] +browser-tests = true + [lib] crate-type = [ "cdylib", "rlib", ] diff --git a/dom/augdom/Cargo.toml b/dom/augdom/Cargo.toml index 16736445f..94e3f543f 100644 --- a/dom/augdom/Cargo.toml +++ b/dom/augdom/Cargo.toml @@ -17,6 +17,9 @@ edition = "2018" default-target = "wasm32-unknown-unknown" all-features = true +[package.metadata.honk] +browser-tests = true + [features] default = ["webdom"] rsdom = ["illicit"] diff --git a/dom/examples/drivertest/Cargo.toml b/dom/examples/drivertest/Cargo.toml index 6a6944858..cdcc53e76 100644 --- a/dom/examples/drivertest/Cargo.toml +++ b/dom/examples/drivertest/Cargo.toml @@ -5,6 +5,9 @@ version = "0.1.0" authors = ["Adam Perry "] edition = "2018" +[package.metadata.honk] +browser-tests = true + [package.metadata.wasm-pack.profile.release] wasm-opt = false diff --git a/dom/examples/hacking/Cargo.toml b/dom/examples/hacking/Cargo.toml index d72822c98..bb9b2c098 100644 --- a/dom/examples/hacking/Cargo.toml +++ b/dom/examples/hacking/Cargo.toml @@ -7,6 +7,9 @@ edition = "2018" license-file = "../../../../LICENSE-MIT" repository = "https://github.com/anp/moxie.git" +[package.metadata.honk] +browser-tests = true + [package.metadata.wasm-pack.profile.release] wasm-opt = false diff --git a/dom/examples/todo/Cargo.toml b/dom/examples/todo/Cargo.toml index db34d64c4..f2daac302 100644 --- a/dom/examples/todo/Cargo.toml +++ b/dom/examples/todo/Cargo.toml @@ -7,6 +7,9 @@ edition = "2018" license-file = "../../../../LICENSE-MIT" repository = "https://github.com/anp/moxie.git" +[package.metadata.honk] +browser-tests = true + [package.metadata.wasm-pack.profile.release] wasm-opt = false diff --git a/dom/prettiest/Cargo.toml b/dom/prettiest/Cargo.toml index 834774224..f5b6f4fce 100644 --- a/dom/prettiest/Cargo.toml +++ b/dom/prettiest/Cargo.toml @@ -13,6 +13,9 @@ repository = "https://github.com/anp/moxie.git" authors = ["Adam Perry "] edition = "2018" +[package.metadata.honk] +browser-tests = true + [dependencies] js-sys = "0.3.25" scopeguard = "1.1.0" diff --git a/honk/rules/cargo/metadata.honk b/honk/rules/cargo/metadata.honk index 0ef141447..cb3dc9cfb 100644 --- a/honk/rules/cargo/metadata.honk +++ b/honk/rules/cargo/metadata.honk @@ -37,6 +37,19 @@ def rust_files_in_target(manifest_path, target): return files +def _custom_honk_metadata(package): + browser_tests = False + metadata = package.get("metadata") + if metadata: + honk_metadata = metadata.get("honk") + if honk_metadata and honk_metadata.get("browser-tests"): + browser_tests = True + + return struct( + browser_tests=browser_tests, + ) + + def _package_dict_to_struct(package): dependencies = [_dependency_dict_to_struct(dep) for dep in package["dependencies"]] targets = [_target_dict_to_struct(target) for target in package["targets"]] @@ -62,6 +75,7 @@ def _package_dict_to_struct(package): repository=package["repository"], edition=package["edition"], links=package["links"], + honk=_custom_honk_metadata(package), ) diff --git a/honk/rules/cargo/wasm-pack.honk b/honk/rules/cargo/wasm-pack.honk index 11665e36e..06c096a3b 100644 --- a/honk/rules/cargo/wasm-pack.honk +++ b/honk/rules/cargo/wasm-pack.honk @@ -1,11 +1,3 @@ -def has_wasm_tests(package): - fail(msg="TODO check for wasm-bindgen-test") - - -def wasm_bindgen_test(package): - fail(msg="TODO define wasm-pack testing") - - def maybe_wasm_crate(package): - if has_wasm_tests(package): - wasm_bindgen_test(package) + if package.honk.browser_tests: + fail("TODO define wasm-bindgen-test stuff for %s" % package.name) From cb95695797d7ca972252a5beda65103139689fee Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 28 Nov 2020 09:37:22 -0800 Subject: [PATCH 29/73] [honk] convert wasm funciton to a stub without failure --- honk/rules/cargo/wasm-pack.honk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/honk/rules/cargo/wasm-pack.honk b/honk/rules/cargo/wasm-pack.honk index 06c096a3b..bdf5ea306 100644 --- a/honk/rules/cargo/wasm-pack.honk +++ b/honk/rules/cargo/wasm-pack.honk @@ -1,3 +1,5 @@ def maybe_wasm_crate(package): + # TODO figure out a way to define wasm "binary" targets for wasm-pack if package.honk.browser_tests: - fail("TODO define wasm-bindgen-test stuff for %s" % package.name) + # TODO define wasm-bindgen-test stuff + pass From 99d23207a85b52e5f98f54a2a206c42e71c2fb9f Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 28 Nov 2020 09:55:45 -0800 Subject: [PATCH 30/73] [honk] stub out doc/test/lint targets --- honk/rules/cargo/clippy.honk | 12 +++++++++++- honk/rules/cargo/metadata.honk | 7 +++++++ honk/rules/cargo/workspace.honk | 26 ++++++++++++++++++++++---- honk/src/builtins.rs | 2 ++ honk/src/builtins/target.rs | 14 ++++++++++++++ 5 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 honk/src/builtins/target.rs diff --git a/honk/rules/cargo/clippy.honk b/honk/rules/cargo/clippy.honk index 965feecd8..682731173 100644 --- a/honk/rules/cargo/clippy.honk +++ b/honk/rules/cargo/clippy.honk @@ -1,5 +1,15 @@ +load("//honk/rules/cargo/metadata.honk", "rust_files_in_package") + + def lint_crate(package): """ Run clippy on ${package}. """ - fail(msg="TODO define clippy") + target( + name="lint-" + package.name, + command=command( + "cargo", + ["clippy", "--all-targets", "--all-features", "--package", package.name], + ), + inputs=rust_files_in_package(package), + ) diff --git a/honk/rules/cargo/metadata.honk b/honk/rules/cargo/metadata.honk index cb3dc9cfb..78a1ae693 100644 --- a/honk/rules/cargo/metadata.honk +++ b/honk/rules/cargo/metadata.honk @@ -37,6 +37,13 @@ def rust_files_in_target(manifest_path, target): return files +def rust_files_in_package(package): + files = set() + for target in package.targets: + files += rust_files_in_target(package.manifest_path, package.targets) + return files + + def _custom_honk_metadata(package): browser_tests = False metadata = package.get("metadata") diff --git a/honk/rules/cargo/workspace.honk b/honk/rules/cargo/workspace.honk index 96fb3b192..030ac751b 100644 --- a/honk/rules/cargo/workspace.honk +++ b/honk/rules/cargo/workspace.honk @@ -1,5 +1,5 @@ load("//honk/rules/cargo/clippy.honk", "lint_crate") -load("//honk/rules/cargo/metadata.honk", "cargo_metadata") +load("//honk/rules/cargo/metadata.honk", "cargo_metadata", "rust_files_in_package") load("//honk/rules/cargo/rustfmt.honk", "format_crate") load("//honk/rules/cargo/wasm-pack.honk", "maybe_wasm_crate") @@ -8,21 +8,39 @@ def test_crate(package): """ Run `cargo test --all-targets -p ${package}`. """ - fail(msg="TODO define tests") + target( + name="test-" + package.name, + command=command("cargo", ["test", "--all-targets", "--package", package.name]), + inputs=rust_files_in_package(package), + # TODO more granular output tracking somehow? + outputs=["target"], + ) def doctest_crate(package): """ Run `cargo test --doc -p ${package}`. """ - fail(msg="TODO define doctests") + target( + name="doctest-" + package.name, + command=command("cargo", ["test", "--doc", "--package", package.name]), + inputs=rust_files_in_package(package), + # TODO more granular output tracking somehow? + outputs=["target"], + ) def document_crate(package): """ Run `cargo doc --no-deps -p ${package}`. """ - fail(msg="TODO define documentation") + target( + name="rustdoc-" + package.name, + command=command("cargo", ["doc", "--no-deps", "--package", package.name]), + inputs=rust_files_in_package(package), + # TODO more granular output tracking somehow? + outputs=["target/doc"], + ) def cargo_workspace(manifest): diff --git a/honk/src/builtins.rs b/honk/src/builtins.rs index 0c8b0770e..5fce2c7c3 100644 --- a/honk/src/builtins.rs +++ b/honk/src/builtins.rs @@ -20,9 +20,11 @@ macro_rules! starlark_module { pub mod command; pub mod formatter; pub mod json; +pub mod target; pub fn register(env: &mut Environment, tvs: &mut TypeValues) { command::globals(env, tvs); formatter::globals(env, tvs); json::globals(env, tvs); + target::globals(env, tvs); } diff --git a/honk/src/builtins/target.rs b/honk/src/builtins/target.rs new file mode 100644 index 000000000..560a2040f --- /dev/null +++ b/honk/src/builtins/target.rs @@ -0,0 +1,14 @@ +use crate::builtins::command::Command; +use starlark::values::{none::NoneType, Value}; + +starlark_module! { globals => + target( + name: String, + command: Command, + inputs: Value, + outputs: Value = Value::new(NoneType::None) + ) { + tracing::warn!(%name, ?command, "TODO implement targets"); + Ok(Value::new(NoneType::None)) + } +} From ae43d112162ac69c77f9f6f2f90b44a2758e3d32 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 28 Nov 2020 11:23:08 -0800 Subject: [PATCH 31/73] [honk] track inputs/outputs on commands, not actions --- honk/rules/cargo/clippy.honk | 10 ++++++++-- honk/rules/cargo/rustfmt.honk | 7 +++++-- honk/rules/cargo/workspace.honk | 33 +++++++++++++++++++++------------ honk/src/builtins/command.rs | 7 ++++++- honk/src/builtins/formatter.rs | 2 +- honk/src/builtins/target.rs | 7 +------ honk/src/lib.rs | 1 + 7 files changed, 43 insertions(+), 24 deletions(-) diff --git a/honk/rules/cargo/clippy.honk b/honk/rules/cargo/clippy.honk index 682731173..cb8a36c6c 100644 --- a/honk/rules/cargo/clippy.honk +++ b/honk/rules/cargo/clippy.honk @@ -9,7 +9,13 @@ def lint_crate(package): name="lint-" + package.name, command=command( "cargo", - ["clippy", "--all-targets", "--all-features", "--package", package.name], + args=[ + "clippy", + "--all-targets", + "--all-features", + "--package", + package.name, + ], + inputs=rust_files_in_package(package), ), - inputs=rust_files_in_package(package), ) diff --git a/honk/rules/cargo/rustfmt.honk b/honk/rules/cargo/rustfmt.honk index cc2e12cd7..ca3e213ee 100644 --- a/honk/rules/cargo/rustfmt.honk +++ b/honk/rules/cargo/rustfmt.honk @@ -14,6 +14,9 @@ def format_crate(package, check=False): for target in package.targets: formatter( name="format-" + package.name + "-" + target.name, - command=command("rustfmt", args + [target.src_path]), - affected=rust_files_in_target(package.manifest_path, target), + command=command( + "rustfmt", + args=args + [target.src_path], + inputs=rust_files_in_target(package.manifest_path, target), + ), ) diff --git a/honk/rules/cargo/workspace.honk b/honk/rules/cargo/workspace.honk index 030ac751b..f2a159d12 100644 --- a/honk/rules/cargo/workspace.honk +++ b/honk/rules/cargo/workspace.honk @@ -10,10 +10,13 @@ def test_crate(package): """ target( name="test-" + package.name, - command=command("cargo", ["test", "--all-targets", "--package", package.name]), - inputs=rust_files_in_package(package), - # TODO more granular output tracking somehow? - outputs=["target"], + command=command( + "cargo", + args=["test", "--all-targets", "--package", package.name], + inputs=rust_files_in_package(package), + # TODO more granular output tracking somehow? + outputs=["target"], + ), ) @@ -23,10 +26,13 @@ def doctest_crate(package): """ target( name="doctest-" + package.name, - command=command("cargo", ["test", "--doc", "--package", package.name]), - inputs=rust_files_in_package(package), - # TODO more granular output tracking somehow? - outputs=["target"], + command=command( + "cargo", + args=["test", "--doc", "--package", package.name], + inputs=rust_files_in_package(package), + # TODO more granular output tracking somehow? + outputs=["target"], + ), ) @@ -36,10 +42,13 @@ def document_crate(package): """ target( name="rustdoc-" + package.name, - command=command("cargo", ["doc", "--no-deps", "--package", package.name]), - inputs=rust_files_in_package(package), - # TODO more granular output tracking somehow? - outputs=["target/doc"], + command=command( + "cargo", + args=["doc", "--no-deps", "--package", package.name], + inputs=rust_files_in_package(package), + # TODO more granular output tracking somehow? + outputs=["target/doc"], + ), ) diff --git a/honk/src/builtins/command.rs b/honk/src/builtins/command.rs index 5b032f253..0f7cee97b 100644 --- a/honk/src/builtins/command.rs +++ b/honk/src/builtins/command.rs @@ -6,7 +6,12 @@ use tracing::instrument; type Asset = Value; starlark_module! { globals => - command(command: String, args: Vec, inputs: Vec = vec![]) { + command( + command: String, + args: Vec, + inputs: Vec = vec![], + outputs: Vec = vec![] + ) { let args = args.iter().map(Value::to_str).collect(); Ok(Value::new(Command::new(command, args, inputs))) } diff --git a/honk/src/builtins/formatter.rs b/honk/src/builtins/formatter.rs index 06b255835..ff050c950 100644 --- a/honk/src/builtins/formatter.rs +++ b/honk/src/builtins/formatter.rs @@ -2,7 +2,7 @@ use crate::builtins::command::Command; use starlark::values::{none::NoneType, Value}; starlark_module! { globals => - formatter(name: String, command: Command, affected: Value) { + formatter(name: String, command: Command) { tracing::warn!(%name, ?command, "TODO implement formatters"); Ok(Value::new(NoneType::None)) } diff --git a/honk/src/builtins/target.rs b/honk/src/builtins/target.rs index 560a2040f..63a62afcd 100644 --- a/honk/src/builtins/target.rs +++ b/honk/src/builtins/target.rs @@ -2,12 +2,7 @@ use crate::builtins::command::Command; use starlark::values::{none::NoneType, Value}; starlark_module! { globals => - target( - name: String, - command: Command, - inputs: Value, - outputs: Value = Value::new(NoneType::None) - ) { + target(name: String, command: Command) { tracing::warn!(%name, ?command, "TODO implement targets"); Ok(Value::new(NoneType::None)) } diff --git a/honk/src/lib.rs b/honk/src/lib.rs index be5f1e86a..4a31aa3b5 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -44,6 +44,7 @@ impl Workspace { } pub fn maintain(self) -> Result<()> { + // TODO change current directory to workspace root? info!("maintaining workspace"); loop { if let Err(error) = self.converge() { From d7d13eca0c653e32630bbd9d66473e85669b9e20 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 28 Nov 2020 11:31:47 -0800 Subject: [PATCH 32/73] [honk] add path module w/ glob support --- honk/Cargo.lock | 7 +++ honk/Cargo.toml | 1 + honk/rules/cargo/clippy.honk | 1 + honk/rules/cargo/metadata.honk | 24 +++++++--- honk/rules/cargo/rustfmt.honk | 4 +- honk/rules/cargo/workspace.honk | 9 ++-- honk/src/builtins.rs | 2 + honk/src/builtins/command.rs | 18 ++++---- honk/src/builtins/path.rs | 82 +++++++++++++++++++++++++++++++++ 9 files changed, 128 insertions(+), 20 deletions(-) create mode 100644 honk/src/builtins/path.rs diff --git a/honk/Cargo.lock b/honk/Cargo.lock index c57ba9491..2178ff9bc 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -426,6 +426,12 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + [[package]] name = "heck" version = "0.3.1" @@ -453,6 +459,7 @@ dependencies = [ "codemap-diagnostic", "color-eyre", "crossbeam-channel", + "glob", "memofs", "serde_json", "starlark", diff --git a/honk/Cargo.toml b/honk/Cargo.toml index 5f4b530ff..fbf004bf6 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -19,6 +19,7 @@ codemap = "0.1.3" codemap-diagnostic = "0.1.1" color-eyre = "0.5.6" crossbeam-channel = "0.4.0" +glob = "0.3.0" memofs = "0.1.2" serde_json = "1.0.59" starlark = "0.3.1" diff --git a/honk/rules/cargo/clippy.honk b/honk/rules/cargo/clippy.honk index cb8a36c6c..79ceede32 100644 --- a/honk/rules/cargo/clippy.honk +++ b/honk/rules/cargo/clippy.honk @@ -17,5 +17,6 @@ def lint_crate(package): package.name, ], inputs=rust_files_in_package(package), + outputs=[], ), ) diff --git a/honk/rules/cargo/metadata.honk b/honk/rules/cargo/metadata.honk index 78a1ae693..e463256d4 100644 --- a/honk/rules/cargo/metadata.honk +++ b/honk/rules/cargo/metadata.honk @@ -21,7 +21,7 @@ def _target_dict_to_struct(target): name=target["name"], kind=target["kind"], crate_types=target["crate_types"], - src_path=target["src_path"], + src_path=path(target["src_path"]), edition=target["edition"], required_features=target.get("required-features"), doctest=target["doctest"], @@ -30,17 +30,28 @@ def _target_dict_to_struct(target): def rust_files_in_target(manifest_path, target): - files = set() + """ + Defined in https://doc.rust-lang.org/cargo/guide/project-layout.html. + """ + crate_dir = manifest_path.parent() + files = [] + bin_files = crate_dir.glob("src/bin/**/*.rs") + for file in crate_dir.glob("src/**/*.rs"): + if file not in bin_files: + files.append(file) - # TODO glob the files + if target.src_path.filename() == "main.rs": + files.extend(target.src_path.parent().glob("**/*.rs")) + else: + files.append(target.src_path) - return files + return set(files) def rust_files_in_package(package): files = set() for target in package.targets: - files += rust_files_in_target(package.manifest_path, package.targets) + files += rust_files_in_target(package.manifest_path, target) return files @@ -72,7 +83,7 @@ def _package_dict_to_struct(package): dependencies=dependencies, targets=targets, features=package["features"], - manifest_path=package["manifest_path"], + manifest_path=path(package["manifest_path"]), metadata=package["metadata"], publish=package["publish"], authors=package["authors"], @@ -117,6 +128,7 @@ def cargo_metadata(manifest): manifest, ], inputs=metadata_inputs, + outputs=[], ) command_output = metadata_command.run().stdout() # TODO json.decode from starlark spec diff --git a/honk/rules/cargo/rustfmt.honk b/honk/rules/cargo/rustfmt.honk index ca3e213ee..6aa455129 100644 --- a/honk/rules/cargo/rustfmt.honk +++ b/honk/rules/cargo/rustfmt.honk @@ -12,11 +12,13 @@ def format_crate(package, check=False): args += "--check" for target in package.targets: + target_files = rust_files_in_target(package.manifest_path, target) formatter( name="format-" + package.name + "-" + target.name, command=command( "rustfmt", args=args + [target.src_path], - inputs=rust_files_in_target(package.manifest_path, target), + inputs=target_files, + outputs=target_files, ), ) diff --git a/honk/rules/cargo/workspace.honk b/honk/rules/cargo/workspace.honk index f2a159d12..b5ed87516 100644 --- a/honk/rules/cargo/workspace.honk +++ b/honk/rules/cargo/workspace.honk @@ -15,7 +15,8 @@ def test_crate(package): args=["test", "--all-targets", "--package", package.name], inputs=rust_files_in_package(package), # TODO more granular output tracking somehow? - outputs=["target"], + # TODO automagically convert strings for inputs/outputs + outputs=[path("target")], ), ) @@ -31,7 +32,8 @@ def doctest_crate(package): args=["test", "--doc", "--package", package.name], inputs=rust_files_in_package(package), # TODO more granular output tracking somehow? - outputs=["target"], + # TODO automagically convert strings for inputs/outputs + outputs=[path("target")], ), ) @@ -47,7 +49,8 @@ def document_crate(package): args=["doc", "--no-deps", "--package", package.name], inputs=rust_files_in_package(package), # TODO more granular output tracking somehow? - outputs=["target/doc"], + # TODO automagically convert strings for inputs/outputs + outputs=[path("target/doc")], ), ) diff --git a/honk/src/builtins.rs b/honk/src/builtins.rs index 5fce2c7c3..87cf97997 100644 --- a/honk/src/builtins.rs +++ b/honk/src/builtins.rs @@ -20,11 +20,13 @@ macro_rules! starlark_module { pub mod command; pub mod formatter; pub mod json; +pub mod path; pub mod target; pub fn register(env: &mut Environment, tvs: &mut TypeValues) { command::globals(env, tvs); formatter::globals(env, tvs); json::globals(env, tvs); + path::globals(env, tvs); target::globals(env, tvs); } diff --git a/honk/src/builtins/command.rs b/honk/src/builtins/command.rs index 0f7cee97b..f7ca4cec7 100644 --- a/honk/src/builtins/command.rs +++ b/honk/src/builtins/command.rs @@ -1,19 +1,16 @@ -use crate::error::Error; +use crate::{builtins::path::Path, error::Error}; use starlark::values::{TypedValue, Value}; use tracing::instrument; -// TODO define an actual asset type that can be linked to vfs -type Asset = Value; - starlark_module! { globals => command( command: String, args: Vec, - inputs: Vec = vec![], - outputs: Vec = vec![] + inputs: Vec, + outputs: Vec ) { let args = args.iter().map(Value::to_str).collect(); - Ok(Value::new(Command::new(command, args, inputs))) + Ok(Value::new(Command::new(command, args, inputs, outputs))) } Command.run(this: Command) { @@ -29,12 +26,13 @@ starlark_module! { globals => pub struct Command { command: String, args: Vec, - inputs: Vec, + inputs: Vec, + outputs: Vec, } impl Command { - pub fn new(command: String, args: Vec, inputs: Vec) -> Self { - Self { command, args, inputs } + pub fn new(command: String, args: Vec, inputs: Vec, outputs: Vec) -> Self { + Self { command, args, inputs, outputs } } #[instrument] diff --git a/honk/src/builtins/path.rs b/honk/src/builtins/path.rs new file mode 100644 index 000000000..bc8173b9d --- /dev/null +++ b/honk/src/builtins/path.rs @@ -0,0 +1,82 @@ +use starlark::values::{error::ValueError, list::List, none::NoneType, TypedValue, Value}; +use std::{ + hash::{Hash, Hasher}, + path::PathBuf, +}; + +starlark_module! { globals => + path(p: String) { + Ok(Value::new(Path::new(PathBuf::from(p)))) + } + + Path.parent(this: Path) { + Ok(opt_typed_val(this.parent())) + } + + Path.filename(this: Path) { + Ok(opt_typed_val(this.filename())) + } + + Path.glob(this: Path, pattern: String) { + Ok(Value::new(this.glob(&pattern))) + } +} + +fn opt_typed_val(v: Option) -> Value { + if let Some(v) = v { Value::new(v) } else { Value::new(NoneType::None) } +} + +#[derive(Clone, Debug, Hash)] +pub struct Path { + inner: PathBuf, +} + +impl Path { + fn new(inner: PathBuf) -> Self { + Self { inner } + } + + fn parent(&self) -> Option { + self.inner.parent().map(|p| Self { inner: p.to_path_buf() }) + } + + fn filename(&self) -> Option { + self.inner.file_name().map(|n| n.to_string_lossy().to_string()) + } + + // TODO return a Set once exposed from starlark crate + fn glob(&self, pattern: &str) -> List { + let mut results = List::default(); + // FIXME this might be a broken way to do globs "scoped" to a parent path? + let full_pattern = self.inner.to_string_lossy() + "/" + pattern; + + // TODO glob against the vfs + for entry in glob::glob(&full_pattern).expect("must pass a valid glob") { + let matched = Path::new(entry.unwrap()); + results.push(Value::new(matched)).unwrap(); + } + + results + } +} + +impl TypedValue for Path { + type Holder = starlark::values::Immutable; + + const TYPE: &'static str = "Path"; + + fn values_for_descendant_check_and_freeze(&self) -> Box + '_> { + Box::new(std::iter::empty()) + } + + fn get_hash(&self) -> Result { + let mut hasher = std::collections::hash_map::DefaultHasher::new(); + self.hash(&mut hasher); + Ok(hasher.finish()) + } + + fn to_repr_impl(&self, buf: &mut String) -> std::fmt::Result { + buf.push_str(&self.inner.to_string_lossy()); + Ok(()) + } +} From 86994a8f16703df07ef48e6c3d190f1c0b100987 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 5 Dec 2020 10:51:15 -0800 Subject: [PATCH 33/73] [honk] add metadata command's inputs wow thats slowwww --- .cargo/config.toml | 2 +- honk/rules/cargo/metadata.honk | 19 +++++++++++++++++-- honk/src/builtins/path.rs | 30 ++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 00a7b742b..3dcd3a396 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -130,4 +130,4 @@ docs-ofl = "doc --manifest-path ofl/Cargo.toml --workspace --no-deps" #################################################################################################### # honk -honk = "run --manifest-path honk/Cargo.toml --" +honk = "run --manifest-path honk/Cargo.toml --release --" diff --git a/honk/rules/cargo/metadata.honk b/honk/rules/cargo/metadata.honk index e463256d4..1a39f432e 100644 --- a/honk/rules/cargo/metadata.honk +++ b/honk/rules/cargo/metadata.honk @@ -115,8 +115,23 @@ def _metadata_dict_to_struct(metadata): def cargo_metadata(manifest): requested_version = 1 # only valid value at time of writing - metadata_inputs = [] - # TODO glob for Cargo.toml and all auto-target files + metadata_inputs = honk_root().glob("**/Cargo.toml") + for cargo_toml in list(metadata_inputs): + crate_root = cargo_toml.parent() + # TODO possible to do this without auto-targets from cargo? + # i think we'd have to parse toml ourselves + metadata_inputs.append(crate_root.join("src/lib.rs")) + + main_rs = crate_root.join("src/main.rs") + if main_rs.exists(): + metadata_inputs.append(main_rs) + + for other_dir in ["src/bin", "benches", "examples", "tests"]: + other_dir = path(other_dir) + metadata_inputs += other_dir.glob("*.rs") + metadata_inputs += other_dir.glob("*/main.rs") + + metadata_inputs += honk_root().glob("**/Cargo.lock") metadata_command = command( "cargo", # TODO get this from a specified toolchain diff --git a/honk/src/builtins/path.rs b/honk/src/builtins/path.rs index bc8173b9d..8b1f80142 100644 --- a/honk/src/builtins/path.rs +++ b/honk/src/builtins/path.rs @@ -5,10 +5,19 @@ use std::{ }; starlark_module! { globals => + honk_root() { + // TODO handle error here + Ok(Value::new(Path::new(std::env::current_dir().unwrap()))) + } + path(p: String) { Ok(Value::new(Path::new(PathBuf::from(p)))) } + Path.exists(this: Path) { + Ok(Value::new(this.exists())) + } + Path.parent(this: Path) { Ok(opt_typed_val(this.parent())) } @@ -17,6 +26,14 @@ starlark_module! { globals => Ok(opt_typed_val(this.filename())) } + Path.join(this: Path, to_join: String) { + Ok(Value::new(this.join(&to_join))) + } + + Path.canonicalize(this: Path) { + Ok(Value::new(this.canonicalize())) + } + Path.glob(this: Path, pattern: String) { Ok(Value::new(this.glob(&pattern))) } @@ -36,6 +53,10 @@ impl Path { Self { inner } } + fn exists(&self) -> bool { + self.inner.exists() + } + fn parent(&self) -> Option { self.inner.parent().map(|p| Self { inner: p.to_path_buf() }) } @@ -44,6 +65,15 @@ impl Path { self.inner.file_name().map(|n| n.to_string_lossy().to_string()) } + fn join(&self, to_join: &str) -> Self { + Self { inner: self.inner.join(to_join) } + } + + fn canonicalize(&self) -> Self { + // TODO handle errors here + Self { inner: self.inner.canonicalize().unwrap() } + } + // TODO return a Set once exposed from starlark crate fn glob(&self, pattern: &str) -> List { let mut results = List::default(); From 7b63d96b0da2324b8f565739c7d9f5a98fb1f1ed Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 6 Dec 2020 09:17:36 -0800 Subject: [PATCH 34/73] [honk] add repr for command --- honk/src/builtins/command.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/honk/src/builtins/command.rs b/honk/src/builtins/command.rs index f7ca4cec7..a15375946 100644 --- a/honk/src/builtins/command.rs +++ b/honk/src/builtins/command.rs @@ -56,6 +56,11 @@ impl TypedValue for Command { fn values_for_descendant_check_and_freeze(&self) -> Box + '_> { Box::new(std::iter::empty()) } + + fn to_repr_impl(&self, buf: &mut String) -> std::fmt::Result { + use std::fmt::Write; + write!(buf, "{:?}", self) + } } #[derive(Debug, Clone)] From 4e8f8b90f617d9964c4690bed0f7c88050284585 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 6 Dec 2020 09:17:55 -0800 Subject: [PATCH 35/73] [honk] add debug log before constructing env --- honk/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 4a31aa3b5..aaf7e9408 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -56,6 +56,7 @@ impl Workspace { #[instrument(level = "info", skip(self), fields(root = %self.root.display()))] fn converge(&self) -> Result<(), Error> { + debug!("constructing workspace env"); let _workspace_env = self .load(Self::ASSET_PATH, &self.type_values) .map_err(|e| EvalError::from_exception(e, self.codemap.clone()))?; From 0c4fae170fc2e32d13bda1d3a03f0bbac2f11a7a Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 6 Dec 2020 09:18:57 -0800 Subject: [PATCH 36/73] [honk] honk-flow command --- .cargo/config.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 3dcd3a396..a7ba53be5 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -131,3 +131,4 @@ docs-ofl = "doc --manifest-path ofl/Cargo.toml --workspace --no-deps" # honk honk = "run --manifest-path honk/Cargo.toml --release --" +honk-flow = "watch -w honk/src -w Cargo.toml -x honk" From 73afcae4b55211f656613247a3bf6c9093bd1974 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 6 Dec 2020 09:22:22 -0800 Subject: [PATCH 37/73] [honk] add todo --- honk/rules/cargo/workspace.honk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/honk/rules/cargo/workspace.honk b/honk/rules/cargo/workspace.honk index b5ed87516..2c1d9bf1d 100644 --- a/honk/rules/cargo/workspace.honk +++ b/honk/rules/cargo/workspace.honk @@ -4,6 +4,13 @@ load("//honk/rules/cargo/rustfmt.honk", "format_crate") load("//honk/rules/cargo/wasm-pack.honk", "maybe_wasm_crate") +# TODO do the tests in two stages -- a build and then a run +# something like this to discover the filename cargo makes (thanks @yaahc) +# cargo test --no-run --message-format=json | \ +# jq -r "select(.profile.test == true) | \ +# .filenames[]" | grep -v dSYM - > filenames.txt + + def test_crate(package): """ Run `cargo test --all-targets -p ${package}`. From 2d0a7efa1759b4494fb043fd8ac421fe5eb88466 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 6 Dec 2020 11:15:00 -0800 Subject: [PATCH 38/73] [honk] better repr for commands --- honk/src/builtins/command.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/honk/src/builtins/command.rs b/honk/src/builtins/command.rs index a15375946..fde7bfbbd 100644 --- a/honk/src/builtins/command.rs +++ b/honk/src/builtins/command.rs @@ -59,7 +59,33 @@ impl TypedValue for Command { fn to_repr_impl(&self, buf: &mut String) -> std::fmt::Result { use std::fmt::Write; - write!(buf, "{:?}", self) + write!(buf, "{}", self) + } +} + +impl std::fmt::Display for Command { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + writeln!(f, "Command:")?; + write!(f, "\t{}", &self.command)?; + for arg in &self.args { + write!(f, " {}", arg)?; + } + + if !self.inputs.is_empty() { + write!(f, "\n\tinputs:")?; + for input in &self.inputs { + write!(f, " {},", input)?; + } + } + + if !self.outputs.is_empty() { + writeln!(f, "\n\toutputs:")?; + for output in &self.outputs { + write!(f, " {},", output)?; + } + } + + Ok(()) } } From 6b5f8aa86366673e007a0b2b88ced1f269d822ba Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 6 Dec 2020 11:15:22 -0800 Subject: [PATCH 39/73] [honk] clean up path repr impl --- honk/src/builtins/path.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/honk/src/builtins/path.rs b/honk/src/builtins/path.rs index 8b1f80142..10ad7abfc 100644 --- a/honk/src/builtins/path.rs +++ b/honk/src/builtins/path.rs @@ -90,6 +90,12 @@ impl Path { } } +impl std::fmt::Display for Path { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.inner.display().fmt(f) + } +} + impl TypedValue for Path { type Holder = starlark::values::Immutable; @@ -106,7 +112,7 @@ impl TypedValue for Path { } fn to_repr_impl(&self, buf: &mut String) -> std::fmt::Result { - buf.push_str(&self.inner.to_string_lossy()); - Ok(()) + use std::fmt::Write; + write!(buf, "{}", self) } } From f3f796c53121716a1521bd3ad874149d767979e8 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 6 Dec 2020 11:22:48 -0800 Subject: [PATCH 40/73] [honk] implement glob method with list of patterns --- honk/src/builtins/path.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/honk/src/builtins/path.rs b/honk/src/builtins/path.rs index 10ad7abfc..0e64a7f3a 100644 --- a/honk/src/builtins/path.rs +++ b/honk/src/builtins/path.rs @@ -35,7 +35,7 @@ starlark_module! { globals => } Path.glob(this: Path, pattern: String) { - Ok(Value::new(this.glob(&pattern))) + Ok(Value::new(this.globs(&[pattern]))) } } @@ -75,15 +75,19 @@ impl Path { } // TODO return a Set once exposed from starlark crate - fn glob(&self, pattern: &str) -> List { + fn globs(&self, patterns: &[impl AsRef]) -> List { let mut results = List::default(); - // FIXME this might be a broken way to do globs "scoped" to a parent path? - let full_pattern = self.inner.to_string_lossy() + "/" + pattern; - // TODO glob against the vfs - for entry in glob::glob(&full_pattern).expect("must pass a valid glob") { - let matched = Path::new(entry.unwrap()); - results.push(Value::new(matched)).unwrap(); + for pattern in patterns { + let pattern = pattern.as_ref(); + // FIXME this might be a broken way to do globs "scoped" to a parent path? + let full_pattern = self.inner.to_string_lossy() + "/" + pattern; + + // TODO glob against the vfs + for entry in glob::glob(&full_pattern).expect("must pass a valid glob") { + let matched = Path::new(entry.unwrap()); + results.push(Value::new(matched)).unwrap(); + } } results From 9e07834357ef4f5d26ec516c045519a122e8f39e Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 6 Dec 2020 11:35:54 -0800 Subject: [PATCH 41/73] [honk] expose batch globbing in path api --- honk/src/builtins/path.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/honk/src/builtins/path.rs b/honk/src/builtins/path.rs index 0e64a7f3a..76e69bf2d 100644 --- a/honk/src/builtins/path.rs +++ b/honk/src/builtins/path.rs @@ -37,6 +37,10 @@ starlark_module! { globals => Path.glob(this: Path, pattern: String) { Ok(Value::new(this.globs(&[pattern]))) } + + Path.globs(this: Path, patterns: Vec) { + Ok(Value::new(this.globs(&patterns))) + } } fn opt_typed_val(v: Option) -> Value { From 9ca934fc6a42a1a2cfce3032dcc0d2fba8e107ac Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 6 Dec 2020 11:45:15 -0800 Subject: [PATCH 42/73] [honk] support resolving paths relative to workspace root --- honk/rules/cargo/workspace.honk | 1 + honk/src/builtins/path.rs | 22 ++++++++++++++++------ workspace.honk | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/honk/rules/cargo/workspace.honk b/honk/rules/cargo/workspace.honk index 2c1d9bf1d..ce60439ea 100644 --- a/honk/rules/cargo/workspace.honk +++ b/honk/rules/cargo/workspace.honk @@ -66,6 +66,7 @@ def cargo_workspace(manifest): """ Discovers targets from a Cargo workspace, defined by the path to its root ${manifest}. """ + manifest = path(manifest) metadata = cargo_metadata(manifest) for id in metadata.member_ids: package = metadata.packages[id] diff --git a/honk/src/builtins/path.rs b/honk/src/builtins/path.rs index 76e69bf2d..a026fad89 100644 --- a/honk/src/builtins/path.rs +++ b/honk/src/builtins/path.rs @@ -7,11 +7,11 @@ use std::{ starlark_module! { globals => honk_root() { // TODO handle error here - Ok(Value::new(Path::new(std::env::current_dir().unwrap()))) + Ok(Value::new(honk_root_impl())) } path(p: String) { - Ok(Value::new(Path::new(PathBuf::from(p)))) + Ok(Value::new(Path::new(p))) } Path.exists(this: Path) { @@ -43,6 +43,11 @@ starlark_module! { globals => } } +fn honk_root_impl() -> Path { + // FIXME get this from the CLI arg + Path { inner: std::env::current_dir().unwrap() } +} + fn opt_typed_val(v: Option) -> Value { if let Some(v) = v { Value::new(v) } else { Value::new(NoneType::None) } } @@ -53,8 +58,14 @@ pub struct Path { } impl Path { - fn new(inner: PathBuf) -> Self { - Self { inner } + fn new(inner: String) -> Self { + Self { + inner: if inner.starts_with("//") { + honk_root_impl().inner.join(inner.trim_start_matches("//")) + } else { + PathBuf::from(inner) + }, + } } fn exists(&self) -> bool { @@ -89,8 +100,7 @@ impl Path { // TODO glob against the vfs for entry in glob::glob(&full_pattern).expect("must pass a valid glob") { - let matched = Path::new(entry.unwrap()); - results.push(Value::new(matched)).unwrap(); + results.push(Value::new(Path { inner: entry.unwrap() })).unwrap(); } } diff --git a/workspace.honk b/workspace.honk index 03a22b762..91011b3d7 100644 --- a/workspace.honk +++ b/workspace.honk @@ -1,5 +1,5 @@ load("//honk/rules/cargo/workspace.honk", "cargo_workspace") -cargo_workspace(manifest="./Cargo.toml") +cargo_workspace(manifest="//Cargo.toml") # TODO specify website construction & HTTP server From b49ef5a9f93975ab6cc2d5254592ee13313d9840 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 6 Dec 2020 11:46:26 -0800 Subject: [PATCH 43/73] [honk][cargo] make metadata command volatile again i see a path to it being fast and sandboxed but not today --- honk/rules/cargo/metadata.honk | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/honk/rules/cargo/metadata.honk b/honk/rules/cargo/metadata.honk index 1a39f432e..a57e752f3 100644 --- a/honk/rules/cargo/metadata.honk +++ b/honk/rules/cargo/metadata.honk @@ -115,23 +115,19 @@ def _metadata_dict_to_struct(metadata): def cargo_metadata(manifest): requested_version = 1 # only valid value at time of writing - metadata_inputs = honk_root().glob("**/Cargo.toml") - for cargo_toml in list(metadata_inputs): - crate_root = cargo_toml.parent() - # TODO possible to do this without auto-targets from cargo? - # i think we'd have to parse toml ourselves - metadata_inputs.append(crate_root.join("src/lib.rs")) - - main_rs = crate_root.join("src/main.rs") - if main_rs.exists(): - metadata_inputs.append(main_rs) - - for other_dir in ["src/bin", "benches", "examples", "tests"]: - other_dir = path(other_dir) - metadata_inputs += other_dir.glob("*.rs") - metadata_inputs += other_dir.glob("*/main.rs") - - metadata_inputs += honk_root().glob("**/Cargo.lock") + metadata_inputs = [] + # TODO make incremental globs more efficient and uncomment + # metadata_inputs = manifest.parent().globs( + # # TODO figure out a better way to exclude target + # [ + # "**/Cargo.toml", + # "**/Cargo.lock", + # "**/src/*.rs", + # "**/benches/**/*.rs", + # "**/examples/**/*.rs", + # "**/tests/**/*.rs", + # ] + # ) metadata_command = command( "cargo", # TODO get this from a specified toolchain From e40d5615db5583421cefed5a9d5dde741e6c7649 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 6 Dec 2020 11:51:10 -0800 Subject: [PATCH 44/73] [honk] add todo --- honk/rules/cargo/metadata.honk | 1 + 1 file changed, 1 insertion(+) diff --git a/honk/rules/cargo/metadata.honk b/honk/rules/cargo/metadata.honk index a57e752f3..47b553815 100644 --- a/honk/rules/cargo/metadata.honk +++ b/honk/rules/cargo/metadata.honk @@ -129,6 +129,7 @@ def cargo_metadata(manifest): # ] # ) + # TODO find a way to mark this volatile metadata_command = command( "cargo", # TODO get this from a specified toolchain args=[ From b15f1a12784fdeb85e34511de3a69cd4b7d75446 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Mon, 7 Dec 2020 18:10:12 -0800 Subject: [PATCH 45/73] [honk] add todo --- honk/rules/cargo/workspace.honk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/honk/rules/cargo/workspace.honk b/honk/rules/cargo/workspace.honk index ce60439ea..84df55b2e 100644 --- a/honk/rules/cargo/workspace.honk +++ b/honk/rules/cargo/workspace.honk @@ -11,6 +11,9 @@ load("//honk/rules/cargo/wasm-pack.honk", "maybe_wasm_crate") # .filenames[]" | grep -v dSYM - > filenames.txt +# TODO add workspace dependencies between crates + + def test_crate(package): """ Run `cargo test --all-targets -p ${package}`. From 3352bf2af55ba0776fe200cab42e3ac67ebf1e7c Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 14 Mar 2021 16:29:19 -0700 Subject: [PATCH 46/73] [honk] Start port to facebook's starlark crate. --- .cargo/config.toml | 2 +- .vscode/settings.json | 3 +- honk/Cargo.lock | 1180 ++++++++++++++++++++++++++++++++--------- honk/Cargo.toml | 5 +- honk/src/error.rs | 56 +- honk/src/lib.rs | 70 ++- 6 files changed, 960 insertions(+), 356 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index a7ba53be5..ae406a063 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -131,4 +131,4 @@ docs-ofl = "doc --manifest-path ofl/Cargo.toml --workspace --no-deps" # honk honk = "run --manifest-path honk/Cargo.toml --release --" -honk-flow = "watch -w honk/src -w Cargo.toml -x honk" +honk-flow = "watch --clear -w honk/src -w Cargo.toml -x honk" diff --git a/.vscode/settings.json b/.vscode/settings.json index de288e1ea..32c8f3adb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "python.formatting.provider": "black" + "python.formatting.provider": "black", + "editor.formatOnSave": true } \ No newline at end of file diff --git a/honk/Cargo.lock b/honk/Cargo.lock index 2178ff9bc..4aba486e7 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -1,5 +1,17 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "addr2line" version = "0.14.0" @@ -15,6 +27,15 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +[[package]] +name = "ahash" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" +dependencies = [ + "const-random", +] + [[package]] name = "aho-corasick" version = "0.7.14" @@ -24,6 +45,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "annotate-snippets" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c96c3d1062ea7101741480185a6a1275eab01cbe8b20e378d1311bc056d2e08" +dependencies = [ + "unicode-width", + "yansi-term", +] + [[package]] name = "ansi_term" version = "0.11.0" @@ -42,6 +73,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "anyhow" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" + [[package]] name = "argh" version = "0.1.4" @@ -71,15 +108,38 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "781f336cc9826dbaddb9754cb5db61e64cab4f69668bd19dcc4a0394a86f4cb1" +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "ascii-canvas" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b385d69402821a1c254533a011a312531cbcc0e3e24f19bbb4747a5a2daf37e2" +checksum = "ff8eb72df928aafb99fe5d37b383f2fe25bd2a765e3e5f7c365916b6f2463a29" dependencies = [ "term", ] +[[package]] +name = "async-trait" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atty" version = "0.2.14" @@ -92,10 +152,16 @@ dependencies = [ ] [[package]] -name = "autocfg" -version = "0.1.7" +name = "auto_impl" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +checksum = "42cbf586c80ada5e5ccdecae80d3ef0854f224e2dd74435f8d87e6831b8d0a38" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] [[package]] name = "autocfg" @@ -117,6 +183,24 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "beef" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "474a626a67200bd107d44179bb3d4fc61891172d11696609264589be6a0e6a43" + [[package]] name = "bit-set" version = "0.5.2" @@ -139,31 +223,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] -name = "block-buffer" -version = "0.7.3" +name = "blake2b_simd" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array", + "arrayref", + "arrayvec", + "constant_time_eq", ] [[package]] -name = "block-padding" -version = "0.1.5" +name = "bumpalo" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" [[package]] name = "byteorder" @@ -171,6 +245,12 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + [[package]] name = "cc" version = "1.0.61" @@ -203,12 +283,18 @@ dependencies = [ ] [[package]] -name = "cloudabi" -version = "0.0.3" +name = "clap" +version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ + "ansi_term 0.11.0", + "atty", "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", ] [[package]] @@ -217,17 +303,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e769b5c8c8283982a987c6e948e540254f1058d5a74b8794914d4ef5fc2a24" -[[package]] -name = "codemap-diagnostic" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ba0e6be8e2774e750f9e90625b490249715bece38a12f9d09e82477caba5028" -dependencies = [ - "atty", - "codemap", - "termcolor", -] - [[package]] name = "color-eyre" version = "0.5.6" @@ -254,13 +329,41 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "const-random" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f590d95d011aa80b063ffe3253422ed5aa462af4e9867d43ce8337562bac77c4" +dependencies = [ + "const-random-macro", + "proc-macro-hack", +] + +[[package]] +name = "const-random-macro" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "615f6e27d000a2bffbc7f2f6a8669179378fa27ee4d0a509e985dfc0a7defb40" +dependencies = [ + "getrandom 0.2.2", + "lazy_static", + "proc-macro-hack", + "tiny-keccak", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "crossbeam-channel" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" dependencies = [ - "crossbeam-utils", + "crossbeam-utils 0.7.2", "maybe-uninit", ] @@ -270,11 +373,72 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg 1.0.1", + "autocfg", "cfg-if 0.1.10", "lazy_static", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +dependencies = [ + "autocfg", + "cfg-if 1.0.0", + "lazy_static", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "dashmap" +version = "3.11.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f260e2fc850179ef410018660006951c1b55b79e8087e87111a2c388994b9b5" +dependencies = [ + "ahash", + "cfg-if 0.1.10", + "num_cpus", +] + +[[package]] +name = "debugserver-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf6834a70ed14e8e4e41882df27190bea150f1f6ecf461f1033f8739cd8af4a" +dependencies = [ + "schemafy", + "serde", + "serde_json", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive_more" +version = "0.99.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "diff" version = "0.1.12" @@ -282,24 +446,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" [[package]] -name = "digest" -version = "0.8.1" +name = "dirs" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" dependencies = [ - "generic-array", + "libc", + "redox_users 0.3.5", + "winapi 0.3.9", ] [[package]] -name = "docopt" -version = "1.1.0" +name = "dirs-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f525a586d310c87df72ebcd98009e57f1cc030c8c268305287a476beb653969" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "lazy_static", - "regex", - "serde", - "strsim", + "cfg-if 1.0.0", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users 0.4.0", + "winapi 0.3.9", ] [[package]] @@ -310,9 +485,9 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "ena" -version = "0.11.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00" +checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" dependencies = [ "log", ] @@ -327,12 +502,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "filetime" version = "0.2.12" @@ -341,15 +510,31 @@ checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e" dependencies = [ "cfg-if 0.1.10", "libc", - "redox_syscall", + "redox_syscall 0.1.57", "winapi 0.3.9", ] [[package]] name = "fixedbitset" -version = "0.1.9" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] [[package]] name = "fs-err" @@ -357,6 +542,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcd1163ae48bda72a20ae26d66a04d3094135cadab911cff418ae5e33f253431" +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "fsevent" version = "0.4.0" @@ -376,12 +571,6 @@ dependencies = [ "libc", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -398,6 +587,104 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +[[package]] +name = "futures" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" + +[[package]] +name = "futures-io" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59" + +[[package]] +name = "futures-macro" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea405816a5139fb39af82c2beb921d52143f556038378d6db21183a5c37fbfb7" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3" + +[[package]] +name = "futures-task" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" + +[[package]] +name = "futures-util" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite 0.2.6", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + +[[package]] +name = "gazebo" +version = "0.1.0" +source = "git+https://github.com/facebookincubator/gazebo#604500f2775efa3c36bb53b5241a6911547fabdb" +dependencies = [ + "gazebo_derive", +] + +[[package]] +name = "gazebo_derive" +version = "0.1.0" +source = "git+https://github.com/facebookincubator/gazebo#604500f2775efa3c36bb53b5241a6911547fabdb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "generator" version = "0.6.23" @@ -412,12 +699,25 @@ dependencies = [ ] [[package]] -name = "generic-array" -version = "0.12.3" +name = "getrandom" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "typenum", + "cfg-if 1.0.0", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", ] [[package]] @@ -432,6 +732,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + [[package]] name = "heck" version = "0.3.1" @@ -454,9 +760,8 @@ dependencies = [ name = "honk" version = "7.0.0" dependencies = [ + "anyhow", "argh", - "codemap", - "codemap-diagnostic", "color-eyre", "crossbeam-channel", "glob", @@ -469,12 +774,33 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "idna" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89829a5d69c23d348314a7ac337fe39173b61149a9864deabd260983aed48c21" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indenter" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0bd112d44d9d870a6819eb505d04dd92b5e4d94bb8c304924a0872ae7016fb5" +[[package]] +name = "indexmap" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "inotify" version = "0.7.1" @@ -506,9 +832,18 @@ dependencies = [ [[package]] name = "itertools" -version = "0.8.2" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +checksum = "37d572918e350e82412fe766d24b15e6682fb2ed2bbe018280caa810397cb319" dependencies = [ "either", ] @@ -531,34 +866,35 @@ dependencies = [ [[package]] name = "lalrpop" -version = "0.16.3" +version = "0.19.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e2e80bee40b22bca46665b4ef1f3cd88ed0fb043c971407eac17a0712c02572" +checksum = "46962a8c71b91c3524b117dfdd70844d4265a173c4c9109f98171aebdcf1195f" dependencies = [ "ascii-canvas", "atty", "bit-set", "diff", - "docopt", "ena", - "itertools", + "itertools 0.10.0", "lalrpop-util", "petgraph", + "pico-args", "regex", "regex-syntax", - "serde", - "serde_derive", - "sha2", "string_cache", "term", - "unicode-xid 0.1.0", + "tiny-keccak", + "unicode-xid", ] [[package]] name = "lalrpop-util" -version = "0.16.3" +version = "0.19.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b27d8490dbe1f9704b0088d61e8d46edc10d5673a8829836c6ded26a9912c7" +checksum = "7a708007b751af124d09e9c5d97515257902bc6b486a56b40bcafd939e8ff467" +dependencies = [ + "regex", +] [[package]] name = "lazy_static" @@ -578,12 +914,6 @@ version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" -[[package]] -name = "linked-hash-map" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" - [[package]] name = "log" version = "0.4.11" @@ -593,6 +923,30 @@ dependencies = [ "cfg-if 0.1.10", ] +[[package]] +name = "logos" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91c49573597a5d6c094f9031617bb1fed15c0db68c81e6546d313414ce107e4" +dependencies = [ + "logos-derive", +] + +[[package]] +name = "logos-derive" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "797b1f8a0571b331c1b47e7db245af3dc634838da7a92b3bef4e30376ae1c347" +dependencies = [ + "beef", + "fnv", + "proc-macro2", + "quote", + "regex-syntax", + "syn", + "utf8-ranges", +] + [[package]] name = "loom" version = "0.3.6" @@ -606,6 +960,26 @@ dependencies = [ "serde_json", ] +[[package]] +name = "lsp-types" +version = "0.81.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e02724627e9ef8ba91f461ebc01d48aebbd13a4b7c9dc547a0a2890f53e2171" +dependencies = [ + "base64 0.12.3", + "bitflags", + "serde", + "serde_json", + "serde_repr", + "url", +] + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "matchers" version = "0.0.1" @@ -615,6 +989,12 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + [[package]] name = "maybe-uninit" version = "2.0.0" @@ -646,7 +1026,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ "adler", - "autocfg 1.0.1", + "autocfg", ] [[package]] @@ -709,6 +1089,28 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "nix" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2" +dependencies = [ + "bitflags", + "cc", + "cfg-if 1.0.0", + "libc", +] + +[[package]] +name = "nom" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +dependencies = [ + "memchr", + "version_check", +] + [[package]] name = "notify" version = "4.0.15" @@ -733,7 +1135,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "autocfg 1.0.1", + "autocfg", "num-traits", ] @@ -743,7 +1145,17 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "autocfg 1.0.1", + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", ] [[package]] @@ -759,51 +1171,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" [[package]] -name = "opaque-debug" -version = "0.2.3" +name = "owo-colors" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +checksum = "7a1250cdd103eef6bd542b5ae82989f931fc00a41a27f60377338241594410f3" [[package]] -name = "ordermap" -version = "0.3.5" +name = "paste" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" [[package]] -name = "owo-colors" -version = "1.1.3" +name = "percent-encoding" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a1250cdd103eef6bd542b5ae82989f931fc00a41a27f60377338241594410f3" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "petgraph" -version = "0.4.13" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" +checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" dependencies = [ "fixedbitset", - "ordermap", + "indexmap", ] [[package]] -name = "phf_generator" -version = "0.7.24" +name = "phf_shared" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" +checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" dependencies = [ - "phf_shared", - "rand", + "siphasher", ] [[package]] -name = "phf_shared" -version = "0.7.24" +name = "pico-args" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" -dependencies = [ - "siphasher", -] +checksum = "d70072c20945e1ab871c472a285fc772aefd4f5407723c206242f2c6f94595d6" [[package]] name = "pin-project-lite" @@ -812,150 +1220,113 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" [[package]] -name = "precomputed-hash" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" - -[[package]] -name = "proc-macro2" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" -dependencies = [ - "unicode-xid 0.2.1", -] - -[[package]] -name = "quote" -version = "1.0.7" +name = "pin-project-lite" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" -dependencies = [ - "proc-macro2", -] +checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" [[package]] -name = "rand" -version = "0.6.5" +name = "pin-utils" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha", - "rand_core 0.4.2", - "rand_hc", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.9", -] +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "rand_chacha" +name = "precomputed-hash" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", ] [[package]] -name = "rand_core" -version = "0.3.1" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "rand_core 0.4.2", + "proc-macro2", + "quote", + "version_check", ] [[package]] -name = "rand_core" -version = "0.4.2" +name = "proc-macro-hack" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] -name = "rand_hc" -version = "0.1.0" +name = "proc-macro-nested" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] -name = "rand_isaac" -version = "0.1.1" +name = "proc-macro2" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ - "rand_core 0.3.1", + "unicode-xid", ] [[package]] -name = "rand_jitter" -version = "0.1.4" +name = "quote" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", + "proc-macro2", ] [[package]] -name = "rand_os" -version = "0.1.3" +name = "redox_syscall" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] -name = "rand_pcg" -version = "0.1.2" +name = "redox_syscall" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", + "bitflags", ] [[package]] -name = "rand_xorshift" -version = "0.1.1" +name = "redox_users" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "rand_core 0.3.1", + "getrandom 0.1.16", + "redox_syscall 0.1.57", + "rust-argon2", ] [[package]] -name = "rdrand" +name = "redox_users" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "rand_core 0.3.1", + "getrandom 0.2.2", + "redox_syscall 0.2.5", ] -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - [[package]] name = "regex" version = "1.4.2" @@ -984,6 +1355,18 @@ version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +[[package]] +name = "rust-argon2" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" +dependencies = [ + "base64 0.13.0", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils 0.8.3", +] + [[package]] name = "rustc-demangle" version = "0.1.18" @@ -999,6 +1382,27 @@ dependencies = [ "semver", ] +[[package]] +name = "rustyline" +version = "7.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8227301bfc717136f0ecbd3d064ba8199e44497a0bdd46bb01ede4387cfd2cec" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "dirs-next", + "fs2", + "libc", + "log", + "memchr", + "nix", + "scopeguard", + "unicode-segmentation", + "unicode-width", + "utf8parse", + "winapi 0.3.9", +] + [[package]] name = "ryu" version = "1.0.5" @@ -1014,12 +1418,60 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schemafy" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c16a6854d2bb501c578caa4c760efa1f689c6de9c416b09df043cf26de3c05e3" +dependencies = [ + "Inflector", + "schemafy_core", + "schemafy_lib", + "serde", + "serde_derive", + "serde_json", + "serde_repr", + "syn", +] + +[[package]] +name = "schemafy_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8335227b124c84befc4021af80ab1d47c4a3a25f0fee28e61e45cef11e51dd60" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "schemafy_lib" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30c96bf8382cc2e9f5900598b7f161ab1ea6d8c4146ab766a949509924cbb5c6" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "schemafy_core", + "serde", + "serde_derive", + "serde_json", + "syn", +] + [[package]] name = "scoped-tls" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + [[package]] name = "semver" version = "0.9.0" @@ -1067,15 +1519,14 @@ dependencies = [ ] [[package]] -name = "sha2" -version = "0.8.2" +name = "serde_repr" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +checksum = "2dc6b7951b17b051f3210b063f12cc17320e2fe30ae05b0fe2a3abb068551c76" dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1090,9 +1541,9 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.2.3" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" +checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7" [[package]] name = "slab" @@ -1108,56 +1559,98 @@ checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" [[package]] name = "starlark" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48390a8b2d8db3a5165ec70d803570582d801823a2b112c203cf72f66b1652c4" +version = "0.4.0-pre" +source = "git+https://github.com/facebookexperimental/starlark-rust?rev=3bb2016#3bb20164a18f1e0fe65ba9cfc4c5bbfc7f41f621" dependencies = [ + "annotate-snippets", + "anyhow", + "bumpalo", "codemap", - "codemap-diagnostic", + "debugserver-types", + "derivative", + "derive_more", + "either", + "gazebo", + "indexmap", + "itertools 0.9.0", "lalrpop", "lalrpop-util", - "linked-hash-map", + "logos", + "maplit", + "once_cell", + "paste", + "regex", + "rustyline", + "serde", + "serde_json", + "starlark_module", + "static_assertions", + "structopt", + "thiserror", + "tokio", + "tower-lsp", + "void", + "walkdir", +] + +[[package]] +name = "starlark_module" +version = "0.4.0-pre" +source = "git+https://github.com/facebookexperimental/starlark-rust?rev=3bb2016#3bb20164a18f1e0fe65ba9cfc4c5bbfc7f41f621" +dependencies = [ + "gazebo", + "proc-macro2", + "quote", + "syn", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "string_cache" -version = "0.7.5" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89c058a82f9fd69b1becf8c274f412281038877c553182f1d02eb027045a2d67" +checksum = "8ddb1139b5353f96e429e1a5e19fbaf663bddedaa06d1dbd49f82e352601209a" dependencies = [ "lazy_static", "new_debug_unreachable", "phf_shared", "precomputed-hash", - "serde", - "string_cache_codegen", - "string_cache_shared", ] [[package]] -name = "string_cache_codegen" -version = "0.4.4" +name = "strsim" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6" -dependencies = [ - "phf_generator", - "phf_shared", - "proc-macro2", - "quote", - "string_cache_shared", -] +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] -name = "string_cache_shared" -version = "0.3.0" +name = "structopt" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc" +checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] [[package]] -name = "strsim" -version = "0.9.3" +name = "structopt-derive" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" +checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] [[package]] name = "syn" @@ -1167,26 +1660,27 @@ checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" dependencies = [ "proc-macro2", "quote", - "unicode-xid 0.2.1", + "unicode-xid", ] [[package]] name = "term" -version = "0.4.6" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" +checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" dependencies = [ - "kernel32-sys", - "winapi 0.2.8", + "byteorder", + "dirs", + "winapi 0.3.9", ] [[package]] -name = "termcolor" -version = "1.1.0" +name = "textwrap" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "winapi-util", + "unicode-width", ] [[package]] @@ -1225,10 +1719,100 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ "libc", - "wasi", + "wasi 0.10.0+wasi-snapshot-preview1", "winapi 0.3.9", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tinyvec" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" +dependencies = [ + "bytes", + "futures-core", + "pin-project-lite 0.1.11", + "slab", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite 0.1.11", + "tokio", +] + +[[package]] +name = "tower-lsp" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75aeada84f07dfc4e81bc58a36a12b22c01c418af2180587cf80f9f3228acad" +dependencies = [ + "async-trait", + "auto_impl", + "bytes", + "dashmap", + "futures", + "log", + "lsp-types", + "nom", + "serde", + "serde_json", + "tokio", + "tokio-util", + "tower-lsp-macros", + "tower-service", +] + +[[package]] +name = "tower-lsp-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c51c24e3b5909be30d6ed472f934aa9b7d91abf2688013956b296b1d1e7b186" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tower-service" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" + [[package]] name = "tracing" version = "0.1.21" @@ -1236,7 +1820,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" dependencies = [ "cfg-if 0.1.10", - "pin-project-lite", + "pin-project-lite 0.1.11", "tracing-attributes", "tracing-core", ] @@ -1315,10 +1899,22 @@ dependencies = [ ] [[package]] -name = "typenum" -version = "1.12.0" +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef" +dependencies = [ + "tinyvec", +] [[package]] name = "unicode-segmentation" @@ -1327,10 +1923,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" [[package]] -name = "unicode-xid" -version = "0.1.0" +name = "unicode-width" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" @@ -1338,6 +1934,49 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "url" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8-ranges" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" + +[[package]] +name = "utf8parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + [[package]] name = "walkdir" version = "2.3.1" @@ -1349,6 +1988,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" @@ -1407,3 +2052,12 @@ dependencies = [ "winapi 0.2.8", "winapi-build", ] + +[[package]] +name = "yansi-term" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1" +dependencies = [ + "winapi 0.3.9", +] diff --git a/honk/Cargo.toml b/honk/Cargo.toml index fbf004bf6..7cc4baf8c 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -14,15 +14,14 @@ authors = ["Adam Perry "] edition = "2018" [dependencies] +anyhow = "1" argh = "0.1.4" -codemap = "0.1.3" -codemap-diagnostic = "0.1.1" color-eyre = "0.5.6" crossbeam-channel = "0.4.0" glob = "0.3.0" memofs = "0.1.2" serde_json = "1.0.59" -starlark = "0.3.1" +starlark = { git = "https://github.com/facebookexperimental/starlark-rust", rev = "3bb2016" } thiserror = "1.0.21" tracing = "0.1.21" tracing-error = "0.1.2" diff --git a/honk/src/error.rs b/honk/src/error.rs index 42c128a3c..e99dae40d 100644 --- a/honk/src/error.rs +++ b/honk/src/error.rs @@ -1,34 +1,25 @@ -use crate::builtins::command::{Command, Output}; -use codemap::CodeMap; -use codemap_diagnostic::{ColorConfig, Emitter}; -use starlark::values::error::ValueError; +use starlark::values::ValueError; use std::{ - fmt::{Debug, Display, Formatter, Result as FmtResult}, path::PathBuf, str::Utf8Error, - string::FromUtf8Error, - sync::{Arc, Mutex}, }; #[derive(Debug, thiserror::Error)] pub enum Error { - #[error("evaluation error: {source}")] - Eval { - #[from] - source: EvalError, - }, - #[error("i/o error: {source}")] Io { #[from] source: std::io::Error, }, - #[error("failed to run command: {0:#?}")] - CommandFailed(Output), + #[error("starlark error")] + StarlarkError(#[source] anyhow::Error), - #[error("`{command:?}` returned non utf-8: {source}")] - StdoutEncoding { source: FromUtf8Error, command: Command }, + // #[error("failed to run command: {0:#?}")] + // CommandFailed(Output), + + // #[error("`{command}` returned non utf-8: {source}")] + // StdoutEncoding { source: FromUtf8Error, command: String}, #[error("error handling JSON: {source}")] JsonError { @@ -46,34 +37,3 @@ impl From for ValueError { todo!("uh do this conversion properly: {:?}", e); } } - -#[derive(thiserror::Error)] -pub struct EvalError { - pub map: Arc>, - pub diagnostic: codemap_diagnostic::Diagnostic, -} - -impl EvalError { - pub fn from_exception(except: starlark::eval::EvalException, map: Arc>) -> Self { - Self { diagnostic: except.into(), map } - } - - fn emit(&self) { - let map = self.map.lock().unwrap(); - let mut emitter = Emitter::stderr(ColorConfig::Auto, Some(&*map)); - emitter.emit(&[self.diagnostic.clone()]); - } -} - -impl Debug for EvalError { - fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { - self.diagnostic.fmt(f) - } -} - -impl Display for EvalError { - fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { - self.emit(); - f.debug_struct("EvalError").finish() - } -} diff --git a/honk/src/lib.rs b/honk/src/lib.rs index aaf7e9408..92b304360 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,20 +1,20 @@ -use codemap::CodeMap; use color_eyre::eyre::Result; use starlark::{ - environment::{Environment, TypeValues}, - eval::{EvalException, FileLoader}, + environment::FrozenModule, + environment::{Globals, Module}, + eval::{Evaluator, FileLoader}, + syntax::{AstModule, Dialect}, }; use std::{ path::{Path, PathBuf}, - sync::{Arc, Mutex}, }; use tracing::{debug, error, info, instrument, warn}; -mod builtins; +// mod builtins; mod error; mod vfs; -use error::{Error, EvalError}; +use error::{Error}; use vfs::Vfs; pub struct Workspace { @@ -23,24 +23,14 @@ pub struct Workspace { /// Tracks changes to files we've read. vfs: Vfs, - - codemap: Arc>, - type_values: TypeValues, } impl Workspace { /// The asset path used to resolve the root of a honk workspace. - const ASSET_PATH: &'static str = "//workspace.honk"; + const ASSET_PATH: &'static str = "workspace.honk"; pub fn new(root: impl AsRef) -> Self { - let codemap = Arc::new(Mutex::new(CodeMap::new())); - - let (mut throwaway_env, mut type_values) = - starlark::stdlib::global_environment_with_extensions(); - // TODO figure out how to do this once instead of here *and* below in `load()`? - builtins::register(&mut throwaway_env, &mut type_values); - - Self { root: root.as_ref().to_path_buf(), vfs: Vfs::new(), codemap, type_values } + Self { root: root.as_ref().to_path_buf(), vfs: Vfs::new() } } pub fn maintain(self) -> Result<()> { @@ -57,9 +47,7 @@ impl Workspace { #[instrument(level = "info", skip(self), fields(root = %self.root.display()))] fn converge(&self) -> Result<(), Error> { debug!("constructing workspace env"); - let _workspace_env = self - .load(Self::ASSET_PATH, &self.type_values) - .map_err(|e| EvalError::from_exception(e, self.codemap.clone()))?; + let _workspace_env = self.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; warn!("TODO display discovered targets"); @@ -68,9 +56,13 @@ impl Workspace { } } +struct Revision { + modules: (), +} + impl FileLoader for Workspace { - #[instrument(skip(self, type_values))] - fn load(&self, path: &str, type_values: &TypeValues) -> Result { + #[instrument(skip(self))] + fn load(&self, path: &str) -> anyhow::Result { // TODO smarter way to resolve assets etc // TODO handle relative paths somehow? let file = self.root.join(path.strip_prefix("//").unwrap_or(path)); @@ -80,22 +72,20 @@ impl FileLoader for Workspace { let root_contents = std::str::from_utf8(&*root_contents).expect("TODO pass errors back correctly here"); - let (mut env, mut throwaway_tvs) = starlark::stdlib::global_environment_with_extensions(); - // TODO figure out how to do this once instead of here *and* above in `new()`? - builtins::register(&mut env, &mut throwaway_tvs); - - debug!("evaluating"); - starlark::eval::eval( - &self.codemap, - &file.to_string_lossy(), - &root_contents, - // TODO do we ever want to restrict function definitions? - starlark::syntax::dialect::Dialect::Bzl, - &mut env, - type_values, - self, - )?; - - Ok(env) + let root_module = std::fs::read_to_string(Self::ASSET_PATH)?; + + let ast: AstModule = + AstModule::parse(Self::ASSET_PATH, root_module, &Dialect::Standard)?; + + let globals: Globals = Globals::default(); + + // TODO register our builtins as globals + + let module: Module = Module::new(); + let mut eval: Evaluator = Evaluator::new(&module, &globals); + eval.set_loader(self); + let _res = eval.eval_module(ast)?; + + Ok(module.freeze()) } } From 070b6438126c5f194411f5cd7503204152464910 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 12:03:22 -0700 Subject: [PATCH 47/73] [ofl] Format honk directory. --- ofl/src/format.rs | 5 +++++ ofl/src/workspace.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/ofl/src/format.rs b/ofl/src/format.rs index 957f92951..275b105b0 100644 --- a/ofl/src/format.rs +++ b/ofl/src/format.rs @@ -32,6 +32,11 @@ impl Format { command.args(ofl_targets.iter().map(|t| &t.src_path)); } + for honk_member in workspace.honk_members() { + let honk_targets = &workspace.honk_metadata[&honk_member].targets; + command.args(honk_targets.iter().map(|t| &t.src_path)); + } + debug!({ ?command }, "running rustfmt"); let status = command.status().context("running rustfmt command")?; diff --git a/ofl/src/workspace.rs b/ofl/src/workspace.rs index 1c5024a23..bf269059f 100644 --- a/ofl/src/workspace.rs +++ b/ofl/src/workspace.rs @@ -7,6 +7,7 @@ use tracing::info; pub struct Workspace { pub metadata: Metadata, pub ofl_metadata: Metadata, + pub honk_metadata: Metadata, pub repo: Repository, } @@ -17,6 +18,7 @@ impl Workspace { Ok(Self { metadata: metadata_for_directory(project_root)?, ofl_metadata: metadata_for_directory(project_root.join("ofl"))?, + honk_metadata: metadata_for_directory(project_root.join("honk"))?, repo: Repository::open(project_root)?, }) } @@ -29,6 +31,10 @@ impl Workspace { local_metadata_members_reverse_topo(&self.ofl_metadata) } + pub fn honk_members(&self) -> Vec { + local_metadata_members_reverse_topo(&self.honk_metadata) + } + /// Returns a list of all crates which express a dependency upon `id` in /// their manifest. pub fn local_dependents(&self, id: &PackageId) -> Vec { From bd897553ebab8fd753b65eb68777947a7966edee Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 12:03:35 -0700 Subject: [PATCH 48/73] [honk] Include honk's Cargo.toml in flow. --- .cargo/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index ae406a063..6312ef774 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -131,4 +131,4 @@ docs-ofl = "doc --manifest-path ofl/Cargo.toml --workspace --no-deps" # honk honk = "run --manifest-path honk/Cargo.toml --release --" -honk-flow = "watch --clear -w honk/src -w Cargo.toml -x honk" +honk-flow = "watch --clear -w honk/src -w honk/Cargo.toml -w Cargo.toml -x honk" From 4746093331b12c3cfc326f51a29b07846d083f63 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 15:08:40 -0700 Subject: [PATCH 49/73] [honk] Compiling successfully with FB starlark. It's...pretty damn fast. Still some rough edges to smooth out. --- honk/Cargo.lock | 7 +- honk/Cargo.toml | 7 +- honk/rules/cargo/metadata.honk | 8 ++- honk/src/builtins.rs | 37 +++++------ honk/src/builtins/command.rs | 105 ++++++++++++++++-------------- honk/src/builtins/formatter.rs | 13 ++-- honk/src/builtins/json.rs | 48 +++++++------- honk/src/builtins/path.rs | 115 ++++++++++++++++++--------------- honk/src/builtins/target.rs | 13 ++-- honk/src/error.rs | 16 ++--- honk/src/lib.rs | 44 ++++++------- honk/src/main.rs | 2 +- 12 files changed, 219 insertions(+), 196 deletions(-) diff --git a/honk/Cargo.lock b/honk/Cargo.lock index 4aba486e7..9dd8f4d69 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -764,10 +764,13 @@ dependencies = [ "argh", "color-eyre", "crossbeam-channel", + "gazebo", "glob", "memofs", + "once_cell", "serde_json", "starlark", + "starlark_module", "thiserror", "tracing", "tracing-error", @@ -1560,7 +1563,7 @@ checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" [[package]] name = "starlark" version = "0.4.0-pre" -source = "git+https://github.com/facebookexperimental/starlark-rust?rev=3bb2016#3bb20164a18f1e0fe65ba9cfc4c5bbfc7f41f621" +source = "git+https://github.com/facebookexperimental/starlark-rust?rev=8a8523f#8a8523fc4d7700cdea6cf8a31a56d29ee7be4764" dependencies = [ "annotate-snippets", "anyhow", @@ -1596,7 +1599,7 @@ dependencies = [ [[package]] name = "starlark_module" version = "0.4.0-pre" -source = "git+https://github.com/facebookexperimental/starlark-rust?rev=3bb2016#3bb20164a18f1e0fe65ba9cfc4c5bbfc7f41f621" +source = "git+https://github.com/facebookexperimental/starlark-rust?rev=8a8523f#8a8523fc4d7700cdea6cf8a31a56d29ee7be4764" dependencies = [ "gazebo", "proc-macro2", diff --git a/honk/Cargo.toml b/honk/Cargo.toml index 7cc4baf8c..dc39eb331 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -20,9 +20,14 @@ color-eyre = "0.5.6" crossbeam-channel = "0.4.0" glob = "0.3.0" memofs = "0.1.2" +once_cell = "1" serde_json = "1.0.59" -starlark = { git = "https://github.com/facebookexperimental/starlark-rust", rev = "3bb2016" } thiserror = "1.0.21" tracing = "0.1.21" tracing-error = "0.1.2" tracing-subscriber = { version = "0.2.15", features = ["fmt"] } + +# starlark deps -- revisions must be kept in sync +gazebo = { git = "https://github.com/facebookincubator/gazebo" } +starlark = { git = "https://github.com/facebookexperimental/starlark-rust", rev = "8a8523f" } +starlark_module = { git = "https://github.com/facebookexperimental/starlark-rust", rev = "8a8523f" } diff --git a/honk/rules/cargo/metadata.honk b/honk/rules/cargo/metadata.honk index 47b553815..f62484b5d 100644 --- a/honk/rules/cargo/metadata.honk +++ b/honk/rules/cargo/metadata.honk @@ -45,11 +45,13 @@ def rust_files_in_target(manifest_path, target): else: files.append(target.src_path) - return set(files) + # FIXME restore set() call here + return list(files) def rust_files_in_package(package): - files = set() + # FIXME restore set() call here + files = list() for target in package.targets: files += rust_files_in_target(package.manifest_path, target) return files @@ -148,6 +150,6 @@ def cargo_metadata(manifest): metadata = _metadata_dict_to_struct(decoded) if metadata.version != requested_version: - fail(msg="Got metadata v" + version + ", expected v" + requested_version) + fail(msg="Got metadata v" + metadata.version + ", expected v" + requested_version) return metadata diff --git a/honk/src/builtins.rs b/honk/src/builtins.rs index 87cf97997..0b103562d 100644 --- a/honk/src/builtins.rs +++ b/honk/src/builtins.rs @@ -1,19 +1,16 @@ -use starlark::environment::{Environment, TypeValues}; +/// To be invoked inside of an `impl TypedValue<'_> for Foo { ... }` item. Expands to an +/// implementation of the `get_members()` method. +macro_rules! declare_members { + ($register:ident) => { + fn get_members(&self) -> Option<&'static starlark::environment::Globals> { + use once_cell::sync::Lazy; + use starlark::environment::{Globals, GlobalsBuilder}; -// TODO delete this -macro_rules! starlark_module { - ($($tok:tt)+) => { - // TODO submit an upstream patch to use $crate in all these macros - use starlark::{ - starlark_fun, - starlark_module as raw_starlark_module, - starlark_parse_param_type, - starlark_signature, - starlark_signature_extraction, - starlark_signatures, - }; + static MEMBERS: Lazy = + Lazy::new(|| GlobalsBuilder::new().with($register).build()); - raw_starlark_module! {$($tok)+} + Some(&*MEMBERS) + } }; } @@ -23,10 +20,10 @@ pub mod json; pub mod path; pub mod target; -pub fn register(env: &mut Environment, tvs: &mut TypeValues) { - command::globals(env, tvs); - formatter::globals(env, tvs); - json::globals(env, tvs); - path::globals(env, tvs); - target::globals(env, tvs); +pub fn register(globals: &mut starlark::environment::GlobalsBuilder) { + command::register(globals); + formatter::register(globals); + json::register(globals); + path::register(globals); + target::register(globals); } diff --git a/honk/src/builtins/command.rs b/honk/src/builtins/command.rs index fde7bfbbd..1d488b6a3 100644 --- a/honk/src/builtins/command.rs +++ b/honk/src/builtins/command.rs @@ -1,71 +1,78 @@ -use crate::{builtins::path::Path, error::Error}; -use starlark::values::{TypedValue, Value}; +use crate::{ + builtins::path::{HonkPath, RefHonkPath}, + error::Error, +}; +use starlark::{ + environment::GlobalsBuilder, + starlark_immutable_value, + values::{TypedValue, Value}, +}; +use starlark_module::starlark_module; use tracing::instrument; -starlark_module! { globals => - command( +#[starlark_module] +pub fn register(builder: &mut GlobalsBuilder) { + fn command( command: String, - args: Vec, - inputs: Vec, - outputs: Vec - ) { - let args = args.iter().map(Value::to_str).collect(); - Ok(Value::new(Command::new(command, args, inputs, outputs))) - } - - Command.run(this: Command) { - Ok(Value::new(this.run()?)) - } - - Output.stdout(this: Output) { - Ok(Value::new(this.stdout()?)) + _args: Vec>, + inputs: Vec, + outputs: Vec, + ) -> HonkCommand { + let args = _args.iter().map(|a| a.to_str()).collect(); + let inputs = inputs.iter().map(|i| (*i).clone()).collect(); + let outputs = outputs.iter().map(|o| (*o).clone()).collect(); + Ok(HonkCommand { command, args, inputs, outputs }) } } #[derive(Clone, Debug)] -pub struct Command { +pub struct HonkCommand { command: String, args: Vec, - inputs: Vec, - outputs: Vec, + inputs: Vec, + outputs: Vec, } -impl Command { - pub fn new(command: String, args: Vec, inputs: Vec, outputs: Vec) -> Self { - Self { command, args, inputs, outputs } - } - +impl HonkCommand { #[instrument] - pub fn run(self) -> Result { + pub fn run(&self) -> Result { // TODO read file metadata for inputs from vfs let output = Output { // TODO set working dir // TODO set environment inner: std::process::Command::new(&self.command).args(&self.args).output()?, - command: self, + command: self.to_string(), }; - if output.inner.status.success() { Ok(output) } else { Err(Error::CommandFailed(output)) } + if output.inner.status.success() { + Ok(output) + } else { + Err(Error::CommandFailed(output)) + } } } -impl TypedValue for Command { - type Holder = starlark::values::Immutable; +starlark_immutable_value!(pub HonkCommand); - const TYPE: &'static str = "Command"; - - fn values_for_descendant_check_and_freeze(&self) -> Box + '_> { - Box::new(std::iter::empty()) +#[starlark_module::starlark_module] +fn register_command_methods(globals: &mut GlobalsBuilder) { + fn run(this: RefHonkCommand) -> Output { + Ok(this.run()?) } +} - fn to_repr_impl(&self, buf: &mut String) -> std::fmt::Result { +impl TypedValue<'_> for HonkCommand { + starlark::starlark_type!("command"); + declare_members!(register_command_methods); + + fn collect_repr(&self, buf: &mut String) { use std::fmt::Write; - write!(buf, "{}", self) + write!(buf, "{}", self).unwrap(); } } -impl std::fmt::Display for Command { +impl std::fmt::Display for HonkCommand { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - writeln!(f, "Command:")?; + writeln!(f, "HonkCommand:")?; write!(f, "\t{}", &self.command)?; for arg in &self.args { write!(f, " {}", arg)?; @@ -91,23 +98,27 @@ impl std::fmt::Display for Command { #[derive(Debug, Clone)] pub struct Output { - command: Command, + command: String, inner: std::process::Output, } impl Output { fn stdout(&self) -> Result { Ok(String::from_utf8(self.inner.stdout.clone()) - .map_err(|source| Error::StdoutEncoding { source, command: self.command.clone() })?) + .map_err(|source| Error::StdoutEncoding { source, command: self.command.to_owned() })?) } } -impl TypedValue for Output { - type Holder = starlark::values::Immutable; +#[starlark_module::starlark_module] +fn register_output_methods(globals: &mut GlobalsBuilder) { + fn stdout(this: RefOutput) -> String { + Ok(this.stdout()?) + } +} - const TYPE: &'static str = "Output"; +starlark_immutable_value!(Output); - fn values_for_descendant_check_and_freeze(&self) -> Box + '_> { - Box::new(std::iter::empty()) - } +impl TypedValue<'_> for Output { + starlark::starlark_type!("Output"); + declare_members!(register_output_methods); } diff --git a/honk/src/builtins/formatter.rs b/honk/src/builtins/formatter.rs index ff050c950..bb07c7d1c 100644 --- a/honk/src/builtins/formatter.rs +++ b/honk/src/builtins/formatter.rs @@ -1,9 +1,10 @@ -use crate::builtins::command::Command; -use starlark::values::{none::NoneType, Value}; +use crate::builtins::command::RefHonkCommand; +use starlark::{environment::GlobalsBuilder, values::none::NoneType}; -starlark_module! { globals => - formatter(name: String, command: Command) { - tracing::warn!(%name, ?command, "TODO implement formatters"); - Ok(Value::new(NoneType::None)) +#[starlark_module::starlark_module] +pub fn register(globals: &mut GlobalsBuilder) { + fn formatter(name: String, command: RefHonkCommand) -> NoneType { + tracing::warn!(%name, command = %&*command, "TODO implement formatters"); + Ok(NoneType) } } diff --git a/honk/src/builtins/json.rs b/honk/src/builtins/json.rs index ee9d14e50..66249e9f3 100644 --- a/honk/src/builtins/json.rs +++ b/honk/src/builtins/json.rs @@ -1,41 +1,43 @@ -use crate::error::Error; use serde_json::Value as JsonValue; -use starlark::values::{dict::Dictionary, list::List, none::NoneType, Value}; +use starlark::{ + collections::SmallMap, + environment::GlobalsBuilder, + values::{dict::Dict, list::List, Heap, Value}, +}; +use std::convert::TryInto; -starlark_module! { globals => +#[starlark_module::starlark_module] +pub fn register(globals: &mut GlobalsBuilder) { // TODO make this work with the dotted syntax from the spec!!! - json_decode(x: String) { - Ok(decode_json(&x)?) + fn json_decode(x: String) -> Value<'v> { + Ok(json_to_starlark(heap, serde_json::from_str(&x)?)) } } -fn decode_json(x: &str) -> Result { - Ok(json_to_starlark(serde_json::from_str(x)?)) -} - -fn json_to_starlark(value: JsonValue) -> Value { +fn json_to_starlark<'h>(heap: &'h Heap, value: JsonValue) -> Value<'h> { match value { - JsonValue::Null => Value::new(NoneType::None), - JsonValue::Bool(b) => Value::new(b), - JsonValue::Number(n) => Value::new(n.as_i64().expect("TODO support floats")), - JsonValue::String(s) => Value::new(s), + JsonValue::Null => Value::new_none(), + JsonValue::Bool(b) => Value::new_bool(b), + JsonValue::Number(n) => { + let n = n.as_i64().expect("floats not yet supported"); + let n: i32 = n.try_into().expect("only numbers within +/- 2gb are supported"); + Value::new_int(n) + } + JsonValue::String(s) => heap.alloc(s), JsonValue::Array(a) => { let mut list = List::default(); - for value in a { - list.push(json_to_starlark(value)).unwrap(); + list.push(json_to_starlark(heap, value)); } - - Value::new(list) + heap.alloc(list) } JsonValue::Object(o) => { - let mut dict = Dictionary::default(); - + let mut dict: SmallMap = Default::default(); for (key, value) in o { - dict.insert(Value::new(key), json_to_starlark(value)).unwrap(); + let key = heap.alloc(key); + dict.insert_hashed(key.get_hashed().unwrap(), json_to_starlark(heap, value)); } - - Value::new(dict) + heap.alloc(Dict::new(dict)) } } } diff --git a/honk/src/builtins/path.rs b/honk/src/builtins/path.rs index a026fad89..5d2cb8b3a 100644 --- a/honk/src/builtins/path.rs +++ b/honk/src/builtins/path.rs @@ -1,64 +1,45 @@ -use starlark::values::{error::ValueError, list::List, none::NoneType, TypedValue, Value}; +use starlark::{ + environment::GlobalsBuilder, + starlark_immutable_value, starlark_type, + values::{list::List, AllocValue, Heap, TypedValue, Value}, +}; +use starlark_module::starlark_module; use std::{ hash::{Hash, Hasher}, path::PathBuf, }; -starlark_module! { globals => - honk_root() { - // TODO handle error here - Ok(Value::new(honk_root_impl())) - } - - path(p: String) { - Ok(Value::new(Path::new(p))) - } - - Path.exists(this: Path) { - Ok(Value::new(this.exists())) - } - - Path.parent(this: Path) { - Ok(opt_typed_val(this.parent())) - } - - Path.filename(this: Path) { - Ok(opt_typed_val(this.filename())) - } - - Path.join(this: Path, to_join: String) { - Ok(Value::new(this.join(&to_join))) - } - - Path.canonicalize(this: Path) { - Ok(Value::new(this.canonicalize())) - } - - Path.glob(this: Path, pattern: String) { - Ok(Value::new(this.globs(&[pattern]))) +#[starlark_module] +pub fn register(builder: &mut GlobalsBuilder) { + fn honk_root() -> HonkPath { + Ok(honk_root_impl()) } - Path.globs(this: Path, patterns: Vec) { - Ok(Value::new(this.globs(&patterns))) + fn path(p: &str) -> HonkPath { + Ok(HonkPath::new(p)) } } -fn honk_root_impl() -> Path { +fn honk_root_impl() -> HonkPath { // FIXME get this from the CLI arg - Path { inner: std::env::current_dir().unwrap() } + HonkPath { inner: std::env::current_dir().unwrap() } } -fn opt_typed_val(v: Option) -> Value { - if let Some(v) = v { Value::new(v) } else { Value::new(NoneType::None) } +fn opt_typed_val<'h>(heap: &'h Heap, v: Option>) -> Value<'h> { + if let Some(v) = v { + heap.alloc(v) + } else { + Value::new_none() + } } #[derive(Clone, Debug, Hash)] -pub struct Path { +pub struct HonkPath { inner: PathBuf, } -impl Path { - fn new(inner: String) -> Self { +impl HonkPath { + fn new(inner: &str) -> Self { Self { inner: if inner.starts_with("//") { honk_root_impl().inner.join(inner.trim_start_matches("//")) @@ -90,7 +71,7 @@ impl Path { } // TODO return a Set once exposed from starlark crate - fn globs(&self, patterns: &[impl AsRef]) -> List { + fn globs<'h>(&self, heap: &'h Heap, patterns: &[impl AsRef]) -> List<'h> { let mut results = List::default(); for pattern in patterns { @@ -100,7 +81,7 @@ impl Path { // TODO glob against the vfs for entry in glob::glob(&full_pattern).expect("must pass a valid glob") { - results.push(Value::new(Path { inner: entry.unwrap() })).unwrap(); + results.push(heap.alloc(HonkPath { inner: entry.unwrap() })); } } @@ -108,29 +89,57 @@ impl Path { } } -impl std::fmt::Display for Path { +impl std::fmt::Display for HonkPath { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.inner.display().fmt(f) } } -impl TypedValue for Path { - type Holder = starlark::values::Immutable; +#[starlark_module::starlark_module] +fn register_path_methods(globals: &mut GlobalsBuilder) { + fn exists(this: RefHonkPath) -> bool { + Ok(this.exists()) + } + + fn parent(this: RefHonkPath) -> Value<'v> { + Ok(opt_typed_val(heap, this.parent())) + } + + fn filename(this: RefHonkPath) -> Value<'v> { + Ok(opt_typed_val(heap, this.filename())) + } + + fn join(this: RefHonkPath, to_join: &str) -> HonkPath { + Ok(this.join(&to_join)) + } - const TYPE: &'static str = "Path"; + fn canonicalize(this: RefHonkPath) -> HonkPath { + Ok(this.canonicalize()) + } - fn values_for_descendant_check_and_freeze(&self) -> Box + '_> { - Box::new(std::iter::empty()) + fn glob(this: RefHonkPath, pattern: &str) -> List<'v> { + Ok(this.globs(heap, &[pattern])) } - fn get_hash(&self) -> Result { + fn globs(this: RefHonkPath, patterns: Vec<&str>) -> List<'v> { + Ok(this.globs(heap, &patterns)) + } +} + +impl TypedValue<'_> for HonkPath { + starlark_type!("path"); + declare_members!(register_path_methods); + + fn get_hash(&self) -> anyhow::Result { let mut hasher = std::collections::hash_map::DefaultHasher::new(); self.hash(&mut hasher); Ok(hasher.finish()) } - fn to_repr_impl(&self, buf: &mut String) -> std::fmt::Result { + fn collect_repr(&self, collector: &mut String) { use std::fmt::Write; - write!(buf, "{}", self) + write!(collector, "{}", self).expect("when can write! into a string even fail???"); } } + +starlark_immutable_value!(pub HonkPath); diff --git a/honk/src/builtins/target.rs b/honk/src/builtins/target.rs index 63a62afcd..be30a4c8e 100644 --- a/honk/src/builtins/target.rs +++ b/honk/src/builtins/target.rs @@ -1,9 +1,10 @@ -use crate::builtins::command::Command; -use starlark::values::{none::NoneType, Value}; +use crate::builtins::command::RefHonkCommand; +use starlark::{environment::GlobalsBuilder, values::none::NoneType}; -starlark_module! { globals => - target(name: String, command: Command) { - tracing::warn!(%name, ?command, "TODO implement targets"); - Ok(Value::new(NoneType::None)) +#[starlark_module::starlark_module] +pub fn register(globals: &mut GlobalsBuilder) { + fn target(name: String, command: RefHonkCommand) -> NoneType { + tracing::warn!(%name, command = %&*command, "TODO implement targets"); + Ok(NoneType) } } diff --git a/honk/src/error.rs b/honk/src/error.rs index e99dae40d..d8b329588 100644 --- a/honk/src/error.rs +++ b/honk/src/error.rs @@ -1,8 +1,6 @@ +use crate::builtins::command::Output; use starlark::values::ValueError; -use std::{ - path::PathBuf, - str::Utf8Error, -}; +use std::{path::PathBuf, str::Utf8Error, string::FromUtf8Error}; #[derive(Debug, thiserror::Error)] pub enum Error { @@ -12,14 +10,14 @@ pub enum Error { source: std::io::Error, }, - #[error("starlark error")] + #[error("starlark error:\n{0}")] StarlarkError(#[source] anyhow::Error), - // #[error("failed to run command: {0:#?}")] - // CommandFailed(Output), + #[error("failed to run command: {0:#?}")] + CommandFailed(Output), - // #[error("`{command}` returned non utf-8: {source}")] - // StdoutEncoding { source: FromUtf8Error, command: String}, + #[error("`{command}` returned non utf-8: {source}")] + StdoutEncoding { source: FromUtf8Error, command: String }, #[error("error handling JSON: {source}")] JsonError { diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 92b304360..62dd9f1c8 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,22 +1,21 @@ -use color_eyre::eyre::Result; use starlark::{ environment::FrozenModule, - environment::{Globals, Module}, + environment::Module, eval::{Evaluator, FileLoader}, syntax::{AstModule, Dialect}, }; -use std::{ - path::{Path, PathBuf}, -}; +use std::path::{Path, PathBuf}; use tracing::{debug, error, info, instrument, warn}; -// mod builtins; -mod error; -mod vfs; +pub mod builtins; +pub mod error; +pub mod vfs; -use error::{Error}; +use error::Error; use vfs::Vfs; +pub(crate) type Result = color_eyre::eyre::Result; + pub struct Workspace { /// Path to `workspace.honk`. root: PathBuf, @@ -33,7 +32,7 @@ impl Workspace { Self { root: root.as_ref().to_path_buf(), vfs: Vfs::new() } } - pub fn maintain(self) -> Result<()> { + pub fn maintain(mut self) -> crate::Result<()> { // TODO change current directory to workspace root? info!("maintaining workspace"); loop { @@ -45,7 +44,7 @@ impl Workspace { } #[instrument(level = "info", skip(self), fields(root = %self.root.display()))] - fn converge(&self) -> Result<(), Error> { + fn converge(&mut self) -> crate::Result<()> { debug!("constructing workspace env"); let _workspace_env = self.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; @@ -56,31 +55,26 @@ impl Workspace { } } -struct Revision { - modules: (), -} - impl FileLoader for Workspace { #[instrument(skip(self))] - fn load(&self, path: &str) -> anyhow::Result { + fn load(&mut self, path: &str) -> anyhow::Result { // TODO smarter way to resolve assets etc // TODO handle relative paths somehow? - let file = self.root.join(path.strip_prefix("//").unwrap_or(path)); + let path = path.strip_prefix("//").unwrap_or(path); + let file = self.root.join(path); debug!(file = %file.display(), "loading"); let root_contents = self.vfs.read(&file).expect("TODO pass errors back correctly here"); let root_contents = std::str::from_utf8(&*root_contents).expect("TODO pass errors back correctly here"); - let root_module = std::fs::read_to_string(Self::ASSET_PATH)?; - - let ast: AstModule = - AstModule::parse(Self::ASSET_PATH, root_module, &Dialect::Standard)?; - - let globals: Globals = Globals::default(); - - // TODO register our builtins as globals + let ast: AstModule = AstModule::parse(path, root_contents.to_string(), &Dialect::Standard)?; + let globals = starlark::stdlib::standard_environment() + // TODO figure out how to add set() back + .with(starlark::stdlib::add_struct) + .with(crate::builtins::register) + .build(); let module: Module = Module::new(); let mut eval: Evaluator = Evaluator::new(&module, &globals); eval.set_loader(self); diff --git a/honk/src/main.rs b/honk/src/main.rs index 50aabf1b3..58408823b 100644 --- a/honk/src/main.rs +++ b/honk/src/main.rs @@ -17,5 +17,5 @@ fn main() -> color_eyre::eyre::Result<()> { tracing::subscriber::set_global_default(subscriber)?; color_eyre::install()?; let HonkCli { workspace } = argh::from_env(); - Workspace::new(workspace).maintain() + Ok(Workspace::new(workspace).maintain()?) } From d5d099674ea14a633bbb39138215c1cb891a64a2 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 15:14:48 -0700 Subject: [PATCH 50/73] [honk] json.decode syntax matches starlark spec. --- honk/rules/cargo/metadata.honk | 3 +-- honk/src/builtins/json.rs | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/honk/rules/cargo/metadata.honk b/honk/rules/cargo/metadata.honk index f62484b5d..63f9c74aa 100644 --- a/honk/rules/cargo/metadata.honk +++ b/honk/rules/cargo/metadata.honk @@ -145,8 +145,7 @@ def cargo_metadata(manifest): outputs=[], ) command_output = metadata_command.run().stdout() - # TODO json.decode from starlark spec - decoded = json_decode(command_output) + decoded = json.decode(command_output) metadata = _metadata_dict_to_struct(decoded) if metadata.version != requested_version: diff --git a/honk/src/builtins/json.rs b/honk/src/builtins/json.rs index 66249e9f3..d42c32e41 100644 --- a/honk/src/builtins/json.rs +++ b/honk/src/builtins/json.rs @@ -2,18 +2,34 @@ use serde_json::Value as JsonValue; use starlark::{ collections::SmallMap, environment::GlobalsBuilder, - values::{dict::Dict, list::List, Heap, Value}, + starlark_immutable_value, + values::{dict::Dict, list::List, Heap, TypedValue, Value}, }; +use starlark_module::starlark_module; use std::convert::TryInto; #[starlark_module::starlark_module] pub fn register(globals: &mut GlobalsBuilder) { - // TODO make this work with the dotted syntax from the spec!!! - fn json_decode(x: String) -> Value<'v> { + const json: JsonModule = JsonModule; +} + +#[derive(Debug)] +struct JsonModule; + +#[starlark_module] +fn register_json_methods(globals: &mut GlobalsBuilder) { + fn decode(_this: RefJsonModule, x: String) -> Value<'v> { Ok(json_to_starlark(heap, serde_json::from_str(&x)?)) } } +starlark_immutable_value!(JsonModule); + +impl TypedValue<'_> for JsonModule { + starlark::starlark_type!("json"); + declare_members!(register_json_methods); +} + fn json_to_starlark<'h>(heap: &'h Heap, value: JsonValue) -> Value<'h> { match value { JsonValue::Null => Value::new_none(), From b76331e8e323e36f8fdd244c49809dfe5bc09dc4 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 15:25:09 -0700 Subject: [PATCH 51/73] [honk] Try an all-caps name to delineate project config from rules. --- workspace.honk => WORKSPACE.honk | 0 honk/src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename workspace.honk => WORKSPACE.honk (100%) diff --git a/workspace.honk b/WORKSPACE.honk similarity index 100% rename from workspace.honk rename to WORKSPACE.honk diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 62dd9f1c8..79e607e35 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -26,7 +26,7 @@ pub struct Workspace { impl Workspace { /// The asset path used to resolve the root of a honk workspace. - const ASSET_PATH: &'static str = "workspace.honk"; + const ASSET_PATH: &'static str = "WORKSPACE.honk"; pub fn new(root: impl AsRef) -> Self { Self { root: root.as_ref().to_path_buf(), vfs: Vfs::new() } From 7eaa4cdb334cfad87c23dd24c118359bccffc81e Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 15:45:10 -0700 Subject: [PATCH 52/73] [honk] Clean up FileLoader impl. --- honk/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 79e607e35..36102c170 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -64,9 +64,8 @@ impl FileLoader for Workspace { let file = self.root.join(path); debug!(file = %file.display(), "loading"); - let root_contents = self.vfs.read(&file).expect("TODO pass errors back correctly here"); - let root_contents = - std::str::from_utf8(&*root_contents).expect("TODO pass errors back correctly here"); + let root_contents = self.vfs.read(&file)?; + let root_contents = std::str::from_utf8(&*root_contents)?; let ast: AstModule = AstModule::parse(path, root_contents.to_string(), &Dialect::Standard)?; @@ -77,6 +76,7 @@ impl FileLoader for Workspace { .build(); let module: Module = Module::new(); let mut eval: Evaluator = Evaluator::new(&module, &globals); + eval.disable_gc(); // we're going to drop this right away eval.set_loader(self); let _res = eval.eval_module(ast)?; From 8f2e8f924176352e039b027a06f290e96910f61e Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 16:10:20 -0700 Subject: [PATCH 53/73] [honk] Centralize side-effectful rules in Revision. Will collect mutations from the configuration pass and serialize the full graph. --- honk/src/builtins/formatter.rs | 6 +++--- honk/src/builtins/target.rs | 6 +++--- honk/src/lib.rs | 31 +++++++++++++++++++++++++++---- honk/src/revision.rs | 15 +++++++++++++++ 4 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 honk/src/revision.rs diff --git a/honk/src/builtins/formatter.rs b/honk/src/builtins/formatter.rs index bb07c7d1c..4f4906432 100644 --- a/honk/src/builtins/formatter.rs +++ b/honk/src/builtins/formatter.rs @@ -1,10 +1,10 @@ -use crate::builtins::command::RefHonkCommand; +use crate::{builtins::command::RefHonkCommand, EvaluatorExt}; use starlark::{environment::GlobalsBuilder, values::none::NoneType}; #[starlark_module::starlark_module] pub fn register(globals: &mut GlobalsBuilder) { - fn formatter(name: String, command: RefHonkCommand) -> NoneType { - tracing::warn!(%name, command = %&*command, "TODO implement formatters"); + fn formatter(name: &str, command: RefHonkCommand) -> NoneType { + ctx.revision().register_formatter(name, command); Ok(NoneType) } } diff --git a/honk/src/builtins/target.rs b/honk/src/builtins/target.rs index be30a4c8e..70c0bcb1b 100644 --- a/honk/src/builtins/target.rs +++ b/honk/src/builtins/target.rs @@ -1,10 +1,10 @@ -use crate::builtins::command::RefHonkCommand; +use crate::{builtins::command::RefHonkCommand, EvaluatorExt}; use starlark::{environment::GlobalsBuilder, values::none::NoneType}; #[starlark_module::starlark_module] pub fn register(globals: &mut GlobalsBuilder) { - fn target(name: String, command: RefHonkCommand) -> NoneType { - tracing::warn!(%name, command = %&*command, "TODO implement targets"); + fn target(name: &str, command: RefHonkCommand) -> NoneType { + ctx.revision().register_target(name, command); Ok(NoneType) } } diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 36102c170..e7885d5d4 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -9,9 +9,11 @@ use tracing::{debug, error, info, instrument, warn}; pub mod builtins; pub mod error; +pub mod revision; pub mod vfs; use error::Error; +use revision::Revision; use vfs::Vfs; pub(crate) type Result = color_eyre::eyre::Result; @@ -46,7 +48,8 @@ impl Workspace { #[instrument(level = "info", skip(self), fields(root = %self.root.display()))] fn converge(&mut self) -> crate::Result<()> { debug!("constructing workspace env"); - let _workspace_env = self.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; + let mut loader = RevisionLoader(self, Revision::default()); + let _workspace_env = loader.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; warn!("TODO display discovered targets"); @@ -55,16 +58,18 @@ impl Workspace { } } -impl FileLoader for Workspace { +struct RevisionLoader<'w>(&'w Workspace, Revision); + +impl<'w> FileLoader for RevisionLoader<'w> { #[instrument(skip(self))] fn load(&mut self, path: &str) -> anyhow::Result { // TODO smarter way to resolve assets etc // TODO handle relative paths somehow? let path = path.strip_prefix("//").unwrap_or(path); - let file = self.root.join(path); + let file = self.0.root.join(path); debug!(file = %file.display(), "loading"); - let root_contents = self.vfs.read(&file)?; + let root_contents = self.0.vfs.read(&file)?; let root_contents = std::str::from_utf8(&*root_contents)?; let ast: AstModule = AstModule::parse(path, root_contents.to_string(), &Dialect::Standard)?; @@ -77,9 +82,27 @@ impl FileLoader for Workspace { let module: Module = Module::new(); let mut eval: Evaluator = Evaluator::new(&module, &globals); eval.disable_gc(); // we're going to drop this right away + + let revision = self.1.clone(); + eval.set_revision(&revision); eval.set_loader(self); let _res = eval.eval_module(ast)?; Ok(module.freeze()) } } + +pub trait EvaluatorExt<'r> { + fn set_revision(&mut self, revision: &'r Revision); + fn revision(&self) -> &'r Revision; +} + +impl<'a> EvaluatorExt<'a> for Evaluator<'_, 'a> { + fn set_revision(&mut self, revision: &'a Revision) { + self.extra = Some(revision); + } + + fn revision(&self) -> &'a Revision { + self.extra.clone().unwrap().downcast_ref().unwrap() + } +} diff --git a/honk/src/revision.rs b/honk/src/revision.rs new file mode 100644 index 000000000..3f48e4ae6 --- /dev/null +++ b/honk/src/revision.rs @@ -0,0 +1,15 @@ +use crate::builtins::command::RefHonkCommand; +use gazebo::any::AnyLifetime; + +#[derive(AnyLifetime, Clone, Debug, Default)] +pub struct Revision {} + +impl Revision { + pub fn register_formatter(&self, name: &str, command: RefHonkCommand) { + tracing::warn!(%name, command = %&*command, "TODO implement formatters"); + } + + pub fn register_target(&self, name: &str, command: RefHonkCommand) { + tracing::warn!(%name, command = %&*command, "TODO implement targets"); + } +} From 7cdf4bbe0e483ae1e5b68e28a53df3f9585e1c0e Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 16:14:03 -0700 Subject: [PATCH 54/73] [honk] Define RevisionState that can actually be mutated. --- honk/Cargo.lock | 48 ++++++++++++++++++++++++++++++++++++++++++-- honk/Cargo.toml | 1 + honk/src/revision.rs | 21 +++++++++++++++++-- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/honk/Cargo.lock b/honk/Cargo.lock index 9dd8f4d69..c279a5ffc 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -768,6 +768,7 @@ dependencies = [ "glob", "memofs", "once_cell", + "parking_lot", "serde_json", "starlark", "starlark_module", @@ -824,6 +825,15 @@ dependencies = [ "libc", ] +[[package]] +name = "instant" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "iovec" version = "0.1.4" @@ -917,6 +927,15 @@ version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +[[package]] +name = "lock_api" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" +dependencies = [ + "scopeguard", +] + [[package]] name = "log" version = "0.4.11" @@ -1179,6 +1198,31 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a1250cdd103eef6bd542b5ae82989f931fc00a41a27f60377338241594410f3" +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall 0.2.5", + "smallvec", + "winapi 0.3.9", +] + [[package]] name = "paste" version = "1.0.5" @@ -1556,9 +1600,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "1.4.2" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "starlark" diff --git a/honk/Cargo.toml b/honk/Cargo.toml index dc39eb331..bb3e1a965 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -21,6 +21,7 @@ crossbeam-channel = "0.4.0" glob = "0.3.0" memofs = "0.1.2" once_cell = "1" +parking_lot = "0.11.1" serde_json = "1.0.59" thiserror = "1.0.21" tracing = "0.1.21" diff --git a/honk/src/revision.rs b/honk/src/revision.rs index 3f48e4ae6..169d1d794 100644 --- a/honk/src/revision.rs +++ b/honk/src/revision.rs @@ -1,15 +1,32 @@ use crate::builtins::command::RefHonkCommand; use gazebo::any::AnyLifetime; +use parking_lot::Mutex; +use std::sync::Arc; #[derive(AnyLifetime, Clone, Debug, Default)] -pub struct Revision {} +pub struct Revision { + inner: Arc>, +} impl Revision { pub fn register_formatter(&self, name: &str, command: RefHonkCommand) { - tracing::warn!(%name, command = %&*command, "TODO implement formatters"); + self.inner.lock().register_formatter(name, command); } pub fn register_target(&self, name: &str, command: RefHonkCommand) { + self.inner.lock().register_target(name, command); + } +} + +#[derive(Debug, Default)] +struct RevisionState {} + +impl RevisionState { + fn register_formatter(&mut self, name: &str, command: RefHonkCommand) { + tracing::warn!(%name, command = %&*command, "TODO implement formatters"); + } + + fn register_target(&mut self, name: &str, command: RefHonkCommand) { tracing::warn!(%name, command = %&*command, "TODO implement targets"); } } From 02a69e1d146aba987b9f15c52998e4271a25b554 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 16:21:06 -0700 Subject: [PATCH 55/73] [honk] Collect formatters and targets, print at end. --- honk/src/lib.rs | 4 ++-- honk/src/revision.rs | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index e7885d5d4..daeed48e3 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -5,7 +5,7 @@ use starlark::{ syntax::{AstModule, Dialect}, }; use std::path::{Path, PathBuf}; -use tracing::{debug, error, info, instrument, warn}; +use tracing::{debug, error, info, instrument}; pub mod builtins; pub mod error; @@ -51,7 +51,7 @@ impl Workspace { let mut loader = RevisionLoader(self, Revision::default()); let _workspace_env = loader.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; - warn!("TODO display discovered targets"); + info!(revision = ?loader.1, "discovered targets"); info!("finished"); Ok(()) diff --git a/honk/src/revision.rs b/honk/src/revision.rs index 169d1d794..9b4e8273c 100644 --- a/honk/src/revision.rs +++ b/honk/src/revision.rs @@ -1,7 +1,7 @@ -use crate::builtins::command::RefHonkCommand; +use crate::builtins::command::{HonkCommand, RefHonkCommand}; use gazebo::any::AnyLifetime; use parking_lot::Mutex; -use std::sync::Arc; +use std::{collections::BTreeMap, sync::Arc}; #[derive(AnyLifetime, Clone, Debug, Default)] pub struct Revision { @@ -19,14 +19,17 @@ impl Revision { } #[derive(Debug, Default)] -struct RevisionState {} +struct RevisionState { + formatters: BTreeMap, + targets: BTreeMap, +} impl RevisionState { fn register_formatter(&mut self, name: &str, command: RefHonkCommand) { - tracing::warn!(%name, command = %&*command, "TODO implement formatters"); + self.formatters.insert(name.to_owned(), command.clone()); } fn register_target(&mut self, name: &str, command: RefHonkCommand) { - tracing::warn!(%name, command = %&*command, "TODO implement targets"); + self.targets.insert(name.to_owned(), command.clone()); } } From a61093cfb59744d0407cecbbcaa4a29413d802d4 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 18:18:24 -0700 Subject: [PATCH 56/73] [honk] Resolve declared targets into a single graph. Implement Debug using graphviz output for visualization. --- honk/Cargo.lock | 1 + honk/Cargo.toml | 1 + honk/src/builtins/command.rs | 8 +-- honk/src/builtins/path.rs | 2 +- honk/src/lib.rs | 5 +- honk/src/revision.rs | 122 ++++++++++++++++++++++++++++++++++- 6 files changed, 130 insertions(+), 9 deletions(-) diff --git a/honk/Cargo.lock b/honk/Cargo.lock index c279a5ffc..37051fbb5 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -769,6 +769,7 @@ dependencies = [ "memofs", "once_cell", "parking_lot", + "petgraph", "serde_json", "starlark", "starlark_module", diff --git a/honk/Cargo.toml b/honk/Cargo.toml index bb3e1a965..df11fd5df 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -22,6 +22,7 @@ glob = "0.3.0" memofs = "0.1.2" once_cell = "1" parking_lot = "0.11.1" +petgraph = "0.5.1" serde_json = "1.0.59" thiserror = "1.0.21" tracing = "0.1.21" diff --git a/honk/src/builtins/command.rs b/honk/src/builtins/command.rs index 1d488b6a3..4247a15a2 100644 --- a/honk/src/builtins/command.rs +++ b/honk/src/builtins/command.rs @@ -27,10 +27,10 @@ pub fn register(builder: &mut GlobalsBuilder) { #[derive(Clone, Debug)] pub struct HonkCommand { - command: String, - args: Vec, - inputs: Vec, - outputs: Vec, + pub command: String, + pub args: Vec, + pub inputs: Vec, + pub outputs: Vec, } impl HonkCommand { diff --git a/honk/src/builtins/path.rs b/honk/src/builtins/path.rs index 5d2cb8b3a..9d5285a2f 100644 --- a/honk/src/builtins/path.rs +++ b/honk/src/builtins/path.rs @@ -33,7 +33,7 @@ fn opt_typed_val<'h>(heap: &'h Heap, v: Option>) -> Value<'h } } -#[derive(Clone, Debug, Hash)] +#[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct HonkPath { inner: PathBuf, } diff --git a/honk/src/lib.rs b/honk/src/lib.rs index daeed48e3..8d617ed92 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -51,7 +51,10 @@ impl Workspace { let mut loader = RevisionLoader(self, Revision::default()); let _workspace_env = loader.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; - info!(revision = ?loader.1, "discovered targets"); + let build = loader.1.resolve()?; + debug!(?build, "discovered targets"); + + tracing::warn!("uh run some builds i guess?"); info!("finished"); Ok(()) diff --git a/honk/src/revision.rs b/honk/src/revision.rs index 9b4e8273c..c8a253cab 100644 --- a/honk/src/revision.rs +++ b/honk/src/revision.rs @@ -1,7 +1,14 @@ -use crate::builtins::command::{HonkCommand, RefHonkCommand}; +use crate::builtins::{ + command::{HonkCommand, RefHonkCommand}, + path::HonkPath, +}; use gazebo::any::AnyLifetime; use parking_lot::Mutex; -use std::{collections::BTreeMap, sync::Arc}; +use petgraph::prelude::*; +use std::{ + collections::{BTreeMap, HashMap}, + sync::Arc, +}; #[derive(AnyLifetime, Clone, Debug, Default)] pub struct Revision { @@ -16,6 +23,10 @@ impl Revision { pub fn register_target(&self, name: &str, command: RefHonkCommand) { self.inner.lock().register_target(name, command); } + + pub fn resolve(&self) -> crate::Result { + self.inner.lock().resolve() + } } #[derive(Debug, Default)] @@ -26,10 +37,115 @@ struct RevisionState { impl RevisionState { fn register_formatter(&mut self, name: &str, command: RefHonkCommand) { - self.formatters.insert(name.to_owned(), command.clone()); + let mut command = command.clone(); + // TODO find a better way to avoid cycles in the dep graph + command.inputs.clear(); + command.outputs.clear(); + self.formatters.insert(name.to_owned(), command); } fn register_target(&mut self, name: &str, command: RefHonkCommand) { self.targets.insert(name.to_owned(), command.clone()); } + + fn resolve(&mut self) -> crate::Result { + let mut graph = BuildGraph::new(); + + for (name, formatter) in &self.formatters { + let idx = graph.command(name, formatter); + graph.dep(graph.formatted(), idx); + } + + for (name, target) in &self.targets { + let idx = graph.command(name, target); + graph.dep(idx, graph.formatted()); + } + + // TODO validate the dep graph? + + Ok(graph) + } +} + +pub struct BuildGraph { + inner: DiGraph, ()>, + indices: HashMap, NodeIndex>, + formatted: Arc, +} + +impl BuildGraph { + fn new() -> Self { + let mut inner = DiGraph::default(); + let mut indices = HashMap::default(); + let formatted = Arc::new(Node::Formatted); + indices.insert(formatted.clone(), inner.add_node(formatted.clone())); + Self { inner, indices, formatted } + } + + fn command(&mut self, name: &str, command: &HonkCommand) -> NodeIndex { + let idx = self.action(name, &command.command, &command.args[..]); + + for input in &command.inputs { + let input = self.file(input); + self.dep(idx, input); + } + + for output in &command.outputs { + let output = self.file(output); + self.dep(output, idx); + } + + idx + } + + fn file(&mut self, path: &HonkPath) -> NodeIndex { + let Self { inner, indices, .. } = self; + // TODO less allocating? + let node = Arc::new(Node::File(path.to_owned())); + *indices.entry(node.clone()).or_insert_with(|| inner.add_node(node)) + } + + fn action(&mut self, name: &str, command: &str, args: &[String]) -> NodeIndex { + let Self { inner, indices, .. } = self; + // TODO less allocating? + let args = args.iter().map(|a| a.to_string()).collect(); + let node = + Arc::new(Node::Action { name: name.to_owned(), command: command.to_owned(), args }); + *indices.entry(node.clone()).or_insert_with(|| inner.add_node(node)) + } + + fn formatted(&self) -> NodeIndex { + self.indices[&self.formatted] + } + + fn dep(&mut self, from: NodeIndex, to: NodeIndex) { + self.inner.update_edge(from, to, ()); + } +} + +impl std::fmt::Debug for BuildGraph { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + use petgraph::dot::{Config, Dot}; + Dot::with_config(&self.inner, &[Config::EdgeNoLabel]).fmt(f) + } +} + +#[derive(Eq, Hash, PartialEq)] +enum Node { + /// A special node used to schedule all formatters before anything that relies on their output. + Formatted, + /// A file in the build graph. + File(HonkPath), + /// A command to run in the build graph. + Action { name: String, command: String, args: Vec }, +} + +impl std::fmt::Debug for Node { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Formatted => "FORMATTER BARRIER".fmt(f), + Self::File(p) => write!(f, "file:{}", p), + Self::Action { name, .. } => write!(f, "action:{}", name), + } + } } From 12122a303baffba8ae90ba8508786113b1f1bef8 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 18:19:42 -0700 Subject: [PATCH 57/73] [honk] Remove unused muts. --- honk/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 8d617ed92..3fdba88b3 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -34,7 +34,7 @@ impl Workspace { Self { root: root.as_ref().to_path_buf(), vfs: Vfs::new() } } - pub fn maintain(mut self) -> crate::Result<()> { + pub fn maintain(self) -> crate::Result<()> { // TODO change current directory to workspace root? info!("maintaining workspace"); loop { @@ -46,7 +46,7 @@ impl Workspace { } #[instrument(level = "info", skip(self), fields(root = %self.root.display()))] - fn converge(&mut self) -> crate::Result<()> { + fn converge(&self) -> crate::Result<()> { debug!("constructing workspace env"); let mut loader = RevisionLoader(self, Revision::default()); let _workspace_env = loader.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; From f9fb00b9741bec942efce21e51c10378de0b13a6 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 21 Mar 2021 18:30:47 -0700 Subject: [PATCH 58/73] [honk] Validate build graph when resolving. --- honk/src/error.rs | 9 +++++++++ honk/src/revision.rs | 20 ++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/honk/src/error.rs b/honk/src/error.rs index d8b329588..09b13e458 100644 --- a/honk/src/error.rs +++ b/honk/src/error.rs @@ -28,6 +28,15 @@ pub enum Error { #[allow(unused)] #[error("non utf-8 *.honk script encountered at {}", file.display())] ScriptEncoding { source: Utf8Error, file: PathBuf }, + + #[error("graph contains cycles but cycles are not allowed because fixpoints suuuuck")] + GraphContainsCycles, + + #[error( + "graph must have all nodes reachable as a single \ + connected component, found {num_components} components" + )] + GraphIsSplit { num_components: usize }, } impl From for ValueError { diff --git a/honk/src/revision.rs b/honk/src/revision.rs index c8a253cab..3b7a060c1 100644 --- a/honk/src/revision.rs +++ b/honk/src/revision.rs @@ -1,6 +1,9 @@ -use crate::builtins::{ - command::{HonkCommand, RefHonkCommand}, - path::HonkPath, +use crate::{ + builtins::{ + command::{HonkCommand, RefHonkCommand}, + path::HonkPath, + }, + error::Error, }; use gazebo::any::AnyLifetime; use parking_lot::Mutex; @@ -61,9 +64,14 @@ impl RevisionState { graph.dep(idx, graph.formatted()); } - // TODO validate the dep graph? - - Ok(graph) + let num_components = petgraph::algo::connected_components(&graph.inner); + if num_components != 1 { + Err(Error::GraphIsSplit { num_components }) + } else if petgraph::algo::is_cyclic_directed(&graph.inner) { + Err(Error::GraphContainsCycles) + } else { + Ok(graph) + } } } From 7fc159a3768a71debe5314d073358cb531f2705c Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 4 Apr 2021 08:18:08 -0700 Subject: [PATCH 59/73] [vscode] Disable auto run tasks, honk will supercede them. --- .vscode/tasks.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2db8805c8..e52123006 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,5 +1,5 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=733558 + // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ @@ -11,7 +11,7 @@ "panel": "dedicated" }, "runOptions": { - "runOn": "folderOpen" + // "runOn": "folderOpen" }, "isBackground": true, "command": "cargo", @@ -30,7 +30,7 @@ "panel": "dedicated" }, "runOptions": { - "runOn": "folderOpen" + // "runOn": "folderOpen" }, "isBackground": true, "command": "cargo", @@ -49,7 +49,7 @@ "panel": "dedicated" }, "runOptions": { - "runOn": "folderOpen" + // "runOn": "folderOpen" }, "isBackground": true, "command": "cargo", @@ -68,7 +68,7 @@ "panel": "dedicated" }, "runOptions": { - "runOn": "folderOpen" + // "runOn": "folderOpen" }, "isBackground": true, "command": "cargo", @@ -85,7 +85,7 @@ "panel": "dedicated" }, "runOptions": { - "runOn": "folderOpen" + // "runOn": "folderOpen" }, "isBackground": true, "command": "cargo", @@ -104,7 +104,7 @@ "panel": "dedicated" }, "runOptions": { - "runOn": "folderOpen" + // "runOn": "folderOpen" }, "isBackground": true, "command": "cargo", @@ -127,7 +127,7 @@ "panel": "dedicated" }, "runOptions": { - "runOn": "folderOpen" + // "runOn": "folderOpen" }, "isBackground": true, "command": "npx", @@ -141,4 +141,4 @@ "problemMatcher": [] } ] -} \ No newline at end of file +} From 1e5b13830c335992caae61fbfb29eb42a22b4022 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 4 Apr 2021 08:29:29 -0700 Subject: [PATCH 60/73] [honk] Order tests based on dep graph. --- honk/rules/cargo/metadata.honk | 16 ++++++++++++++++ honk/rules/cargo/workspace.honk | 15 ++++++++++++--- honk/src/builtins/target.rs | 4 ++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/honk/rules/cargo/metadata.honk b/honk/rules/cargo/metadata.honk index 63f9c74aa..420659fc5 100644 --- a/honk/rules/cargo/metadata.honk +++ b/honk/rules/cargo/metadata.honk @@ -99,6 +99,22 @@ def _package_dict_to_struct(package): ) +def _dep_is_local(metadata, dep): + for id in metadata.member_ids: + package = metadata.packages[id] + if package.name == dep.name: + return True + return False + + +def package_workspace_deps(metadata, package): + local_deps = [] + for dep in package.dependencies: + if _dep_is_local(metadata, dep): + local_deps.append(dep) + return local_deps + + def _metadata_dict_to_struct(metadata): packages = dict() for raw_package in metadata["packages"]: diff --git a/honk/rules/cargo/workspace.honk b/honk/rules/cargo/workspace.honk index 84df55b2e..bb3737c22 100644 --- a/honk/rules/cargo/workspace.honk +++ b/honk/rules/cargo/workspace.honk @@ -1,5 +1,8 @@ load("//honk/rules/cargo/clippy.honk", "lint_crate") -load("//honk/rules/cargo/metadata.honk", "cargo_metadata", "rust_files_in_package") +load( + "//honk/rules/cargo/metadata.honk", + "cargo_metadata", "package_workspace_deps", "rust_files_in_package" +) load("//honk/rules/cargo/rustfmt.honk", "format_crate") load("//honk/rules/cargo/wasm-pack.honk", "maybe_wasm_crate") @@ -14,10 +17,15 @@ load("//honk/rules/cargo/wasm-pack.honk", "maybe_wasm_crate") # TODO add workspace dependencies between crates -def test_crate(package): +def test_crate(metadata, package): """ Run `cargo test --all-targets -p ${package}`. """ + deps = [] + for local_dep in package_workspace_deps(metadata, package): + # TODO think of a way to distinguish target deps from path deps other than type + deps.append("test-" + local_dep.name) + target( name="test-" + package.name, command=command( @@ -28,6 +36,7 @@ def test_crate(package): # TODO automagically convert strings for inputs/outputs outputs=[path("target")], ), + deps=deps, ) @@ -83,6 +92,6 @@ def cargo_workspace(manifest): document_crate(package) # "tests" - test_crate(package) + test_crate(metadata, package) doctest_crate(package) lint_crate(package) diff --git a/honk/src/builtins/target.rs b/honk/src/builtins/target.rs index 70c0bcb1b..429a6c5a3 100644 --- a/honk/src/builtins/target.rs +++ b/honk/src/builtins/target.rs @@ -1,9 +1,9 @@ use crate::{builtins::command::RefHonkCommand, EvaluatorExt}; -use starlark::{environment::GlobalsBuilder, values::none::NoneType}; +use starlark::{environment::GlobalsBuilder, values::{Value, none::NoneType}}; #[starlark_module::starlark_module] pub fn register(globals: &mut GlobalsBuilder) { - fn target(name: &str, command: RefHonkCommand) -> NoneType { + fn target(name: &str, command: RefHonkCommand, deps: Option>>) -> NoneType { ctx.revision().register_target(name, command); Ok(NoneType) } From 21c946e194995b1fd19bbd66a922b11c07623f78 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 4 Apr 2021 08:29:54 -0700 Subject: [PATCH 61/73] [honk] Dump graphviz of a successful resolution. --- honk/src/lib.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 3fdba88b3..89236df21 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -51,8 +51,11 @@ impl Workspace { let mut loader = RevisionLoader(self, Revision::default()); let _workspace_env = loader.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; - let build = loader.1.resolve()?; - debug!(?build, "discovered targets"); + let _build = loader.1.resolve()?; + info!("discovered targets"); + + // FIXME make this an actual web viewer via http server, right? + dump_graphviz(&_build); tracing::warn!("uh run some builds i guess?"); @@ -61,6 +64,12 @@ impl Workspace { } } +fn dump_graphviz(g: &revision::ActionGraph) { + use petgraph::dot::{Config, Dot}; + let output = Dot::with_config(g, &[Config::EdgeNoLabel]); + println!("{}", output); +} + struct RevisionLoader<'w>(&'w Workspace, Revision); impl<'w> FileLoader for RevisionLoader<'w> { From 8788a6edf2d1171c4e580e7fc175445f821b8c64 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 4 Apr 2021 08:31:30 -0700 Subject: [PATCH 62/73] [honk] Add graph resolution stage. --- honk/src/error.rs | 3 + honk/src/revision.rs | 134 ++++++++++++++++++++++++++++++++----------- 2 files changed, 104 insertions(+), 33 deletions(-) diff --git a/honk/src/error.rs b/honk/src/error.rs index 09b13e458..1733787b0 100644 --- a/honk/src/error.rs +++ b/honk/src/error.rs @@ -37,6 +37,9 @@ pub enum Error { connected component, found {num_components} components" )] GraphIsSplit { num_components: usize }, + + #[error("couldn't find {target} in the dependency graph")] + GraphResolutionFailure { target: String }, } impl From for ValueError { diff --git a/honk/src/revision.rs b/honk/src/revision.rs index 3b7a060c1..1f256baf3 100644 --- a/honk/src/revision.rs +++ b/honk/src/revision.rs @@ -27,7 +27,7 @@ impl Revision { self.inner.lock().register_target(name, command); } - pub fn resolve(&self) -> crate::Result { + pub fn resolve(&self) -> crate::Result { self.inner.lock().resolve() } } @@ -51,8 +51,8 @@ impl RevisionState { self.targets.insert(name.to_owned(), command.clone()); } - fn resolve(&mut self) -> crate::Result { - let mut graph = BuildGraph::new(); + fn resolve(&mut self) -> crate::Result { + let mut graph = GraphBuilder::new(); for (name, formatter) in &self.formatters { let idx = graph.command(name, formatter); @@ -64,38 +64,50 @@ impl RevisionState { graph.dep(idx, graph.formatted()); } - let num_components = petgraph::algo::connected_components(&graph.inner); - if num_components != 1 { - Err(Error::GraphIsSplit { num_components }) - } else if petgraph::algo::is_cyclic_directed(&graph.inner) { - Err(Error::GraphContainsCycles) - } else { - Ok(graph) - } + graph.build() } } -pub struct BuildGraph { - inner: DiGraph, ()>, +pub type ActionGraph = DiGraph; +pub type DepGraph = DiGraph, i32>; + +pub struct GraphBuilder { + inner: DepGraph, indices: HashMap, NodeIndex>, formatted: Arc, + pending_target_name_deps: HashMap>, + target_name_to_idx: HashMap, } -impl BuildGraph { +impl GraphBuilder { fn new() -> Self { - let mut inner = DiGraph::default(); + let mut inner = DepGraph::default(); let mut indices = HashMap::default(); let formatted = Arc::new(Node::Formatted); indices.insert(formatted.clone(), inner.add_node(formatted.clone())); - Self { inner, indices, formatted } + Self { + inner, + indices, + formatted, + pending_target_name_deps: Default::default(), + target_name_to_idx: Default::default(), + } } fn command(&mut self, name: &str, command: &HonkCommand) -> NodeIndex { let idx = self.action(name, &command.command, &command.args[..]); for input in &command.inputs { - let input = self.file(input); - self.dep(idx, input); + todo!() + // match input { + // Input::File(f) => { + // let input = self.file(f); + // self.dep(idx, input); + // } + // Input::Target(t) => { + // self.pending_target_name_deps.entry(t.to_string()).or_default().push(idx) + // } + // } } for output in &command.outputs { @@ -114,12 +126,19 @@ impl BuildGraph { } fn action(&mut self, name: &str, command: &str, args: &[String]) -> NodeIndex { - let Self { inner, indices, .. } = self; + let Self { inner, indices, target_name_to_idx, .. } = self; // TODO less allocating? let args = args.iter().map(|a| a.to_string()).collect(); - let node = - Arc::new(Node::Action { name: name.to_owned(), command: command.to_owned(), args }); - *indices.entry(node.clone()).or_insert_with(|| inner.add_node(node)) + let node = Arc::new(Node::Action(Action { + name: name.to_owned(), + command: command.to_owned(), + args, + })); + *indices.entry(node.clone()).or_insert_with(|| { + let idx = inner.add_node(node); + target_name_to_idx.insert(name.to_owned(), idx); + idx + }) } fn formatted(&self) -> NodeIndex { @@ -127,33 +146,82 @@ impl BuildGraph { } fn dep(&mut self, from: NodeIndex, to: NodeIndex) { - self.inner.update_edge(from, to, ()); + self.inner.update_edge(from, to, 0); } -} -impl std::fmt::Debug for BuildGraph { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - use petgraph::dot::{Config, Dot}; - Dot::with_config(&self.inner, &[Config::EdgeNoLabel]).fmt(f) + fn build(mut self) -> crate::Result { + self.drain_pending()?; + let graph = rewrite_file_edges(self.inner); + + let num_components = petgraph::algo::connected_components(&graph); + if num_components != 1 { + Err(Error::GraphIsSplit { num_components }) + } else if petgraph::algo::is_cyclic_directed(&graph) { + Err(Error::GraphContainsCycles) + } else { + Ok(graph) + } + } + + fn drain_pending(&mut self) -> crate::Result<()> { + for (target, deps) in self.pending_target_name_deps.drain().collect::>() { + let target = if let Some(t) = self.target_name_to_idx.get(&target) { + *t + } else { + return Err(Error::GraphResolutionFailure { target }); + }; + for dep in deps { + self.dep(dep, target); + } + } + + Ok(()) } } -#[derive(Eq, Hash, PartialEq)] -enum Node { +fn rewrite_file_edges(deps: DepGraph) -> ActionGraph { + let mut actions = ActionGraph::new(); + + // FIXME this leaves an empty graph lol + // graph.retain_nodes(|this, idx| !this[idx].is_file()); + actions +} + +#[derive(Debug, Eq, Hash, PartialEq)] +pub enum Node { /// A special node used to schedule all formatters before anything that relies on their output. Formatted, /// A file in the build graph. File(HonkPath), /// A command to run in the build graph. - Action { name: String, command: String, args: Vec }, + Action(Action), } -impl std::fmt::Debug for Node { +impl Node { + fn is_file(&self) -> bool { + matches!(self, Self::File(..)) + } +} + +impl std::fmt::Display for Node { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Formatted => "FORMATTER BARRIER".fmt(f), Self::File(p) => write!(f, "file:{}", p), - Self::Action { name, .. } => write!(f, "action:{}", name), + Self::Action(a) => write!(f, "{}", a), } } } + +#[derive(Debug, Eq, Hash, PartialEq)] +pub struct Action { + name: String, + command: String, + args: Vec, +} + +impl std::fmt::Display for Action { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "action:{}", &self.name) + } +} From 1bc338169711377ba2ed5b1ab5d9872d445881de Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 4 Apr 2021 13:37:04 -0700 Subject: [PATCH 63/73] [honk] format honk during workflow --- .cargo/config.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 6312ef774..c5dd2fbc4 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -131,4 +131,5 @@ docs-ofl = "doc --manifest-path ofl/Cargo.toml --workspace --no-deps" # honk honk = "run --manifest-path honk/Cargo.toml --release --" -honk-flow = "watch --clear -w honk/src -w honk/Cargo.toml -w Cargo.toml -x honk" +fmt-honk = "fmt --manifest-path honk/Cargo.toml" +honk-flow = "watch -w honk/src -w honk/Cargo.toml -w Cargo.toml -x fmt-honk -x honk" From b6f09a618457264044873a4cfc55ce7117fabd9c Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 4 Apr 2021 13:40:42 -0700 Subject: [PATCH 64/73] [honk] Add edges from actions to actions via files. --- honk/src/builtins/target.rs | 35 +++++++++- honk/src/error.rs | 4 +- honk/src/revision.rs | 132 ++++++++++++++++++++++++------------ 3 files changed, 125 insertions(+), 46 deletions(-) diff --git a/honk/src/builtins/target.rs b/honk/src/builtins/target.rs index 429a6c5a3..6098a9de9 100644 --- a/honk/src/builtins/target.rs +++ b/honk/src/builtins/target.rs @@ -1,10 +1,41 @@ use crate::{builtins::command::RefHonkCommand, EvaluatorExt}; -use starlark::{environment::GlobalsBuilder, values::{Value, none::NoneType}}; +use starlark::{ + environment::GlobalsBuilder, + values::{none::NoneType, Value}, +}; +use std::collections::BTreeSet; #[starlark_module::starlark_module] pub fn register(globals: &mut GlobalsBuilder) { fn target(name: &str, command: RefHonkCommand, deps: Option>>) -> NoneType { - ctx.revision().register_target(name, command); + let deps: DepSet = deps.into(); + ctx.revision().register_target(name, command, &deps); Ok(NoneType) } } + +#[derive(Clone, Debug, Default)] +pub struct DepSet { + inner: BTreeSet, +} + +impl<'a> From>>> for DepSet { + fn from(v: Option>>) -> Self { + Self { + inner: v + .into_iter() + .map(IntoIterator::into_iter) + .flatten() + .map(|a| a.to_str()) + .collect(), + } + } +} + +impl<'a> IntoIterator for &'a DepSet { + type Item = &'a String; + type IntoIter = <&'a BTreeSet as IntoIterator>::IntoIter; + fn into_iter(self) -> Self::IntoIter { + (&self.inner).into_iter() + } +} diff --git a/honk/src/error.rs b/honk/src/error.rs index 1733787b0..baebc8172 100644 --- a/honk/src/error.rs +++ b/honk/src/error.rs @@ -29,8 +29,8 @@ pub enum Error { #[error("non utf-8 *.honk script encountered at {}", file.display())] ScriptEncoding { source: Utf8Error, file: PathBuf }, - #[error("graph contains cycles but cycles are not allowed because fixpoints suuuuck")] - GraphContainsCycles, + #[error("graph contains cycle but cycles are not allowed because fixpoints suuuuck")] + GraphContainsCycles(petgraph::algo::Cycle), #[error( "graph must have all nodes reachable as a single \ diff --git a/honk/src/revision.rs b/honk/src/revision.rs index 1f256baf3..4ea8e3547 100644 --- a/honk/src/revision.rs +++ b/honk/src/revision.rs @@ -2,6 +2,7 @@ use crate::{ builtins::{ command::{HonkCommand, RefHonkCommand}, path::HonkPath, + target::DepSet, }, error::Error, }; @@ -23,8 +24,8 @@ impl Revision { self.inner.lock().register_formatter(name, command); } - pub fn register_target(&self, name: &str, command: RefHonkCommand) { - self.inner.lock().register_target(name, command); + pub fn register_target(&self, name: &str, command: RefHonkCommand, deps: &DepSet) { + self.inner.lock().register_target(name, command, deps); } pub fn resolve(&self) -> crate::Result { @@ -34,8 +35,8 @@ impl Revision { #[derive(Debug, Default)] struct RevisionState { - formatters: BTreeMap, - targets: BTreeMap, + formatters: BTreeMap, + targets: BTreeMap, } impl RevisionState { @@ -44,23 +45,23 @@ impl RevisionState { // TODO find a better way to avoid cycles in the dep graph command.inputs.clear(); command.outputs.clear(); - self.formatters.insert(name.to_owned(), command); + self.formatters.insert(name.to_owned(), (command, Default::default())); } - fn register_target(&mut self, name: &str, command: RefHonkCommand) { - self.targets.insert(name.to_owned(), command.clone()); + fn register_target(&mut self, name: &str, command: RefHonkCommand, deps: &DepSet) { + self.targets.insert(name.to_owned(), (command.clone(), deps.clone())); } fn resolve(&mut self) -> crate::Result { let mut graph = GraphBuilder::new(); - for (name, formatter) in &self.formatters { - let idx = graph.command(name, formatter); + for (name, (formatter, deps)) in &self.formatters { + let idx = graph.command(name, formatter, deps); graph.dep(graph.formatted(), idx); } - for (name, target) in &self.targets { - let idx = graph.command(name, target); + for (name, (target, deps)) in &self.targets { + let idx = graph.command(name, target, deps); graph.dep(idx, graph.formatted()); } @@ -94,20 +95,19 @@ impl GraphBuilder { } } - fn command(&mut self, name: &str, command: &HonkCommand) -> NodeIndex { - let idx = self.action(name, &command.command, &command.args[..]); + fn command(&mut self, name: &str, command: &HonkCommand, deps: &DepSet) -> NodeIndex { + let idx = self.action( + name, + &command.command, + &command.args[..], + &command.inputs[..], + &command.outputs[..], + deps, + ); for input in &command.inputs { - todo!() - // match input { - // Input::File(f) => { - // let input = self.file(f); - // self.dep(idx, input); - // } - // Input::Target(t) => { - // self.pending_target_name_deps.entry(t.to_string()).or_default().push(idx) - // } - // } + let input = self.file(input); + self.dep(idx, input); } for output in &command.outputs { @@ -125,7 +125,15 @@ impl GraphBuilder { *indices.entry(node.clone()).or_insert_with(|| inner.add_node(node)) } - fn action(&mut self, name: &str, command: &str, args: &[String]) -> NodeIndex { + fn action( + &mut self, + name: &str, + command: &str, + args: &[String], + inputs: &[HonkPath], + outputs: &[HonkPath], + deps: &DepSet, + ) -> NodeIndex { let Self { inner, indices, target_name_to_idx, .. } = self; // TODO less allocating? let args = args.iter().map(|a| a.to_string()).collect(); @@ -133,12 +141,20 @@ impl GraphBuilder { name: name.to_owned(), command: command.to_owned(), args, + inputs: inputs.to_vec(), + outputs: outputs.to_vec(), })); - *indices.entry(node.clone()).or_insert_with(|| { + let idx = *indices.entry(node.clone()).or_insert_with(|| { let idx = inner.add_node(node); target_name_to_idx.insert(name.to_owned(), idx); idx - }) + }); + + for dep in deps { + self.pending_target_name_deps.entry(dep.to_string()).or_default().push(idx); + } + + idx } fn formatted(&self) -> NodeIndex { @@ -151,13 +167,11 @@ impl GraphBuilder { fn build(mut self) -> crate::Result { self.drain_pending()?; - let graph = rewrite_file_edges(self.inner); + let graph = self.collapse_non_action_edges()?; let num_components = petgraph::algo::connected_components(&graph); if num_components != 1 { Err(Error::GraphIsSplit { num_components }) - } else if petgraph::algo::is_cyclic_directed(&graph) { - Err(Error::GraphContainsCycles) } else { Ok(graph) } @@ -177,14 +191,52 @@ impl GraphBuilder { Ok(()) } -} -fn rewrite_file_edges(deps: DepGraph) -> ActionGraph { - let mut actions = ActionGraph::new(); + fn collapse_non_action_edges(&mut self) -> crate::Result { + // for each non action edge, get all ins and all outs, make edges between + for i in self.inner.node_indices() { + if matches!(&*self.inner[i], Node::Action(..)) { + continue; + } + + let mut in_neighbors = vec![]; + add_all_action_indices(&self.inner, i, &mut in_neighbors, Direction::Incoming); + + let mut out_neighbors = vec![]; + add_all_action_indices(&self.inner, i, &mut out_neighbors, Direction::Outgoing); + + for in_neighbor in in_neighbors { + for out_neighbor in &out_neighbors { + self.inner.add_edge(in_neighbor, *out_neighbor, 0); + } + } + } - // FIXME this leaves an empty graph lol - // graph.retain_nodes(|this, idx| !this[idx].is_file()); - actions + // produce a new graph without any file/formatted edges + let graph = self.inner.filter_map( + |_, n| match &**n { + Node::Action(a) => Some(a.clone()), + _ => None, + }, + |_, e| Some(*e), + ); + + Ok(graph) + } +} + +fn add_all_action_indices( + graph: &DepGraph, + node: NodeIndex, + neighbors: &mut Vec, + dir: Direction, +) { + for neighbor in graph.neighbors_directed(node, dir) { + match &*graph[neighbor] { + Node::Action(..) => neighbors.push(neighbor), + _ => add_all_action_indices(graph, neighbor, neighbors, dir), + } + } } #[derive(Debug, Eq, Hash, PartialEq)] @@ -197,12 +249,6 @@ pub enum Node { Action(Action), } -impl Node { - fn is_file(&self) -> bool { - matches!(self, Self::File(..)) - } -} - impl std::fmt::Display for Node { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { @@ -213,11 +259,13 @@ impl std::fmt::Display for Node { } } -#[derive(Debug, Eq, Hash, PartialEq)] +#[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct Action { name: String, command: String, args: Vec, + inputs: Vec, + outputs: Vec, } impl std::fmt::Display for Action { From bb8c52d61670bbe25ff11c8d7b73be489b2c3497 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 4 Apr 2021 16:22:36 -0700 Subject: [PATCH 65/73] [honk] Extract graph module. --- honk/src/graph.rs | 211 ++++++++++++++++++++++++++++++++++++++++++ honk/src/lib.rs | 3 +- honk/src/revision.rs | 214 +------------------------------------------ 3 files changed, 215 insertions(+), 213 deletions(-) create mode 100644 honk/src/graph.rs diff --git a/honk/src/graph.rs b/honk/src/graph.rs new file mode 100644 index 000000000..13325a912 --- /dev/null +++ b/honk/src/graph.rs @@ -0,0 +1,211 @@ +use crate::{ + builtins::{command::HonkCommand, path::HonkPath, target::DepSet}, + error::Error, +}; +use petgraph::prelude::*; +use std::{collections::HashMap, sync::Arc}; + +pub type ActionGraph = DiGraph; +pub type DepGraph = DiGraph, i32>; + +pub struct GraphBuilder { + inner: DepGraph, + indices: HashMap, NodeIndex>, + formatted: Arc, + pending_target_name_deps: HashMap>, + target_name_to_idx: HashMap, +} + +impl GraphBuilder { + pub fn new() -> Self { + let mut inner = DepGraph::default(); + let mut indices = HashMap::default(); + let formatted = Arc::new(Node::Formatted); + indices.insert(formatted.clone(), inner.add_node(formatted.clone())); + Self { + inner, + indices, + formatted, + pending_target_name_deps: Default::default(), + target_name_to_idx: Default::default(), + } + } + + pub fn command(&mut self, name: &str, command: &HonkCommand, deps: &DepSet) -> NodeIndex { + let idx = self.action( + name, + &command.command, + &command.args[..], + &command.inputs[..], + &command.outputs[..], + deps, + ); + + for input in &command.inputs { + let input = self.file(input); + self.dep(idx, input); + } + + for output in &command.outputs { + let output = self.file(output); + self.dep(output, idx); + } + + idx + } + + pub fn file(&mut self, path: &HonkPath) -> NodeIndex { + let Self { inner, indices, .. } = self; + // TODO less allocating? + let node = Arc::new(Node::File(path.to_owned())); + *indices.entry(node.clone()).or_insert_with(|| inner.add_node(node)) + } + + pub fn action( + &mut self, + name: &str, + command: &str, + args: &[String], + inputs: &[HonkPath], + outputs: &[HonkPath], + deps: &DepSet, + ) -> NodeIndex { + let Self { inner, indices, target_name_to_idx, .. } = self; + // TODO less allocating? + let args = args.iter().map(|a| a.to_string()).collect(); + let node = Arc::new(Node::Action(Action { + name: name.to_owned(), + command: command.to_owned(), + args, + inputs: inputs.to_vec(), + outputs: outputs.to_vec(), + })); + let idx = *indices.entry(node.clone()).or_insert_with(|| { + let idx = inner.add_node(node); + target_name_to_idx.insert(name.to_owned(), idx); + idx + }); + + for dep in deps { + self.pending_target_name_deps.entry(dep.to_string()).or_default().push(idx); + } + + idx + } + + pub fn formatted(&self) -> NodeIndex { + self.indices[&self.formatted] + } + + pub fn dep(&mut self, from: NodeIndex, to: NodeIndex) { + self.inner.update_edge(from, to, 0); + } + + pub fn build(mut self) -> crate::Result { + self.drain_pending()?; + let graph = self.collapse_non_action_edges()?; + + let num_components = petgraph::algo::connected_components(&graph); + if num_components != 1 { + Err(Error::GraphIsSplit { num_components }) + } else { + Ok(graph) + } + } + + fn drain_pending(&mut self) -> crate::Result<()> { + for (target, deps) in self.pending_target_name_deps.drain().collect::>() { + let target = if let Some(t) = self.target_name_to_idx.get(&target) { + *t + } else { + return Err(Error::GraphResolutionFailure { target }); + }; + for dep in deps { + self.dep(dep, target); + } + } + + Ok(()) + } + + fn collapse_non_action_edges(&mut self) -> crate::Result { + // for each non action edge, get all ins and all outs, make edges between + for i in self.inner.node_indices() { + if matches!(&*self.inner[i], Node::Action(..)) { + continue; + } + + let mut in_neighbors = vec![]; + add_all_action_indices(&self.inner, i, &mut in_neighbors, Direction::Incoming); + + let mut out_neighbors = vec![]; + add_all_action_indices(&self.inner, i, &mut out_neighbors, Direction::Outgoing); + + for in_neighbor in in_neighbors { + for out_neighbor in &out_neighbors { + self.inner.add_edge(in_neighbor, *out_neighbor, 0); + } + } + } + + // produce a new graph without any file/formatted edges + let graph = self.inner.filter_map( + |_, n| match &**n { + Node::Action(a) => Some(a.clone()), + _ => None, + }, + |_, e| Some(*e), + ); + + Ok(graph) + } +} + +fn add_all_action_indices( + graph: &DepGraph, + node: NodeIndex, + neighbors: &mut Vec, + dir: Direction, +) { + for neighbor in graph.neighbors_directed(node, dir) { + match &*graph[neighbor] { + Node::Action(..) => neighbors.push(neighbor), + _ => add_all_action_indices(graph, neighbor, neighbors, dir), + } + } +} + +#[derive(Debug, Eq, Hash, PartialEq)] +pub enum Node { + /// A special node used to schedule all formatters before anything that relies on their output. + Formatted, + /// A file in the build graph. + File(HonkPath), + /// A command to run in the build graph. + Action(Action), +} + +impl std::fmt::Display for Node { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Formatted => "FORMATTER BARRIER".fmt(f), + Self::File(p) => write!(f, "file:{}", p), + Self::Action(a) => write!(f, "{}", a), + } + } +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct Action { + name: String, + command: String, + args: Vec, + inputs: Vec, + outputs: Vec, +} + +impl std::fmt::Display for Action { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "action:{}", &self.name) + } +} diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 89236df21..9b9bb08e1 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -9,6 +9,7 @@ use tracing::{debug, error, info, instrument}; pub mod builtins; pub mod error; +pub mod graph; pub mod revision; pub mod vfs; @@ -64,7 +65,7 @@ impl Workspace { } } -fn dump_graphviz(g: &revision::ActionGraph) { +fn dump_graphviz(g: &graph::ActionGraph) { use petgraph::dot::{Config, Dot}; let output = Dot::with_config(g, &[Config::EdgeNoLabel]); println!("{}", output); diff --git a/honk/src/revision.rs b/honk/src/revision.rs index 4ea8e3547..7bd263a0e 100644 --- a/honk/src/revision.rs +++ b/honk/src/revision.rs @@ -1,18 +1,13 @@ use crate::{ builtins::{ command::{HonkCommand, RefHonkCommand}, - path::HonkPath, target::DepSet, }, - error::Error, + graph::{ActionGraph, GraphBuilder}, }; use gazebo::any::AnyLifetime; use parking_lot::Mutex; -use petgraph::prelude::*; -use std::{ - collections::{BTreeMap, HashMap}, - sync::Arc, -}; +use std::{collections::BTreeMap, sync::Arc}; #[derive(AnyLifetime, Clone, Debug, Default)] pub struct Revision { @@ -68,208 +63,3 @@ impl RevisionState { graph.build() } } - -pub type ActionGraph = DiGraph; -pub type DepGraph = DiGraph, i32>; - -pub struct GraphBuilder { - inner: DepGraph, - indices: HashMap, NodeIndex>, - formatted: Arc, - pending_target_name_deps: HashMap>, - target_name_to_idx: HashMap, -} - -impl GraphBuilder { - fn new() -> Self { - let mut inner = DepGraph::default(); - let mut indices = HashMap::default(); - let formatted = Arc::new(Node::Formatted); - indices.insert(formatted.clone(), inner.add_node(formatted.clone())); - Self { - inner, - indices, - formatted, - pending_target_name_deps: Default::default(), - target_name_to_idx: Default::default(), - } - } - - fn command(&mut self, name: &str, command: &HonkCommand, deps: &DepSet) -> NodeIndex { - let idx = self.action( - name, - &command.command, - &command.args[..], - &command.inputs[..], - &command.outputs[..], - deps, - ); - - for input in &command.inputs { - let input = self.file(input); - self.dep(idx, input); - } - - for output in &command.outputs { - let output = self.file(output); - self.dep(output, idx); - } - - idx - } - - fn file(&mut self, path: &HonkPath) -> NodeIndex { - let Self { inner, indices, .. } = self; - // TODO less allocating? - let node = Arc::new(Node::File(path.to_owned())); - *indices.entry(node.clone()).or_insert_with(|| inner.add_node(node)) - } - - fn action( - &mut self, - name: &str, - command: &str, - args: &[String], - inputs: &[HonkPath], - outputs: &[HonkPath], - deps: &DepSet, - ) -> NodeIndex { - let Self { inner, indices, target_name_to_idx, .. } = self; - // TODO less allocating? - let args = args.iter().map(|a| a.to_string()).collect(); - let node = Arc::new(Node::Action(Action { - name: name.to_owned(), - command: command.to_owned(), - args, - inputs: inputs.to_vec(), - outputs: outputs.to_vec(), - })); - let idx = *indices.entry(node.clone()).or_insert_with(|| { - let idx = inner.add_node(node); - target_name_to_idx.insert(name.to_owned(), idx); - idx - }); - - for dep in deps { - self.pending_target_name_deps.entry(dep.to_string()).or_default().push(idx); - } - - idx - } - - fn formatted(&self) -> NodeIndex { - self.indices[&self.formatted] - } - - fn dep(&mut self, from: NodeIndex, to: NodeIndex) { - self.inner.update_edge(from, to, 0); - } - - fn build(mut self) -> crate::Result { - self.drain_pending()?; - let graph = self.collapse_non_action_edges()?; - - let num_components = petgraph::algo::connected_components(&graph); - if num_components != 1 { - Err(Error::GraphIsSplit { num_components }) - } else { - Ok(graph) - } - } - - fn drain_pending(&mut self) -> crate::Result<()> { - for (target, deps) in self.pending_target_name_deps.drain().collect::>() { - let target = if let Some(t) = self.target_name_to_idx.get(&target) { - *t - } else { - return Err(Error::GraphResolutionFailure { target }); - }; - for dep in deps { - self.dep(dep, target); - } - } - - Ok(()) - } - - fn collapse_non_action_edges(&mut self) -> crate::Result { - // for each non action edge, get all ins and all outs, make edges between - for i in self.inner.node_indices() { - if matches!(&*self.inner[i], Node::Action(..)) { - continue; - } - - let mut in_neighbors = vec![]; - add_all_action_indices(&self.inner, i, &mut in_neighbors, Direction::Incoming); - - let mut out_neighbors = vec![]; - add_all_action_indices(&self.inner, i, &mut out_neighbors, Direction::Outgoing); - - for in_neighbor in in_neighbors { - for out_neighbor in &out_neighbors { - self.inner.add_edge(in_neighbor, *out_neighbor, 0); - } - } - } - - // produce a new graph without any file/formatted edges - let graph = self.inner.filter_map( - |_, n| match &**n { - Node::Action(a) => Some(a.clone()), - _ => None, - }, - |_, e| Some(*e), - ); - - Ok(graph) - } -} - -fn add_all_action_indices( - graph: &DepGraph, - node: NodeIndex, - neighbors: &mut Vec, - dir: Direction, -) { - for neighbor in graph.neighbors_directed(node, dir) { - match &*graph[neighbor] { - Node::Action(..) => neighbors.push(neighbor), - _ => add_all_action_indices(graph, neighbor, neighbors, dir), - } - } -} - -#[derive(Debug, Eq, Hash, PartialEq)] -pub enum Node { - /// A special node used to schedule all formatters before anything that relies on their output. - Formatted, - /// A file in the build graph. - File(HonkPath), - /// A command to run in the build graph. - Action(Action), -} - -impl std::fmt::Display for Node { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Formatted => "FORMATTER BARRIER".fmt(f), - Self::File(p) => write!(f, "file:{}", p), - Self::Action(a) => write!(f, "{}", a), - } - } -} - -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct Action { - name: String, - command: String, - args: Vec, - inputs: Vec, - outputs: Vec, -} - -impl std::fmt::Display for Action { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "action:{}", &self.name) - } -} From 9277be616eb9701a21182bfce342607846727a4c Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 4 Apr 2021 16:54:53 -0700 Subject: [PATCH 66/73] [honk] update starlark crate --- honk/Cargo.lock | 592 ++++++++------------------------- honk/Cargo.toml | 6 +- honk/src/builtins/command.rs | 25 +- honk/src/builtins/formatter.rs | 11 +- honk/src/builtins/json.rs | 10 +- honk/src/builtins/path.rs | 22 +- honk/src/builtins/target.rs | 8 +- honk/src/lib.rs | 7 +- honk/src/revision.rs | 13 +- 9 files changed, 186 insertions(+), 508 deletions(-) diff --git a/honk/Cargo.lock b/honk/Cargo.lock index 37051fbb5..c467ced68 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -14,33 +14,24 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" dependencies = [ "gimli", ] [[package]] name = "adler" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" - -[[package]] -name = "ahash" -version = "0.3.8" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" -dependencies = [ - "const-random", -] +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "0.7.14" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b476ce7103678b0c6d3d395dbbae31d48ff910bd28be979ba5d48c6351131d0d" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" dependencies = [ "memchr", ] @@ -75,9 +66,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" +checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" [[package]] name = "argh" @@ -129,17 +120,6 @@ dependencies = [ "term", ] -[[package]] -name = "async-trait" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "atty" version = "0.2.14" @@ -151,18 +131,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "auto_impl" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cbf586c80ada5e5ccdecae80d3ef0854f224e2dd74435f8d87e6831b8d0a38" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "autocfg" version = "1.0.1" @@ -171,9 +139,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.54" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2baad346b2d4e94a24347adeee9c7a93f412ee94b9cc26e5b59dea23848e9f28" +checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" dependencies = [ "addr2line", "cfg-if 1.0.0", @@ -185,9 +153,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.12.3" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" [[package]] name = "base64" @@ -212,9 +180,9 @@ dependencies = [ [[package]] name = "bit-vec" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitflags" @@ -241,21 +209,15 @@ checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" [[package]] name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "bytes" -version = "0.5.6" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.61" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" [[package]] name = "cfg-if" @@ -278,7 +240,6 @@ dependencies = [ "libc", "num-integer", "num-traits", - "time", "winapi 0.3.9", ] @@ -297,17 +258,11 @@ dependencies = [ "vec_map", ] -[[package]] -name = "codemap" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e769b5c8c8283982a987c6e948e540254f1058d5a74b8794914d4ef5fc2a24" - [[package]] name = "color-eyre" -version = "0.5.6" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2a5123db5af8349c41c43ed0e5dca1cd56c911ea0c4ce6e6ff30f159fa5d27e" +checksum = "7b29030875fd8376e4a28ef497790d5b4a7843d8d1396bf08ce46f5eec562c5c" dependencies = [ "backtrace", "color-spantrace", @@ -320,43 +275,28 @@ dependencies = [ [[package]] name = "color-spantrace" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a99aa4aa18448eef4c7d3f86d2720d2d8cad5c860fe9ff9b279293efdc8f5be" +checksum = "b6eee477a4a8a72f4addd4de416eb56d54bc307b284d6601bafdee1f4ea462d1" dependencies = [ - "ansi_term 0.11.0", + "once_cell", + "owo-colors", "tracing-core", "tracing-error", ] -[[package]] -name = "const-random" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f590d95d011aa80b063ffe3253422ed5aa462af4e9867d43ce8337562bac77c4" -dependencies = [ - "const-random-macro", - "proc-macro-hack", -] - -[[package]] -name = "const-random-macro" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "615f6e27d000a2bffbc7f2f6a8669179378fa27ee4d0a509e985dfc0a7defb40" -dependencies = [ - "getrandom 0.2.2", - "lazy_static", - "proc-macro-hack", - "tiny-keccak", -] - [[package]] name = "constant_time_eq" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "crossbeam-channel" version = "0.4.4" @@ -395,17 +335,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "dashmap" -version = "3.11.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f260e2fc850179ef410018660006951c1b55b79e8087e87111a2c388994b9b5" -dependencies = [ - "ahash", - "cfg-if 0.1.10", - "num_cpus", -] - [[package]] name = "debugserver-types" version = "0.5.0" @@ -430,10 +359,11 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.11" +version = "0.99.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" +checksum = "f82b1b72f1263f214c0f823371768776c4f5841b942c9883aa8e5ec584fd0ba6" dependencies = [ + "convert_case", "proc-macro2", "quote", "syn", @@ -494,9 +424,9 @@ dependencies = [ [[package]] name = "eyre" -version = "0.6.2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534ce924bff9118be8b28b24ede6bf7e96a00b53e4ded25050aa7b526e051e1a" +checksum = "221239d1d5ea86bf5d6f91c9d6bc3646ffe471b08ff9b0f91c44f115ac969d2b" dependencies = [ "indenter", "once_cell", @@ -504,13 +434,13 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e" +checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", - "redox_syscall 0.1.57", + "redox_syscall 0.2.5", "winapi 0.3.9", ] @@ -587,117 +517,26 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -[[package]] -name = "futures" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" - -[[package]] -name = "futures-io" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59" - -[[package]] -name = "futures-macro" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea405816a5139fb39af82c2beb921d52143f556038378d6db21183a5c37fbfb7" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3" - -[[package]] -name = "futures-task" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" - -[[package]] -name = "futures-util" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite 0.2.6", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "slab", -] - [[package]] name = "gazebo" -version = "0.1.0" -source = "git+https://github.com/facebookincubator/gazebo#604500f2775efa3c36bb53b5241a6911547fabdb" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69b91762e4652014f5a677ca8cc00546f09f78a8ebc1e6624a6bc931cd9656e8" dependencies = [ "gazebo_derive", ] [[package]] name = "gazebo_derive" -version = "0.1.0" -source = "git+https://github.com/facebookincubator/gazebo#604500f2775efa3c36bb53b5241a6911547fabdb" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d67a8bf744290be7799e50aa9f9d50fa1b693fd7bc37daf7bca57d20988f2c63" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "generator" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cdc09201b2e8ca1b19290cf7e65de2246b8e91fb6874279722189c4de7b94dc" -dependencies = [ - "cc", - "libc", - "log", - "rustc_version", - "winapi 0.3.9", -] - [[package]] name = "getrandom" version = "0.1.16" @@ -717,7 +556,7 @@ checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -740,18 +579,18 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" [[package]] name = "heck" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] @@ -792,9 +631,9 @@ dependencies = [ [[package]] name = "indenter" -version = "0.3.0" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0bd112d44d9d870a6819eb505d04dd92b5e4d94bb8c304924a0872ae7016fb5" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" @@ -819,9 +658,9 @@ dependencies = [ [[package]] name = "inotify-sys" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" dependencies = [ "libc", ] @@ -864,9 +703,9 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "kernel32-sys" @@ -924,26 +763,26 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.80" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714" [[package]] name = "lock_api" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" +checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176" dependencies = [ "scopeguard", ] [[package]] name = "log" -version = "0.4.11" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", ] [[package]] @@ -971,25 +810,24 @@ dependencies = [ ] [[package]] -name = "loom" -version = "0.3.6" +name = "lsp-server" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0e8460f2f2121162705187214720353c517b97bdfb3494c0b1e33d83ebe4bed" +checksum = "87fce8851309a325974ec76efe7c9d954d152c9ff4fded6520eb3c96d0aa3a96" dependencies = [ - "cfg-if 0.1.10", - "generator", - "scoped-tls", + "crossbeam-channel", + "log", "serde", "serde_json", ] [[package]] name = "lsp-types" -version = "0.81.0" +version = "0.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e02724627e9ef8ba91f461ebc01d48aebbd13a4b7c9dc547a0a2890f53e2171" +checksum = "93d0cf64ea141b43d9e055f6b9df13f0bce32b103d84237509ce0a571ab9b159" dependencies = [ - "base64 0.12.3", + "base64 0.11.0", "bitflags", "serde", "serde_json", @@ -1032,9 +870,9 @@ checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "memofs" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "575ca842746f6079cdd96c2412ed1e3954a8a8b1983d962989482970c406c27b" +checksum = "ddcb1dfd75643be5531e4be536c41ffe01be42d12d5c58c52b38ee23707d7b9b" dependencies = [ "crossbeam-channel", "fs-err", @@ -1044,9 +882,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", "autocfg", @@ -1054,9 +892,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" dependencies = [ "cfg-if 0.1.10", "fuchsia-zircon", @@ -1085,9 +923,9 @@ dependencies = [ [[package]] name = "miow" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" dependencies = [ "kernel32-sys", "net2", @@ -1097,9 +935,9 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.35" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" dependencies = [ "cfg-if 0.1.10", "libc", @@ -1124,16 +962,6 @@ dependencies = [ "libc", ] -[[package]] -name = "nom" -version = "5.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" -dependencies = [ - "memchr", - "version_check", -] - [[package]] name = "notify" version = "4.0.15" @@ -1171,33 +999,23 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" [[package]] name = "once_cell" -version = "1.4.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] name = "owo-colors" -version = "1.1.3" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a1250cdd103eef6bd542b5ae82989f931fc00a41a27f60377338241594410f3" +checksum = "2386b4ebe91c2f7f51082d4cefa145d030e33a1842a96b12e4885cc3c01f7a55" [[package]] name = "parking_lot" @@ -1261,24 +1079,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d70072c20945e1ab871c472a285fc772aefd4f5407723c206242f2c6f94595d6" -[[package]] -name = "pin-project-lite" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" - [[package]] name = "pin-project-lite" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - [[package]] name = "precomputed-hash" version = "0.1.1" @@ -1309,32 +1115,20 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] @@ -1377,14 +1171,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.2" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" dependencies = [ "aho-corasick", "memchr", "regex-syntax", - "thread_local", ] [[package]] @@ -1399,9 +1192,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.21" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" [[package]] name = "rust-argon2" @@ -1421,15 +1214,6 @@ version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - [[package]] name = "rustyline" version = "7.1.0" @@ -1508,47 +1292,26 @@ dependencies = [ "syn", ] -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" - [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" -version = "1.0.117" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.117" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ "proc-macro2", "quote", @@ -1557,9 +1320,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.59" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ "itoa", "ryu", @@ -1579,19 +1342,18 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4921be914e16899a80adefb821f8ddb7974e3f1250223575a44ed994882127" +checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3" dependencies = [ "lazy_static", - "loom", ] [[package]] name = "siphasher" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7" +checksum = "cbce6d4507c7e4a3962091436e56e95290cb71fa302d0d270e32130b75fbff27" [[package]] name = "slab" @@ -1608,12 +1370,11 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "starlark" version = "0.4.0-pre" -source = "git+https://github.com/facebookexperimental/starlark-rust?rev=8a8523f#8a8523fc4d7700cdea6cf8a31a56d29ee7be4764" +source = "git+https://github.com/facebookexperimental/starlark-rust?rev=8c6f291#8c6f29148ca896b445d373c65e6914735328df36" dependencies = [ "annotate-snippets", "anyhow", "bumpalo", - "codemap", "debugserver-types", "derivative", "derive_more", @@ -1624,6 +1385,8 @@ dependencies = [ "lalrpop", "lalrpop-util", "logos", + "lsp-server", + "lsp-types", "maplit", "once_cell", "paste", @@ -1635,8 +1398,6 @@ dependencies = [ "static_assertions", "structopt", "thiserror", - "tokio", - "tower-lsp", "void", "walkdir", ] @@ -1644,7 +1405,7 @@ dependencies = [ [[package]] name = "starlark_module" version = "0.4.0-pre" -source = "git+https://github.com/facebookexperimental/starlark-rust?rev=8a8523f#8a8523fc4d7700cdea6cf8a31a56d29ee7be4764" +source = "git+https://github.com/facebookexperimental/starlark-rust?rev=8c6f291#8c6f29148ca896b445d373c65e6914735328df36" dependencies = [ "gazebo", "proc-macro2", @@ -1702,9 +1463,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.48" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" +checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87" dependencies = [ "proc-macro2", "quote", @@ -1733,18 +1494,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.21" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "318234ffa22e0920fe9a40d7b8369b5f649d490980cf7aadcf1eb91594869b42" +checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.21" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cae2447b6282786c3493999f40a9be2a6ad20cb8bd268b0a0dbf5a065535c0ab" +checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" dependencies = [ "proc-macro2", "quote", @@ -1753,22 +1514,11 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "time" -version = "0.1.44" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", + "once_cell", ] [[package]] @@ -1782,9 +1532,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" +checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" dependencies = [ "tinyvec_macros", ] @@ -1795,89 +1545,23 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" -[[package]] -name = "tokio" -version = "0.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" -dependencies = [ - "bytes", - "futures-core", - "pin-project-lite 0.1.11", - "slab", -] - -[[package]] -name = "tokio-util" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite 0.1.11", - "tokio", -] - -[[package]] -name = "tower-lsp" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75aeada84f07dfc4e81bc58a36a12b22c01c418af2180587cf80f9f3228acad" -dependencies = [ - "async-trait", - "auto_impl", - "bytes", - "dashmap", - "futures", - "log", - "lsp-types", - "nom", - "serde", - "serde_json", - "tokio", - "tokio-util", - "tower-lsp-macros", - "tower-service", -] - -[[package]] -name = "tower-lsp-macros" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c51c24e3b5909be30d6ed472f934aa9b7d91abf2688013956b296b1d1e7b186" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tower-service" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" - [[package]] name = "tracing" -version = "0.1.21" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" +checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ - "cfg-if 0.1.10", - "pin-project-lite 0.1.11", + "cfg-if 1.0.0", + "pin-project-lite", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.11" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" dependencies = [ "proc-macro2", "quote", @@ -1905,9 +1589,9 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" dependencies = [ "lazy_static", "log", @@ -1926,9 +1610,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1fa8f0c8f4c594e4fc9debc1990deab13238077271ba84dd853d54902ee3401" +checksum = "705096c6f83bf68ea5d357a6aa01829ddbdac531b357b45abeca842938085baa" dependencies = [ "ansi_term 0.12.1", "chrono", @@ -1966,9 +1650,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-width" @@ -2015,9 +1699,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "void" @@ -2027,9 +1711,9 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "walkdir" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", "winapi 0.3.9", @@ -2044,9 +1728,9 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "winapi" diff --git a/honk/Cargo.toml b/honk/Cargo.toml index df11fd5df..26512199a 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -18,6 +18,7 @@ anyhow = "1" argh = "0.1.4" color-eyre = "0.5.6" crossbeam-channel = "0.4.0" +gazebo = "0.2.0" glob = "0.3.0" memofs = "0.1.2" once_cell = "1" @@ -30,6 +31,5 @@ tracing-error = "0.1.2" tracing-subscriber = { version = "0.2.15", features = ["fmt"] } # starlark deps -- revisions must be kept in sync -gazebo = { git = "https://github.com/facebookincubator/gazebo" } -starlark = { git = "https://github.com/facebookexperimental/starlark-rust", rev = "8a8523f" } -starlark_module = { git = "https://github.com/facebookexperimental/starlark-rust", rev = "8a8523f" } +starlark = { git = "https://github.com/facebookexperimental/starlark-rust", rev = "8c6f291" } +starlark_module = { git = "https://github.com/facebookexperimental/starlark-rust", rev = "8c6f291" } diff --git a/honk/src/builtins/command.rs b/honk/src/builtins/command.rs index 4247a15a2..ea86e506a 100644 --- a/honk/src/builtins/command.rs +++ b/honk/src/builtins/command.rs @@ -1,11 +1,8 @@ -use crate::{ - builtins::path::{HonkPath, RefHonkPath}, - error::Error, -}; +use crate::{builtins::path::HonkPath, error::Error}; use starlark::{ environment::GlobalsBuilder, - starlark_immutable_value, - values::{TypedValue, Value}, + starlark_simple_value, + values::{ARef, StarlarkValue, Value}, }; use starlark_module::starlark_module; use tracing::instrument; @@ -15,8 +12,8 @@ pub fn register(builder: &mut GlobalsBuilder) { fn command( command: String, _args: Vec>, - inputs: Vec, - outputs: Vec, + inputs: Vec>, + outputs: Vec>, ) -> HonkCommand { let args = _args.iter().map(|a| a.to_str()).collect(); let inputs = inputs.iter().map(|i| (*i).clone()).collect(); @@ -51,16 +48,16 @@ impl HonkCommand { } } -starlark_immutable_value!(pub HonkCommand); +starlark_simple_value!(HonkCommand); #[starlark_module::starlark_module] fn register_command_methods(globals: &mut GlobalsBuilder) { - fn run(this: RefHonkCommand) -> Output { + fn run(this: ARef) -> Output { Ok(this.run()?) } } -impl TypedValue<'_> for HonkCommand { +impl StarlarkValue<'_> for HonkCommand { starlark::starlark_type!("command"); declare_members!(register_command_methods); @@ -111,14 +108,14 @@ impl Output { #[starlark_module::starlark_module] fn register_output_methods(globals: &mut GlobalsBuilder) { - fn stdout(this: RefOutput) -> String { + fn stdout(this: ARef) -> String { Ok(this.stdout()?) } } -starlark_immutable_value!(Output); +starlark_simple_value!(Output); -impl TypedValue<'_> for Output { +impl StarlarkValue<'_> for Output { starlark::starlark_type!("Output"); declare_members!(register_output_methods); } diff --git a/honk/src/builtins/formatter.rs b/honk/src/builtins/formatter.rs index 4f4906432..26f9294ae 100644 --- a/honk/src/builtins/formatter.rs +++ b/honk/src/builtins/formatter.rs @@ -1,10 +1,13 @@ -use crate::{builtins::command::RefHonkCommand, EvaluatorExt}; -use starlark::{environment::GlobalsBuilder, values::none::NoneType}; +use crate::{builtins::command::HonkCommand, EvaluatorExt}; +use starlark::{ + environment::GlobalsBuilder, + values::{none::NoneType, ARef}, +}; #[starlark_module::starlark_module] pub fn register(globals: &mut GlobalsBuilder) { - fn formatter(name: &str, command: RefHonkCommand) -> NoneType { - ctx.revision().register_formatter(name, command); + fn formatter(name: &str, command: ARef) -> NoneType { + ctx.revision().register_formatter(name, &*command); Ok(NoneType) } } diff --git a/honk/src/builtins/json.rs b/honk/src/builtins/json.rs index d42c32e41..80c9955f5 100644 --- a/honk/src/builtins/json.rs +++ b/honk/src/builtins/json.rs @@ -2,8 +2,8 @@ use serde_json::Value as JsonValue; use starlark::{ collections::SmallMap, environment::GlobalsBuilder, - starlark_immutable_value, - values::{dict::Dict, list::List, Heap, TypedValue, Value}, + starlark_simple_value, + values::{dict::Dict, list::List, ARef, Heap, StarlarkValue, Value}, }; use starlark_module::starlark_module; use std::convert::TryInto; @@ -18,14 +18,14 @@ struct JsonModule; #[starlark_module] fn register_json_methods(globals: &mut GlobalsBuilder) { - fn decode(_this: RefJsonModule, x: String) -> Value<'v> { + fn decode(_this: ARef, x: String) -> Value<'v> { Ok(json_to_starlark(heap, serde_json::from_str(&x)?)) } } -starlark_immutable_value!(JsonModule); +starlark_simple_value!(JsonModule); -impl TypedValue<'_> for JsonModule { +impl StarlarkValue<'_> for JsonModule { starlark::starlark_type!("json"); declare_members!(register_json_methods); } diff --git a/honk/src/builtins/path.rs b/honk/src/builtins/path.rs index 9d5285a2f..1cab04590 100644 --- a/honk/src/builtins/path.rs +++ b/honk/src/builtins/path.rs @@ -1,7 +1,7 @@ use starlark::{ environment::GlobalsBuilder, - starlark_immutable_value, starlark_type, - values::{list::List, AllocValue, Heap, TypedValue, Value}, + starlark_simple_value, starlark_type, + values::{list::List, ARef, AllocValue, Heap, StarlarkValue, Value}, }; use starlark_module::starlark_module; use std::{ @@ -97,36 +97,36 @@ impl std::fmt::Display for HonkPath { #[starlark_module::starlark_module] fn register_path_methods(globals: &mut GlobalsBuilder) { - fn exists(this: RefHonkPath) -> bool { + fn exists(this: ARef) -> bool { Ok(this.exists()) } - fn parent(this: RefHonkPath) -> Value<'v> { + fn parent(this: ARef) -> Value<'v> { Ok(opt_typed_val(heap, this.parent())) } - fn filename(this: RefHonkPath) -> Value<'v> { + fn filename(this: ARef) -> Value<'v> { Ok(opt_typed_val(heap, this.filename())) } - fn join(this: RefHonkPath, to_join: &str) -> HonkPath { + fn join(this: ARef, to_join: &str) -> HonkPath { Ok(this.join(&to_join)) } - fn canonicalize(this: RefHonkPath) -> HonkPath { + fn canonicalize(this: ARef) -> HonkPath { Ok(this.canonicalize()) } - fn glob(this: RefHonkPath, pattern: &str) -> List<'v> { + fn glob(this: ARef, pattern: &str) -> List<'v> { Ok(this.globs(heap, &[pattern])) } - fn globs(this: RefHonkPath, patterns: Vec<&str>) -> List<'v> { + fn globs(this: ARef, patterns: Vec<&str>) -> List<'v> { Ok(this.globs(heap, &patterns)) } } -impl TypedValue<'_> for HonkPath { +impl StarlarkValue<'_> for HonkPath { starlark_type!("path"); declare_members!(register_path_methods); @@ -142,4 +142,4 @@ impl TypedValue<'_> for HonkPath { } } -starlark_immutable_value!(pub HonkPath); +starlark_simple_value!(HonkPath); diff --git a/honk/src/builtins/target.rs b/honk/src/builtins/target.rs index 6098a9de9..d91b4fe89 100644 --- a/honk/src/builtins/target.rs +++ b/honk/src/builtins/target.rs @@ -1,15 +1,15 @@ -use crate::{builtins::command::RefHonkCommand, EvaluatorExt}; +use crate::{builtins::command::HonkCommand, EvaluatorExt}; use starlark::{ environment::GlobalsBuilder, - values::{none::NoneType, Value}, + values::{none::NoneType, ARef, Value}, }; use std::collections::BTreeSet; #[starlark_module::starlark_module] pub fn register(globals: &mut GlobalsBuilder) { - fn target(name: &str, command: RefHonkCommand, deps: Option>>) -> NoneType { + fn target(name: &str, command: ARef, deps: Option>>) -> NoneType { let deps: DepSet = deps.into(); - ctx.revision().register_target(name, command, &deps); + ctx.revision().register_target(name, &*command, &deps); Ok(NoneType) } } diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 9b9bb08e1..c137a89f7 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,6 +1,5 @@ use starlark::{ - environment::FrozenModule, - environment::Module, + environment::{FrozenModule, GlobalsBuilder, LibraryExtension, Module}, eval::{Evaluator, FileLoader}, syntax::{AstModule, Dialect}, }; @@ -87,9 +86,7 @@ impl<'w> FileLoader for RevisionLoader<'w> { let ast: AstModule = AstModule::parse(path, root_contents.to_string(), &Dialect::Standard)?; - let globals = starlark::stdlib::standard_environment() - // TODO figure out how to add set() back - .with(starlark::stdlib::add_struct) + let globals = GlobalsBuilder::extended_by(&[LibraryExtension::StructType]) .with(crate::builtins::register) .build(); let module: Module = Module::new(); diff --git a/honk/src/revision.rs b/honk/src/revision.rs index 7bd263a0e..76a546c67 100644 --- a/honk/src/revision.rs +++ b/honk/src/revision.rs @@ -1,8 +1,5 @@ use crate::{ - builtins::{ - command::{HonkCommand, RefHonkCommand}, - target::DepSet, - }, + builtins::{command::HonkCommand, target::DepSet}, graph::{ActionGraph, GraphBuilder}, }; use gazebo::any::AnyLifetime; @@ -15,11 +12,11 @@ pub struct Revision { } impl Revision { - pub fn register_formatter(&self, name: &str, command: RefHonkCommand) { + pub fn register_formatter(&self, name: &str, command: &HonkCommand) { self.inner.lock().register_formatter(name, command); } - pub fn register_target(&self, name: &str, command: RefHonkCommand, deps: &DepSet) { + pub fn register_target(&self, name: &str, command: &HonkCommand, deps: &DepSet) { self.inner.lock().register_target(name, command, deps); } @@ -35,7 +32,7 @@ struct RevisionState { } impl RevisionState { - fn register_formatter(&mut self, name: &str, command: RefHonkCommand) { + fn register_formatter(&mut self, name: &str, command: &HonkCommand) { let mut command = command.clone(); // TODO find a better way to avoid cycles in the dep graph command.inputs.clear(); @@ -43,7 +40,7 @@ impl RevisionState { self.formatters.insert(name.to_owned(), (command, Default::default())); } - fn register_target(&mut self, name: &str, command: RefHonkCommand, deps: &DepSet) { + fn register_target(&mut self, name: &str, command: &HonkCommand, deps: &DepSet) { self.targets.insert(name.to_owned(), (command.clone(), deps.clone())); } From c145bddf8732f5e7cc2c2c50264fd6f564e00605 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 4 Apr 2021 17:06:36 -0700 Subject: [PATCH 67/73] [honk] move EvaluatorExt to revision module --- honk/src/lib.rs | 17 +---------------- honk/src/revision.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index c137a89f7..3b9c773e2 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -13,7 +13,7 @@ pub mod revision; pub mod vfs; use error::Error; -use revision::Revision; +use revision::{EvaluatorExt, Revision}; use vfs::Vfs; pub(crate) type Result = color_eyre::eyre::Result; @@ -101,18 +101,3 @@ impl<'w> FileLoader for RevisionLoader<'w> { Ok(module.freeze()) } } - -pub trait EvaluatorExt<'r> { - fn set_revision(&mut self, revision: &'r Revision); - fn revision(&self) -> &'r Revision; -} - -impl<'a> EvaluatorExt<'a> for Evaluator<'_, 'a> { - fn set_revision(&mut self, revision: &'a Revision) { - self.extra = Some(revision); - } - - fn revision(&self) -> &'a Revision { - self.extra.clone().unwrap().downcast_ref().unwrap() - } -} diff --git a/honk/src/revision.rs b/honk/src/revision.rs index 76a546c67..c07bfd4c8 100644 --- a/honk/src/revision.rs +++ b/honk/src/revision.rs @@ -4,6 +4,7 @@ use crate::{ }; use gazebo::any::AnyLifetime; use parking_lot::Mutex; +use starlark::eval::Evaluator; use std::{collections::BTreeMap, sync::Arc}; #[derive(AnyLifetime, Clone, Debug, Default)] @@ -60,3 +61,18 @@ impl RevisionState { graph.build() } } + +pub trait EvaluatorExt<'r> { + fn set_revision(&mut self, revision: &'r Revision); + fn revision(&self) -> &'r Revision; +} + +impl<'a> EvaluatorExt<'a> for Evaluator<'_, 'a> { + fn set_revision(&mut self, revision: &'a Revision) { + self.extra = Some(revision); + } + + fn revision(&self) -> &'a Revision { + self.extra.clone().unwrap().downcast_ref().unwrap() + } +} From 7a16c334628ed8fe2796ed6e4669a2a545224aa0 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 10 Apr 2021 09:42:30 -0700 Subject: [PATCH 68/73] [honk] extract workspace state to cloneable type --- honk/src/lib.rs | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 3b9c773e2..8a1660e6c 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,9 +1,13 @@ +use parking_lot::Mutex; use starlark::{ environment::{FrozenModule, GlobalsBuilder, LibraryExtension, Module}, eval::{Evaluator, FileLoader}, syntax::{AstModule, Dialect}, }; -use std::path::{Path, PathBuf}; +use std::{ + path::{Path, PathBuf}, + sync::Arc, +}; use tracing::{debug, error, info, instrument}; pub mod builtins; @@ -19,11 +23,7 @@ use vfs::Vfs; pub(crate) type Result = color_eyre::eyre::Result; pub struct Workspace { - /// Path to `workspace.honk`. - root: PathBuf, - - /// Tracks changes to files we've read. - vfs: Vfs, + state: WorkspaceState, } impl Workspace { @@ -31,7 +31,11 @@ impl Workspace { const ASSET_PATH: &'static str = "WORKSPACE.honk"; pub fn new(root: impl AsRef) -> Self { - Self { root: root.as_ref().to_path_buf(), vfs: Vfs::new() } + let state = WorkspaceState { + root: root.as_ref().to_path_buf(), + inner: Arc::new(Mutex::new(InnerState { vfs: Vfs::new() })), + }; + Self { state } } pub fn maintain(self) -> crate::Result<()> { @@ -41,14 +45,14 @@ impl Workspace { if let Err(error) = self.converge() { error!(%error, "couldn't converge current workspace revision"); } - self.vfs.wait_for_changes(); + self.state.inner.lock().vfs.wait_for_changes(); } } - #[instrument(level = "info", skip(self), fields(root = %self.root.display()))] + #[instrument(level = "info", skip(self), fields(root = %self.state.root.display()))] fn converge(&self) -> crate::Result<()> { debug!("constructing workspace env"); - let mut loader = RevisionLoader(self, Revision::default()); + let mut loader = RevisionLoader(self.state.clone(), Revision::default()); let _workspace_env = loader.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; let _build = loader.1.resolve()?; @@ -64,15 +68,28 @@ impl Workspace { } } +#[derive(Clone)] +pub struct WorkspaceState { + /// Path to `workspace.honk`. + root: PathBuf, + + inner: Arc>, +} + +struct InnerState { + /// Tracks changes to files we've read. + vfs: Vfs, +} + fn dump_graphviz(g: &graph::ActionGraph) { use petgraph::dot::{Config, Dot}; let output = Dot::with_config(g, &[Config::EdgeNoLabel]); println!("{}", output); } -struct RevisionLoader<'w>(&'w Workspace, Revision); +struct RevisionLoader(WorkspaceState, Revision); -impl<'w> FileLoader for RevisionLoader<'w> { +impl FileLoader for RevisionLoader { #[instrument(skip(self))] fn load(&mut self, path: &str) -> anyhow::Result { // TODO smarter way to resolve assets etc @@ -81,7 +98,7 @@ impl<'w> FileLoader for RevisionLoader<'w> { let file = self.0.root.join(path); debug!(file = %file.display(), "loading"); - let root_contents = self.0.vfs.read(&file)?; + let root_contents = self.0.inner.lock().vfs.read(&file)?; let root_contents = std::str::from_utf8(&*root_contents)?; let ast: AstModule = AstModule::parse(path, root_contents.to_string(), &Dialect::Standard)?; From 792c225cf8a2a04554bec13da991db96c995c8cb Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 10 Apr 2021 09:50:51 -0700 Subject: [PATCH 69/73] [honk] InnerState is the FileLoader now. --- honk/src/lib.rs | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 8a1660e6c..136736808 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -32,8 +32,12 @@ impl Workspace { pub fn new(root: impl AsRef) -> Self { let state = WorkspaceState { - root: root.as_ref().to_path_buf(), - inner: Arc::new(Mutex::new(InnerState { vfs: Vfs::new() })), + inner: Arc::new(Mutex::new(InnerState { + vfs: Vfs::new(), + root: root.as_ref().to_path_buf(), + current_revision: Default::default(), + _prev_revision: Default::default(), + })), }; Self { state } } @@ -49,13 +53,14 @@ impl Workspace { } } - #[instrument(level = "info", skip(self), fields(root = %self.state.root.display()))] + #[instrument(level = "info", skip(self), fields(root = %self.state.inner.lock().root.display()))] fn converge(&self) -> crate::Result<()> { debug!("constructing workspace env"); - let mut loader = RevisionLoader(self.state.clone(), Revision::default()); - let _workspace_env = loader.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; + let mut state = self.state.inner.lock(); + state.start_new_revision(); + let _workspace_env = state.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; - let _build = loader.1.resolve()?; + let _build = state.current_revision.resolve()?; info!("discovered targets"); // FIXME make this an actual web viewer via http server, right? @@ -70,15 +75,24 @@ impl Workspace { #[derive(Clone)] pub struct WorkspaceState { - /// Path to `workspace.honk`. - root: PathBuf, - inner: Arc>, } struct InnerState { + /// Path to `workspace.honk`. + root: PathBuf, + /// Tracks changes to files we've read. vfs: Vfs, + + current_revision: Revision, + _prev_revision: Revision, +} + +impl InnerState { + fn start_new_revision(&mut self) { + self._prev_revision = std::mem::replace(&mut self.current_revision, Revision::default()); + } } fn dump_graphviz(g: &graph::ActionGraph) { @@ -87,18 +101,16 @@ fn dump_graphviz(g: &graph::ActionGraph) { println!("{}", output); } -struct RevisionLoader(WorkspaceState, Revision); - -impl FileLoader for RevisionLoader { +impl FileLoader for InnerState { #[instrument(skip(self))] fn load(&mut self, path: &str) -> anyhow::Result { // TODO smarter way to resolve assets etc // TODO handle relative paths somehow? let path = path.strip_prefix("//").unwrap_or(path); - let file = self.0.root.join(path); + let file = self.root.join(path); debug!(file = %file.display(), "loading"); - let root_contents = self.0.inner.lock().vfs.read(&file)?; + let root_contents = self.vfs.read(&file)?; let root_contents = std::str::from_utf8(&*root_contents)?; let ast: AstModule = AstModule::parse(path, root_contents.to_string(), &Dialect::Standard)?; @@ -110,7 +122,7 @@ impl FileLoader for RevisionLoader { let mut eval: Evaluator = Evaluator::new(&module, &globals); eval.disable_gc(); // we're going to drop this right away - let revision = self.1.clone(); + let revision = self.current_revision.clone(); eval.set_revision(&revision); eval.set_loader(self); let _res = eval.eval_module(ast)?; From ea71528f378a19d3daf51461460faec64ea5edcb Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 10 Apr 2021 09:53:47 -0700 Subject: [PATCH 70/73] [honk] switch to starlark on crates.io --- honk/Cargo.toml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/honk/Cargo.toml b/honk/Cargo.toml index 26512199a..e92ebef3c 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -25,11 +25,9 @@ once_cell = "1" parking_lot = "0.11.1" petgraph = "0.5.1" serde_json = "1.0.59" +starlark = "0.4" +starlark_module = "0.4" thiserror = "1.0.21" tracing = "0.1.21" tracing-error = "0.1.2" tracing-subscriber = { version = "0.2.15", features = ["fmt"] } - -# starlark deps -- revisions must be kept in sync -starlark = { git = "https://github.com/facebookexperimental/starlark-rust", rev = "8c6f291" } -starlark_module = { git = "https://github.com/facebookexperimental/starlark-rust", rev = "8c6f291" } From c79e84ad4cc07f18ea70278908a3465864f3d101 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 10 Apr 2021 11:00:31 -0700 Subject: [PATCH 71/73] [honk] move mutable workspace lifecycle to state module --- honk/src/lib.rs | 90 +++++------------------------------------ honk/src/state.rs | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 80 deletions(-) create mode 100644 honk/src/state.rs diff --git a/honk/src/lib.rs b/honk/src/lib.rs index 136736808..e06a8885a 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,24 +1,14 @@ -use parking_lot::Mutex; -use starlark::{ - environment::{FrozenModule, GlobalsBuilder, LibraryExtension, Module}, - eval::{Evaluator, FileLoader}, - syntax::{AstModule, Dialect}, -}; -use std::{ - path::{Path, PathBuf}, - sync::Arc, -}; +use std::path::Path; use tracing::{debug, error, info, instrument}; pub mod builtins; pub mod error; pub mod graph; pub mod revision; +pub mod state; pub mod vfs; -use error::Error; -use revision::{EvaluatorExt, Revision}; -use vfs::Vfs; +use crate::{error::Error, revision::EvaluatorExt, state::WorkspaceState}; pub(crate) type Result = color_eyre::eyre::Result; @@ -31,14 +21,7 @@ impl Workspace { const ASSET_PATH: &'static str = "WORKSPACE.honk"; pub fn new(root: impl AsRef) -> Self { - let state = WorkspaceState { - inner: Arc::new(Mutex::new(InnerState { - vfs: Vfs::new(), - root: root.as_ref().to_path_buf(), - current_revision: Default::default(), - _prev_revision: Default::default(), - })), - }; + let state = WorkspaceState::new(root); Self { state } } @@ -49,18 +32,17 @@ impl Workspace { if let Err(error) = self.converge() { error!(%error, "couldn't converge current workspace revision"); } - self.state.inner.lock().vfs.wait_for_changes(); + self.state.wait_for_changes(); } } - #[instrument(level = "info", skip(self), fields(root = %self.state.inner.lock().root.display()))] + #[instrument(level = "info", skip(self), fields(root = %self.state.root().display()))] fn converge(&self) -> crate::Result<()> { debug!("constructing workspace env"); - let mut state = self.state.inner.lock(); - state.start_new_revision(); - let _workspace_env = state.load(Self::ASSET_PATH).map_err(Error::StarlarkError)?; + self.state.start_new_revision(); + let _workspace_env = self.state.load(Self::ASSET_PATH)?; - let _build = state.current_revision.resolve()?; + let _build = self.state.current_revision().resolve()?; info!("discovered targets"); // FIXME make this an actual web viewer via http server, right? @@ -73,60 +55,8 @@ impl Workspace { } } -#[derive(Clone)] -pub struct WorkspaceState { - inner: Arc>, -} - -struct InnerState { - /// Path to `workspace.honk`. - root: PathBuf, - - /// Tracks changes to files we've read. - vfs: Vfs, - - current_revision: Revision, - _prev_revision: Revision, -} - -impl InnerState { - fn start_new_revision(&mut self) { - self._prev_revision = std::mem::replace(&mut self.current_revision, Revision::default()); - } -} - -fn dump_graphviz(g: &graph::ActionGraph) { +fn dump_graphviz(g: &crate::graph::ActionGraph) { use petgraph::dot::{Config, Dot}; let output = Dot::with_config(g, &[Config::EdgeNoLabel]); println!("{}", output); } - -impl FileLoader for InnerState { - #[instrument(skip(self))] - fn load(&mut self, path: &str) -> anyhow::Result { - // TODO smarter way to resolve assets etc - // TODO handle relative paths somehow? - let path = path.strip_prefix("//").unwrap_or(path); - let file = self.root.join(path); - debug!(file = %file.display(), "loading"); - - let root_contents = self.vfs.read(&file)?; - let root_contents = std::str::from_utf8(&*root_contents)?; - - let ast: AstModule = AstModule::parse(path, root_contents.to_string(), &Dialect::Standard)?; - - let globals = GlobalsBuilder::extended_by(&[LibraryExtension::StructType]) - .with(crate::builtins::register) - .build(); - let module: Module = Module::new(); - let mut eval: Evaluator = Evaluator::new(&module, &globals); - eval.disable_gc(); // we're going to drop this right away - - let revision = self.current_revision.clone(); - eval.set_revision(&revision); - eval.set_loader(self); - let _res = eval.eval_module(ast)?; - - Ok(module.freeze()) - } -} diff --git a/honk/src/state.rs b/honk/src/state.rs new file mode 100644 index 000000000..074e8fadb --- /dev/null +++ b/honk/src/state.rs @@ -0,0 +1,101 @@ +use crate::{ + error::Error, + revision::{EvaluatorExt, Revision}, + vfs::Vfs, +}; +use parking_lot::Mutex; +use starlark::{ + environment::{FrozenModule, GlobalsBuilder, LibraryExtension, Module}, + eval::{Evaluator, FileLoader}, + syntax::{AstModule, Dialect}, +}; +use std::{ + path::{Path, PathBuf}, + sync::Arc, +}; +use tracing::{debug, instrument}; + +#[derive(Clone)] +pub struct WorkspaceState { + inner: Arc>, +} + +impl WorkspaceState { + pub fn new(root: impl AsRef) -> Self { + Self { + inner: Arc::new(Mutex::new(InnerState { + vfs: Vfs::new(), + root: root.as_ref().to_path_buf(), + current_revision: Default::default(), + _prev_revision: Default::default(), + })), + } + } + + pub fn root(&self) -> PathBuf { + self.inner.lock().root.clone() + } + + pub fn load(&self, path: &str) -> crate::Result { + self.inner.lock().load(path).map_err(Error::StarlarkError) + } + + pub fn current_revision(&self) -> Revision { + self.inner.lock().current_revision.clone() + } + + pub fn start_new_revision(&self) { + self.inner.lock().start_new_revision() + } + + pub fn wait_for_changes(&self) { + // TODO undo this lock lol + self.inner.lock().vfs.wait_for_changes() + } +} + +struct InnerState { + /// Path to `workspace.honk`. + root: PathBuf, + + /// Tracks changes to files we've read. + vfs: Vfs, + + current_revision: Revision, + _prev_revision: Revision, +} + +impl InnerState { + fn start_new_revision(&mut self) { + self._prev_revision = std::mem::replace(&mut self.current_revision, Revision::default()); + } +} + +impl FileLoader for InnerState { + #[instrument(skip(self))] + fn load(&mut self, path: &str) -> anyhow::Result { + // TODO smarter way to resolve assets etc + // TODO handle relative paths somehow? + let path = path.strip_prefix("//").unwrap_or(path); + let file = self.root.join(path); + debug!(file = %file.display(), "loading"); + + let root_contents = self.vfs.read(&file)?; + let root_contents = std::str::from_utf8(&*root_contents)?; + + let ast: AstModule = AstModule::parse(path, root_contents.to_string(), &Dialect::Standard)?; + + let globals = GlobalsBuilder::extended_by(&[LibraryExtension::StructType]) + .with(crate::builtins::register) + .build(); + let module: Module = Module::new(); + let mut eval: Evaluator = Evaluator::new(&module, &globals); + + let revision = self.current_revision.clone(); + eval.set_revision(&revision); + eval.set_loader(self); + let _res = eval.eval_module(ast)?; + + Ok(module.freeze()) + } +} From c3265df9f3a57d6b7c6c4a2daa9f984d9ead6ef4 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 10 Apr 2021 11:21:07 -0700 Subject: [PATCH 72/73] [honk] add basic http server --- honk/Cargo.lock | 1144 ++++++++++++++++++++++++++++++++++++++++++++- honk/Cargo.toml | 1 + honk/src/lib.rs | 32 +- honk/src/state.rs | 13 +- honk/src/vfs.rs | 34 +- 5 files changed, 1189 insertions(+), 35 deletions(-) diff --git a/honk/Cargo.lock b/honk/Cargo.lock index c467ced68..0a1fdabc5 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -12,6 +12,267 @@ dependencies = [ "regex", ] +[[package]] +name = "actix-codec" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78d1833b3838dbe990df0f1f87baf640cf6146e898166afe401839d1b001e570" +dependencies = [ + "bitflags", + "bytes 0.5.6", + "futures-core", + "futures-sink", + "log", + "pin-project 0.4.28", + "tokio", + "tokio-util", +] + +[[package]] +name = "actix-connect" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177837a10863f15ba8d3ae3ec12fac1099099529ed20083a27fdfe247381d0dc" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "derive_more", + "either", + "futures-util", + "http", + "log", + "trust-dns-proto", + "trust-dns-resolver", +] + +[[package]] +name = "actix-http" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "452299e87817ae5673910e53c243484ca38be3828db819b6011736fc6982e874" +dependencies = [ + "actix-codec", + "actix-connect", + "actix-rt", + "actix-service", + "actix-threadpool", + "actix-utils", + "base64 0.13.0", + "bitflags", + "brotli2", + "bytes 0.5.6", + "cookie", + "copyless", + "derive_more", + "either", + "encoding_rs", + "flate2", + "futures-channel", + "futures-core", + "futures-util", + "fxhash", + "h2", + "http", + "httparse", + "indexmap", + "itoa", + "language-tags", + "lazy_static", + "log", + "mime", + "percent-encoding", + "pin-project 1.0.6", + "rand", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "sha-1", + "slab", + "time", +] + +[[package]] +name = "actix-macros" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ca8ce00b267af8ccebbd647de0d61e0674b6e61185cc7a592ff88772bed655" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-router" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ad299af73649e1fc893e333ccf86f377751eb95ff875d095131574c6f43452c" +dependencies = [ + "bytestring", + "http", + "log", + "regex", + "serde", +] + +[[package]] +name = "actix-rt" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143fcc2912e0d1de2bcf4e2f720d2a60c28652ab4179685a1ee159e0fb3db227" +dependencies = [ + "actix-macros", + "actix-threadpool", + "copyless", + "futures-channel", + "futures-util", + "smallvec", + "tokio", +] + +[[package]] +name = "actix-server" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45407e6e672ca24784baa667c5d32ef109ccdd8d5e0b5ebb9ef8a67f4dfb708e" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "futures-channel", + "futures-util", + "log", + "mio", + "mio-uds", + "num_cpus", + "slab", + "socket2", +] + +[[package]] +name = "actix-service" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0052435d581b5be835d11f4eb3bce417c8af18d87ddf8ace99f8e67e595882bb" +dependencies = [ + "futures-util", + "pin-project 0.4.28", +] + +[[package]] +name = "actix-testing" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47239ca38799ab74ee6a8a94d1ce857014b2ac36f242f70f3f75a66f691e791c" +dependencies = [ + "actix-macros", + "actix-rt", + "actix-server", + "actix-service", + "log", + "socket2", +] + +[[package]] +name = "actix-threadpool" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d209f04d002854b9afd3743032a27b066158817965bf5d036824d19ac2cc0e30" +dependencies = [ + "derive_more", + "futures-channel", + "lazy_static", + "log", + "num_cpus", + "parking_lot", + "threadpool", +] + +[[package]] +name = "actix-tls" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24789b7d7361cf5503a504ebe1c10806896f61e96eca9a7350e23001aca715fb" +dependencies = [ + "actix-codec", + "actix-service", + "actix-utils", + "futures-util", +] + +[[package]] +name = "actix-utils" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9022dec56632d1d7979e59af14f0597a28a830a9c1c7fec8b2327eb9f16b5a" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "bitflags", + "bytes 0.5.6", + "either", + "futures-channel", + "futures-sink", + "futures-util", + "log", + "pin-project 0.4.28", + "slab", +] + +[[package]] +name = "actix-web" +version = "3.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e641d4a172e7faa0862241a20ff4f1f5ab0ab7c279f00c2d4587b77483477b86" +dependencies = [ + "actix-codec", + "actix-http", + "actix-macros", + "actix-router", + "actix-rt", + "actix-server", + "actix-service", + "actix-testing", + "actix-threadpool", + "actix-tls", + "actix-utils", + "actix-web-codegen", + "awc", + "bytes 0.5.6", + "derive_more", + "encoding_rs", + "futures-channel", + "futures-core", + "futures-util", + "fxhash", + "log", + "mime", + "pin-project 1.0.6", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "socket2", + "time", + "tinyvec", + "url", +] + +[[package]] +name = "actix-web-codegen" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad26f77093333e0e7c6ffe54ebe3582d908a104e448723eec6d43d08b07143fb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "addr2line" version = "0.14.1" @@ -120,6 +381,17 @@ dependencies = [ "term", ] +[[package]] +name = "async-trait" +version = "0.1.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atty" version = "0.2.14" @@ -137,6 +409,30 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "awc" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b381e490e7b0cfc37ebc54079b0413d8093ef43d14a4e4747083f7fa47a9e691" +dependencies = [ + "actix-codec", + "actix-http", + "actix-rt", + "actix-service", + "base64 0.13.0", + "bytes 0.5.6", + "cfg-if 1.0.0", + "derive_more", + "futures-core", + "log", + "mime", + "percent-encoding", + "rand", + "serde", + "serde_json", + "serde_urlencoded", +] + [[package]] name = "backtrace" version = "0.3.56" @@ -151,6 +447,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base-x" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" + [[package]] name = "base64" version = "0.11.0" @@ -201,6 +503,35 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "brotli-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "brotli2" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" +dependencies = [ + "brotli-sys", + "libc", +] + [[package]] name = "bumpalo" version = "3.6.1" @@ -213,6 +544,27 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + +[[package]] +name = "bytes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" + +[[package]] +name = "bytestring" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d" +dependencies = [ + "bytes 1.0.1", +] + [[package]] name = "cc" version = "1.0.67" @@ -285,6 +637,12 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "const_fn" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "076a6803b0dacd6a88cfe64deba628b01533ff5ef265687e6938280c1afd0a28" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -297,6 +655,38 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "cookie" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a5d7b21829bc7b4bf4754a978a241ae54ea55a40f92bb20216e54096f4b951" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "copyless" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2df960f5d869b2dd8532793fde43eb5427cceb126c929747a26823ab0eeb536" + +[[package]] +name = "cpuid-bool" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" + +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crossbeam-channel" version = "0.4.4" @@ -375,6 +765,15 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + [[package]] name = "dirs" version = "1.0.5" @@ -407,6 +806,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "discard" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" + [[package]] name = "either" version = "1.6.1" @@ -422,6 +827,27 @@ dependencies = [ "log", ] +[[package]] +name = "encoding_rs" +version = "0.8.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "enum-as-inner" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c5f0096a91d210159eceb2ff5e1c4da18388a170e1e3ce948aac9c8fdbbf595" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "eyre" version = "0.6.5" @@ -450,6 +876,18 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" +[[package]] +name = "flate2" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" +dependencies = [ + "cfg-if 1.0.0", + "crc32fast", + "libc", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" @@ -517,6 +955,95 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +[[package]] +name = "futures" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815" + +[[package]] +name = "futures-io" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04" + +[[package]] +name = "futures-macro" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668c6733a182cd7deb4f1de7ba3bf2120823835b3bcfbeacf7d2c4a773c1bb8b" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23" + +[[package]] +name = "futures-task" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc" + +[[package]] +name = "futures-util" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite 0.2.6", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "gazebo" version = "0.2.0" @@ -537,6 +1064,16 @@ dependencies = [ "syn", ] +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.1.16" @@ -571,6 +1108,26 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "h2" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" +dependencies = [ + "bytes 0.5.6", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", + "tracing-futures", +] + [[package]] name = "hashbrown" version = "0.9.1" @@ -599,6 +1156,7 @@ dependencies = [ name = "honk" version = "7.0.0" dependencies = [ + "actix-web", "anyhow", "argh", "color-eyre", @@ -618,6 +1176,34 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi 0.3.9", +] + +[[package]] +name = "http" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" +dependencies = [ + "bytes 1.0.1", + "fnv", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc35c995b9d93ec174cf9a27d425c7892722101e14993cd227fdb51d70cf9589" + [[package]] name = "idna" version = "0.2.2" @@ -683,6 +1269,18 @@ dependencies = [ "libc", ] +[[package]] +name = "ipconfig" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" +dependencies = [ + "socket2", + "widestring", + "winapi 0.3.9", + "winreg", +] + [[package]] name = "itertools" version = "0.9.0" @@ -749,6 +1347,12 @@ dependencies = [ "regex", ] +[[package]] +name = "language-tags" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" + [[package]] name = "lazy_static" version = "1.4.0" @@ -767,6 +1371,12 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714" +[[package]] +name = "linked-hash-map" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" + [[package]] name = "lock_api" version = "0.4.3" @@ -809,6 +1419,15 @@ dependencies = [ "utf8-ranges", ] +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "lsp-server" version = "0.3.4" @@ -841,6 +1460,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + [[package]] name = "matchers" version = "0.0.1" @@ -880,6 +1505,12 @@ dependencies = [ "serde", ] +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + [[package]] name = "miniz_oxide" version = "0.4.4" @@ -921,6 +1552,17 @@ dependencies = [ "slab", ] +[[package]] +name = "mio-uds" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" +dependencies = [ + "iovec", + "libc", + "mio", +] + [[package]] name = "miow" version = "0.2.2" @@ -999,6 +1641,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "object" version = "0.23.0" @@ -1011,6 +1663,12 @@ version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + [[package]] name = "owo-colors" version = "1.3.0" @@ -1077,13 +1735,71 @@ dependencies = [ name = "pico-args" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d70072c20945e1ab871c472a285fc772aefd4f5407723c206242f2c6f94595d6" +checksum = "d70072c20945e1ab871c472a285fc772aefd4f5407723c206242f2c6f94595d6" + +[[package]] +name = "pin-project" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918192b5c59119d51e0cd221f4d49dde9112824ba717369e903c97d076083d0f" +dependencies = [ + "pin-project-internal 0.4.28", +] + +[[package]] +name = "pin-project" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc174859768806e91ae575187ada95c91a29e96a98dc5d2cd9a1fed039501ba6" +dependencies = [ + "pin-project-internal 1.0.6", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be26700300be6d9d23264c73211d8190e755b6b5ca7a1b28230025511b52a5e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a490329918e856ed1b083f244e3bfe2d8c4f336407e4ea9e1a9f479ff09049e5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" + +[[package]] +name = "pin-project-lite" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "pin-project-lite" -version = "0.2.6" +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "precomputed-hash" @@ -1115,6 +1831,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro-nested" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" + [[package]] name = "proc-macro2" version = "1.0.26" @@ -1124,6 +1852,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" version = "1.0.9" @@ -1133,6 +1867,47 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + [[package]] name = "redox_syscall" version = "0.1.57" @@ -1196,6 +1971,16 @@ version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", +] + [[package]] name = "rust-argon2" version = "0.8.3" @@ -1214,6 +1999,15 @@ version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + [[package]] name = "rustyline" version = "7.1.0" @@ -1298,6 +2092,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + [[package]] name = "serde" version = "1.0.125" @@ -1340,6 +2149,37 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha-1" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfebf75d25bd900fd1e7d11501efab59bc846dbc76196839663e6637bba9f25f" +dependencies = [ + "block-buffer", + "cfg-if 1.0.0", + "cpuid-bool", + "digest", + "opaque-debug", +] + +[[package]] +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + [[package]] name = "sharded-slab" version = "0.1.1" @@ -1349,6 +2189,15 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "signal-hook-registry" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +dependencies = [ + "libc", +] + [[package]] name = "siphasher" version = "0.3.5" @@ -1367,10 +2216,31 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +[[package]] +name = "socket2" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "standback" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" +dependencies = [ + "version_check", +] + [[package]] name = "starlark" -version = "0.4.0-pre" -source = "git+https://github.com/facebookexperimental/starlark-rust?rev=8c6f291#8c6f29148ca896b445d373c65e6914735328df36" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd4a5e075ef3a8778f3e9ee4e5ff5f52337f31a02914e2073f378cb8586425e" dependencies = [ "annotate-snippets", "anyhow", @@ -1404,8 +2274,9 @@ dependencies = [ [[package]] name = "starlark_module" -version = "0.4.0-pre" -source = "git+https://github.com/facebookexperimental/starlark-rust?rev=8c6f291#8c6f29148ca896b445d373c65e6914735328df36" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d14a34c22bb57848d5fc890ca61a28649f599a3137f3fb0580861a3959f303cd" dependencies = [ "gazebo", "proc-macro2", @@ -1419,6 +2290,55 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "stdweb" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" +dependencies = [ + "discard", + "rustc_version", + "stdweb-derive", + "stdweb-internal-macros", + "stdweb-internal-runtime", + "wasm-bindgen", +] + +[[package]] +name = "stdweb-derive" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_derive", + "syn", +] + +[[package]] +name = "stdweb-internal-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" +dependencies = [ + "base-x", + "proc-macro2", + "quote", + "serde", + "serde_derive", + "serde_json", + "sha1", + "syn", +] + +[[package]] +name = "stdweb-internal-runtime" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" + [[package]] name = "string_cache" version = "0.8.1" @@ -1521,6 +2441,53 @@ dependencies = [ "once_cell", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + +[[package]] +name = "time" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a8cbfbf47955132d0202d1662f49b2423ae35862aee471f3ba4b133358f372" +dependencies = [ + "const_fn", + "libc", + "standback", + "stdweb", + "time-macros", + "version_check", + "winapi 0.3.9", +] + +[[package]] +name = "time-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" +dependencies = [ + "proc-macro-hack", + "time-macros-impl", +] + +[[package]] +name = "time-macros-impl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "standback", + "syn", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -1545,6 +2512,40 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "tokio" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" +dependencies = [ + "bytes 0.5.6", + "futures-core", + "iovec", + "lazy_static", + "libc", + "memchr", + "mio", + "mio-uds", + "pin-project-lite 0.1.12", + "signal-hook-registry", + "slab", + "winapi 0.3.9", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes 0.5.6", + "futures-core", + "futures-sink", + "log", + "pin-project-lite 0.1.12", + "tokio", +] + [[package]] name = "tracing" version = "0.1.25" @@ -1552,7 +2553,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ "cfg-if 1.0.0", - "pin-project-lite", + "log", + "pin-project-lite 0.2.6", "tracing-attributes", "tracing-core", ] @@ -1587,6 +2589,16 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project 1.0.6", + "tracing", +] + [[package]] name = "tracing-log" version = "0.1.2" @@ -1630,6 +2642,51 @@ dependencies = [ "tracing-serde", ] +[[package]] +name = "trust-dns-proto" +version = "0.19.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cad71a0c0d68ab9941d2fb6e82f8fb2e86d9945b94e1661dd0aaea2b88215a9" +dependencies = [ + "async-trait", + "cfg-if 1.0.0", + "enum-as-inner", + "futures", + "idna", + "lazy_static", + "log", + "rand", + "smallvec", + "thiserror", + "tokio", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.19.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "710f593b371175db53a26d0b38ed2978fafb9e9e8d3868b1acd753ea18df0ceb" +dependencies = [ + "cfg-if 0.1.10", + "futures", + "ipconfig", + "lazy_static", + "log", + "lru-cache", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "trust-dns-proto", +] + +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + [[package]] name = "unicode-bidi" version = "0.3.4" @@ -1732,6 +2789,66 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasm-bindgen" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" + +[[package]] +name = "widestring" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" + [[package]] name = "winapi" version = "0.2.8" @@ -1775,6 +2892,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winreg" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" diff --git a/honk/Cargo.toml b/honk/Cargo.toml index e92ebef3c..c495de11c 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -14,6 +14,7 @@ authors = ["Adam Perry "] edition = "2018" [dependencies] +actix-web = "3" anyhow = "1" argh = "0.1.4" color-eyre = "0.5.6" diff --git a/honk/src/lib.rs b/honk/src/lib.rs index e06a8885a..e5a92dac1 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,4 +1,5 @@ -use std::path::Path; +use actix_web::{get, web, App, HttpResponse, HttpServer, Responder}; +use std::{path::Path, thread::JoinHandle}; use tracing::{debug, error, info, instrument}; pub mod builtins; @@ -28,6 +29,7 @@ impl Workspace { pub fn maintain(self) -> crate::Result<()> { // TODO change current directory to workspace root? info!("maintaining workspace"); + spawn_server(self.state.clone()); loop { if let Err(error) = self.converge() { error!(%error, "couldn't converge current workspace revision"); @@ -42,12 +44,9 @@ impl Workspace { self.state.start_new_revision(); let _workspace_env = self.state.load(Self::ASSET_PATH)?; - let _build = self.state.current_revision().resolve()?; + let _build = self.state.resolve()?; info!("discovered targets"); - // FIXME make this an actual web viewer via http server, right? - dump_graphviz(&_build); - tracing::warn!("uh run some builds i guess?"); info!("finished"); @@ -55,8 +54,25 @@ impl Workspace { } } -fn dump_graphviz(g: &crate::graph::ActionGraph) { +pub fn spawn_server(state: crate::WorkspaceState) -> JoinHandle> { + info!("spawning server"); + std::thread::spawn(move || { + actix_web::rt::System::new("honk_workspace_server").block_on(async move { + HttpServer::new(move || App::new().data(state.clone()).service(http_root)) + // FIXME make this configurable + .bind("[::1]:8080")? + .run() + .await + }) + }) +} + +#[get("/")] +async fn http_root(data: web::Data) -> impl Responder { use petgraph::dot::{Config, Dot}; - let output = Dot::with_config(g, &[Config::EdgeNoLabel]); - println!("{}", output); + HttpResponse::Ok().body(format!( + "Hello world! from {}\n\n{}", + data.root().display(), + Dot::with_config(&data.resolve().unwrap(), &[Config::EdgeNoLabel]), + )) } diff --git a/honk/src/state.rs b/honk/src/state.rs index 074e8fadb..3131f6876 100644 --- a/honk/src/state.rs +++ b/honk/src/state.rs @@ -44,13 +44,18 @@ impl WorkspaceState { self.inner.lock().current_revision.clone() } + pub fn resolve(&self) -> crate::Result { + self.inner.lock().current_revision.resolve() + } + pub fn start_new_revision(&self) { self.inner.lock().start_new_revision() } pub fn wait_for_changes(&self) { - // TODO undo this lock lol - self.inner.lock().vfs.wait_for_changes() + // can't one-liner because we need the lock to be dropped + let spawned = { self.inner.lock().spawn_wait_for_changes() }; + spawned.join().unwrap(); } } @@ -69,6 +74,10 @@ impl InnerState { fn start_new_revision(&mut self) { self._prev_revision = std::mem::replace(&mut self.current_revision, Revision::default()); } + + fn spawn_wait_for_changes(&mut self) -> std::thread::JoinHandle<()> { + self.vfs.spawn_wait_for_changes() + } } impl FileLoader for InnerState { diff --git a/honk/src/vfs.rs b/honk/src/vfs.rs index ededd183f..7f1bfcfbe 100644 --- a/honk/src/vfs.rs +++ b/honk/src/vfs.rs @@ -12,26 +12,28 @@ impl Vfs { Self { inner: MemoVfs::new_default() } } - pub fn wait_for_changes(&self) { + pub fn spawn_wait_for_changes(&self) -> std::thread::JoinHandle<()> { let changes = self.inner.event_receiver(); - match changes.recv().unwrap() { - VfsEvent::Create(created) => info!(created = %created.display()), - VfsEvent::Write(modified) => info!(modified = %modified.display()), - VfsEvent::Remove(removed) => info!(removed = %removed.display()), - _ => unimplemented!("unrecognized filesystem event"), - } + std::thread::spawn(move || { + match changes.recv().unwrap() { + VfsEvent::Create(created) => info!(created = %created.display()), + VfsEvent::Write(modified) => info!(modified = %modified.display()), + VfsEvent::Remove(removed) => info!(removed = %removed.display()), + _ => unimplemented!("unrecognized filesystem event"), + } - // TODO figure out how much memofs debounces, make sure its enough or we do some - debug!("draining other fs events until quiescent"); - loop { - match changes.try_recv() { - Ok(event) => trace!(?event, "discarding"), - Err(TryRecvError::Empty) => break, - Err(TryRecvError::Disconnected) => { - unreachable!("other end is kept alive by ourselves") + // TODO figure out how much memofs debounces, make sure its enough or we do some + debug!("draining other fs events until quiescent"); + loop { + match changes.try_recv() { + Ok(event) => trace!(?event, "discarding"), + Err(TryRecvError::Empty) => break, + Err(TryRecvError::Disconnected) => { + unreachable!("other end is kept alive by ourselves") + } } } - } + }) } } From eba5a14926c8bde8868684a264ef7f8db51eea50 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sun, 25 Apr 2021 08:06:34 -0700 Subject: [PATCH 73/73] [honk] wip graphql server --- honk/Cargo.lock | 272 +++++++++++++++++++++++++++++++++++++++++++++++- honk/Cargo.toml | 2 + honk/src/gql.rs | 47 +++++++++ honk/src/lib.rs | 32 ++++-- 4 files changed, 342 insertions(+), 11 deletions(-) create mode 100644 honk/src/gql.rs diff --git a/honk/Cargo.lock b/honk/Cargo.lock index 0a1fdabc5..453e4a181 100644 --- a/honk/Cargo.lock +++ b/honk/Cargo.lock @@ -12,6 +12,31 @@ dependencies = [ "regex", ] +[[package]] +name = "actix" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1be241f88f3b1e7e9a3fbe3b5a8a0f6915b5a1d7ee0d9a248d3376d01068cc60" +dependencies = [ + "actix-rt", + "actix_derive", + "bitflags", + "bytes 0.5.6", + "crossbeam-channel", + "derive_more", + "futures-channel", + "futures-util", + "log", + "once_cell", + "parking_lot", + "pin-project 0.4.28", + "smallvec", + "tokio", + "tokio-util", + "trust-dns-proto", + "trust-dns-resolver", +] + [[package]] name = "actix-codec" version = "0.3.0" @@ -91,7 +116,7 @@ dependencies = [ "serde_urlencoded", "sha-1", "slab", - "time", + "time 0.2.26", ] [[package]] @@ -257,11 +282,27 @@ dependencies = [ "serde_json", "serde_urlencoded", "socket2", - "time", + "time 0.2.26", "tinyvec", "url", ] +[[package]] +name = "actix-web-actors" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6edf3c2693e2a8c422800c87ee89a6a4eac7dd01109bc172a1093ce1f4f001" +dependencies = [ + "actix", + "actix-codec", + "actix-http", + "actix-web", + "bytes 0.5.6", + "futures-channel", + "futures-core", + "pin-project 0.4.28", +] + [[package]] name = "actix-web-codegen" version = "0.4.0" @@ -273,6 +314,17 @@ dependencies = [ "syn", ] +[[package]] +name = "actix_derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95aceadaf327f18f0df5962fedc1bde2f870566a0b9f65c89508a3b1f79334c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "addr2line" version = "0.14.1" @@ -372,6 +424,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "ascii" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" + [[package]] name = "ascii-canvas" version = "2.0.0" @@ -532,6 +590,23 @@ dependencies = [ "libc", ] +[[package]] +name = "bson" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b6553abdb9d2d8f262f0b5bccf807321d5b7d1a12796bcede8e1f150e85f2e" +dependencies = [ + "base64 0.13.0", + "chrono", + "hex", + "lazy_static", + "linked-hash-map", + "rand", + "serde", + "serde_json", + "uuid", +] + [[package]] name = "bumpalo" version = "3.6.1" @@ -592,6 +667,7 @@ dependencies = [ "libc", "num-integer", "num-traits", + "time 0.1.43", "winapi 0.3.9", ] @@ -637,6 +713,19 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "combine" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" +dependencies = [ + "ascii", + "byteorder", + "either", + "memchr", + "unreachable", +] + [[package]] name = "const_fn" version = "0.4.6" @@ -662,7 +751,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a5d7b21829bc7b4bf4754a978a241ae54ea55a40f92bb20216e54096f4b951" dependencies = [ "percent-encoding", - "time", + "time 0.2.26", "version_check", ] @@ -759,6 +848,17 @@ dependencies = [ "syn", ] +[[package]] +name = "derive_utils" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "532b4c15dccee12c7044f1fcad956e98410860b22231e44a3b827464797ca7bf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "diff" version = "0.1.12" @@ -963,6 +1063,7 @@ checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253" dependencies = [ "futures-channel", "futures-core", + "futures-executor", "futures-io", "futures-sink", "futures-task", @@ -985,6 +1086,28 @@ version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815" +[[package]] +name = "futures-enum" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3422d14de7903a52e9dbc10ae05a7e14445ec61890100e098754e120b2bd7b1e" +dependencies = [ + "derive_utils", + "quote", + "syn", +] + +[[package]] +name = "futures-executor" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f6cb7042eda00f0049b1d2080aa4b93442997ee507eb3828e8bd7577f94c9d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.14" @@ -1108,6 +1231,16 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "graphql-parser" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1abd4ce5247dfc04a03ccde70f87a048458c9356c7e41d21ad8c407b3dde6f2" +dependencies = [ + "combine", + "thiserror", +] + [[package]] name = "h2" version = "0.2.7" @@ -1152,6 +1285,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "honk" version = "7.0.0" @@ -1163,6 +1302,8 @@ dependencies = [ "crossbeam-channel", "gazebo", "glob", + "juniper", + "juniper_actix", "memofs", "once_cell", "parking_lot", @@ -1229,6 +1370,7 @@ checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" dependencies = [ "autocfg", "hashbrown", + "serde", ] [[package]] @@ -1305,6 +1447,81 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +[[package]] +name = "juniper" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e1330b4b3b2fe7de256fd08738f7fba28ffa574109c834988c28972f0760dbd" +dependencies = [ + "async-trait", + "bson", + "chrono", + "fnv", + "futures", + "futures-enum", + "graphql-parser", + "indexmap", + "juniper_codegen", + "serde", + "smartstring", + "static_assertions", + "url", + "uuid", +] + +[[package]] +name = "juniper_actix" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3afc38d7583ee66c8a0f7e18e9b7de55cc5717e19990eb4ae7280a0094a2f3c" +dependencies = [ + "actix", + "actix-web", + "actix-web-actors", + "anyhow", + "futures", + "juniper", + "juniper_graphql_ws", + "serde", + "serde_json", + "thiserror", + "tokio", +] + +[[package]] +name = "juniper_codegen" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3faf2a1e2e86cadc6bcc6082d63c73e8eafe6b703a0c5723e585b3d4afcec9cd" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "juniper_graphql_ws" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d4b8208e5a27e81dbc3217a8752adfa661538b91456534baf1c9ae724fdfbd" +dependencies = [ + "juniper", + "juniper_subscriptions", + "serde", + "tokio", +] + +[[package]] +name = "juniper_subscriptions" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a20ddcec070ee33abcaa88383dc61a23d13965e40d1cab84e3533fc3b34d03c0" +dependencies = [ + "futures", + "juniper", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -2133,6 +2350,7 @@ version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ + "indexmap", "itoa", "ryu", "serde", @@ -2216,6 +2434,15 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +[[package]] +name = "smartstring" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ada87540bf8ef4cf8a1789deb175626829bb59b1fefd816cf7f7f55efcdbae9" +dependencies = [ + "static_assertions", +] + [[package]] name = "socket2" version = "0.3.19" @@ -2450,6 +2677,16 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "time" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "time" version = "0.2.26" @@ -2519,6 +2756,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" dependencies = [ "bytes 0.5.6", + "fnv", "futures-core", "iovec", "lazy_static", @@ -2529,9 +2767,21 @@ dependencies = [ "pin-project-lite 0.1.12", "signal-hook-registry", "slab", + "tokio-macros", "winapi 0.3.9", ] +[[package]] +name = "tokio-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tokio-util" version = "0.3.1" @@ -2540,6 +2790,7 @@ checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ "bytes 0.5.6", "futures-core", + "futures-io", "futures-sink", "log", "pin-project-lite 0.1.12", @@ -2723,6 +2974,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "unreachable" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" +dependencies = [ + "void", +] + [[package]] name = "url" version = "2.2.1" @@ -2748,6 +3008,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372" +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + [[package]] name = "vec_map" version = "0.8.2" diff --git a/honk/Cargo.toml b/honk/Cargo.toml index c495de11c..e448c8c9f 100644 --- a/honk/Cargo.toml +++ b/honk/Cargo.toml @@ -21,6 +21,8 @@ color-eyre = "0.5.6" crossbeam-channel = "0.4.0" gazebo = "0.2.0" glob = "0.3.0" +juniper = "0.15" +juniper_actix = { version = "0.2", features = ["subscriptions"] } memofs = "0.1.2" once_cell = "1" parking_lot = "0.11.1" diff --git a/honk/src/gql.rs b/honk/src/gql.rs new file mode 100644 index 000000000..e1d177b7d --- /dev/null +++ b/honk/src/gql.rs @@ -0,0 +1,47 @@ +use crate::state::WorkspaceState; +use actix_web::{http::header, middleware, web, App, Error, HttpResponse, HttpServer}; +use juniper::{graphql_object, EmptyMutation, EmptySubscription, GraphQLObject, RootNode}; +use juniper_actix::{graphiql_handler, graphql_handler, playground_handler}; + +impl juniper::Context for WorkspaceState {} + +pub struct Query; + +#[graphql_object(context = WorkspaceState)] +impl Query { + fn apiVersion() -> String { + "1.0".to_string() + } + // #[graphql(arguments(id(description = "id of the user")))] + // fn user(database: &Database, id: i32) -> Option<&User> { + // database.get_user(&id) + // } +} + +pub type Schema = + RootNode<'static, Query, EmptyMutation, EmptySubscription>; + +pub fn schema() -> Schema { + Schema::new( + Query, + EmptyMutation::::new(), + EmptySubscription::::new(), + ) +} + +pub async fn graphiql_route() -> Result { + graphiql_handler("/graphgl", None).await +} + +pub async fn playground_route() -> Result { + playground_handler("/graphgl", None).await +} + +pub async fn graphql_route( + req: actix_web::HttpRequest, + // state: &WorkspaceState, + payload: actix_web::web::Payload, + schema: web::Data, +) -> Result { + graphql_handler(&schema, todo!("get the state"), req, payload).await +} diff --git a/honk/src/lib.rs b/honk/src/lib.rs index e5a92dac1..e696c78a7 100644 --- a/honk/src/lib.rs +++ b/honk/src/lib.rs @@ -1,16 +1,17 @@ -use actix_web::{get, web, App, HttpResponse, HttpServer, Responder}; +use crate::{error::Error, revision::EvaluatorExt, state::WorkspaceState}; +use actix_web::{get, middleware, web, App, HttpResponse, HttpServer, Responder}; +use juniper_actix::graphql_handler; use std::{path::Path, thread::JoinHandle}; use tracing::{debug, error, info, instrument}; pub mod builtins; pub mod error; +pub mod gql; pub mod graph; pub mod revision; pub mod state; pub mod vfs; -use crate::{error::Error, revision::EvaluatorExt, state::WorkspaceState}; - pub(crate) type Result = color_eyre::eyre::Result; pub struct Workspace { @@ -58,11 +59,26 @@ pub fn spawn_server(state: crate::WorkspaceState) -> JoinHandle