Git Product home page Git Product logo

Comments (12)

wraithan avatar wraithan commented on May 20, 2024 1

Sorry, I've been busy at work and these notifications went to my personal email (since they weren't on work repo) and I missed them. We lowered the priority of moving to node-crc@2 and have been digging in to a few other things lately. I don't have any code to share, I only got as far as playing with prebuildify to learn a bit before I tried to get it working on this codebase.

from node-crc.

rafaelmaeuer avatar rafaelmaeuer commented on May 20, 2024 1

Leaving some links here for documentation:

from node-crc.

magiclen avatar magiclen commented on May 20, 2024

I think this a great idea. Any PR is welcome!

from node-crc.

rafaelmaeuer avatar rafaelmaeuer commented on May 20, 2024

Using prebuild binaries would probably solve #8 too.

from node-crc.

rafaelmaeuer avatar rafaelmaeuer commented on May 20, 2024

@wraithan how are your plans regarding this? If you don't plan a PR soon, I would give it a try...

from node-crc.

rafaelmaeuer avatar rafaelmaeuer commented on May 20, 2024

@wraithan are you still there? Any comment on this?

from node-crc.

rafaelmaeuer avatar rafaelmaeuer commented on May 20, 2024

I also gave prebuildify a short try today, but getting this error when running prebuildify --all --strip:

node:events:371
      throw er; // Unhandled 'error' event
      ^

Error: spawn node-gyp ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
    at onErrorNT (node:internal/child_process:480:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
    at onErrorNT (node:internal/child_process:480:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn node-gyp',
  path: 'node-gyp',
  spawnargs: [
    'rebuild',
    '--target=5.0.0',
    '--devdir=/var/folders/79/20rjf5910x9c32y41kvvtcv80000gn/T/prebuildify/node',
    '--target_arch=x64',
    '--release'
  ]
}

from node-crc.

rafaelmaeuer avatar rafaelmaeuer commented on May 20, 2024

So I finally found the time to search for a solution, first I was playing around with napi-rs. It was possible to produce a prebuild binary which can be used with require (see rafaelmaeuer/node-crc/tree/dev/napi).

Then I found out, that cargo already produces the prebuild-binary index.node which can be used as main file in package.json. Mocca-Tests are still passing and I tested it in docker without the need of installing the rust toolchain.

I have made the following PR, please review and test it: #12

from node-crc.

rafaelmaeuer avatar rafaelmaeuer commented on May 20, 2024

Just found this error in github-actions:

Error: /home/runner/work/***/***/node_modules/node-crc/index.node: invalid ELF header

Seems like pre-compiling need to handle all the possible OS (win/mac/linux) and platform types (x86/x64/arm64/aarch64).

from node-crc.

rafaelmaeuer avatar rafaelmaeuer commented on May 20, 2024

After learning about the necessity of cross-platform binaries (invalid ELF header in Github actions) I ended up writing a build-script based on cross-rs and rustup/cross-compilation which can produce binaries for following platforms:

  • macOS x64
  • macOS ARM64
  • Linux x64 (gnu/musl)
  • Linux x86 (gnu/musl)
  • Linux ARM64 (gnu/musl)
  • Windows x64
  • Windows x86

I slightly modified the lib to load the correct binary on each platform, I updated #12 accordingly.

from node-crc.

rafaelmaeuer avatar rafaelmaeuer commented on May 20, 2024

@magiclen would you mind reviewing or commenting on it?

from node-crc.

magiclen avatar magiclen commented on May 20, 2024

@rafaelmaeuer Thank you for everything you have done. My idea is to separate the precompiled .node files and automatically download them from the internet during the npm install node-crc stage. If the download fails, then local compilation will be performed.

I guess we need a script to build the .node files for different architectures and upload them to github releases. And when running npm install node-crc, we need a script to detect the environment and download the corresponding .node file or run the compilation.

from node-crc.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.