[FL-2052] New build system based on scons (#1269)

This commit is contained in:
hedger
2022-06-26 15:00:03 +03:00
committed by GitHub
parent c79fb61909
commit f3b1475ede
179 changed files with 3986 additions and 5196 deletions

78
lib/SConscript Normal file
View File

@@ -0,0 +1,78 @@
Import("env")
env.Append(
LINT_SOURCES=[
"lib/app-scened-template",
"lib/digital_signal",
"lib/drivers",
"lib/flipper_format",
"lib/infrared",
"lib/nfc_protocols",
"lib/one_wire",
"lib/ST25RFAL002",
"lib/subghz",
"lib/toolbox",
"lib/u8g2",
"lib/update_util",
]
)
env.Append(
CPPPATH=[
"#/",
"#/lib", # TODO: remove!
"#/lib/mlib",
# Ugly hack
"${BUILD_DIR}/assets/compiled",
],
CPPDEFINES=[
'"M_MEMORY_FULL(x)=abort()"',
],
)
# drivers
# fatfs
# flipper_format
# infrared
# littlefs
# subghz
# toolbox
# misc
# digital_signal
# fnv1a-hash
# micro-ecc
# microtar
# nfc_protocols
# one_wire
# qrcode
# u8g2
# update_util
# heatshrink
# nanopb
# apps
# app-scened-template
# callback-connector
# app-template
libs = env.BuildModules(
[
"STM32CubeWB",
"freertos",
"microtar",
"toolbox",
"ST25RFAL002",
"libusb_stm32",
"drivers",
"fatfs",
"flipper_format",
"infrared",
"littlefs",
"subghz",
"appframe",
"misc",
],
)
Return("libs")

View File

@@ -0,0 +1,19 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/ST25RFAL002",
"#/lib/ST25RFAL002/include",
"#/lib/ST25RFAL002/source/st25r3916",
],
)
libenv = env.Clone(FW_LIB_NAME="st25rfal002")
libenv.ApplyLibFlags()
sources = libenv.GlobRecursive("*.c")
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

66
lib/STM32CubeWB.scons Normal file
View File

@@ -0,0 +1,66 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/STM32CubeWB/Drivers/CMSIS/Device/ST",
"#/lib/STM32CubeWB/Drivers/CMSIS/Device/ST/STM32WBxx/Include",
"#/lib/STM32CubeWB/Drivers/CMSIS/Include",
"#/lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc",
"#/lib/STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Inc/Legacy",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/ble",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/template",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/shci",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl",
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities",
],
CPPDEFINES=[
"STM32WB",
"STM32WB55xx",
"USE_FULL_ASSERT",
"USE_FULL_LL_DRIVER",
],
)
if env["RAM_EXEC"]:
env.Append(
CPPDEFINES=[
"VECT_TAB_SRAM",
],
)
libenv = env.Clone(FW_LIB_NAME="stm32cubewb")
libenv.ApplyLibFlags()
sources = libenv.GlobRecursive(
"*_ll_*.c", "STM32CubeWB/Drivers/STM32WBxx_HAL_Driver/Src/", exclude="*usb.c"
)
sources += Glob(
"STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/shci/*.c",
source=True,
)
sources += Glob(
"STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl/*_tl*.c",
source=True,
)
sources += [
"STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl/tl_mbox.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/svc/Src/svc_ctl.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_gap_aci.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_gatt_aci.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_hal_aci.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_hci_le.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/auto/ble_l2cap_aci.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/ble/core/template/osal.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities/dbg_trace.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities/otp.c",
"STM32CubeWB/Middlewares/ST/STM32_WPAN/utilities/stm_list.c",
]
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

26
lib/appframe.scons Normal file
View File

@@ -0,0 +1,26 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/app-scened-template",
"#/lib/callback-connector",
],
)
libenv = env.Clone(FW_LIB_NAME="appframe")
libenv.ApplyLibFlags()
sources = []
recurse_dirs = [
"app-scened-template",
"callback-connector",
]
for recurse_dir in recurse_dirs:
sources += libenv.GlobRecursive("*.c*", recurse_dir)
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

17
lib/drivers/SConscript Normal file
View File

@@ -0,0 +1,17 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/drivers",
],
)
libenv = env.Clone(FW_LIB_NAME="hwdrivers")
libenv.ApplyLibFlags()
sources = Glob("*.c", source=True)
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

13
lib/fatfs/SConscript Normal file
View File

@@ -0,0 +1,13 @@
Import("env")
libenv = env.Clone(FW_LIB_NAME="fatfs")
libenv.ApplyLibFlags()
sources = ["option/unicode.c"]
sources += Glob("*.c", source=True)
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

View File

@@ -0,0 +1,25 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/flipper_format",
],
)
libenv = env.Clone(FW_LIB_NAME="flipperformat")
libenv.ApplyLibFlags()
if libenv["RAM_EXEC"]:
libenv.Append(
CPPDEFINES=[
"FLIPPER_STREAM_LITE",
],
)
sources = libenv.GlobRecursive("*.c")
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

28
lib/freertos.scons Normal file
View File

@@ -0,0 +1,28 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/drivers",
"#/lib/FreeRTOS-Kernel/include",
"#/lib/FreeRTOS-Kernel/portable/GCC/ARM_CM4F",
"#/lib/FreeRTOS-glue",
],
CPPDEFINES=[
"HAVE_FREERTOS",
],
)
libenv = env.Clone(FW_LIB_NAME="freertos")
libenv.ApplyLibFlags()
sources = libenv.Glob("FreeRTOS-Kernel/*.c", source=True)
sources += [
"FreeRTOS-Kernel/portable/GCC/ARM_CM4F/port.c",
"FreeRTOS-glue/cmsis_os2.c",
]
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

18
lib/infrared/SConscript Normal file
View File

@@ -0,0 +1,18 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/infrared/encoder_decoder",
"#/lib/infrared/worker",
],
)
libenv = env.Clone(FW_LIB_NAME="infrared")
libenv.ApplyLibFlags()
sources = libenv.GlobRecursive("*.c")
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

View File

@@ -1,138 +0,0 @@
LIB_DIR = $(PROJECT_ROOT)/lib
# TODO: some places use lib/header.h includes, is it ok?
CFLAGS += -I$(LIB_DIR)
# Mlib containers
CFLAGS += -I$(LIB_DIR)/mlib -D'M_MEMORY_FULL(x)=abort()'
# U8G2 display library
U8G2_DIR = $(LIB_DIR)/u8g2
CFLAGS += -I$(U8G2_DIR)
C_SOURCES += $(U8G2_DIR)/u8g2_glue.c
C_SOURCES += $(U8G2_DIR)/u8g2_intersection.c
C_SOURCES += $(U8G2_DIR)/u8g2_setup.c
C_SOURCES += $(U8G2_DIR)/u8g2_d_memory.c
C_SOURCES += $(U8G2_DIR)/u8x8_cad.c
C_SOURCES += $(U8G2_DIR)/u8x8_byte.c
C_SOURCES += $(U8G2_DIR)/u8x8_gpio.c
C_SOURCES += $(U8G2_DIR)/u8x8_display.c
C_SOURCES += $(U8G2_DIR)/u8x8_setup.c
C_SOURCES += $(U8G2_DIR)/u8g2_hvline.c
C_SOURCES += $(U8G2_DIR)/u8g2_line.c
C_SOURCES += $(U8G2_DIR)/u8g2_ll_hvline.c
C_SOURCES += $(U8G2_DIR)/u8g2_circle.c
C_SOURCES += $(U8G2_DIR)/u8g2_box.c
C_SOURCES += $(U8G2_DIR)/u8g2_buffer.c
C_SOURCES += $(U8G2_DIR)/u8g2_font.c
C_SOURCES += $(U8G2_DIR)/u8g2_fonts.c
C_SOURCES += $(U8G2_DIR)/u8x8_8x8.c
C_SOURCES += $(U8G2_DIR)/u8g2_bitmap.c
FATFS_DIR = $(LIB_DIR)/fatfs
C_SOURCES += $(FATFS_DIR)/ff.c
C_SOURCES += $(FATFS_DIR)/ff_gen_drv.c
C_SOURCES += $(FATFS_DIR)/diskio.c
C_SOURCES += $(FATFS_DIR)/option/unicode.c
# Little FS
LITTLEFS_DIR = $(LIB_DIR)/littlefs
CFLAGS += -I$(LITTLEFS_DIR) -DLFS_CONFIG=lfs_config.h
C_SOURCES += $(LITTLEFS_DIR)/lfs.c
C_SOURCES += $(LITTLEFS_DIR)/lfs_util.c
ST25RFAL002_DIR = $(LIB_DIR)/ST25RFAL002
CFLAGS += -I$(ST25RFAL002_DIR)
CFLAGS += -I$(ST25RFAL002_DIR)/include
CFLAGS += -I$(ST25RFAL002_DIR)/source/st25r3916
C_SOURCES += $(wildcard $(ST25RFAL002_DIR)/*.c)
C_SOURCES += $(wildcard $(ST25RFAL002_DIR)/source/*.c)
C_SOURCES += $(wildcard $(ST25RFAL002_DIR)/source/st25r3916/*.c)
CFLAGS += -I$(LIB_DIR)/nfc_protocols
C_SOURCES += $(wildcard $(LIB_DIR)/nfc_protocols/*.c)
# callback connector (C to CPP) library
CFLAGS += -I$(LIB_DIR)/callback-connector
# app template library
CFLAGS += -I$(LIB_DIR)/app-template
# add C scene template
CFLAGS += -I$(LIB_DIR)/app_scene_template
# fnv1a hash library
CFLAGS += -I$(LIB_DIR)/fnv1a-hash
C_SOURCES += $(LIB_DIR)/fnv1a-hash/fnv1a-hash.c
# common apps api
CFLAGS += -I$(LIB_DIR)/common-api
# drivers
CFLAGS += -I$(LIB_DIR)/drivers
C_SOURCES += $(wildcard $(LIB_DIR)/drivers/*.c)
# IR lib
CFLAGS += -I$(LIB_DIR)/infrared/encoder_decoder
CFLAGS += -I$(LIB_DIR)/infrared/worker
C_SOURCES += $(wildcard $(LIB_DIR)/infrared/encoder_decoder/*.c)
C_SOURCES += $(wildcard $(LIB_DIR)/infrared/encoder_decoder/*/*.c)
C_SOURCES += $(wildcard $(LIB_DIR)/infrared/worker/*.c)
# SubGhz
C_SOURCES += $(wildcard $(LIB_DIR)/subghz/*.c)
C_SOURCES += $(wildcard $(LIB_DIR)/subghz/*/*.c)
#scened app template lib
CFLAGS += -I$(LIB_DIR)/app-scened-template
C_SOURCES += $(wildcard $(LIB_DIR)/app-scened-template/*.c)
CPP_SOURCES += $(wildcard $(LIB_DIR)/app-scened-template/*.cpp)
CPP_SOURCES += $(wildcard $(LIB_DIR)/app-scened-template/*/*.cpp)
# Toolbox
C_SOURCES += $(wildcard $(LIB_DIR)/toolbox/*.c)
C_SOURCES += $(wildcard $(LIB_DIR)/toolbox/*/*.c)
CPP_SOURCES += $(wildcard $(LIB_DIR)/toolbox/*.cpp)
CPP_SOURCES += $(wildcard $(LIB_DIR)/toolbox/*/*.cpp)
# Digital signal
CFLAGS += -I$(LIB_DIR)/digital_signal
C_SOURCES += $(wildcard $(LIB_DIR)/digital_signal/*.c)
# USB Stack
CFLAGS += -I$(LIB_DIR)/libusb_stm32/inc
C_SOURCES += $(LIB_DIR)/libusb_stm32/src/usbd_stm32wb55_devfs.c
C_SOURCES += $(LIB_DIR)/libusb_stm32/src/usbd_core.c
# protobuf
CFLAGS += -I$(LIB_DIR)/nanopb
C_SOURCES += $(wildcard $(LIB_DIR)/nanopb/*.c)
# heatshrink
CFLAGS += -I$(LIB_DIR)/heatshrink
C_SOURCES += $(wildcard $(LIB_DIR)/heatshrink/*.c)
# Toolbox
CFLAGS += -I$(LIB_DIR)/flipper_file
C_SOURCES += $(wildcard $(LIB_DIR)/flipper_file/*.c)
# Flipper format
CFLAGS += -I$(LIB_DIR)/flipper_format
C_SOURCES += $(wildcard $(LIB_DIR)/flipper_format/*.c)
# Micro-ECC
CFLAGS += -I$(LIB_DIR)/micro-ecc
C_SOURCES += $(wildcard $(LIB_DIR)/micro-ecc/*.c)
# iButton and OneWire
C_SOURCES += $(wildcard $(LIB_DIR)/one_wire/*.c)
C_SOURCES += $(wildcard $(LIB_DIR)/one_wire/*/*.c)
C_SOURCES += $(wildcard $(LIB_DIR)/one_wire/*/*/*.c)
# microtar
CFLAGS += -I$(LIB_DIR)/microtar/src
C_SOURCES += $(wildcard $(LIB_DIR)/microtar/src/*.c)
# Update-related common code
C_SOURCES += $(wildcard $(LIB_DIR)/update_util/*.c)

24
lib/libusb_stm32.scons Normal file
View File

@@ -0,0 +1,24 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/libusb_stm32/inc",
],
CPPDEFINES=[
("USB_PMASIZE", "0x400"),
],
)
libenv = env.Clone(FW_LIB_NAME="usb_stm32")
libenv.ApplyLibFlags()
sources = [
"libusb_stm32/src/usbd_core.c",
"libusb_stm32/src/usbd_stm32wb55_devfs.c",
]
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

20
lib/littlefs.scons Normal file
View File

@@ -0,0 +1,20 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/littlefs",
],
CPPDEFINES=[
("LFS_CONFIG", "lfs_config.h"),
],
)
libenv = env.Clone(FW_LIB_NAME="littlefs")
libenv.ApplyLibFlags()
sources = Glob("littlefs/*.c", source=True)
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

21
lib/microtar.scons Normal file
View File

@@ -0,0 +1,21 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/microtar/src",
],
)
libenv = env.Clone(FW_LIB_NAME="microtar")
libenv.ApplyLibFlags()
libenv.Append(
CPPDEFINES=["MICROTAR_DISABLE_API_CHECKS"],
)
sources = libenv.GlobRecursive("*.c", "microtar/src")
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

46
lib/misc.scons Normal file
View File

@@ -0,0 +1,46 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/digital_signal",
"#/lib/fnv1a_hash",
"#/lib/heatshrink",
"#/lib/micro-ecc",
"#/lib/nanopb",
"#/lib/nfc_protocols",
"#/lib/u8g2",
],
CPPDEFINES=[
"PB_ENABLE_MALLOC",
],
)
libenv = env.Clone(FW_LIB_NAME="misc")
libenv.ApplyLibFlags()
sources = []
libs_recurse = [
"digital_signal",
"micro-ecc",
"nfc_protocols",
"one_wire",
"u8g2",
"update_util",
]
for lib in libs_recurse:
sources += libenv.GlobRecursive("*.c*", lib)
libs_plain = [
"heatshrink",
"nanopb",
]
for lib in libs_plain:
sources += Glob(lib + "/*.c*", source=True)
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

View File

@@ -27,9 +27,9 @@ typedef enum {
typedef struct {
const uint32_t quant;
void (*const start) (iButtonWorker* worker);
void (*const tick) (iButtonWorker* worker);
void (*const stop) (iButtonWorker* worker);
void (*const start)(iButtonWorker* worker);
void (*const tick)(iButtonWorker* worker);
void (*const stop)(iButtonWorker* worker);
} iButtonWorkerModeType;
typedef enum {

View File

@@ -212,7 +212,8 @@ static void exti_cb(void* context) {
static uint32_t pulse_start = 0;
if(input_state) {
uint32_t pulse_length = (DWT->CYCCNT - pulse_start) / furi_hal_delay_instructions_per_microsecond();
uint32_t pulse_length =
(DWT->CYCCNT - pulse_start) / furi_hal_delay_instructions_per_microsecond();
if(pulse_length >= OWS_RESET_MIN) {
if(pulse_length <= OWS_RESET_MAX) {
// reset cycle ok

1
lib/scons Submodule

Submodule lib/scons added at c2d1f09f61

16
lib/subghz/SConscript Normal file
View File

@@ -0,0 +1,16 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/subghz",
],
)
libenv = env.Clone(FW_LIB_NAME="subghz")
libenv.ApplyLibFlags()
sources = libenv.GlobRecursive("*.c*")
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

1
lib/toolbox/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
version.inc.h

47
lib/toolbox/SConscript Normal file
View File

@@ -0,0 +1,47 @@
Import("env")
from fbt.version import get_fast_git_version_id
env.Append(
CPPPATH=[
"#/lib/toolbox",
],
)
libenv = env.Clone(tools=["fbt_version"], FW_LIB_NAME="toolbox")
libenv.ApplyLibFlags()
# Git Version management
version_depends = []
version_id_data = get_fast_git_version_id()
if version_id_data:
version_depends = Value(version_id_data)
# Only invoke version generator if preliminary check target (version_depends) has changed
build_version = libenv.VersionBuilder(
Dir("."),
version_depends,
)
fw_version_json = libenv.InstallAs(
"${BUILD_DIR}/${FIRMWARE_BUILD_CFG}.json", "version.json"
)
env.Append(FW_VERSION_JSON=fw_version_json)
# Default(fw_version_json)
if not version_depends:
libenv.Precious(build_version)
libenv.AlwaysBuild(build_version)
sources = libenv.GlobRecursive("*.c")
libenv.Append(CPPPATH=["."])
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

View File

@@ -83,3 +83,32 @@ void path_concat(const char* path, const char* suffix, string_t out_path) {
string_set(out_path, path);
path_append(out_path, suffix);
}
bool path_contains_only_ascii(const char* path) {
const char* name_pos = strrchr(path, '/');
if(name_pos == NULL) {
name_pos = path;
} else {
name_pos++;
}
while(*name_pos != '\0') {
if((*name_pos >= '0') && (*name_pos <= '9')) {
name_pos++;
continue;
} else if((*name_pos >= 'A') && (*name_pos <= 'Z')) {
name_pos++;
continue;
} else if((*name_pos >= 'a') && (*name_pos <= 'z')) {
name_pos++;
continue;
} else if(strchr(".!#\\$%&'()-@^_`{}~", *name_pos) != NULL) {
name_pos++;
continue;
}
return false;
}
return true;
}

View File

@@ -65,6 +65,15 @@ void path_append(string_t path, const char* suffix);
*/
void path_concat(const char* path, const char* suffix, string_t out_path);
/**
* @brief Check that path contains only ascii characters
*
* @param path
* @return true
* @return false
*/
bool path_contains_only_ascii(const char* path);
#ifdef __cplusplus
}
#endif

View File

@@ -1,5 +1,8 @@
#include "version.h"
/* This header is autogenerated by build system */
#include "version.inc.h"
struct Version {
const char* git_hash;
const char* git_branch;