Unverified Commit ec3e71ca authored by Cristian Maglie's avatar Cristian Maglie Committed by GitHub

Added libraries `.development` flag detection (#1962)

* Added in_development flag in Library gRPC message

* Small cosmetic fix in docs

* Implemented 'in_development' flag in libraries loader

* Added unit-test
parent 4dcf0da6
......@@ -74,6 +74,7 @@ type Library struct {
PrecompiledWithSources bool
LDflags string
IsLegacy bool
InDevelopment bool
Version *semver.Version
License string
Properties *properties.Map
......@@ -136,6 +137,7 @@ func (library *Library) ToRPCLibrary() (*rpc.Library, error) {
Precompiled: library.Precompiled,
LdFlags: library.LDflags,
IsLegacy: library.IsLegacy,
InDevelopment: library.InDevelopment,
Version: library.Version.String(),
License: library.License,
Examples: library.Examples.AsStrings(),
......
......@@ -19,6 +19,7 @@ import (
"encoding/json"
"testing"
paths "github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
)
......@@ -48,3 +49,22 @@ func TestLibLayoutAndLocationJSONUnMarshaler(t *testing.T) {
testLocation(User)
testLocation(Unmanaged)
}
func TestLibrariesLoader(t *testing.T) {
{
lib, err := Load(paths.New("testdata", "TestLib"), User)
require.NoError(t, err)
require.Equal(t, "TestLib", lib.Name)
require.Equal(t, "1.0.3", lib.Version.String())
require.False(t, lib.IsLegacy)
require.False(t, lib.InDevelopment)
}
{
lib, err := Load(paths.New("testdata", "TestLibInDev"), User)
require.NoError(t, err)
require.Equal(t, "TestLibInDev", lib.Name)
require.Equal(t, "1.0.3", lib.Version.String())
require.False(t, lib.IsLegacy)
require.True(t, lib.InDevelopment)
}
}
......@@ -121,7 +121,7 @@ func makeNewLibrary(libraryDir *paths.Path, location LibraryLocation) (*Library,
library.Precompiled = libProperties.Get("precompiled") == "true" || library.PrecompiledWithSources
library.LDflags = strings.TrimSpace(libProperties.Get("ldflags"))
library.Properties = libProperties
library.InDevelopment = libraryDir.Join(".development").Exist()
return library, nil
}
......@@ -136,6 +136,7 @@ func makeLegacyLibrary(path *paths.Path, location LibraryLocation) (*Library, er
Architectures: []string{"*"},
IsLegacy: true,
Version: semver.MustParse(""),
InDevelopment: path.Join(".development").Exist(),
}
if err := addExamples(library); err != nil {
return nil, errors.Errorf(tr("scanning examples: %s"), err)
......
name=TestLib
version=1.0.3
author=Arduino
maintainer=Arduino <info@arduino.cc>
sentence=A test lib
paragraph=very powerful!
category=Device Control
url=http://www.arduino.cc/en/Reference/TestLib
architectures=avr
\ No newline at end of file
name=TestLibInDev
version=1.0.3
author=Arduino
maintainer=Arduino <info@arduino.cc>
sentence=A test lib
paragraph=very powerful!
category=Device Control
url=http://www.arduino.cc/en/Reference/TestLib
architectures=avr
\ No newline at end of file
......@@ -359,9 +359,9 @@ In Arduino IDE 1.6.5 and newer this field overrides `KEYWORD_TOKENTYPE`. In prev
Normally the Arduino IDE treats the contents of the library folder as read-only. This is to prevent users from
accidentally modifying example sketches. During the library development process you may want to edit example sketches in
place using the Arduino IDE. With Arduino IDE 1.6.6 and newer, the read-only behavior can be disabled by adding a file
named .development to the root of the library folder. A [library.properties](#libraryproperties-file-format) file must
named `.development` to the root of the library folder. A [library.properties](#libraryproperties-file-format) file must
also be present. The [Library Manager indexer](https://github.com/arduino/library-registry/blob/main/FAQ.md#readme) will
not pick up releases that contain a .development file so be sure not to push this file to your remote repository.
not pick up releases that contain a `.development` file so be sure not to push this file to your remote repository.
### A complete example
......
This diff is collapsed.
......@@ -305,6 +305,10 @@ message Library {
repeated string provides_includes = 27;
// Map of FQBNs that specifies if library is compatible with this library
map<string, bool> compatible_with = 28;
// This value is set to true if the library is in development and should not
// be treated as read-only. This status is determined by the presence of a
// `.development` file in the library root directory.
bool in_development = 29;
}
enum LibraryLayout {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment