Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ webcpp/
webcpp.jam the Jamfile API (chapter 4): webcpp.targets, webcpp.run, ...
target.jam the targets, and the target a toolset builds for, which webcpp.jam and
component.jam both read
webcpp-mkdir.jam the action that makes a directory of the build on Windows, which
webcpp.jam loads: as idempotent as b2's mkdir -p elsewhere (chapter 6)
throw_exception.cpp what Boost calls in place of a throw, in a user's build without
exceptions
boost_json.cpp Boost.JSON's definitions, built as /webcpp//boost_json
Expand Down Expand Up @@ -2181,6 +2183,17 @@ Each of these was measured; each has cost time.
program with that value.
- **A checkout path that holds a space** builds: every path b2 hands to an
action is quoted, and the tests of the build run in such a path.
- **b2 makes a directory once per spelling of it,** relative or absolute
(`common.MkDir`), and a build names some by both: `bin/third_party`, a
configuration's own directory absolute and a consumer's selection
relative, and a library's test directory under `bin/libs`, the oracle's
`node-modules.stamp` absolute. Under `-j` the two actions run at once.
b2's action on Windows, `if not exist "d" mkdir "d"`, then fails when the
other one makes the directory between its test and its mkdir, and every
target under it is skipped (CI run 44690351573, `...failed common.mkdir
bin\third_party...`); `mkdir -p`, elsewhere, does not.
`tools/webcpp-mkdir.jam` makes Windows's action succeed whenever the
directory is there after it, and `tools/test/mkdir_test.py` checks it.
- **A target named `release-<word>` is no target.** b2 reads it as the
variant `release` with a subfeature and stops before it builds anything
(`"release-check" is not a known value of feature <variant>`); `debug-`
Expand Down
59 changes: 59 additions & 0 deletions tools/test/mkdir_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python3
# Copyright (c) 2026 WebCpp.org
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)

"""Checks tools/webcpp-mkdir.jam: on Windows, the action that makes a directory of the build
succeeds when another action made the directory between its test and its mkdir, which happens
when b2 -j makes one directory under two spellings, relative and absolute, at once (CI run
44690351573: `...failed common.mkdir bin\\third_party...`). A dry run of a project that imports
webcpp, whose b2 believes it is on Windows, prints for each directory b2's test and mkdir, then a
last line that decides by the directory alone: a mkdir that found it made fails, and the action
still succeeds. Run with the names of some cases to run only those."""

from __future__ import annotations

import sys
from pathlib import Path

import harness

# A project of one file in out/made, from a superproject that imports webcpp as a library's Jamfile
# does.
JAMFILE = '''import webcpp ;
make made.txt : : @touch : <location>out/made ;
actions touch
{
echo made > "$(<)"
}
'''

# The action's last line, for a directory.
DECIDES = 'if exist "{}\\" (exit /b 0) else (exit /b 1)'


def test_the_action_on_windows_decides_by_the_directory(root: Path) -> None:
# The user-config makes b2 believe it runs on Windows and leaves it so, for webcpp to choose
# Windows's action; a dry run executes nothing.
harness.configure(root, harness.user_config(root).read_text()
+ '\nimport modules ;\nmodules.poke os : .name : NT ;\n')
# Boost's version is read with Windows's findstr, which a dry run on another host has not.
harness.replace(root / 'Jamroot', '<conditional>@boost-check', '<webcpp-boost-check>off')
(root / 'libs/demo/test/mkdir').mkdir(parents=True)
(root / 'libs/demo/test/mkdir/Jamfile').write_text(JAMFILE)
result = harness.run_b2(root, '-n', '-a', '-d+2', 'libs/demo/test/mkdir//made.txt')
harness.expect(result, True, 'common.mkdir')
made = [line for line in result.stdout.splitlines() if line.startswith('common.mkdir ')]
assert made, result.stdout
for line in made:
directory = line[len('common.mkdir '):].strip()
assert DECIDES.format(directory) in result.stdout, (directory, result.stdout)
assert f'if not exist "{directory}\\" mkdir "{directory}"' in result.stdout, result.stdout


CASES = [test_the_action_on_windows_decides_by_the_directory]

if __name__ == '__main__':
sys.exit(harness.run_cases('mkdir_test', CASES, sys.argv[1:]))
37 changes: 37 additions & 0 deletions tools/webcpp-mkdir.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) 2026 WebCpp.org
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)
#
# The action that makes a directory of the build on Windows, as idempotent
# as `mkdir -p`, b2's own on every other system. b2 makes each directory of
# a target's path once per spelling of it (common.MkDir), and a build names
# some of its directories by two: bin/third_party, relative, for a
# consumer's selection of a configuration, and absolute for the
# configuration's own directory (tools/webcpp-third-party.jam); a
# library's test directory under bin/libs, relative for its programs, and
# absolute for the oracle's node-modules.stamp (tools/oracle/oracle.jam).
# The two actions are independent, so b2 -j runs them at once, and b2's
# action on Windows, `if not exist "d" mkdir "d"`, fails when the other one
# makes the directory between its test and its mkdir; the targets under it
# are then skipped (CI run 44690351573, the asio lane openssl-upstream on
# MSVC 14.5: `...failed common.mkdir bin\third_party...`, and the two
# upstream suites not run). Here a mkdir that finds the directory made in
# the meantime is a success, and the action fails only when no directory is
# there after it. tools/webcpp.jam loads this module, so every build that
# imports webcpp has it.
import common ;
import os ;

if [ os.name ] = NT
{
module common
{
actions quietly mkdir
{
if not exist "$(<)\" mkdir "$(<)"
if exist "$(<)\" (exit /b 0) else (exit /b 1)
}
}
}
4 changes: 4 additions & 0 deletions tools/webcpp.jam
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ modules.load webcpp-target : target.jam : [ path.native $(.tools) ] ;
import webcpp-target ;
.known = [ webcpp-target.known ] ;

# The action that makes a directory of the build on Windows, idempotent as
# `mkdir -p` is elsewhere (tools/webcpp-mkdir.jam).
modules.load webcpp-mkdir : webcpp-mkdir.jam : [ path.native $(.tools) ] ;

# The documentation's rules, loaded as the module webcpp-doc: b2 has a
# module named doc of its own, the one of --help, which an import of
# tools/doc/doc would find in its place.
Expand Down
Loading