Skip to content

Commit

Permalink
remove findCrate stage
Browse files Browse the repository at this point in the history
The method of using metadata to check for a workspace before munging the desired
crate's toml needs to do so before we munge the workspace.

It made sense to get rid of the extraneous phase, especially now that everything
is refactored a bit.
  • Loading branch information
psionic-k committed Oct 17, 2023
1 parent 807d916 commit a2ab864
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions overlay/mkcrate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,6 @@ let

extraRustcBuildFlags = rustcBuildFlags;

# If the crate is a workspace, reduce it to a crate of just a single workspace
findCrate = ''
. ${./mkcrate-utils.sh}
manifest_path=$(cargoRelativeManifest ${name})
manifest_dir=''${manifest_path%Cargo.toml}
if [ $manifest_path != "Cargo.toml" ]; then
shopt -s globstar
if [[ -d .cargo ]]; then
mv .cargo .cargo.workspace
fi
mv Cargo.toml Cargo.workspace.toml
sanitizeTomlForRemarshal Cargo.workspace.toml
reduceWorkspaceToml Cargo.workspace.toml Cargo.toml "$manifest_dir"
fi
'';

configureCargo = ''
mkdir -p .cargo
cat > .cargo/config <<'EOF'
Expand Down Expand Up @@ -215,7 +197,6 @@ let

configurePhase = ''
runHook preConfigure
runHook findCrate
runHook configureCargo
runHook postConfigure
'';
Expand All @@ -226,9 +207,9 @@ let
};

overrideCargoManifest = ''
manifest_path=$(cargoRelativeManifest ${name})
manifest_dir=''${manifest_path%Cargo.toml}
. ${./mkcrate-utils.sh}
# Synthesize a lock file
echo "[[package]]" > Cargo.lock
echo name = \"${name}\" >> Cargo.lock
echo version = \"${version}\" >> Cargo.lock
Expand All @@ -237,11 +218,23 @@ let
echo source = \"registry+''${registry}\" >> Cargo.lock
fi
manifest_path=$(cargoRelativeManifest ${name})
manifest_dir=''${manifest_path%Cargo.toml}
# Rewrite the crate's toml
if [ -n "$manifest_dir" ]; then pushd $manifest_dir; fi
mv Cargo.toml Cargo.original.toml
sanitizeTomlForRemarshal Cargo.original.toml
reducePackageToml Cargo.original.toml Cargo.toml "$manifestPatch"
if [ -n "$manifest_dir" ]; then popd; fi
# If the crate is a workspace, reduce it to a crate of just a workspace of a single crate
if [ $manifest_path != "Cargo.toml" ]; then
mv Cargo.toml Cargo.workspace.toml
sanitizeTomlForRemarshal Cargo.workspace.toml
reduceWorkspaceToml Cargo.workspace.toml Cargo.toml "$manifest_dir"
fi
'';

setBuildEnv = ''
Expand Down

0 comments on commit a2ab864

Please sign in to comment.