Skip to content

Commit

Permalink
Polish the extension files
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrus-and committed Sep 30, 2023
1 parent 34704bf commit 77ddc09
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 22 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ apt-get install php8.2-dev libjson-c-dev pkg-config

Then move into the `./ext/` directory and just run `make` to fetch Xdebug, apply the patch, and build Fracker.

(To rebuild after nontrivial code changes just run `make` inside the `./ext/xdebug/` directory.)

To check that everything is working fine, start the [listener application](#listener-application) then run PHP like this:

```console
Expand Down
23 changes: 11 additions & 12 deletions ext/Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
MAKEFLAGS += --always-make

XDEBUG_VERSION := 3.2.2
XDEBUG_GIT_URL := https://github.com/xdebug/xdebug

all: fetch-xdebug apply-patch build
@echo Use zend_extension=$$PWD/xdebug/modules/xdebug.so

fetch-xdebug: cleanall
git clone --depth 1 --branch "$(XDEBUG_VERSION)" 'https://github.com/xdebug/xdebug'
@git clone --depth 1 --branch "$(XDEBUG_VERSION)" "$(XDEBUG_GIT_URL)"

patch-status:
git -C ./xdebug/ status
show-status:
@git -C ./xdebug/ status

apply-patch:
git -C ./xdebug/ apply ../fracker.patch
@git -C ./xdebug/ apply ../fracker.patch

format-patch:
git -C ./xdebug/ add .
git -C ./xdebug/ diff --cached | grep --invert-match '^index ' >fracker.patch
@git -C ./xdebug/ add .
@git -C ./xdebug/ diff --cached | grep --invert-match '^index ' >fracker.patch

build:
cd ./xdebug/ \
@cd ./xdebug/ \
&& make distclean || true \
&& phpize --clean \
&& phpize \
&& ./configure \
&& make -j "$(shell nproc)"

clean:
git -C ./xdebug/ reset --hard HEAD
git -C ./xdebug/ clean -dx --force
@git -C ./xdebug/ reset --hard HEAD
@git -C ./xdebug/ clean -dx --force

cleanall:
rm -fr ./xdebug/
@rm -fr ./xdebug/
36 changes: 28 additions & 8 deletions ext/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
# Development
# PHP extension development

Instead of keeping a fork of Xdebug, we keep a single patch file so that all the changes are self-contained.
All the changes introduced by Fracker to Xdebug are self-contained in a single [patch file](./fracker.patch), to update it:

To make a change to the extension:
1. first make sure to start from a fresh state with:

1. first make sure to start from a fresh state with `make fetch-xdebug`;
```
make fetch-xdebug
```

2. then load the existing patch with `make apply-patch`;
2. then load the existing patch with:

3. experiment and make the changes in the `./xdebug/` directory;
```
make apply-patch
```

4. finally save the patch with `make format-patch`.
3. make the changes in the `./xdebug/` directory, each time building with:

To update the Xdebug version change the `XDEBUG_VERSION` variable in the `Makefile` then continue with the above steps. You might need to resolve conflicts and other issues manually.
```
make build
```

4. try the extansion with:

```
php -d zend_extension=$PWD/xdebug/modules/xdebug.so -r 'var_dump(123);'
```

5. finally save the patch with:

```
make format-patch
```

To update the Xdebug version, change the `XDEBUG_VERSION` variable in the `Makefile` then repeat the above steps. You might need to resolve conflicts and other issues manually.

0 comments on commit 77ddc09

Please sign in to comment.