Skip to content

Commit 7128555

Browse files
committed
Makefile: correctly handle windows x linux toolchains
1 parent 68c6072 commit 7128555

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

Makefile

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,7 @@ endif
8585
# then please raise a GitHub issue on this work.
8686
#
8787

88-
ifndef $(OS)
89-
# Assume Windows if MAKE_HOST contains "indows" and Linux otherwise
90-
ifneq (,$(findstring indows,$(MAKE_HOST)))
91-
OS := windows
92-
else
93-
OS := linux
94-
endif
95-
endif
96-
97-
ifneq (,$(findstring indows,$(OS)))
88+
ifeq ($(OS),Windows_NT)
9889
#------------ BEGIN UNTESTED ------------ We are not under Linux, e.g.under windows.
9990
ifeq ($(XTENSA_CORE),lx106)
10091
# It is xcc
@@ -116,19 +107,22 @@ ifneq (,$(findstring indows,$(OS)))
116107
NM = xtensa-lx106-elf-nm
117108
CPP = xtensa-lx106-elf-cpp
118109
OBJCOPY = xtensa-lx106-elf-objcopy
110+
TOOLCHAIN_VERSION = 2020r3
111+
GCCTOOLCHAIN = xtensa-lx106-elf-gcc8_4_0-esp-$(TOOLCHAIN_VERSION)-win32
112+
TOOLCHAIN_ROOT = $(TOP_DIR)/tools/toolchains/esp8266-$(GCCTOOLCHAIN)
113+
ESPRESSIF_URL = https://dl.espressif.com/dl
114+
TOOLCHAIN_EXT = zip
115+
TOOLCHAIN_URL = $(ESPRESSIF_URL)/$(GCCTOOLCHAIN).$(TOOLCHAIN_EXT)
116+
WGET = wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused
117+
export PATH := $(PATH):$(TOOLCHAIN_ROOT)/bin
119118
endif
120119
FIRMWAREDIR = ..\\bin\\
121120
ifndef COMPORT
122121
ESPPORT = com1
123122
else
124123
ESPPORT = $(COMPORT)
125124
endif
126-
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
127-
# ->AMD64
128-
endif
129-
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
130-
# ->IA32
131-
endif
125+
132126
#---------------- END UNTESTED ---------------- We are under windows.
133127
else
134128
# We are under other system, may be Linux. Assume using gcc.
@@ -141,6 +135,8 @@ else
141135
GCCTOOLCHAIN = linux-x86_64-$(TOOLCHAIN_VERSION)
142136
TOOLCHAIN_ROOT = $(TOP_DIR)/tools/toolchains/esp8266-$(GCCTOOLCHAIN)
143137
GITHUB_TOOLCHAIN = https://github.com/jmattsson/esp-toolchains
138+
TOOLCHAIN_EXT = tar.xz
139+
TOOLCHAIN_URL = $(GITHUB_TOOLCHAIN)/releases/download/$(GCCTOOLCHAIN)/toolchain-esp8266-$(GCCTOOLCHAIN).$(TOOLCHAIN_EXT)
144140
export PATH:=$(PATH):$(TOOLCHAIN_ROOT)/bin
145141
endif
146142
endif
@@ -286,21 +282,24 @@ endif
286282
sdk_extracted: $(TOP_DIR)/sdk/.extracted-$(SDK_VER)
287283
sdk_pruned: sdk_extracted toolchain $(TOP_DIR)/sdk/.pruned-$(SDK_VER)
288284

289-
ifdef GITHUB_TOOLCHAIN
290-
TOOLCHAIN_ROOT := $(TOP_DIR)/tools/toolchains/esp8266-linux-x86_64-$(TOOLCHAIN_VERSION)
291-
285+
ifdef TOOLCHAIN_URL
292286
toolchain: $(TOOLCHAIN_ROOT)/bin $(ESPTOOL)
293287

294-
$(TOOLCHAIN_ROOT)/bin: $(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz
288+
$(TOOLCHAIN_ROOT)/bin: $(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).$(TOOLCHAIN_EXT)
295289
mkdir -p $(TOP_DIR)/tools/toolchains/
296290
$(summary) EXTRACT $(patsubst $(TOP_DIR)/%,%,$<)
297-
tar -xJf $< -C $(TOP_DIR)/tools/toolchains/
291+
ifeq ($(TOOLCHAIN_EXT),tar.xz)
292+
tar -xJf $< -C $(TOP_DIR)/tools/toolchains/
293+
else ifeq ($(TOOLCHAIN_EXT),zip)
294+
unzip -q $< -d $(TOP_DIR)/tools/toolchains/
295+
mv $(TOP_DIR)/tools/toolchains/xtensa-lx106-elf $(TOOLCHAIN_ROOT)
296+
endif
298297
touch $@
299298

300-
$(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz:
299+
$(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).$(TOOLCHAIN_EXT):
301300
mkdir -p $(TOP_DIR)/cache
302301
$(summary) WGET $(patsubst $(TOP_DIR)/%,%,$@)
303-
$(WGET) $(GITHUB_TOOLCHAIN)/releases/download/$(GCCTOOLCHAIN)/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz -O $@ \
302+
$(WGET) $(TOOLCHAIN_URL) -O $@ \
304303
|| { rm -f "$@"; exit 1; }
305304
else
306305
toolchain: $(ESPTOOL)

0 commit comments

Comments
 (0)