Cannot build parser on windows
rm -rf seems to be used - which is not portable to windows. The windows build instructions suggest npm ci which will run the clean command and break.
other places in the build file seem to do rm -rf.
Is there interests in porting these scripts to a windows like shell? or is there a smarter work around?
rm -rfseems to be used - which is not portable to windows. The windows build instructions suggestnpm ciwhich will run the clean command and break.other places in the build file seem to do rm -rf.
Is there interests in porting these scripts to a windows like shell? or is there a smarter work around?
@TomzBench
There is something you can do I am a windows programmer myself. Although a bit hacky I had to come up with my own shell script for windows since another library in Python/Cython that utilizes this project (Known as aiohttp). This here is a snippet of my powershell code but to simplify what I am doing I'll break it down for you in steps.
if ($llhttp) {
Write-Output "Generating llhttp scripts..."
if (Test-Path -Path "vendor/llhttp/lib"){
Write-Output "Cleaning up previously Generated scripts"
Start-Process "cmd" -ArgumentList "/s /c del vendor\llhttp\lib /S /Q" -NoNewWindow -Wait
Start-Process "cmd" -ArgumentList "/s /c rmdir /S /Q vendor\llhttp\lib" -NoNewWindow -Wait
}
Write-Output "Generating C Files..."
Start-Process "cmd" -ArgumentList "/s /c cd vendor\llhttp && npm run build-ts" -NoNewWindow -Wait
Start-Process "cmd" -ArgumentList "/s /c cd vendor\llhttp && npm run build" -NoNewWindow -Wait
}
Iink to the shell script if you want the nitty gritty details.
How to compile llhttp on windows
-
- change directories to the directory that llhttp is located in.
-
- Run
npm run build-ts
- Run
-
- Run
npm run build
- Run
-
- For cleanup of the library directory do
del llhttp/lib /S /Qand thenrmdir /S /Q llhttp/libor where ever else the library directory is located.
- For cleanup of the library directory do
@Vizonex
Thank you for your kind response. I will look into implementing this solution when i switch back to my windows build and lyk how it goes!
Thank you for your kind response. I will look into implementing this solution when i switch back to my windows build and lyk how it goes!
@TomzBench It already works but yes thank you for the kind response ^^
@Vizonex
I seem to have the classic "does not work on my machine" situation. Clearly it works for you as you maintain this in a larger project. However, something for me is missing.
I don't follow how this works on windows. The power shell you paste above is just navigating to the llhttp directory and running npm build commands. If i am in a power shell, or run the npm build commands from a power shell script, i get the same results.
specifically, i get npm ERR! and rm is not recognized as an internal or external command.
Maybe i am miss understanding something?
I seem to have the classic "does not work on my machine" situation. Clearly it works for you as you maintain this in a larger project. However, something for me is missing.
I don't follow how this works on windows. The power shell you paste above is just navigating to the llhttp directory and running npm build commands. If i am in a power shell, or run the npm build commands from a power shell script, i get the same results.
specifically, i get
npm ERR!andrm is not recognized as an internal or external command.Maybe i am miss understanding something?
@TomzBench Perhaps I need to make a fork and pull request and adds windows support for this functionality to work, would it be better if I wrote a bash script, powershell script or if I tried writing an all platform solution in typescript?
@Vizonex
Actually - i see what is going on. The build scripts do not run npm install so on a fresh vendor directory, the prepare script of the package.json will by default run npm run clean && ... which triggers the build error.
Otherwise, running build and build-ts are not a problem. just the npm install
running npm install --ignore-scripts will work around the error.
my solution ends up looking something like this:
if ($llhttp) {
Write-Output "Generating llhttp scripts..."
if (Test-Path -Path "vendor/llhttp/lib"){
Write-Output "Cleaning up previously Generated scripts"
Start-Process "cmd" -ArgumentList "/s /c del vendor\llhttp\lib /S /Q" -NoNewWindow -Wait
Start-Process "cmd" -ArgumentList "/s /c rmdir /S /Q vendor\llhttp\lib" -NoNewWindow -Wait
}
Write-Output "Generating C Files..."
Start-Process "cmd" -ArgumentList "/s /c cd vendor\llhttp && npm install --ignore-scripts" -NoNewWindow -Wait
Start-Process "cmd" -ArgumentList "/s /c cd vendor\llhttp && npm run build-ts" -NoNewWindow -Wait
Start-Process "cmd" -ArgumentList "/s /c cd vendor\llhttp && npm run build" -NoNewWindow -Wait
}
with an install command prior to building
@TomzBench There should now be a pull request that solves this problem hopefully a maintainer will see this and merge it.
Thanks!
@TomzBench You'll have be a bit patient about this pr as some of the maintainers of aiohttp told me this process can be a bit slow. In the meantime if this is still a problem cloning from the fork that fixes the problem will work.
Also - I am also using the native build of llhttp. So i also need to run the make file. Copying your pattern for the lib build. i also do this...
Not sure if necessary to make a cross platform native make file or not. but so far this is working for me
Write-Output "Build llhttp..."
$llhttp = $args[0]
if (Test-Path -Path "$llhttp\lib") {
Write-Output "Clean up previous lib"
Start-Process "cmd" -ArgumentList "/s /c del $llhttp\lib /S /Q" -NoNewWindow -Wait
Start-Process "cmd" -ArgumentList "/s /c rmdir /S /Q $llhttp\lib" -NoNewWindow -Wait
}
if (Test-Path -Path "$llhttp\release") {
Write-Output "Clean up previous release"
Start-Process "cmd" -ArgumentList "/s /c del $llhttp\release /S /Q" -NoNewWindow -Wait
Start-Process "cmd" -ArgumentList "/s /c rmdir /S /Q $llhttp\release" -NoNewWindow -Wait
}
Write-Output "Generating C Files... [path: $llhttp]"
Start-Process "cmd" -ArgumentList "/s /c cd $llhttp && npm install --ignore-scripts" -NoNewWindow -Wait
Start-Process "cmd" -ArgumentList "/s /c cd $llhttp && npm run build-ts" -NoNewWindow -Wait
Start-Process "cmd" -ArgumentList "/s /c cd $llhttp && npm run build" -NoNewWindow -Wait
Start-Process "cmd" -ArgumentList "/s /c cd $llhttp && mkdir release\src" -NoNewWindow -Wait
Start-Process "cmd" -ArgumentList "/s /c cd $llhttp && mkdir release\include" -NoNewWindow -Wait
Start-process "cmd" -ArgumentList "/s /c cd $llhttp && copy $llhttp\build\llhttp.h $llhttp\release\include" -NoNewWindow -Wait
Start-process "cmd" -ArgumentList "/s /c cd $llhttp && copy $llhttp\build\c\llhttp.c $llhttp\release\src" -NoNewWindow -Wait
Start-process "cmd" -ArgumentList "/s /c cd $llhttp && copy $llhttp\src\native\*.c $llhttp\release\src" -NoNewWindow -Wait
Start-process "cmd" -ArgumentList "/s /c cd $llhttp && copy $llhttp\src\llhttp.gyp $llhttp\release" -NoNewWindow -Wait
Start-process "cmd" -ArgumentList "/s /c cd $llhttp && copy $llhttp\src\common.gypi $llhttp\release" -NoNewWindow -Wait
Start-process "cmd" -ArgumentList "/s /c cd $llhttp && copy $llhttp\libllhttp.pc.in $llhttp\release" -NoNewWindow -Wait
Start-process "cmd" -ArgumentList "/s /c cd $llhttp && copy $llhttp\README.md $llhttp\release" -NoNewWindow -Wait
Start-process "cmd" -ArgumentList "/s /c cd $llhttp && copy $llhttp\LICENSE $llhttp\release" -NoNewWindow -Wait
(Get-Content -Path "$llhttp\CMakeLists.txt" -Raw) -replace "_RELEASE_",
"9.3.0" | Set-Content -Path "$llhttp\release\CMakeLists.txt"