Skip to content
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

Make it more OS independent #11

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Make it more OS independent #11

wants to merge 18 commits into from

Conversation

ek9852
Copy link

@ek9852 ek9852 commented Mar 2, 2018

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

@dataplayer12
Copy link

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

@jjo-in-pdx
Copy link

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.

@ek9852
Copy link
Author

ek9852 commented Mar 7, 2018

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.

@jjo-in-pdx
Copy link

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 "" "$@"
}

@deadprogram
Copy link

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

@xleafr
Copy link

xleafr commented Jul 27, 2018

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.

@milosgajdos
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants