autobuild flags in package.json#35
Conversation
|
Thanks for the PR, this looks like a reasonable feature for me, although I do not quite understand, why setting the proper env doesn't work for you. Two things:
|
|
Using this module as a dependency unless I set the environment variable before running the npm install command the values are not set when here are read. Agree with the consistency issue you raise on flags property, and sorry for did not spot the install.ts file :|. |
|
Sorry for the delay. PR looks good to me! |
|
Any plan to publish on registry? |
|
I will publish it in the coming days along with the PR that's currently open at opencv4nodejs. |
|
Your feature is now published to npm. |
|
Hello. It would be nice check if there's |
|
@zaquest I completely forgot that a package can be installed even outside a package.json containing folder. Imho checking the existance of @justadudewhohacks seems fair to you? |
Definitely. I mean it doesn't hurt to include that check. |
|
@wouldgo I am currently working on modifying the script, such that we can also set other environments via package.json. I think the behaviour should be such, that when an env is set via package.json, it should override the process environment variable and not merge both definitions as done with process.env.OPENCV4NODEJS_AUTOBUILD_FLAGS currently. Does that conflict with your initial incentives / did you implement it on purpose that way? |
|
@justadudewhohacks I merged because the defaults were ok for what I need. But If it's possible to declare back the same cmake configurations I have no problems in what your're doing. |
Hi,
thanks for making opencv compilation process easy to handle. For a personal need (pkg-config file creation), I have to enable some cmake flags. I already saw the autobuild flags way but setting an environment variable before the install script was run did not propagate the variables to the install.js script.
What I did was something like:
{ "name": "my-project-where-i-ll-using-opencv", "scripts": { "preinstall": "export OPENCV4NODEJS_AUTOBUILD_FLAGS='...'" }I also tried this way:
{ "name": "my-project-where-i-ll-using-opencv", "scripts": { "install": "export OPENCV4NODEJS_AUTOBUILD_FLAGS='...'" }In the first scenario, nothing was read by the build process; in the latter "install" stage is before the installation of dependencies so it's useless.
In the end, I choose for setting the flags into dependent
package.jsonlike this:{ "name": "my-project-where-i-ll-using-opencv", "opencv4nodejs": { "flags": "-DOPENCV_GENERATE_PKGCONFIG=ON -DOPENCV_PC_FILE_NAME=opencv.pc" } }This PR bring this logic into the module setting the environment variable following the "flags" property.
Hope this will help as helped me.
Have a great day
Dario