Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit505bb8a

Browse files
author
Federico Fissore
committed
When an included header is part of an already included library, use that
libraryThe order in which -libraries parameters are specified matters: second one ismore important than first oneSigned-off-by: Federico Fissore <f.fissore@arduino.cc>
1 parent03fc189 commit505bb8a

38 files changed

+8558
-17
lines changed

‎src/arduino.cc/builder/includes_to_include_folders.go‎

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (s *IncludesToIncludeFolders) Run(context map[string]interface{}) error {
5353
ifutils.MapHas(context,constants.CTX_IMPORTED_LIBRARIES) {
5454
importedLibraries=context[constants.CTX_IMPORTED_LIBRARIES].([]*types.Library)
5555
}
56-
newlyImportedLibraries,err:=resolveLibraries(includes,headerToLibraries, []*types.Platform{platform,actualPlatform},libraryResolutionResults)
56+
newlyImportedLibraries,err:=resolveLibraries(includes,headerToLibraries,importedLibraries,[]*types.Platform{platform,actualPlatform},libraryResolutionResults)
5757
iferr!=nil {
5858
returnutils.WrapError(err)
5959
}
@@ -92,24 +92,27 @@ func resolveIncludeFolders(importedLibraries []*types.Library, buildProperties m
9292
}
9393

9494
//FIXME it's also resolving previously resolved libraries
95-
funcresolveLibraries(includes []string,headerToLibrariesmap[string][]*types.Library,platforms []*types.Platform,libraryResolutionResultsmap[string]types.LibraryResolutionResult) ([]*types.Library,error) {
95+
funcresolveLibraries(includes []string,headerToLibrariesmap[string][]*types.Library,importedLibraries []*types.Library,platforms []*types.Platform,libraryResolutionResultsmap[string]types.LibraryResolutionResult) ([]*types.Library,error) {
9696
markImportedLibrary:=make(map[*types.Library]bool)
97+
for_,library:=rangeimportedLibraries {
98+
markImportedLibrary[library]=true
99+
}
97100
for_,header:=rangeincludes {
98101
resolveLibrary(header,headerToLibraries,markImportedLibrary,platforms,libraryResolutionResults)
99102
}
100103

101-
varimportedLibraries []*types.Library
104+
varnewlyImportedLibraries []*types.Library
102105
forlibrary,_:=rangemarkImportedLibrary {
103-
importedLibraries=append(importedLibraries,library)
106+
newlyImportedLibraries=append(newlyImportedLibraries,library)
104107
}
105108

106-
returnimportedLibraries,nil
109+
returnnewlyImportedLibraries,nil
107110
}
108111

109112
funcresolveLibrary(headerstring,headerToLibrariesmap[string][]*types.Library,markImportedLibrarymap[*types.Library]bool,platforms []*types.Platform,libraryResolutionResultsmap[string]types.LibraryResolutionResult) {
110113
libraries:=headerToLibraries[header]
111114

112-
iflibraries==nil {
115+
iflibraries==nil||len(libraries)==0{
113116
return
114117
}
115118

@@ -118,6 +121,10 @@ func resolveLibrary(header string, headerToLibraries map[string][]*types.Library
118121
return
119122
}
120123

124+
ifmarkedLibrariesContainOneOfCandidate(markImportedLibrary,libraries) {
125+
return
126+
}
127+
121128
varlibrary*types.Library
122129

123130
for_,platform:=rangeplatforms {
@@ -138,14 +145,36 @@ func resolveLibrary(header string, headerToLibraries map[string][]*types.Library
138145
}
139146

140147
iflibrary==nil {
141-
library=libraries[0]
148+
library=libraries[len(libraries)-1]
142149
}
143150

151+
library=useAlreadyImportedLibraryWithSameNameIfExists(library,markImportedLibrary)
152+
144153
libraryResolutionResults[header]= types.LibraryResolutionResult{Library:library,NotUsedLibraries:filterOutLibraryFrom(libraries,library)}
145154

146155
markImportedLibrary[library]=true
147156
}
148157

158+
funcmarkedLibrariesContainOneOfCandidate(markImportedLibrarymap[*types.Library]bool,libraries []*types.Library)bool {
159+
formarkedLibrary,_:=rangemarkImportedLibrary {
160+
for_,library:=rangelibraries {
161+
ifmarkedLibrary==library {
162+
returntrue
163+
}
164+
}
165+
}
166+
returnfalse
167+
}
168+
169+
funcuseAlreadyImportedLibraryWithSameNameIfExists(library*types.Library,markImportedLibrarymap[*types.Library]bool)*types.Library {
170+
forlib,_:=rangemarkImportedLibrary {
171+
iflib.Name==library.Name {
172+
returnlib
173+
}
174+
}
175+
returnlibrary
176+
}
177+
149178
funcfilterOutLibraryFrom(libraries []*types.Library,library*types.Library) []*types.Library {
150179
filteredOutLibraries:= []*types.Library{}
151180
for_,lib:=rangelibraries {

‎src/arduino.cc/builder/libraries_loader.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ import (
4343
typeLibrariesLoaderstruct{}
4444

4545
func (s*LibrariesLoader)Run(contextmap[string]interface{})error {
46-
if!utils.MapHas(context,constants.CTX_LIBRARIES_FOLDERS) {
47-
returnnil
46+
librariesFolders:= []string{}
47+
ifutils.MapHas(context,constants.CTX_LIBRARIES_FOLDERS) {
48+
librariesFolders=context[constants.CTX_LIBRARIES_FOLDERS].([]string)
4849
}
4950

50-
librariesFolders:=context[constants.CTX_LIBRARIES_FOLDERS].([]string)
5151
platform:=context[constants.CTX_TARGET_PLATFORM].(*types.Platform)
5252
debugLevel:=utils.DebugLevel(context)
5353
logger:=context[constants.CTX_LOGGER].(i18n.Logger)
@@ -57,11 +57,11 @@ func (s *LibrariesLoader) Run(context map[string]interface{}) error {
5757
returnutils.WrapError(err)
5858
}
5959

60-
librariesFolders=appendPathToLibrariesFolders(librariesFolders,filepath.Join(platform.Folder,constants.FOLDER_LIBRARIES))
60+
librariesFolders=prependPathToLibrariesFolders(librariesFolders,filepath.Join(platform.Folder,constants.FOLDER_LIBRARIES))
6161

6262
actualPlatform:=context[constants.CTX_ACTUAL_PLATFORM].(*types.Platform)
6363
ifactualPlatform!=platform {
64-
librariesFolders=appendPathToLibrariesFolders(librariesFolders,filepath.Join(actualPlatform.Folder,constants.FOLDER_LIBRARIES))
64+
librariesFolders=prependPathToLibrariesFolders(librariesFolders,filepath.Join(actualPlatform.Folder,constants.FOLDER_LIBRARIES))
6565
}
6666

6767
librariesFolders,err=utils.AbsolutizePaths(librariesFolders)
@@ -208,7 +208,7 @@ func makeLegacyLibrary(libraryFolder string) (*types.Library, error) {
208208
returnlibrary,nil
209209
}
210210

211-
funcappendPathToLibrariesFolders(librariesFolders []string,newLibrariesFolderstring) []string {
211+
funcprependPathToLibrariesFolders(librariesFolders []string,newLibrariesFolderstring) []string {
212212
ifstat,err:=os.Stat(newLibrariesFolder);os.IsNotExist(err)||!stat.IsDir() {
213213
returnlibrariesFolders
214214
}
@@ -217,5 +217,5 @@ func appendPathToLibrariesFolders(librariesFolders []string, newLibrariesFolder
217217
returnlibrariesFolders
218218
}
219219

220-
returnappend(librariesFolders,newLibrariesFolder)
220+
returnappend([]string{newLibrariesFolder},librariesFolders...)
221221
}

‎src/arduino.cc/builder/test/includes_to_include_folders_test.go‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func TestIncludesToIncludeFoldersANewLibrary(t *testing.T) {
162162
context[constants.CTX_FQBN]="arduino:avr:leonardo"
163163
context[constants.CTX_SKETCH_LOCATION]=filepath.Join("sketch10","sketch.ino")
164164
context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION]="10600"
165-
context[constants.CTX_LIBRARIES_FOLDERS]= []string{"libraries","downloaded_libraries"}
165+
context[constants.CTX_LIBRARIES_FOLDERS]= []string{"downloaded_libraries","libraries"}
166166
context[constants.CTX_VERBOSE]=false
167167

168168
commands:= []types.Command{
@@ -224,3 +224,40 @@ func TestIncludesToIncludeFoldersDuplicateLibs(t *testing.T) {
224224
require.Equal(t,"SPI",importedLibraries[0].Name)
225225
require.Equal(t,Abs(t,filepath.Join("user_hardware","my_avr_platform","avr","libraries","SPI")),importedLibraries[0].SrcFolder)
226226
}
227+
228+
funcTestIncludesToIncludeFoldersDuplicateLibs2(t*testing.T) {
229+
DownloadCoresAndToolsAndLibraries(t)
230+
231+
context:=make(map[string]interface{})
232+
233+
buildPath:=SetupBuildPath(t,context)
234+
deferos.RemoveAll(buildPath)
235+
236+
context[constants.CTX_HARDWARE_FOLDERS]= []string{filepath.Join("..","hardware"),"hardware","downloaded_hardware","downloaded_board_manager_stuff"}
237+
context[constants.CTX_TOOLS_FOLDERS]= []string{"downloaded_tools","downloaded_board_manager_stuff"}
238+
context[constants.CTX_FQBN]="arduino:samd:arduino_zero_native"
239+
context[constants.CTX_SKETCH_LOCATION]=filepath.Join("sketch_usbhost","sketch_usbhost.ino")
240+
context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION]="10600"
241+
context[constants.CTX_LIBRARIES_FOLDERS]= []string{"libraries","downloaded_libraries"}
242+
243+
commands:= []types.Command{
244+
&builder.SetupHumanLoggerIfMissing{},
245+
246+
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
247+
248+
&builder.ContainerMergeCopySketchFiles{},
249+
250+
&builder.ContainerFindIncludes{},
251+
}
252+
253+
for_,command:=rangecommands {
254+
err:=command.Run(context)
255+
NoError(t,err)
256+
}
257+
258+
importedLibraries:=context[constants.CTX_IMPORTED_LIBRARIES].([]*types.Library)
259+
sort.Sort(ByLibraryName(importedLibraries))
260+
require.Equal(t,1,len(importedLibraries))
261+
require.Equal(t,"USBHost",importedLibraries[0].Name)
262+
require.Equal(t,Abs(t,filepath.Join("libraries","USBHost","src")),importedLibraries[0].SrcFolder)
263+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#######################################
2+
# Syntax Coloring Map For USBHost
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
MouseControllerKEYWORD1
10+
USBHostKEYWORD1
11+
KeyboardControllerKEYWORD1
12+
13+
#######################################
14+
# Methods and Functions (KEYWORD2)
15+
#######################################
16+
17+
TaskKEYWORD2
18+
mouseMovedKEYWORD2
19+
mouseDraggedKEYWORD2
20+
mousePressedKEYWORD2
21+
mouseReleasedKEYWORD2
22+
getXChangeKEYWORD2
23+
getYChangeKEYWORD2
24+
getButtonKEYWORD2
25+
keyPressedKEYWORD2
26+
keyReleasedKEYWORD2
27+
getModifiersKEYWORD2
28+
getKeyKEYWORD2
29+
getOemKeyKEYWORD2
30+
31+
32+
#######################################
33+
# Constants (LITERAL1)
34+
#######################################
35+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name=USBHost
2+
version=1.0
3+
author=Arduino
4+
maintainer=Arduino <info@arduino.cc>
5+
sentence=Allows the communication with USB peripherals like mice, keyboards, and thumbdrives. For Arduino Due and Zero.
6+
paragraph=The USBHost library allows the board to appear as a USB host, enabling it to communicate with peripherals like USB mice and keyboards. USBHost does not support devices that are connected through USB hubs. This includes some keyboards that have an internal hub.
7+
url=http://arduino.cc/en/Reference/USBHost
8+
architectures=samd
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
Copyright (c) 2012 Arduino. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#include<KeyboardController.h>
20+
21+
extern"C" {
22+
void__keyboardControllerEmptyCallback() { }
23+
}
24+
25+
voidkeyPressed() __attribute__ ((weak, alias("__keyboardControllerEmptyCallback")));
26+
voidkeyReleased() __attribute__ ((weak, alias("__keyboardControllerEmptyCallback")));
27+
28+
voidKeyboardController::OnKeyDown(uint8_t _mod,uint8_t _oemKey) {
29+
modifiers = _mod;
30+
keyOem = _oemKey;
31+
key =OemToAscii(_mod, _oemKey);
32+
keyPressed();
33+
}
34+
35+
voidKeyboardController::OnKeyUp(uint8_t _mod,uint8_t _oemKey) {
36+
modifiers = _mod;
37+
keyOem = _oemKey;
38+
key =OemToAscii(_mod, _oemKey);
39+
keyReleased();
40+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Copyright (c) 2012 Arduino. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#ifndef KEYBOARD_CONTROLLER_H
20+
#defineKEYBOARD_CONTROLLER_H
21+
22+
#include<hidboot.h>
23+
24+
enum KeyboardModifiers {
25+
LeftCtrl =1,
26+
LeftShift =2,
27+
Alt =4,
28+
LeftCmd =8,
29+
RightCtrl =16,
30+
RightShift =32,
31+
AltGr =64,
32+
RightCmd =128
33+
};
34+
35+
classKeyboardController :publicKeyboardReportParser {
36+
public:
37+
KeyboardController(USBHost &usb) : hostKeyboard(&usb), key(0), keyOem(0), modifiers(0) {
38+
hostKeyboard.SetReportParser(0,this);
39+
};
40+
41+
uint8_tgetKey() {return key; };
42+
uint8_tgetModifiers() {return modifiers; };
43+
uint8_tgetOemKey() {return keyOem; };
44+
45+
protected:
46+
virtualvoidOnKeyDown(uint8_t mod,uint8_t key);
47+
virtualvoidOnKeyUp(uint8_t mod,uint8_t key);
48+
49+
private:
50+
HIDBoot<HID_PROTOCOL_KEYBOARD> hostKeyboard;
51+
uint8_t key, keyOem, modifiers;
52+
};
53+
54+
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp