Commit 9b9f026
committed
review: one parser for mcpp.toml, and a cmd.exe line cmd.exe accepts
Follow-up to the [hooks] feature. Five things the first shape got wrong, in
descending order of how loudly they fail.
1. Windows: the hook never ran. `run_shell_deadline` built the command line
with `windows_command_from_argv({"cmd.exe","/d","/s","/c", command})`, which
quotes every token — so the switches stopped being switches and the command
arrived carrying a quote pair cmd.exe does not consume:
'"echo start>>hooks.log' is not recognized as an internal or external
command
That is #425 one layer up (`cmd.exe /c` does not use CreateProcess argument
quoting). A shell command now has its own host-independent shaper,
`windows_shell_command_line` — bare switches plus the single outer pair /s
strips — and its own tests in test_windows_command_line.cpp, which compile
on every platform. The Windows branch is unreachable on the machines this
is developed on; a unit test is the only thing that can fail there first.
2. `[hooks]` is a section of mcpp.toml, so mcpp.manifest parses it. The
feature came with a second, independent reader of the same file. It cost a
redundant parse on every build, and it reported ITS syntax errors in ITS
vocabulary: any manifest typo, anywhere in the file, came out as
`error: invalid hook configuration: ...` for every project whether or not
it used hooks. `Manifest::hooks` now carries the config, unknown keys warn
(and error under --strict) like every other section, and mcpp.hooks is left
with the part that is policy rather than grammar.
3. A hook no longer moves mcpp's working directory. The launchers already
carry a per-child cwd (posix_spawn_file_actions_addchdir_np,
lpCurrentDirectory); `run_shell_deadline` takes one, and the
chdir-and-restore dance around the call is gone.
4. The fast-path veto moved into try_fast_build, next to the manifest read
that answers it — cmd_build no longer loads the manifest a second time to
ask whether it may call a function that loads it again.
5. Coverage the claims did not have: workspace members (each member's own
hooks, in that member's root, root manifest silent), preparation failing
fires nothing, an unknown key warns and the known ones still run, and the
e2e compares hook logs by CONTENT — cmd.exe writes CRLF, so the previous
`$'start\nfinished'` comparison could not have passed on Windows even with
the command line fixed. Plus seven manifest tests for the grammar.
Docs (en + zh) state what was implicit: which commands run hooks and which
deliberately do not, what a virtual workspace root does, that an active hook
opts the project out of the fast path, that preparation failure is silent, and
that a `[hooks]` table is executable content in a repository you may have just
cloned.1 parent 32437da commit 9b9f026
12 files changed
Lines changed: 821 additions & 337 deletions
File tree
- docs
- zh
- modules
- manifest/src
- platform/src
- src
- build
- cli
- tests
- e2e
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2116 | 2116 | | |
2117 | 2117 | | |
2118 | 2118 | | |
2119 | | - | |
| 2119 | + | |
2120 | 2120 | | |
2121 | 2121 | | |
2122 | 2122 | | |
2123 | | - | |
2124 | | - | |
2125 | | - | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
2126 | 2128 | | |
2127 | 2129 | | |
2128 | 2130 | | |
| |||
2132 | 2134 | | |
2133 | 2135 | | |
2134 | 2136 | | |
2135 | | - | |
2136 | | - | |
2137 | | - | |
2138 | | - | |
2139 | | - | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
2140 | 2174 | | |
2141 | 2175 | | |
2142 | 2176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1812 | 1812 | | |
1813 | 1813 | | |
1814 | 1814 | | |
1815 | | - | |
| 1815 | + | |
1816 | 1816 | | |
1817 | 1817 | | |
1818 | 1818 | | |
1819 | | - | |
1820 | | - | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
1821 | 1822 | | |
1822 | 1823 | | |
1823 | 1824 | | |
| |||
1827 | 1828 | | |
1828 | 1829 | | |
1829 | 1830 | | |
1830 | | - | |
1831 | | - | |
1832 | | - | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
1833 | 1860 | | |
1834 | 1861 | | |
1835 | 1862 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1520 | 1520 | | |
1521 | 1521 | | |
1522 | 1522 | | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
1523 | 1598 | | |
1524 | 1599 | | |
1525 | 1600 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
919 | 919 | | |
920 | 920 | | |
921 | 921 | | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
922 | 953 | | |
923 | 954 | | |
924 | 955 | | |
| |||
985 | 1016 | | |
986 | 1017 | | |
987 | 1018 | | |
| 1019 | + | |
988 | 1020 | | |
989 | 1021 | | |
990 | 1022 | | |
| |||
0 commit comments