-
Notifications
You must be signed in to change notification settings - Fork 429
feat: Windows support #2119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dunglas
wants to merge
66
commits into
main
Choose a base branch
from
windows
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+547
−158
Open
feat: Windows support #2119
Changes from 9 commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
8820a26
feat: Windows support
a5b6be8
fix tests
9b214e6
revert changes to watcher_test.go
dunglas 0d67a8f
cs
dunglas 29bf6df
fix remaining failing tests
58f55ef
fix watcher support
d91e8ba
cleanup
cc1be56
improve watcher tests (wip)
dunglas 5b39fa8
all tests are green now!
4799c3a
cleanup
5da1dc0
test forward slashes on Windows
12585fd
upgrade watcher to simplify Windows linking
25d9a98
add php-cli support
c9ab80e
review
4bbe362
GitHub Actions worklow
dunglas f08f4bb
wip
dunglas 6bab64f
work on windows workflow
henderkes 36e3492
linter
henderkes 684b5e0
fix env var
dunglas 25b4b9f
use xcaddy
henderkes bb3fb4e
correct path
henderkes 4aa0cbb
remove tmate action
henderkes d720ab1
add caddy modules back in
henderkes a7ed504
remove extra v
henderkes 2e71f67
brotlidec missing
henderkes 734203f
wip
dunglas 4946a17
wip
dunglas 63103cb
with GOFLAGS
dunglas 7c4507a
wip
dunglas 8136c69
wip
dunglas 4bf3e92
wip
dunglas 45b5bfe
don't use xcaddy
dunglas 5c1fe58
fix Caddy module tests
aa2d96e
-X CustomVersion is part of -ldflags
henderkes 75615e5
fix
henderkes 2dbed0a
don't forget to add FRANKENPHP_VERSION to CGO_CFLAGS, otherwise phpin…
henderkes 7e8e250
why is quoting so hard in powershell
henderkes 6f2745d
permanently change it
henderkes 3a66f36
seems impossible to do with GOFLAGS
henderkes efbd362
woopsie
henderkes ebb4fbd
fix \n vs \r\n issues
henderkes 7e75699
fix double zipping, re-enable compression (actually makes a big diffe…
henderkes 5645b66
fix worker match
c83af6f
Merge branch 'windows' of https://github.com/php/frankenphp into windows
fb9ff0a
add frankenphp icon for windows .exe
henderkes c0a3ffc
use goversioninfo to embed icon and metadata
henderkes 05cdf29
Merge branch 'main' into windows
henderkes e01a08e
remove unnecessary moving of watcher-c.h file
henderkes 5482bbb
go mod tidy
henderkes 79db4c0
goversioninfo param
henderkes 451c96f
throw AI at how to create a file without BOM in powershell
henderkes e522dfc
fix file path to icon
henderkes 13de7c3
use the latest windows release, apparently the php hosted one is out …
henderkes 3697e0c
use malloc/free because I don't want to mess with linking against php…
henderkes 71f5b56
Revert "use malloc/free because I don't want to mess with linking aga…
henderkes 247de71
maybe?
henderkes 158c689
use malloc/free instead @dunglas revert this
henderkes c2aab04
explicitly utf8 no bom
henderkes 376635f
use cover as icon
henderkes b084121
attempt to encode é character
henderkes 590658a
hail mary
henderkes c1e5a21
oops
henderkes 06322ac
god I hate windows BOM
henderkes 7779485
at least it doesn't fail the job, even though it doesn't correctly en…
henderkes db995d2
try windows-1252
henderkes cce64a6
linter
henderkes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| //go:build !nobrotli | ||
|
|
||
| package main | ||
|
|
||
| import _ "github.com/dunglas/caddy-cbrotli" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| //go:build !windows | ||
|
|
||
| package caddy | ||
|
|
||
| import ( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| package frankenphp | ||
|
|
||
| // #cgo darwin pkg-config: libxml-2.0 | ||
| // #cgo CFLAGS: -Wall -Werror | ||
| // #cgo unix CFLAGS: -Wall -Werror | ||
| // #cgo linux CFLAGS: -D_GNU_SOURCE | ||
| // #cgo LDFLAGS: -lphp -lm -lutil | ||
| // #cgo unix LDFLAGS: -lphp -lm -lutil | ||
| // #cgo linux LDFLAGS: -ldl -lresolv | ||
| // #cgo darwin LDFLAGS: -Wl,-rpath,/usr/local/lib -liconv -ldl | ||
| // #cgo windows CFLAGS: -D_WINDOWS -DWINDOWS=1 -DZEND_WIN32=1 -DPHP_WIN32=1 -DWIN32 -D_MBCS -D_USE_MATH_DEFINES -DNDebug -DNDEBUG -DZEND_DEBUG=0 -DZTS=1 -DFD_SETSIZE=256 | ||
| // #cgo windows LDFLAGS: -lpthreadVC3 | ||
| import "C" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| //go:build !windows | ||
|
|
||
| // TODO: ignored on Windows for now (even if it should work with a custom PHP build), | ||
| // because static builds of the embed SAPI aren't available yet and php.exe is ship with | ||
| // the standard PHP distribution. | ||
|
|
||
| package frankenphp | ||
|
|
||
| // #include "frankenphp.h" | ||
| import "C" | ||
| import "unsafe" | ||
|
|
||
| // ExecuteScriptCLI executes the PHP script passed as parameter. | ||
| // It returns the exit status code of the script. | ||
| func ExecuteScriptCLI(script string, args []string) int { | ||
| // Ensure extensions are registered before CLI execution | ||
| registerExtensions() | ||
|
|
||
| cScript := C.CString(script) | ||
| defer C.free(unsafe.Pointer(cScript)) | ||
|
|
||
| argc, argv := convertArgs(args) | ||
| defer freeArgs(argv) | ||
|
|
||
| return int(C.frankenphp_execute_script_cli(cScript, argc, (**C.char)(unsafe.Pointer(&argv[0])), false)) | ||
| } | ||
|
|
||
| func ExecutePHPCode(phpCode string) int { | ||
| // Ensure extensions are registered before CLI execution | ||
| registerExtensions() | ||
|
|
||
| cCode := C.CString(phpCode) | ||
| defer C.free(unsafe.Pointer(cCode)) | ||
| return int(C.frankenphp_execute_script_cli(cCode, 0, nil, true)) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| //go:build !windows | ||
|
|
||
| package frankenphp_test | ||
|
|
||
| import ( | ||
| "errors" | ||
| "log" | ||
| "os" | ||
| "os/exec" | ||
| "testing" | ||
|
|
||
| "github.com/dunglas/frankenphp" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestExecuteScriptCLI(t *testing.T) { | ||
| if _, err := os.Stat("internal/testcli/testcli"); err != nil { | ||
| t.Skip("internal/testcli/testcli has not been compiled, run `cd internal/testcli/ && go build`") | ||
| } | ||
|
|
||
| cmd := exec.Command("internal/testcli/testcli", "testdata/command.php", "foo", "bar") | ||
| stdoutStderr, err := cmd.CombinedOutput() | ||
| assert.Error(t, err) | ||
|
|
||
| var exitError *exec.ExitError | ||
| if errors.As(err, &exitError) { | ||
| assert.Equal(t, 3, exitError.ExitCode()) | ||
| } | ||
|
|
||
| stdoutStderrStr := string(stdoutStderr) | ||
|
|
||
| assert.Contains(t, stdoutStderrStr, `"foo"`) | ||
| assert.Contains(t, stdoutStderrStr, `"bar"`) | ||
| assert.Contains(t, stdoutStderrStr, "From the CLI") | ||
| } | ||
|
|
||
| func TestExecuteCLICode(t *testing.T) { | ||
| if _, err := os.Stat("internal/testcli/testcli"); err != nil { | ||
| t.Skip("internal/testcli/testcli has not been compiled, run `cd internal/testcli/ && go build`") | ||
| } | ||
|
|
||
| cmd := exec.Command("internal/testcli/testcli", "-r", "echo 'Hello World';") | ||
| stdoutStderr, err := cmd.CombinedOutput() | ||
| assert.NoError(t, err) | ||
|
|
||
| stdoutStderrStr := string(stdoutStderr) | ||
| assert.Equal(t, stdoutStderrStr, `Hello World`) | ||
| } | ||
|
|
||
| func ExampleExecuteScriptCLI() { | ||
| if len(os.Args) <= 1 { | ||
| log.Println("Usage: my-program script.php") | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| os.Exit(frankenphp.ExecuteScriptCLI(os.Args[1], os.Args)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| package frankenphp | ||
|
|
||
| //#include "frankenphp.h" | ||
| // #include "frankenphp.h" | ||
| import "C" | ||
| import ( | ||
| "sync" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| //go:build unix | ||
|
|
||
| package cpu | ||
|
|
||
| // #include <time.h> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.