Auto detect Windows sketchbook path using USERPROFILE not HOME and spelling

This commit is contained in:
John Whittington 2017-09-06 10:34:07 +01:00
parent e413feedbb
commit 42b5d2dbd8
3 changed files with 27 additions and 15 deletions

View file

@ -62,12 +62,15 @@
# AVR_TOOLS_DIR = /usr
#
# On Windows declare this environmental variables using the windows
# configuration options. Control Panel > System > Advanced system settings
# Also take into account that when you set them you have to add '\' on
# all spaces and special characters.
# configuration options or Cygwin .bashrc. Control Panel > System > Advanced system settings
# The paths must use Unix style forward slash and not have any spaces
# or escape charactors. One must use a symbolic link if the path does
# contain spaces.
#
# This are just examples, you have to adapt this variables accordingly to
# your system. Note the difference between ARDMK_DIR, which can use /cygdrive/
# and USER_LIB_PATH, which cannnot due to invoking with the build tools
# and USER_LIB_PATH, which cannnot due to invoking with the build tools.
# It is best practice to avoid cygdrive all together.
#
# ARDUINO_DIR = C:/Arduino
# AVR_TOOLS_DIR = C:/Arduino/hardware/tools/avr
@ -75,7 +78,7 @@
#
# On Windows it is highly recommended that you create a symbolic link directory
# for avoiding using the normal directories name of windows such as
# c:\Program Files (x86)\Arduino
# C:\Program Files (x86)\Arduino
# For this use the command mklink on the console.
#
#
@ -364,9 +367,15 @@ ifndef ARDUINO_SKETCHBOOK
ifneq ($(ARDUINO_SKETCHBOOK),)
$(call show_config_variable,ARDUINO_SKETCHBOOK,[AUTODETECTED],(from arduino preferences file))
else
ARDUINO_SKETCHBOOK := $(firstword \
$(call dir_if_exists,$(HOME)/sketchbook) \
$(call dir_if_exists,$(HOME)/Documents/Arduino) )
ifeq ($(CURRENT_OS), WINDOWS)
ARDUINO_SKETCHBOOK := $(firstword \
$(call dir_if_exists,$(USERPROFILE)/sketchbook) \
$(call dir_if_exists,$(USERPROFILE)/Documents/Arduino) )
else
ARDUINO_SKETCHBOOK := $(firstword \
$(call dir_if_exists,$(HOME)/sketchbook) \
$(call dir_if_exists,$(HOME)/Documents/Arduino) )
endif
$(call show_config_variable,ARDUINO_SKETCHBOOK,[DEFAULT])
endif
else

View file

@ -79,3 +79,9 @@ ifndef ARDUINO_DIR
else
$(call show_config_variable,ARDUINO_DIR,[USER])
endif
ifeq ($(CURRENT_OS),WINDOWS)
ifneq ($(shell echo $(ARDUINO_DIR) | egrep '\\|[[:space:]]|cygdrive'),)
echo $(error On Windows, ARDUINO_DIR and other defines must use forward slash and not contain spaces, special characters or be cygdrive relative)
endif
endif

View file

@ -205,16 +205,13 @@ On Windows (using Cygwin), you might want to set:
# Symbolic link to Arduino installation directory - see below
ARDUINO_DIR = C:/Arduino
ARDMK_DIR = path/to/mkfile
ARDUINO_SKETCHBOOK = C:/Users/USERNAME/Documents/Arduino
MONITOR_PORT = com3
BOARD_TAG = mega2560
```
**NOTE: Use forward slash not backslash and there should be no spaces or
special characters in the Windows paths (due to Win/Unix crossover). The paths
should not be *cygdrive* paths.** `ARDUINO_SKETCHBOOK` is defined to avoid
automatic resolution, which resolve to *cygdrive* and is incompatable with the
build tools.
should not be *cygdrive* paths.**
On Windows (using MSYS and PuTTY), you might want to set the following extra parameters:
@ -262,7 +259,7 @@ Instead of:
ARDUINO_DIR=C:/Program\ Files\ \(x86\)/Arduino
```
### Usefull Variables
### Useful Variables
The list of all variables that can be overridden is available at [arduino-mk-vars.md](arduino-mk-vars.md) file.
@ -271,8 +268,8 @@ The list of all variables that can be overridden is available at [arduino-mk-var
- `ARDUINO_DIR` - Path to Arduino installation. Using Windows with Cygwin,
this path must use Unix / and not Windows \\ (eg "C:/Arduino" not
"C:\\Arduino).
- `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 nessessary and must use / not \\.
- `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.
- `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 \\.
- `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.