Skip to content

Auto-initialize git submodules in bundle target#2

Merged
EdgeOfAssembly merged 2 commits intomainfrom
copilot/fix-bundle-error
Dec 2, 2025
Merged

Auto-initialize git submodules in bundle target#2
EdgeOfAssembly merged 2 commits intomainfrom
copilot/fix-bundle-error

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 2, 2025

The make bundle command fails with No such file or directory when the z-core submodule containing zbundler.py is uninitialized in fresh clones.

Changes

  • Modified bundle target to detect missing bundler script and auto-initialize submodules via git submodule update --init --recursive
  • Zero overhead when submodule already exists

Behavior

# Previously required manual initialization
make init
make bundle

# Now works immediately on fresh clone
make bundle  # Auto-initializes submodules if needed

All targets depending on bundle (bench_c, bench_optimized, lua, etc.) now work without manual intervention.

Original prompt

please can you fix following error make USE_MIMALLOC=1 bench_optimized
Bundling zstr.h...
python3 z-core/zbundler.py src/zstr.c zstr.h
/usr/lib/python-exec/python3.13/python3: can't open file '/tmp/test/zstr.h/z-core/zbundler.py': [Errno 2] No such file or directory
make: *** [Makefile:84: bundle] Error 2


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: EdgeOfAssembly <223567695+EdgeOfAssembly@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error in bundling zstr.h for make Auto-initialize git submodules in bundle target Dec 2, 2025
Copilot AI requested a review from EdgeOfAssembly December 2, 2025 22:14
@EdgeOfAssembly EdgeOfAssembly marked this pull request as ready for review December 2, 2025 22:15
Copilot AI review requested due to automatic review settings December 2, 2025 22:15
@EdgeOfAssembly EdgeOfAssembly merged commit bc4fbe0 into main Dec 2, 2025
4 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds automatic git submodule initialization to the bundle target, eliminating the need for users to manually run make init before building. The change detects when the bundler script is missing and automatically initializes submodules.

  • Adds conditional check for missing zbundler.py script before bundle execution
  • Auto-initializes git submodules when the bundler script is not found
  • Removes manual initialization step from the workflow for fresh repository clones

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile
@echo "Bundling $(DIST_HEADER)..."
@if [ ! -f $(BUNDLER) ]; then \
echo "Initializing git submodules..."; \
git submodule update --init --recursive; \
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The git submodule update --init --recursive command could fail (e.g., network issues, invalid git repository), but this failure would not stop the make process. The subsequent python3 $(BUNDLER) command would still execute and fail with a confusing error message.

Consider adding error handling by appending || exit 1 to the git command:

@if [ ! -f $(BUNDLER) ]; then \
	echo "Initializing git submodules..."; \
	git submodule update --init --recursive || exit 1; \
fi

This ensures the build fails immediately with a clear error if submodule initialization fails.

Suggested change
git submodule update --init --recursive; \
git submodule update --init --recursive || exit 1; \

Copilot uses AI. Check for mistakes.
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