[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

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;