line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::ArduinoBuilder::System; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
19
|
use Cwd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
8
|
1
|
|
|
1
|
|
7
|
use Exporter 'import'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
9
|
1
|
|
|
1
|
|
415
|
use File::Spec::Functions 'catdir', 'rel2abs', 'canonpath'; |
|
1
|
|
|
|
|
850
|
|
|
1
|
|
|
|
|
69
|
|
10
|
1
|
|
|
1
|
|
7
|
use List::Util 'first'; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
416
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(find_arduino_dir system_cwd system_canonpath); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub find_arduino_dir { |
15
|
0
|
|
|
0
|
0
|
|
my @tests; |
16
|
0
|
0
|
0
|
|
|
|
if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'msys') { |
|
|
|
0
|
|
|
|
|
17
|
0
|
0
|
|
|
|
|
if (exists $ENV{LOCALAPPDATA}) { |
18
|
0
|
|
|
|
|
|
push @tests, catdir($ENV{LOCALAPPDATA}, 'Arduino15'); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
0
|
0
|
|
|
|
|
if ($^O ne 'MSWin32') { |
22
|
0
|
|
|
|
|
|
push @tests, '/usr/share/arduino', '/usr/local/share/arduino'; |
23
|
0
|
0
|
|
|
|
|
if (`which arduino 2>/dev/null` =~ m{^(.*)/bin/arduino}) { |
24
|
0
|
|
|
|
|
|
push @tests, catdir($1, 'share/arduino'); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
0
|
|
|
return first { -d } @tests; |
|
0
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub system_cwd { |
31
|
0
|
|
|
0
|
0
|
|
my $cwd = getcwd(); |
32
|
|
|
|
|
|
|
# Todo: we could have a "use_native_cygwin" option somewhere in the improbable |
33
|
|
|
|
|
|
|
# case of a native toolchain to deactivate this logic (as well as using |
34
|
|
|
|
|
|
|
# /dev/null instal of nul in the builder). |
35
|
0
|
0
|
|
|
|
|
if ($^O eq 'cygwin') { |
36
|
0
|
|
|
|
|
|
$cwd = `cygpath -w '${cwd}'`; |
37
|
0
|
|
|
|
|
|
chomp($cwd); |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
|
return $cwd; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Canonicalize a file path to be used to compare file paths (can’t be fed to |
43
|
|
|
|
|
|
|
# external utilities). |
44
|
|
|
|
|
|
|
sub system_canonpath { |
45
|
0
|
|
|
0
|
0
|
|
my ($path) = @_; |
46
|
0
|
|
|
|
|
|
my $canon = canonpath(rel2abs($path)); |
47
|
0
|
0
|
|
|
|
|
if ($^O eq 'cygwin') { |
48
|
0
|
|
|
|
|
|
$canon = `cygpath '$canon'`; |
49
|
0
|
|
|
|
|
|
chomp($canon); |
50
|
|
|
|
|
|
|
} |
51
|
0
|
|
|
|
|
|
return $canon; |
52
|
|
|
|
|
|
|
} |