ARMmbed/mbed-cli

mbed compile not working in cygwin

BlackstoneEngineering opened this issue · 7 comments

Problem

mbed compile does not work in cygwin. I believe this is due to it grabbing cygwin formatted paths and then calling the compiler in windows context. Thus it is passing linux formatted addresses to a tool that expects windows formatted addresses.

Solution

a) make a more universal call that doesnt pass in linux formatted paths
b) detect cygwin is running and call the cygwin path conversion tool on all addresses
c) grab the paths in a windows context instead of within the cygwin context.

Example

Running mbed build on cmd works just fine, but if i run it in cygwin it returns the following

...
...
Compile: SVC_Table.S
Compile: rt_Event.c
Compile: rt_List.c
Compile: rt_Mailbox.c
Compile: rt_MemBox.c
Compile: rt_CMSIS.c
Compile: rt_Memory.c
Compile: rt_Mutex.c
Compile: rt_OsEventObserver.c
Compile: rt_Semaphore.c
Compile: rt_Robin.c
Compile: rt_System.c
Compile: test_env.cpp
[ERROR] arm-none-eabi-g++.exe: error: /home/ausbla01/mbed/test/mbed-os-example-blinky/mbed-os/libraries/tests/mbed/env/test_env.cpp: No such file or directory
arm-none-eabi-g++.exe: fatal error: no input files
compilation terminated.

[mbed] ERROR: "python" returned error code 1.
[mbed] ERROR: Command "python -u /home/ausbla01/mbed/test/mbed-os-example-blinky/mbed-os/tools/make.py -t GCC_ARM -m K64F -c --source . --build ./.build/K64F/GCC_ARM" in "/home/ausbla01/mbed/test/mbed-os-example-blinky"

---

@BlackstoneEngineering This is a very strange error, since it looks like it was able to compile a few source files before this particular file caused an issue. The stranger thing is, if you're compiling the blinky example, it shouldn't even try to compile that particular file since there's an .mbedignore file in the /libraries folder.

Can you paste the full log of mbed compile -v after deleting your .build folder? I'd be curious to see what commands are being sent to the compiler.

Will add to the documentation that cygwin is not supported at this time. PRs welcome! :)

Right, here is the info on the cygpath tool for future reference: https://cygwin.com/cygwin-ug-net/cygpath.html . cygpath comes bundles with cygwin and enables translating file paths between windows / posix formats for use in cygwin.

The problem seems to be the main processs in cygwin runs in cygwin env using POSIX paths, but all subprocesses get spun off into windows environments that need windows paths, thus a posix path is given to a windows path, which promptly blows up.

The solution is

  1. Detect env is cygwin, then convert all paths appropriately using cygpath as needed
  2. Spin up subprocesses in same env as main process, ie when using cygwin put subprocesses into cygwin env as well. Not sure how to do this though.

After discussing with @screamerbg we will not be supporting cygwin at this time, however it is a welcome PR feature update in the future. Low priority for the internal team, but more than welcome as a contribution.

Now covered in the Troubleshooting section of mbed CLI documentation.

You can sidestep the cygwin path issue by avoiding absolute paths. In mbed-os/tools/settings.py I set ROOT = ".."

As an update to @mukymuk, the settings.py doesn't exist anymore. The relevant code is now contained in ../Python27/Lib/site-packages/mbed/mbed.py

I just added ROOT = ".." after the import statements and then my program compiled.

This issue is closed. Should someone remove the "in progress" label?