ncsdk icon indicating copy to clipboard operation
ncsdk copied to clipboard

Make it more OS independent

Open ek9852 opened this issue 6 years ago • 7 comments

Make sed works on both linux and darwin Fix rules in Makefile Use pkg-config to find libusb instead of hard code the path

ek9852 avatar Mar 02 '18 23:03 ek9852

With these changes are you able to get the NCS to work natively on darwin?

dataplayer12 avatar Mar 07 '18 10:03 dataplayer12

Can you explain why sed -e is needed on Darwin? I don't have Darwin system but Apple man page https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/sed.1.html says "Multiple commands may be specified by using the -e or -f options." This agrees with others including Linux man page. I don't see the need for -e as there isn't multiple commands.

jjo-in-pdx avatar Mar 07 '18 17:03 jjo-in-pdx

See manpage in MBP. sed [-Ealn] [-e command] [-f command_file] [-i extension] [file ...]

without the -e, the command will be interpret as extension not commend.

Adding the -e will work for both linux and darwin.

ek9852 avatar Mar 07 '18 17:03 ek9852

I forgot to say thanks for your submissions, so thanks.

On Mac OS, sed -i -e 's/\r//' ncsdk.conf creates a backup file ncsdk.conf-e which isn't intended. This has a good description of the issue of sed on Linux vs. Mac OS - in particular the comment on using the sedi function to switch options based. However, I'm not sure how to do that from within a Makefile.

sedi () { sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@" }

jjo-in-pdx avatar Mar 09 '18 22:03 jjo-in-pdx

Any chance for this to get merged in soon? It would be great to be able to develop code targeting NCS using macOS.

deadprogram avatar Jun 21 '18 14:06 deadprogram

I was working on getting everything setup on macOS independently when I found this... I think there is still a lot of work to be done here. Running make install will still break when it starts running install.sh and /opt/movidius/NCSDK/install-ncsdk.sh

In install.sh, cp /tmp/ncsdk.conf . won't run without sudo. After that you'd probably need to change the permissions/ownership of that file.

Things really get out of hand when the Makefile calls install-ncsdk.sh. Here is where I am at so far:

  1. nproc does not exist in macOS. I read that sysctl -n hw.physicalcpu works as a replacement.
  2. macOS does not ship with bash 4.0, so the ${OS_DISTRO,,} business will fail (first seen on line 41). This means that the condition on line 41 will fail, and that whole OS checking will get skipped, so if you run this on macOS, you don't see "Your current combination of linux distribution and distribution version is not officially supported!" You see:
Checking OS and version...
./install-ncsdk.sh: line 41: ${OS_DISTRO,,}: bad substitution
Malformed line at line no. 1
Malformed line at line no. 2
Malformed line at line no. 3
Malformed line at line no. 4
Malformed line at line no. 5
Malformed line at line no. 6
Malformed line at line no. 7
Malformed line at line no. 8

Found 8 errors in config file. Please fix errors before running setup.

If you fix that by replacing ${OS_DISTRO,,} with something like $(echo $OS_DISTRO | tr '[:upper:]' '[:lower:]'), then you'll finally at least get the useful: "Your current combination of linux distribution and distribution version is not officially supported!"

Thats where I stopped. If you want to get this working on macOS you're in for another 600 lines of bash just to get through install-ncsdk.sh. There will be a lot of similar gnu/linux → BSD replacements. There is also the fact that macOS does not have a package manager, and this install script uses apt quite a bit it looks like. You'd have to make sure to have MacPorts and or Homebrew installed and find the equivalents to all the packages that install-ncsdk.sh installs and install them.

I personally don't have the time (or feel like) going through this, but if I do, I'll be sure to report back to you all.

Edit: Also, it is nice that this project has a Makefile, and uses .phony targets like it should, but if all the Makefile essentially does is call install.sh it is not really taking advantage of the power of make.

xleafr avatar Jul 27 '18 19:07 xleafr

I got NCSDK v1 working on macOS perfectly fine. If you are interested in getting this working on your laptop you can find the info in my fork README here

milosgajdos avatar Nov 20 '18 00:11 milosgajdos