Skip to content

Commit 54bac41

Browse files
committed
refactor: Move the libm crate to a subdirectory
In preparation for switching to a virtual manifest, move the `libm` crate into a subdirectory and update paths to match. Updating `Cargo.toml` is done in the next commit so git tracks the moved file correctly.
1 parent 161036a commit 54bac41

File tree

183 files changed

+334
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+334
-23
lines changed

libm/.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ jobs:
213213
steps:
214214
- uses: actions/checkout@master
215215
- run: |
216-
msrv="$(perl -ne 'print if s/rust-version\s*=\s*"(.*)"/\1/g' Cargo.toml)"
216+
msrv="$(perl -ne 'print if s/rust-version\s*=\s*"(.*)"/\1/g' libm/Cargo.toml)"
217217
echo "MSRV: $msrv"
218218
echo "MSRV=$msrv" >> "$GITHUB_ENV"
219219
- name: Install Rust

libm/ci/ci-util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
# Don't run exhaustive tests if these files change, even if they contaiin a function
6464
# definition.
6565
IGNORE_FILES = [
66-
"src/math/support/",
67-
"src/libm_helper.rs",
68-
"src/math/arch/intrinsics.rs",
66+
"libm/src/math/support/",
67+
"libm/src/libm_helper.rs",
68+
"libm/src/math/arch/intrinsics.rs",
6969
]
7070

7171
TYPES = ["f16", "f32", "f64", "f128"]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#[path = "../../configure.rs"]
1+
#[path = "../../libm/configure.rs"]
22
mod configure;
33

44
fn main() {
5-
println!("cargo:rerun-if-changed=../../configure.rs");
5+
println!("cargo:rerun-if-changed=../../libm/configure.rs");
66
let cfg = configure::Config::from_env();
77
configure::emit_libm_config(&cfg);
88
}

libm/crates/compiler-builtins-smoke-test/src/math.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::ffi::c_int;
33
#[allow(dead_code)]
44
#[allow(clippy::all)] // We don't get `libm`'s list of `allow`s, so just ignore Clippy.
55
#[allow(unused_imports)]
6-
#[path = "../../../src/math/mod.rs"]
6+
#[path = "../../../libm/src/math/mod.rs"]
77
pub mod libm;
88

99
/// Mark functions `#[no_mangle]` and with the C ABI.

libm/crates/libm-test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ anyhow = "1.0.97"
3232
gmp-mpfr-sys = { version = "1.6.4", optional = true, default-features = false }
3333
iai-callgrind = { version = "0.14.0", optional = true }
3434
indicatif = { version = "0.17.11", default-features = false }
35-
libm = { path = "../..", features = ["unstable-public-internals"] }
35+
libm = { path = "../../libm", features = ["unstable-public-internals"] }
3636
libm-macros = { path = "../libm-macros" }
3737
musl-math-sys = { path = "../musl-math-sys", optional = true }
3838
paste = "1.0.15"

libm/crates/libm-test/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#[path = "../../configure.rs"]
1+
#[path = "../../libm/configure.rs"]
22
mod configure;
33
use configure::Config;
44

55
fn main() {
6-
println!("cargo:rerun-if-changed=../../configure.rs");
6+
println!("cargo:rerun-if-changed=../../libm/configure.rs");
77
let cfg = Config::from_env();
88
configure::emit_test_config(&cfg);
99
}

libm/crates/musl-math-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77
[dependencies]
88

99
[dev-dependencies]
10-
libm = { path = "../../" }
10+
libm = { path = "../../libm" }
1111

1212
[build-dependencies]
1313
cc = "1.2.16"

libm/crates/util/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ build-mpfr = ["libm-test/build-mpfr", "dep:rug"]
1111
unstable-float = ["libm/unstable-float", "libm-test/unstable-float", "rug?/nightly-float"]
1212

1313
[dependencies]
14-
libm = { path = "../..", default-features = false }
14+
libm = { path = "../../libm", default-features = false }
1515
libm-macros = { path = "../libm-macros" }
1616
libm-test = { path = "../libm-test", default-features = false }
1717
musl-math-sys = { path = "../musl-math-sys", optional = true }

libm/crates/util/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#![allow(unexpected_cfgs)]
22

3-
#[path = "../../configure.rs"]
3+
#[path = "../../libm/configure.rs"]
44
mod configure;
55

66
fn main() {
7-
println!("cargo:rerun-if-changed=../../configure.rs");
7+
println!("cargo:rerun-if-changed=../../libm/configure.rs");
88
let cfg = configure::Config::from_env();
99
configure::emit_libm_config(&cfg);
1010
}

libm/etc/update-api-list.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
SELF_PATH = Path(__file__)
2020
ETC_DIR = SELF_PATH.parent
21-
ROOT_DIR = ETC_DIR.parent
21+
LIBM_DIR = ETC_DIR.parent.joinpath("libm")
2222

2323
# These files do not trigger a retest.
2424
IGNORED_SOURCES = ["src/libm_helper.rs", "src/math/support/float_traits.rs"]
@@ -75,7 +75,7 @@ def get_rustdoc_json() -> dict[Any, Any]:
7575
"-Zunstable-options",
7676
"-o-",
7777
],
78-
cwd=ROOT_DIR,
78+
cwd=LIBM_DIR,
7979
text=True,
8080
)
8181
j = json.loads(j)
@@ -121,8 +121,8 @@ def _init_defs(self, index: IndexTy) -> None:
121121

122122
# A lot of the `arch` module is often configured out so doesn't show up in docs. Use
123123
# string matching as a fallback.
124-
for fname in glob("src/math/arch/**.rs", root_dir=ROOT_DIR):
125-
contents = (ROOT_DIR.joinpath(fname)).read_text()
124+
for fname in glob("src/math/arch/**.rs", root_dir=LIBM_DIR):
125+
contents = (LIBM_DIR.joinpath(fname)).read_text()
126126

127127
for name in self.public_functions:
128128
if f"fn {name}" in contents:
@@ -188,10 +188,10 @@ def tidy_lists(self) -> None:
188188
include all public API.
189189
"""
190190

191-
flist = sp.check_output(["git", "ls-files"], cwd=ROOT_DIR, text=True)
191+
flist = sp.check_output(["git", "ls-files"], cwd=LIBM_DIR, text=True)
192192

193193
for path in flist.splitlines():
194-
fpath = ROOT_DIR.joinpath(path)
194+
fpath = LIBM_DIR.joinpath(path)
195195
if fpath.is_dir() or fpath == SELF_PATH:
196196
continue
197197

@@ -229,7 +229,7 @@ def ensure_contains_api(self, fpath: Path, line_num: int, lines: list[str]):
229229
if len(not_found) == 0:
230230
return
231231

232-
relpath = fpath.relative_to(ROOT_DIR)
232+
relpath = fpath.relative_to(LIBM_DIR)
233233
eprint(f"functions not found at {relpath}:{line_num}: {not_found}")
234234
exit(1)
235235

@@ -244,7 +244,7 @@ def validate_delimited_block(
244244
"""Identify blocks of code wrapped within `start` and `end`, collect their contents
245245
to a list of strings, and call `validate` for each of those lists.
246246
"""
247-
relpath = fpath.relative_to(ROOT_DIR)
247+
relpath = fpath.relative_to(LIBM_DIR)
248248
block_lines = []
249249
block_start_line: None | int = None
250250
for line_num, line in enumerate(lines):
@@ -274,7 +274,7 @@ def validate_delimited_block(
274274

275275
def ensure_sorted(fpath: Path, block_start_line: int, lines: list[str]) -> None:
276276
"""Ensure that a list of lines is sorted, otherwise print a diff and exit."""
277-
relpath = fpath.relative_to(ROOT_DIR)
277+
relpath = fpath.relative_to(LIBM_DIR)
278278
diff_and_exit(
279279
"\n".join(lines),
280280
"\n".join(sorted(lines)),

0 commit comments

Comments
 (0)