Skip to content

Commit 9708e82

Browse files
authored
Merge pull request #525 from tuna-f1sh/master
Update Windows documentation to allow non-relative paths
2 parents 360db6f + 770d3a7 commit 9708e82

File tree

4 files changed

+82
-35
lines changed

4 files changed

+82
-35
lines changed

Arduino.mk

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,23 @@
6262
# AVR_TOOLS_DIR = /usr
6363
#
6464
# On Windows declare this environmental variables using the windows
65-
# configuration options. Control Panel > System > Advanced system settings
66-
# Also take into account that when you set them you have to add '\' on
67-
# all spaces and special characters.
68-
# ARDUINO_DIR and AVR_TOOLS_DIR have to be relative and not absolute.
65+
# configuration options or Cygwin .bashrc. Control Panel > System > Advanced system settings
66+
# The paths must use Unix style forward slash and not have any spaces
67+
# or escape charactors. One must use a symbolic link if the path does
68+
# contain spaces.
69+
#
6970
# This are just examples, you have to adapt this variables accordingly to
70-
# your system.
71+
# your system. Note the difference between ARDMK_DIR, which can use /cygdrive/
72+
# and USER_LIB_PATH, which cannnot due to invoking with the build tools.
73+
# It is best practice to avoid cygdrive all together.
7174
#
72-
# ARDUINO_DIR =../../../../../Arduino
73-
# AVR_TOOLS_DIR =../../../../../Arduino/hardware/tools/avr
75+
# ARDUINO_DIR = C:/Arduino
76+
# AVR_TOOLS_DIR = C:/Arduino/hardware/tools/avr
7477
# ARDMK_DIR = /cygdrive/c/Users/"YourUser"/Arduino-Makefile
7578
#
7679
# On Windows it is highly recommended that you create a symbolic link directory
7780
# for avoiding using the normal directories name of windows such as
78-
# c:\Program Files (x86)\Arduino
81+
# C:\Program Files (x86)\Arduino
7982
# For this use the command mklink on the console.
8083
#
8184
#
@@ -364,9 +367,15 @@ ifndef ARDUINO_SKETCHBOOK
364367
ifneq ($(ARDUINO_SKETCHBOOK),)
365368
$(call show_config_variable,ARDUINO_SKETCHBOOK,[AUTODETECTED],(from arduino preferences file))
366369
else
367-
ARDUINO_SKETCHBOOK := $(firstword \
368-
$(call dir_if_exists,$(HOME)/sketchbook) \
369-
$(call dir_if_exists,$(HOME)/Documents/Arduino) )
370+
ifeq ($(CURRENT_OS), WINDOWS)
371+
ARDUINO_SKETCHBOOK := $(firstword \
372+
$(call dir_if_exists,$(USERPROFILE)/sketchbook) \
373+
$(call dir_if_exists,$(USERPROFILE)/Documents/Arduino) )
374+
else
375+
ARDUINO_SKETCHBOOK := $(firstword \
376+
$(call dir_if_exists,$(HOME)/sketchbook) \
377+
$(call dir_if_exists,$(HOME)/Documents/Arduino) )
378+
endif
370379
$(call show_config_variable,ARDUINO_SKETCHBOOK,[DEFAULT])
371380
endif
372381
else
@@ -744,13 +753,23 @@ ifndef RESET_CMD
744753
endif
745754
ifneq ($(CATERINA),)
746755
ifneq (,$(findstring CYGWIN,$(shell uname -s)))
756+
# confirm user is using default cygwin unix Python (which uses ttySx) and not Windows Python (which uses COMx)
757+
ifeq ($(shell which python),/usr/bin/python)
747758
RESET_CMD = $(ARD_RESET_ARDUINO) --caterina $(ARD_RESET_OPTS) $(DEVICE_PATH)
759+
else
760+
RESET_CMD = $(ARD_RESET_ARDUINO) --caterina $(ARD_RESET_OPTS) $(call get_monitor_port)
761+
endif
748762
else
749763
RESET_CMD = $(ARD_RESET_ARDUINO) --caterina $(ARD_RESET_OPTS) $(call get_monitor_port)
750764
endif
751765
else
752766
ifneq (,$(findstring CYGWIN,$(shell uname -s)))
767+
# confirm user is using default cygwin unix Python (which uses ttySx) and not Windows Python (which uses COMx)
768+
ifeq ($(shell which python),/usr/bin/python)
753769
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(DEVICE_PATH)
770+
else
771+
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port)
772+
endif
754773
else
755774
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port)
756775
endif

Common.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ else
8181
endif
8282

8383
ifeq ($(CURRENT_OS),WINDOWS)
84-
ifneq ($(shell echo $(ARDUINO_DIR) | egrep '^(/|[a-zA-Z]:\\)'),)
85-
echo $(error On Windows, ARDUINO_DIR must be a relative path)
84+
ifneq ($(shell echo $(ARDUINO_DIR) | egrep '\\|[[:space:]]|cygdrive'),)
85+
echo $(error On Windows, ARDUINO_DIR and other defines must use forward slash and not contain spaces, special characters or be cygdrive relative)
8686
endif
8787
endif

HISTORY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
99
- Fix: Quote the prefix tag in the space_pad_to function
1010
- Tweak: Set ARDMK_VERSION to 1.6 (https://github.com/sej7278)
1111
- Tweak: Move non-standard-related items from CxxFLAGS_STD to CxxFLAGS (issue #523) (https://github.com/sej7278)
12+
- Tweak: Update Windows usage documentation and allow non-relative paths (issue #519) (https://github.com/tuna-f1sh)
13+
- Tweak: Support Cygwin Unix Python and Windows installation on Windows to pass correct port binding. (https://github.com/tuna-f1sh)
1214
- New: Added -fdiagnostics-color to *STD flags (https://github.com/sej7278)
1315
- New: Add generation of tags file using ctags, which automatically includes project libs and Arduino core. (https://github.com/tuna-f1sh)
1416

README.md

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ You need to install Cygwin and its packages for Make, Perl and the following Ser
127127
Assuming you included Python in your Cygwin installation:
128128

129129
1. download PySerial source package from [https://pypi.python.org/pypi/pyserial](https://pypi.python.org/pypi/pyserial)
130-
2. extract downloaded package running
131-
```tar xvzf dowloaded_package_name.tar.gz```
130+
2. extract downloaded package running `tar xvzf dowloaded_package_name.tar.gz`
132131
3. navigate to extracted package folder
133132
4. build and install Python module:
134133

@@ -137,14 +136,24 @@ python setup.py build
137136
python setup.py install
138137
```
139138

139+
Alternatively, if you have setup Cygwin to use a Windows Python installation,
140+
simply install using pip:
141+
142+
```
143+
pip install pyserial
144+
```
145+
146+
Arduino-Makefile should automatically detect the Python installation type and
147+
use the correct device port binding.
148+
140149
## Usage
141150

142151
Download a copy of this repo somewhere to your system or install it through a package by following the above installation instruction.
143152

144153
Sample makefiles are provided in the `examples/` directory. E.g. [Makefile-example](examples/MakefileExample/Makefile-example.mk) demonstrates some of the more advanced options,
145154
whilst [Blink](examples/Blink/Makefile) demonstrates the minimal settings required for various boards like the Uno, Nano, Mega, Teensy, ATtiny etc.
146155

147-
MAC:
156+
### Mac
148157

149158
On the Mac with IDE 1.0 you might want to set:
150159

@@ -158,24 +167,28 @@ On the Mac with IDE 1.0 you might want to set:
158167

159168
On the Mac with IDE 1.5+ it's like above but with
160169

161-
```
170+
```make
162171
ARDUINO_DIR = /Applications/Arduino.app/Contents/Java
163172
```
164-
LINUX:
173+
### Linux
165174

166175
You can either declare following variables in your project's makefile or set them as environmental variables.
167176

177+
```make
168178
ARDUINO_DIR – Directory where Arduino is installed
169179
ARDMK_DIR – Directory where you have copied the makefile
170180
AVR_TOOLS_DIR – Directory where avr tools are installed
181+
```
171182

172183
Keep in mind, that Arduino 1.5.x+ comes with it's own copy of avr tools which you can leverage in your build process here.
173184

174185
Example of ~/.bashrc file:
175186

176-
export ARDUINO_DIR=/home/sudar/apps/arduino-1.0.5
177-
export ARDMK_DIR=/home/sudar/Dropbox/code/Arduino-Makefile
178-
export AVR_TOOLS_DIR=/usr/include
187+
```make
188+
export ARDUINO_DIR=/home/sudar/apps/arduino-1.0.5
189+
export ARDMK_DIR=/home/sudar/Dropbox/code/Arduino-Makefile
190+
export AVR_TOOLS_DIR=/usr/include
191+
```
179192

180193
Example of the project's make file:
181194

@@ -184,17 +197,22 @@ Example of the project's make file:
184197
MONITOR_PORT = /dev/ttyACM0
185198
```
186199

187-
WINDOWS:
200+
### Windows
188201

189-
On Windows (using cygwin), you might want to set:
202+
On Windows (using Cygwin), you might want to set:
190203

191204
```make
192-
ARDUINO_DIR = ../../arduino
205+
# Symbolic link to Arduino installation directory - see below
206+
ARDUINO_DIR = C:/Arduino
193207
ARDMK_DIR = path/to/mkfile
194208
MONITOR_PORT = com3
195209
BOARD_TAG = mega2560
196210
```
197211

212+
**NOTE: Use forward slash not backslash and there should be no spaces or
213+
special characters in the Windows paths (due to Win/Unix crossover). The paths
214+
should not be *cygdrive* paths.**
215+
198216
On Windows (using MSYS and PuTTY), you might want to set the following extra parameters:
199217

200218
```make
@@ -205,45 +223,53 @@ On Windows (using MSYS and PuTTY), you might want to set the following extra par
205223
On Arduino 1.5+ installs, you should set the architecture to either `avr` or `sam` and if using a submenu CPU type, then also set that:
206224

207225
```make
208-
ARCHITECTURE = avr
226+
ARCHITECTURE = avr
209227
BOARD_TAG = atmegang
210228
BOARD_SUB = atmega168
211229
```
212230

213-
It is recommended in Windows that you create a symbolic link to avoid problems with file naming conventions on Windows. For example, if your your Arduino directory is in:
231+
#### Symbolic Link
214232

215-
c:\Program Files (x86)\Arduino
233+
It is recommended in Windows that you create a symbolic link to avoid problems with file naming conventions on Windows; unless one installs to a non-default location. For example, if your your Arduino directory is in:
234+
235+
C:\Program Files (x86)\Arduino
216236

217237
You will get problems with the special characters on the directory name. More details about this can be found in [issue #94](https://github.com/sudar/Arduino-Makefile/issues/94)
218238

219239
To create a symbolic link, you can use the command “mklink” on Windows, e.g.
220240

221241
```sh
222-
mklink /d c:\Arduino c:\Program Files (x86)\Arduino
242+
mklink /d C:\Arduino C:\Program Files (x86)\Arduino
243+
```
244+
Alternatively if you've setup Cygwin hard symbolic links ([CYGWIN=winsymlinks:native](https://www.cygwin.com/cygwin-ug-net/using-cygwinenv.html)):
245+
246+
```sh
247+
ln -s /cygdrive/c/Program Files\ \(x86\)/Arduino/ C:/Arduino
223248
```
224249

225250
After which, the variables should be:
226251

227252
```make
228-
ARDUINO_DIR=../../../../../Arduino
253+
ARDUINO_DIR=C:/Arduino
229254
```
230255

231256
Instead of:
232257

233258
```make
234-
ARDUINO_DIR=../../../../../Program\ Files\ \(x86\)/Arduino
259+
ARDUINO_DIR=C:/Program\ Files\ \(x86\)/Arduino
235260
```
236261

237-
Usefull Variables:
262+
### Useful Variables
238263

239264
The list of all variables that can be overridden is available at [arduino-mk-vars.md](arduino-mk-vars.md) file.
240265

241266
- `BOARD_TAG` - Type of board, for a list see boards.txt or `make show_boards`
242267
- `MONITOR_PORT` - The port where your Arduino is plugged in, usually `/dev/ttyACM0` or `/dev/ttyUSB0` in Linux or Mac OS X and `com3`, `com4`, etc. in Windows.
243-
- `ARDUINO_DIR` - Path to Arduino installation. In Cygwin in Windows this path must be
244-
relative, not absolute (e.g. "../../arduino" and not "/c/cygwin/Arduino").
245-
- `ARDMK_DIR` - Path where the `*.mk` are present. If you installed the package, then it is usually `/usr/share/arduino`
246-
- `AVR_TOOLS_DIR` - Path where the avr tools chain binaries are present. If you are going to use the binaries that came with Arduino installation, then you don't have to set it. Otherwise set it realtive and not absolute.
268+
- `ARDUINO_DIR` - Path to Arduino installation. Using Windows with Cygwin,
269+
this path must use Unix / and not Windows \\ (eg "C:/Arduino" not
270+
"C:\\Arduino).
271+
- `ARDMK_DIR` - Path where the `*.mk` are present. If you installed the package, then it is usually `/usr/share/arduino`. On Windows, this should be a path without spaces and no special characters, it can be a *cygdrive* path if necessary and must use / not \\.
272+
- `AVR_TOOLS_DIR` - Path where the avr tools chain binaries are present. If you are going to use the binaries that came with Arduino installation, then you don't have to set it. Otherwise set it relative and not absolute.
247273

248274

249275

0 commit comments

Comments
 (0)