Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libdefs: a way for user to configure libraries #1517

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions i18n/data/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ msgstr "Compiling core..."
msgid "Compiling libraries..."
msgstr "Compiling libraries..."

#: legacy/builder/phases/libraries_builder.go:135
#: legacy/builder/phases/libraries_builder.go:136
msgid "Compiling library \"{0}\""
msgstr "Compiling library \"{0}\""

Expand Down Expand Up @@ -1358,7 +1358,7 @@ msgstr "Library installed"
msgid "Library name"
msgstr "Library name"

#: legacy/builder/phases/libraries_builder.go:91
#: legacy/builder/phases/libraries_builder.go:92
msgid "Library {0} has been declared precompiled:"
msgstr "Library {0} has been declared precompiled:"

Expand Down Expand Up @@ -1745,8 +1745,8 @@ msgstr "Port closed:"
msgid "Port monitor error"
msgstr "Port monitor error"

#: legacy/builder/phases/libraries_builder.go:101
#: legacy/builder/phases/libraries_builder.go:109
#: legacy/builder/phases/libraries_builder.go:102
#: legacy/builder/phases/libraries_builder.go:110
msgid "Precompiled library in \"{0}\" not found"
msgstr "Precompiled library in \"{0}\" not found"

Expand Down Expand Up @@ -2069,7 +2069,7 @@ msgstr "The key '%[1]v' is not a list of items, can't remove from it.\n"
msgid "The output format for the logs, can be: %s"
msgstr "The output format for the logs, can be: %s"

#: legacy/builder/phases/libraries_builder.go:151
#: legacy/builder/phases/libraries_builder.go:152
msgid "The platform does not support '{0}' for precompiled libraries."
msgstr "The platform does not support '{0}' for precompiled libraries."

Expand Down Expand Up @@ -2333,8 +2333,8 @@ msgstr "Using library {0} in folder: {1} {2}"
msgid "Using precompiled core: {0}"
msgstr "Using precompiled core: {0}"

#: legacy/builder/phases/libraries_builder.go:98
#: legacy/builder/phases/libraries_builder.go:106
#: legacy/builder/phases/libraries_builder.go:99
#: legacy/builder/phases/libraries_builder.go:107
msgid "Using precompiled library in {0}"
msgstr "Using precompiled library in {0}"

Expand Down
3 changes: 2 additions & 1 deletion legacy/builder/phases/libraries_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ type LibrariesBuilder struct{}
func (s *LibrariesBuilder) Run(ctx *types.Context) error {
librariesBuildPath := ctx.LibrariesBuildPath
buildProperties := ctx.BuildProperties
includes := utils.Map(ctx.IncludeFolders.AsStrings(), utils.WrapWithHyphenI)
libFolders := append(ctx.IncludeFolders.AsStrings(), ctx.BuildPath.Join("sketch").Join("libdefs").String()) // user definitions for library include files
includes := utils.Map(libFolders, utils.WrapWithHyphenI)
libs := ctx.ImportedLibraries

if err := librariesBuildPath.MkdirAll(); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion legacy/builder/phases/sketch_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ type SketchBuilder struct{}
func (s *SketchBuilder) Run(ctx *types.Context) error {
sketchBuildPath := ctx.SketchBuildPath
buildProperties := ctx.BuildProperties
includes := utils.Map(ctx.IncludeFolders.AsStrings(), utils.WrapWithHyphenI)
libFolders := append(ctx.IncludeFolders.AsStrings(), ctx.BuildPath.Join("sketch").Join("libdefs").String()) // user definitions for library include files
includes := utils.Map(libFolders, utils.WrapWithHyphenI)

if err := sketchBuildPath.MkdirAll(); err != nil {
return errors.WithStack(err)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

// This user file is in 'sketchDir/libdefs/' so it can be included by libraries.
//
// Its name and what to include is specified by the library documentation.

#pragma once

#define LIB2_SOME_CONFIG 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

#if defined __has_include
# if __has_include (<lib2_user_config.h>)
# pragma message "Including local project config file <lib2_user_config.h>"
# include <lib2_user_config.h>
# define DEFAULT_VALUES_ARE_GIVEN 1
# endif
#endif

#ifndef LIB2_SOME_CONFIG
#define LIB2_SOME_CONFIG 0
#endif

#define LIB2_SOME_SIZE ((LIB2_SOME_CONFIG) * 42)
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "lib1.h"
#include "lib2.h"

#if LIB2_SOME_SIZE == 42
#pragma message "this was expected"
#endif

void setup() {
}

Expand Down