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
[question] How to build node from source (autotools, make) #16136
Comments
Hi @peakschris Thanks for your question. I guess that you know there is a recipe for nodejs in ConanCenter in https://github.com/conan-io/conan-center-index/blob/master/recipes/nodejs/all/conanfile.py, but this one is downloading the pre-compiled binaries, and you really need to build it from sources? Then I was trying to reproduce with your recipe and I got:
Then I realized that I didn't have the files that it seems you are Maybe the build of |
Hi @memsharded thanks for your reply. I have seen the binary-only nodejs package, we have a requirement to build from source. We already have this working in a dockerfile, very straightforward:
With Conan, I get exactly the same behaviour as you - configure works, but make does not. I've removed exports_sources, and there is no difference. Which current working directory does conan run make from? And isn't it curious that there is no source copied into the build folder? |
Ok, I see what is happening. class nodeConan(ConanFile):
name = "node"
version = "18.20.2" # better remove the "v" works better with version ranges
package_type = "application"
# Optional metadata
description = "Node.js is an open-source, cross-platform JavaScript runtime environment."
license = "MIT"
homepage = "https://nodejs.org"
# Binary configuration
settings = "os", "arch"
def source(self):
zip_name = f"node-v{self.version}.tar.gz"
# Immutable source .zip
download(self, f"https://nodejs.org/dist/v{self.version}/{zip_name}", zip_name)
# Recommended practice, always check hashes of downloaded files
check_sha1(self, zip_name, "e231c65c504a083654538cd368338f81e298311f")
unzip(self, zip_name, strip_root=True)
os.unlink(zip_name)
def build(self):
self.run("./configure")
self.run("make V=1")
def package(self):
self.run("make install") # missing something to target the self.package_folder That should work fine with Some notes:
Please let me know if this helps. |
@memsharded thank you for this suggestion, it looks much more straightforward. We do need to run the build on two different machines (windows and rockylinux), and upload the resulting binaries to our internal Conan repo. configure and make without arguments will do the right thing on each of these platforms. Do we need to add anything back in to label the binaries appropriately? Thanks! |
Most likely not, if you control well your build environments, and don't have any issues with those binaries, this might be a perfectly valid (and pragmatic) approach. The recipe models Note I also changed the version to not include the What you might want to add is some |
Any further question or feedback here? |
Yes, this input was very helpful and it's now working. Thank you! |
Happy to hear, thanks for the feedback and following up. |
What is your question?
I am attempting to automate build of nodejs from sources, as part of our company's build chain. This package uses AutoTools and make. My current conanfile is:
This works to download the source and configure it. However, when I run:
conan create . -vvv
, it fails to find the Makefile:There is a makefile in the src directory after running configure:
There is no makefile in the build-release directory:
It feels like I must be making a basic mistake, but having pored over all the docs, I can't figure out what this might be. Any help would be much appreciated!
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: