Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.16k stars 1.17k forks source link

Canvas On Android #1756

Open berkfelix opened 3 years ago

berkfelix commented 3 years ago

Hello,how can i recompile canvas to use on android termux(arm)?

nodejs v14

zbjornson commented 3 years ago

1609 has a suggestion for how to build on termux that worked for one person. Can you try that?

PR welcome if you figure out the build changes needed.

4aiman commented 1 year ago

I'm sorry for bumping this old issue, but it wasn't easy to find an answer for #Android-specific deps for #Termux.

So, this is for anyone searching:

  1. *-dev packages in Termux are built into the main packages
  2. If at some point you'll run in xproto not being available, try "xorgproto"
  3. Rather controversial thing to say: use sudo - some devices won't allow you to create symlinks or even explore your sd card (even after termux-setup-storage)
EntropicBlackhole commented 1 year ago

@4aiman Thank you very much, currently I'm just trying to use my phone as a temporary server until I have wifi again back at home, for my actual home server, and I do keep getting symlinks error and like permission errors once I keep trying to install canvas, I'll try these things in a bit and I'll let you know the result

EntropicBlackhole commented 1 year ago

@4aiman By the way, question, how exactly do i use sudo? I'm somewhat familiar with the bash terminal but not too much, how exactly to activate it to be on root? (probably getting the terminology wrong)

4aiman commented 1 year ago

@EntropicBlackhole I think I just did something like apt install sudo or pkg install sudo In my experience some packages come from apt, some from pkg, and some from both. Pretty sure that's not healthy, but I'm using what I have to use.

Once installed, just prepend your commands with sudo, like sudo npm start.

In all honesty, the biggest hurdle was realizing the ability of packages to be installed via sudo and not via "normal user" is tied not with privileges, but the file system.

There's a reason your internal SD card is called "emulated/0". It's not a real file system, and it cannot be used to mount things or create symlinks.

In the end I've created a folder in /data and placed all my node-related stuff there. I still have to use sudo, even after changing permissions to 777 (which is yet another bad idea), but I can finally install any package and build it if necessary, canvas included.

Hope that helps

EntropicBlackhole commented 1 year ago

@4aiman Termux actually asked me to do pkg install tsu (for sudo to work), which I did, but I still get symlink errors, I'm trying to install canvas on a folder that's inside the shared directory, however when it said that my GitHub ownership was dubious, the little command it gives you to type out afterwards actually went to the emulated path instead, which had me confused, but might be a reason as to why I keep getting symlink errors, also my phone is not rooted and a friend of mine pointed out it has to be for sudo work

In this case, would it be better if I tried having the cloned repo in another folder, that's personal to the phone only? This would avoid the emulated folder as you mentioned I believe

4aiman commented 1 year ago

@EntropicBlackhole Not sure what you're asking, sorry.

I've flashed a different ROM since (a modified crDroid12.1) and used a more frequent version of Termux (fDroid). Everything built even from the emulated FS flawlessly, even w/o sudo. (I still have a rooted Android and gave Termux root access)