lwthiker / curl-impersonate

curl-impersonate: A special build of curl that can impersonate Chrome & Firefox
MIT License
3.47k stars 230 forks source link

Native Windows build #37

Open lwthiker opened 2 years ago

lwthiker commented 2 years ago

Write a script to build curl-impersonate natively on Windows. This will probably require building each of the dependencies (boringssl, nghttp2, brotli & curl) on Windows.

yuzd commented 2 years ago

nice future

qwerty12 commented 2 years ago

Hi,

Thanks for this, and for the recent switch to an autotools-based system. I managed to build the Firefox variant of this (curl-impersonate-ff.exe and libcurl-impersonate-ff-4.dll) on 64-bit Windows 11 with MSYS 2. The way I did it has some problems, though:

I wonder if it would be easier to build everything with MSVC/VS. I might try at some point, but I doubt I'll be successful. In any case, I hope this helps someone while waiting for something better to come along.

I've updated the instructions and placed them here: https://github.com/qwerty12/subliminal/wiki/Building-curl-impersonate-Firefox-for-Windows-x64

lwthiker commented 2 years ago

@qwerty12 Thank you for the thorough work and documentation. What parts are not suited for automation? If it's changing the patches, then of course we can upload patches that will fit both Linux and Windows (maybe by checking the host OS)

qwerty12 commented 2 years ago

I appear to have been exaggerating. By automation, I tend to mean in the CI/GitHub Actions sense, but I guess that could also mean someone running a script after preparing the MSYS environment. My steps as I've written them aren't really automation friendly but, as you say, there's nothing stopping the existing patches etc. from being integrated with your work and adapting anything else.

Only one pressing issue comes to mind:

From what I can see, for building NSPR in MSYS2, all of the patches are needed.

For NSS, I think nss-build.patch is the most important one. I don't know if every change in there is needed, but I do know L54 and L91 are required changes. L43 too, so it can find MSYS2's libraries. Not sure if the other modifications (patched nss-config and pkg-config definition) are absolutely needed for cURL's build process to find NSS, though I had them applied as part of using MSYS2's PKGBUILDs to install NSS and NSPR.

EDIT: I can't get NSS to build with MSVC, even when using the MozillaBuild environment. At this point, I'm just going to suck it up and stick with dynamically-linked cURL built in MSYS 2. Right, after seeing Has the time come to drop NSS?, I'm definitely going to cut my losses and stick with what I have currently.

lwthiker commented 2 years ago

Regarding statically linking with NSS, I found this reference in Mozilla's application-services code. It shows the needed static libraries and their order according to os and arch. I'll try this as well for the macOS version (to support M1 processors).

avently commented 2 years ago

@lwthiker is there a progress regarding building firefox version for windows?

If you're unable to build nss there is a "solution". We can just use prebuilt libraries downloaded using this method: https://github.com/mozilla/application-services/blob/main/libs/build-nss-desktop.sh#L71

lwthiker commented 2 years ago

@avently There is no progress unfortunately, my windows knowledge is extremely lacking and this seems like quite some work in order to make it part of the regular build process. It is still in the project's priorities though. Any external help in this regard would be highly appreciated as well.