-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
support Electron: respect process.env.npm_config_arch & process.env.npm_config_platform #35
Comments
Bundling the binaries with the npm package gradually became too clunky, as outlined in #20 and #33. This breaks Electron for now, sorry. (Keep in mind that the previous hacks were helpful but not very future-proof.) First, let me put the problem in the perspective of The new download-based approach is a problem whenever you want to package I don't see this a problem of `ffmpeg-static though. Developers need to figure this out in their build scripts anyways whenever they use
Therefore, developers should configure their build tooling to set up the right environment for these dependencies to build (themselves) correctly. I don't have any experience with building Electron apps. It seems like it has a mechanism for this: Digging into the They which mention the @mifi Would you mind to add the env vars to |
👋 this comment pietrop#1 (comment) and blog post explains how I dealt with making static ffmpeg work with electron build process. Sharing it in case it helps. |
Maybe I misunderstood it, but It's not as zero-config as I'd like it to be:
|
Yeah, fair, at the moment is not zero-config but it works. The main problem is if you want to build for mac, linux, and windows on OSX (I do that on travis CI) then you'd still need all 3 binaries to be able to do the build, but you'd just want to package only the one you need for each distribution to keep the package size contained etc.. Hope this use case helps. I do agree that having binaries inside a repo is not ideal, and perhaps there could be a way to pull those down eg from github releases section and add them to the module this way as part of a pre installation step. But not sure if that's a possibility? |
It seems that install.js isn't being run when I run a complete build with |
That is the case right now: The
Again, I don't know Electron well, but I think running the But downloading the intended binaries for a different platform than the current one seems to be the crucial point here. You could help me by
|
That’s Essentially what i already did. I tried to modify install.js in ffmpeg-static in node_modules and add console.log, then run electron-builder, but it was never being executed. The install script only gets executed when running npm install / yarn. Electron-builder never runs this afaik. I think wwhat electron builder does is to take modules from node_modules as is and pacakge them up. But first it will run node-gyp to rebuild any binary dependencies inside node_modules to the target arch. If ffmpeg-static was using node-gyp to compile ffmpeg then i think it would just work. So i think if there is some way we can hook into node gyp and make it run the install.js script, that might be a way to do it. But i know next to nothing about node gyp. |
Sorry, I'm not going to do that:
|
Keep in mind that the
PR welcome! |
Yea, I just tested adding the following scripts in
I think you are right that prebuild is the right way to do it. I will instead just rely on GitHub actions for my project which builds on separate OS images for win, mac and linux. I believe all major build systems support this. Only drawback with this is that there is no easy way to build non-open source electron apps using ffmpeg-static without paying monthly for a build service. |
No, i'm not trying to say that!! I don't want to use All I want to do is change |
As I said, this is not only the case with |
What about Travis CI? I’ve used that in a couple of projects (that use ffmpeg). |
I was thinking that ffmpeg-static could publish prebuild binaries using prebuild, kind of like how other packages are doing, like drivelist for example. But I've never used prebuild so I don't know if that is possible with downloaded binaries like ffmpeg-static does.
I'm not sure if I understand how that will help when we don't know how we can make install.js run during electron-builder's build phase.
Yea Travis CI or github actions or similar will work, but afaik it's only free for open source projects. Which is fine in my case for LosslessCut but for proprietary software / private repos they typically requires you to pay a subscription. |
One might be able to trick As I said several times: Let's respect |
I stumbled on the same problem and researched electron-builder source code to handle this problem. It actually can be handled without fixing electron-builder, but adding
While building-packaing two-layered app (with 2
And newly installed
I think |
Had time to test the resulting package on windows just now. For some reason ffmpeg binary doesn't have This commit seems to resolve the issue without manual interventions. |
Thanks @RavisMsk for investigating this! It's nice to hear that your findings are in line with what I found out earlier. |
I will close this ticket. Please re-open if there's a bug with @RavisMsk's logic that I have just published. |
In my current setup I use electron builder on TravisCI to build for Mac, Linux and Windows on a TravisCI OSX image. It then publishes to GitHub release. The recent change would not work in this “edge” case, right? Coz it would just use the OS of the platform / npm etc..? Or am I missing something? As mentioned in previous comment I already have a workaround to package the right ffmpeg bin a part of the electron build process But wanted to check if this latest change, changes anything in this context. If it doesn’t no worries. |
@pietrop Cross-platform-packaging Electron apps should just work with
In the macOS Travis build, do |
Awesome, thanks will try it out, at the moment I do all 3 in one command but I guess I could split it |
@RavisMsk i'm a little confused how your commands listed are working O.o Given you delete all your node_modules, how does I'm trying to get this to work on my end, but if I |
Tested locally, still need to run it as a GitHub action to verify that it is working as intended. Refs: - https://www.npmjs.com/package/ffmpeg-static#electron--other-cross-platform-packaging-tools - eugeneware/ffmpeg-static#35 - eugeneware/ffmpeg-static#136
Tested locally, still need to run it as a GitHub action to verify that it is working as intended. Refs: - https://www.npmjs.com/package/ffmpeg-static#electron--other-cross-platform-packaging-tools - eugeneware/ffmpeg-static#35 - eugeneware/ffmpeg-static#136
Maybe this will help someone. This is how we created a macOS universal ffmpeg binary (download for both archs, and then combine with lipo): npm rebuild --arch=x64 -f ffmpeg-static && mv node_modules/ffmpeg-static/ffmpeg{,-x64}
npm rebuild --arch=arm64 -f ffmpeg-static && mv node_modules/ffmpeg-static/ffmpeg{,-arm64}
cd node_modules/ffmpeg-static
lipo -create ffmpeg-arm64 ffmpeg-x64 -output ffmpeg Since ffmpeg-static does not overwrite the existing |
Because in v4 it only downloads the binary for the current operating system arch, how can I now build an electron app that includes the correct ffmpeg binary according to which target platform I am building for?
For example if I want to run
electron-builder --mac --win --linux
Before v4, I would just include the correct binary from the right arch directory when building like this:
electron-builder package.json "build":
See
https://github.com/mifi/lossless-cut/blob/74439d716db5ff550a1851fa5b58e30ba188c477/package.json#L108
But now this doesn't work. Any tips of how to cleanly solve this? Or isn't electron really supported by this module anymore?
The text was updated successfully, but these errors were encountered: