diff options
-rw-r--r-- | .gitignore | 7 | ||||
-rw-r--r-- | Cargo.lock (renamed from src/lix-doc/Cargo.lock) | 0 | ||||
-rw-r--r-- | Cargo.toml | 6 | ||||
-rw-r--r-- | meson.build | 26 | ||||
-rw-r--r-- | package.nix | 4 | ||||
-rw-r--r-- | src/lix-doc/Cargo.toml | 3 | ||||
-rw-r--r-- | src/lix-doc/meson.build | 27 |
7 files changed, 42 insertions, 31 deletions
diff --git a/.gitignore b/.gitignore index 55e6e5c8b..0ae2c44a2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,10 @@ GTAGS # ccls /.ccls-cache +# auto-generated compilation database +compile_commands.json +rust-project.json + result result-* @@ -29,3 +33,6 @@ buildtime.bin /.pre-commit-config.yaml /.nocontribmsg /release + +# Rust build files when using Cargo (not actually supported for building but it spews the files anyway) +/target/ diff --git a/src/lix-doc/Cargo.lock b/Cargo.lock index e82e138f5..e82e138f5 100644 --- a/src/lix-doc/Cargo.lock +++ b/Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 000000000..79bcbe0dd --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[workspace] +resolver = "2" +members = ["src/lix-doc"] + +[workspace.package] +edition = "2021" diff --git a/meson.build b/meson.build index bcf0d06bc..596373c8c 100644 --- a/meson.build +++ b/meson.build @@ -545,6 +545,32 @@ if cxx.get_id() in ['clang', 'gcc'] ) endif +# Until Meson 1.5¹, we can't just give Meson a Cargo.lock file and be done with it. +# Meson will *detect* what dependencies are needed from Cargo files; it just won't +# fetch them. The Meson 1.5 feature essentially internally translates Cargo.lock entries +# to .wrap files, and that translation is incredibly straightforward, so let's just +# use a simple Python script to generate the .wrap files ourselves while we wait for +# Meson 1.5. Weirdly, it seems Meson will only detect dependencies from other +# dependency() calls, so we have to specify lix-doc's two top-level dependencies, +# rnix and rowan, manually, and then their dependencies will be recursively translated +# into more dependency() calls. +# +# When Meson translates a Cargo dependency, the string passed to `dependency()` follows +# a fixed format, which is important as the .wrap files' basenames must match the string +# passed to `dependency()` exactly. +# In Meson 1.4, this format is `$packageName-rs`. Meson 1.5 changes this to +# `$packageName-$shortenedVersionString-rs`, because of course it does, but we'll cross +# that bridge when we get there... +# +# [1]: https://github.com/mesonbuild/meson/commit/9b8378985dbdc0112d11893dd42b33b7bc8d1e62 +run_command( + python, + meson.project_source_root() / 'meson/cargo-lock-to-wraps.py', + meson.project_source_root() / 'Cargo.lock', + meson.project_source_root() / 'subprojects', + check : true, +) + if is_darwin configure_file( input : 'misc/launchd/org.nixos.nix-daemon.plist.in', diff --git a/package.nix b/package.nix index a678e3dbd..f37e177dd 100644 --- a/package.nix +++ b/package.nix @@ -137,6 +137,8 @@ let ./meson ./scripts/meson.build ./subprojects + # Required for meson to generate Cargo wraps + ./Cargo.lock ]); functionalTestFiles = fileset.unions [ @@ -288,7 +290,7 @@ stdenv.mkDerivation (finalAttrs: { BOOST_LIBRARYDIR = "${lib.getLib boost}/lib"; }; - cargoDeps = rustPlatform.importCargoLock { lockFile = ./src/lix-doc/Cargo.lock; }; + cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; }; preConfigure = lib.optionalString (!finalAttrs.dontBuild && !hostPlatform.isStatic) '' diff --git a/src/lix-doc/Cargo.toml b/src/lix-doc/Cargo.toml index 3f8ded0f7..02494862f 100644 --- a/src/lix-doc/Cargo.toml +++ b/src/lix-doc/Cargo.toml @@ -8,9 +8,6 @@ license = "BSD-2-Clause OR MIT" homepage = "https://github.com/lf-/nix-doc" repository = "https://github.com/lf-/nix-doc" -[lib] -crate_type = ["staticlib"] - [dependencies] rnix = "0.11.0" # Necessary because rnix fails to export a critical trait (Rowan's AstNode). diff --git a/src/lix-doc/meson.build b/src/lix-doc/meson.build index 36a5d8ba4..2fa7381a1 100644 --- a/src/lix-doc/meson.build +++ b/src/lix-doc/meson.build @@ -1,30 +1,3 @@ -# Until Meson 1.5¹, we can't just give Meson a Cargo.lock file and be done with it. -# Meson will *detect* what dependencies are needed from Cargo files; it just won't -# fetch them. The Meson 1.5 feature essentially internally translates Cargo.lock entries -# to .wrap files, and that translation is incredibly straightforward, so let's just -# use a simple Python script to generate the .wrap files ourselves while we wait for -# Meson 1.5. Weirdly, it seems Meson will only detect dependencies from other -# dependency() calls, so we have to specify lix-doc's two top-level dependencies, -# rnix and rowan, manually, and then their dependencies will be recursively translated -# into more dependency() calls. -# -# When Meson translates a Cargo dependency, the string passed to `dependency()` follows -# a fixed format, which is important as the .wrap files' basenames must match the string -# passed to `dependency()` exactly. -# In Meson 1.4, this format is `$packageName-rs`. Meson 1.5 changes this to -# `$packageName-$shortenedVersionString-rs`, because of course it does, but we'll cross -# that bridge when we get there... -# -# [1]: https://github.com/mesonbuild/meson/commit/9b8378985dbdc0112d11893dd42b33b7bc8d1e62 - -run_command( - python, - meson.project_source_root() / 'meson/cargo-lock-to-wraps.py', - meson.current_source_dir() / 'Cargo.lock', - meson.project_source_root() / 'subprojects', - check : true, -) - # The external crate rowan has an ambiguous pointer comparison warning, which # we don't want to fail our whole build if werror is on. subproject('rowan-rs', default_options : ['werror=false']) |