Skip to content

Conversation

@knutties
Copy link
Collaborator

@knutties knutties commented Feb 1, 2026

Problem

The shared CARGO_TARGET_DIR approach was not possible because Leptos depended on files copied to the target directory relative to project root.

Solution

This PR enables symlinking the target in case the CARGO_TARGET_DIR is set to a different value.

Summary by CodeRabbit

  • Chores
    • Refined build infrastructure configuration to improve development environment setup and process orchestration.

✏️ Tip: You can customize this high-level summary in your review settings.

@knutties knutties requested a review from a team as a code owner February 1, 2026 16:16
@semanticdiff-com
Copy link

Review changes with  SemanticDiff

@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Walkthrough

Modified .gitignore to broaden target ignore rules and restore .zed entry. Introduced symlink-target Makefile target to create cargo target directory symlinks. Refactored build orchestration to route superposition process control through make targets instead of direct binary invocations.

Changes

Cohort / File(s) Summary
Build Configuration
.gitignore
Modified ignore rules: changed "target/" to "target" for broader matching; re-added ".zed" entry.
Build Orchestration
makefile
Added symlink-target for cargo directory symlink creation; refactored superposition invocation flows through make targets instead of direct binary calls; added node_modules symlink linking in superposition target; adjusted kill command behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A symlink here, a target there,
Make orchestrates with care,
No more binaries dashed about,
Just clean makefiles throughout,
Node_modules linked so tight,
Our build system's feeling right! 🎯

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: enabling a custom cargo target directory to work completely through symlinking.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-custom-target-dir

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@knutties knutties force-pushed the fix-custom-target-dir branch 2 times, most recently from 1060ea3 to f8053db Compare February 1, 2026 16:27
cargo test
@echo "Running superposition"
@$(CARGO_TARGET_DIR)/debug/superposition &
$(MAKE) run &
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this repeats db frontend superposition though

Copy link
Collaborator Author

@knutties knutties Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally those should be no-ops right if already built. If not, they should be built right ?

In an ideal case all targets should be intelligent not to repeat if its dependencies did not change - but we do a lot of PHONY targets that some might be repeated and it is left to cargo to deal with it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we can create a backend_run which does not build frontend.

Once we add FE tests it might become moot though.


provider-template: setup superposition
@$(CARGO_TARGET_DIR)/debug/superposition &
$(MAKE) run &
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would add frontend building as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ayushjain17 - can we address this separately - the dependencies are bit hay-wire. I promise I will refactor and fix the makefile :)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@makefile`:
- Around line 180-183: The symlink-target Makefile recipe may create a
circular/self-referential symlink when CARGO_TARGET_DIR points to the default
./target; update the symlink-target logic to first resolve and compare the
absolute paths of $(CARGO_TARGET_DIR) and the literal target directory before
creating the link (i.e., get realpath of $(CARGO_TARGET_DIR) and of ./target or
use readlink -f) and only run ln -s when they differ and when target does not
already exist or is not a symlink; reference the symlink-target recipe and the
CARGO_TARGET_DIR variable when making this change.
🧹 Nitpick comments (1)
makefile (1)

234-246: Minor inefficiency: redundant dependency resolution.

The test target already depends on frontend and superposition, but $(MAKE) run & re-evaluates these PHONY targets. While functionally correct (builds are idempotent), this causes redundant work.

Consider extracting a lighter run-only target that skips rebuild deps, or refactoring so run doesn't rebuild what test already built.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
makefile (1)

186-188: ⚠️ Potential issue | 🟠 Major

Relative path for node_modules symlink may break with custom CARGO_TARGET_DIR.

The relative path ../node_modules assumes CARGO_TARGET_DIR is exactly one directory level below the project root. If CARGO_TARGET_DIR is set to an arbitrary location (e.g., /tmp/cargo-target or a shared cache), the symlink will point to the wrong location.

Consider using an absolute path:

🐛 Proposed fix using absolute path
 superposition: CARGO_FLAGS += --features='$(FEATURES)'
 superposition:
 	cargo build $(CARGO_FLAGS) --bin superposition
-	`@cd` $(CARGO_TARGET_DIR) && ln -s ../node_modules node_modules || true
+	`@cd` $(CARGO_TARGET_DIR) && ln -s $(CURDIR)/node_modules node_modules || true

$(CURDIR) is a built-in Make variable that holds the absolute path of the directory where Make was invoked.

🧹 Nitpick comments (1)
makefile (1)

180-184: Consider adding a guard against creating a self-referential symlink.

If CARGO_TARGET_DIR resolves to the project's own target directory (the default), this would attempt to create a symlink pointing to itself. While cargo metadata returns absolute paths, comparing the resolved paths would prevent unexpected behavior.

🔧 Proposed fix to add a guard
 symlink-target:
-	`@if` [ ! -e target ] && [ ! -L target ]; then \
+	`@if` [ ! -e target ] && [ ! -L target ] && [ "$$(cd $(CARGO_TARGET_DIR) && pwd -P)" != "$$(pwd -P)/target" ]; then \
 		ln -s $(CARGO_TARGET_DIR) target; \
 	fi

Alternatively, a simpler check using realpath if available:

 symlink-target:
-	`@if` [ ! -e target ] && [ ! -L target ]; then \
+	`@if` [ ! -e target ] && [ ! -L target ] && [ "$(CARGO_TARGET_DIR)" != "$$(pwd)/target" ]; then \
 		ln -s $(CARGO_TARGET_DIR) target; \
 	fi

@knutties knutties force-pushed the fix-custom-target-dir branch from f8053db to 2ecde93 Compare February 2, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants