Skip to content

Commit ec3e71c

Browse files
authored
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
1 parent 4dcf0da commit ec3e71c

File tree

11 files changed

+134
-76
lines changed

11 files changed

+134
-76
lines changed

Diff for: arduino/libraries/libraries.go

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type Library struct {
7474
PrecompiledWithSources bool
7575
LDflags string
7676
IsLegacy bool
77+
InDevelopment bool
7778
Version *semver.Version
7879
License string
7980
Properties *properties.Map
@@ -136,6 +137,7 @@ func (library *Library) ToRPCLibrary() (*rpc.Library, error) {
136137
Precompiled: library.Precompiled,
137138
LdFlags: library.LDflags,
138139
IsLegacy: library.IsLegacy,
140+
InDevelopment: library.InDevelopment,
139141
Version: library.Version.String(),
140142
License: library.License,
141143
Examples: library.Examples.AsStrings(),

Diff for: arduino/libraries/libraries_test.go

+20
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"encoding/json"
2020
"testing"
2121

22+
paths "github.com/arduino/go-paths-helper"
2223
"github.com/stretchr/testify/require"
2324
)
2425

@@ -48,3 +49,22 @@ func TestLibLayoutAndLocationJSONUnMarshaler(t *testing.T) {
4849
testLocation(User)
4950
testLocation(Unmanaged)
5051
}
52+
53+
func TestLibrariesLoader(t *testing.T) {
54+
{
55+
lib, err := Load(paths.New("testdata", "TestLib"), User)
56+
require.NoError(t, err)
57+
require.Equal(t, "TestLib", lib.Name)
58+
require.Equal(t, "1.0.3", lib.Version.String())
59+
require.False(t, lib.IsLegacy)
60+
require.False(t, lib.InDevelopment)
61+
}
62+
{
63+
lib, err := Load(paths.New("testdata", "TestLibInDev"), User)
64+
require.NoError(t, err)
65+
require.Equal(t, "TestLibInDev", lib.Name)
66+
require.Equal(t, "1.0.3", lib.Version.String())
67+
require.False(t, lib.IsLegacy)
68+
require.True(t, lib.InDevelopment)
69+
}
70+
}

Diff for: arduino/libraries/loader.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func makeNewLibrary(libraryDir *paths.Path, location LibraryLocation) (*Library,
121121
library.Precompiled = libProperties.Get("precompiled") == "true" || library.PrecompiledWithSources
122122
library.LDflags = strings.TrimSpace(libProperties.Get("ldflags"))
123123
library.Properties = libProperties
124-
124+
library.InDevelopment = libraryDir.Join(".development").Exist()
125125
return library, nil
126126
}
127127

@@ -136,6 +136,7 @@ func makeLegacyLibrary(path *paths.Path, location LibraryLocation) (*Library, er
136136
Architectures: []string{"*"},
137137
IsLegacy: true,
138138
Version: semver.MustParse(""),
139+
InDevelopment: path.Join(".development").Exist(),
139140
}
140141
if err := addExamples(library); err != nil {
141142
return nil, errors.Errorf(tr("scanning examples: %s"), err)
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=TestLib
2+
version=1.0.3
3+
author=Arduino
4+
maintainer=Arduino <[email protected]>
5+
sentence=A test lib
6+
paragraph=very powerful!
7+
category=Device Control
8+
url=http://www.arduino.cc/en/Reference/TestLib
9+
architectures=avr

Diff for: arduino/libraries/testdata/TestLib/src/TestLib.h

Whitespace-only changes.

Diff for: arduino/libraries/testdata/TestLibInDev/.development

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=TestLibInDev
2+
version=1.0.3
3+
author=Arduino
4+
maintainer=Arduino <[email protected]>
5+
sentence=A test lib
6+
paragraph=very powerful!
7+
category=Device Control
8+
url=http://www.arduino.cc/en/Reference/TestLib
9+
architectures=avr

Diff for: arduino/libraries/testdata/TestLibInDev/src/TestLib.h

Whitespace-only changes.

Diff for: docs/library-specification.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ In Arduino IDE 1.6.5 and newer this field overrides `KEYWORD_TOKENTYPE`. In prev
359359
Normally the Arduino IDE treats the contents of the library folder as read-only. This is to prevent users from
360360
accidentally modifying example sketches. During the library development process you may want to edit example sketches in
361361
place using the Arduino IDE. With Arduino IDE 1.6.6 and newer, the read-only behavior can be disabled by adding a file
362-
named .development to the root of the library folder. A [library.properties](#libraryproperties-file-format) file must
362+
named `.development` to the root of the library folder. A [library.properties](#libraryproperties-file-format) file must
363363
also be present. The [Library Manager indexer](https://github.com/arduino/library-registry/blob/main/FAQ.md#readme) will
364-
not pick up releases that contain a .development file so be sure not to push this file to your remote repository.
364+
not pick up releases that contain a `.development` file so be sure not to push this file to your remote repository.
365365

366366
### A complete example
367367

Diff for: rpc/cc/arduino/cli/commands/v1/lib.pb.go

+86-73
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: rpc/cc/arduino/cli/commands/v1/lib.proto

+4
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ message Library {
305305
repeated string provides_includes = 27;
306306
// Map of FQBNs that specifies if library is compatible with this library
307307
map<string, bool> compatible_with = 28;
308+
// This value is set to true if the library is in development and should not
309+
// be treated as read-only. This status is determined by the presence of a
310+
// `.development` file in the library root directory.
311+
bool in_development = 29;
308312
}
309313

310314
enum LibraryLayout {

0 commit comments

Comments
 (0)