-
Notifications
You must be signed in to change notification settings - Fork 176
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
Overriding the platform? #176
Comments
@xaviergonz You can't cross compile native node modules, it just doesn't work. That's why you can't override process.platform. Native modules require OS specific header files that typically only exist on the target OS |
So a little question after all these year: Lovell linked an issue created by me on his beautiful sharp node module. I am using electron-builder and sharp provides prebuilds for the target-platform os.
But
And this is now the case. But when i am building my app on Ubunutu for macOS it does not work, because the target binaries are used instead of the platform even if there are the right files available. Is there any was to achieve my goal? Thanks :) |
@MarshallOfSound Yeah - I had the same thought as @KillerCodeMonkey . I understand it's a problem to cross compile native modules, but my native modules are available as "prebuild". So no cross compilation required. Would this be possible or is it a problem in this case as well? If yes - how is electron-builder achieving it? At least their docs state that it's possible (see KillerCodeMonkey's quote above). |
@KillerCodeMonkey It seems you confuse electron-builder with electron-packager/electron-rebuild. You do not need electron-rebuld if you are using electron-builder, it does everything for you. However I use electron-packager and electron-winstaller, because I want to keep Squirrel installer (instead of NSIS) with auto-updates on a generic HTTP server, which seems not possible with electron-builder. Due to a lucky coincidence, I found out, how electron-builder manages Windows builds on Linux. I created a temporary branch and installed electron-builder to figure it out. When I did something wrong, electron-builder revealed how it invoked prebuild-install. It turned out that prebuild-install has hidden parameters
After that I run electron-packager. First it didn't work. But it was just because electron-rebuild reverts everything. I had to remove the hook:
Now I successfully packaged my Windows application on Linux, including native dependecy (YEAH!) Well the question is why did I expect anything different from electron-rebuild. Either you rebuild or you have prebuilt? On the other hand I think it would be more convenient if electron-rebuild does the call for you as end users like me don't understand all the little details. It took me hours to figure everything out. As you can see above I have to cd into the dependencies directory. Effectively I trick prebuild-install to think it's running in a project root.... Yes I think this should also be fixed by prebuild-install and you could say it is not electron-rebuild's responsibility. But isn't the whole purpose of electron-rebuild better convenience in the first place? What do you think @MarshallOfSound ? |
Hey guys, I've been struggling with this problem too, and think I might have solved the problem. Basically I found that the cross platform prebuild-install was NOT working as intended, from the very beginning. The reason was, for some reason the I had to update both
Hoping this will get merged in soon so I can use it without monkey patching |
I'd like to cross compile an OSX electron application from linux using electron-packager, and while electron-rebuild allows to override the arch it seems to take the platform from process.platform.
Would it be possible to add a parameter to override the target platform?
The text was updated successfully, but these errors were encountered: