summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2023-03-06 15:10:21 +0700
committerGitHub <[email protected]>2023-03-06 15:10:21 +0700
commit66da95a0eebcfb6e45980bc894d61b6bfd8fc0cc (patch)
treef96e0829e82976d5a3ed6ae743d06268430c8122 /tools
parenta83cef5e4c8cb54e89a0d4be30edac3574e3a185 (diff)
parentec8c292bbebdbaebe39abef6e88c6a0fbb1f2be7 (diff)
Merge pull request #1938 from hathach/update-build
Fix build on windows and macos
Diffstat (limited to 'tools')
-rw-r--r--tools/build_utils.py17
-rw-r--r--tools/top.mk45
2 files changed, 11 insertions, 51 deletions
diff --git a/tools/build_utils.py b/tools/build_utils.py
index ad1daf8c7..a24cea7bb 100644
--- a/tools/build_utils.py
+++ b/tools/build_utils.py
@@ -114,9 +114,14 @@ def build_example(example, board, make_option):
def build_size(example, board):
- elf_file = 'examples/{}/_build/{}/*.elf'.format(example, board)
- size_output = subprocess.run('size {}'.format(elf_file), shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8")
- size_list = size_output.split('\n')[1].split('\t')
- flash_size = int(size_list[0])
- sram_size = int(size_list[1]) + int(size_list[2])
- return (flash_size, sram_size)
+ size_cmd = 'make -j -C examples/{} BOARD={} size'.format(example, board)
+ size_output = subprocess.run(size_cmd, shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8").splitlines()
+ for i, l in enumerate(size_output):
+ text_title = 'text data bss dec'
+ if text_title in l:
+ size_list = size_output[i+1].split('\t')
+ flash_size = int(size_list[0])
+ sram_size = int(size_list[1]) + int(size_list[2])
+ return (flash_size, sram_size)
+
+ return (0, 0) \ No newline at end of file
diff --git a/tools/top.mk b/tools/top.mk
deleted file mode 100644
index af8d698f5..000000000
--- a/tools/top.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-ifneq ($(lastword a b),b)
-$(error This Makefile requires make 3.81 or newer)
-endif
-
-# Detect whether shell style is windows or not
-# https://stackoverflow.com/questions/714100/os-detecting-makefile/52062069#52062069
-ifeq '$(findstring ;,$(PATH))' ';'
-# PATH contains semicolon - so we're definitely on Windows.
-CMDEXE := 1
-
-# makefile shell commands should use syntax for DOS CMD, not unix sh
-# Unfortunately, SHELL may point to sh or bash, which can't accept DOS syntax.
-# We can't just use sh, because while sh and/or bash shell may be available,
-# many Windows environments won't have utilities like realpath used below, so...
-# Force DOS command shell on Windows.
-SHELL := cmd.exe
-endif
-
-#$(info top.mk: SHELL=$(SHELL))
-#$(info top.mk: CMDEXE=$(CMDEXE))
-
-# Set TOP to be the path to get from the current directory (where make was
-# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns
-# the name of this makefile relative to where make was invoked.
-THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
-
-# strip off /tools/top.mk to get for example ../../..
-TOP := $(patsubst %/tools/top.mk,%,$(THIS_MAKEFILE))
-#$(info top.mk: Initial TOP=$(TOP))
-
-# Set TOP to an absolute path, for example /tinyUSB (from ../../..)
-ifeq ($(CMDEXE),1)
-TOP := $(subst \,/,$(shell for %%i in ( $(TOP) ) do echo %%~fi))
-else
-TOP := $(shell realpath $(TOP))
-endif
-#$(info top.mk: Top directory is $(TOP))
-
-# Set CURRENT_PATH to the relative path from TOP to the current directory, ie examples/device/cdc_msc_freertos
-ifeq ($(CMDEXE),1)
-CURRENT_PATH := $(subst $(TOP)/,,$(subst \,/,$(shell echo %CD%)))
-else
-CURRENT_PATH := $(shell realpath --relative-to=$(TOP) `pwd`)
-endif
-#$(info top.mk: Path from top is $(CURRENT_PATH))