2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 13:26:02 +00:00

Meta.pm: remove JSON::MaybeXS from metadata but keep compatibility

git-svn-id: https://svn.fhem.de/fhem/trunk@19217 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2019-04-18 15:30:39 +00:00
parent 96fdfe63c8
commit 476c7cbbdb
3 changed files with 119 additions and 81 deletions

View File

@ -34,6 +34,44 @@ use FHEM::Meta;
use GPUtils qw(GP_Import); use GPUtils qw(GP_Import);
use Data::Dumper; use Data::Dumper;
# Run before module compilation
BEGIN {
# JSON preference order
$ENV{PERL_JSON_BACKEND} =
'Cpanel::JSON::XS,JSON::XS,JSON::PP,JSON::backportPP'
unless ( defined( $ENV{PERL_JSON_BACKEND} ) );
# Import from main::
GP_Import(
qw(
readingsSingleUpdate
readingsBulkUpdate
readingsBulkUpdateIfChanged
readingsBeginUpdate
readingsEndUpdate
ReadingsTimestamp
defs
modules
Log3
Debug
DoTrigger
CommandAttr
attr
AttrVal
ReadingsVal
Value
IsDisabled
deviceEvents
init_done
gettimeofday
InternalTimer
RemoveInternalTimer
FW_webArgs
)
);
}
# try to use JSON::MaybeXS wrapper # try to use JSON::MaybeXS wrapper
# for chance of better performance + open code # for chance of better performance + open code
eval { eval {
@ -87,38 +125,6 @@ if ($@) {
} }
} }
# Run before module compilation
BEGIN {
# Import from main::
GP_Import(
qw(
readingsSingleUpdate
readingsBulkUpdate
readingsBulkUpdateIfChanged
readingsBeginUpdate
readingsEndUpdate
ReadingsTimestamp
defs
modules
Log3
Debug
DoTrigger
CommandAttr
attr
AttrVal
ReadingsVal
Value
IsDisabled
deviceEvents
init_done
gettimeofday
InternalTimer
RemoveInternalTimer
FW_webArgs
)
);
}
my %fhem_npm_modules = ( my %fhem_npm_modules = (
'alexa-fhem' => { fhem_module => 'alexa', }, 'alexa-fhem' => { fhem_module => 'alexa', },
'gassistant-fhem' => { fhem_module => 'gassistant', }, 'gassistant-fhem' => { fhem_module => 'gassistant', },
@ -1846,8 +1852,7 @@ sub ToDay() {
"SubProcess": 0 "SubProcess": 0
}, },
"recommends": { "recommends": {
"JSON": 0, "JSON": 0
"JSON::MaybeXS": 0
}, },
"suggests": { "suggests": {
"Cpanel::JSON::XS": 0, "Cpanel::JSON::XS": 0,

View File

@ -41,6 +41,51 @@ use Data::Dumper;
use Config; use Config;
use ExtUtils::Installed; use ExtUtils::Installed;
# Run before module compilation
BEGIN {
# JSON preference order
$ENV{PERL_JSON_BACKEND} =
'Cpanel::JSON::XS,JSON::XS,JSON::PP,JSON::backportPP'
unless ( defined( $ENV{PERL_JSON_BACKEND} ) );
# Import from main::
GP_Import(
qw(
attr
AttrVal
cmds
CommandAttr
Debug
defs
deviceEvents
devspec2array
DoTrigger
FW_webArgs
gettimeofday
init_done
InternalTimer
IsDisabled
LoadModule
Log
Log3
maxNum
modules
packages
readingsBeginUpdate
readingsBulkUpdate
readingsBulkUpdateIfChanged
readingsEndUpdate
readingsSingleUpdate
ReadingsTimestamp
ReadingsVal
RemoveInternalTimer
TimeNow
Value
)
);
}
# try to use JSON::MaybeXS wrapper # try to use JSON::MaybeXS wrapper
# for chance of better performance + open code # for chance of better performance + open code
eval { eval {
@ -86,53 +131,25 @@ if ($@) {
# Fallback to built-in JSON which SHOULD # Fallback to built-in JSON which SHOULD
# be available since 5.014 ... # be available since 5.014 ...
require JSON::PP; eval {
import JSON::PP qw(decode_json encode_json); require JSON::PP;
1; import JSON::PP qw(decode_json encode_json);
1;
};
if ($@) {
$@ = undef;
# Fallback to JSON::backportPP in really rare cases
require JSON::backportPP;
import JSON::backportPP qw(decode_json encode_json);
1;
}
} }
} }
} }
} }
# Run before module compilation
BEGIN {
# Import from main::
GP_Import(
qw(
attr
AttrVal
cmds
CommandAttr
Debug
defs
deviceEvents
devspec2array
DoTrigger
FW_webArgs
gettimeofday
init_done
InternalTimer
IsDisabled
LoadModule
Log
Log3
maxNum
modules
packages
readingsBeginUpdate
readingsBulkUpdate
readingsBulkUpdateIfChanged
readingsEndUpdate
readingsSingleUpdate
ReadingsTimestamp
ReadingsVal
RemoveInternalTimer
TimeNow
Value
)
);
}
# Load dependent FHEM modules as packages, # Load dependent FHEM modules as packages,
# no matter if user also defined FHEM devices or not. # no matter if user also defined FHEM devices or not.
# We want to use their functions here :-) # We want to use their functions here :-)
@ -1032,7 +1049,7 @@ sub CpanInstall($) {
print qq($line\n) if ( $cmd->{debug} == 1 ); print qq($line\n) if ( $cmd->{debug} == 1 );
if ( $line =~ if ( $line =~
/^Successfully\s+(\S+)\s+([\S]+)-(\d+\.\d+(?:_\d+)?).*$/i ) /^Successfully\s+(\S+)\s+([\S]+)-(\d+(?:\.\d+(?:_\d+)?)?).*$/i )
{ {
my $r = $1; my $r = $1;
my $m = $2; my $m = $2;
@ -1044,7 +1061,8 @@ sub CpanInstall($) {
} }
elsif ( $line =~ elsif ( $line =~
/^(\S+)\s+is\s+up\s+to\s+date.*\((\d+\.\d+(?:_\d+)?)\).*$/i ) /^(\S+)\s+is\s+up\s+to\s+date.*\((\d+(?:\.\d+(?:_\d+)?)?)\).*$/i
)
{ {
my $m = $1; my $m = $1;
my $v = $2; my $v = $2;
@ -5483,8 +5501,7 @@ sub __list_module {
}, },
"recommends": { "recommends": {
"Perl::PrereqScanner::NotQuiteLite": 0, "Perl::PrereqScanner::NotQuiteLite": 0,
"JSON": 0, "JSON": 0
"JSON::MaybeXS": 0
}, },
"suggests": { "suggests": {
"Cpanel::JSON::XS": 0, "Cpanel::JSON::XS": 0,

View File

@ -22,6 +22,11 @@ use Encode;
# Run before module compilation # Run before module compilation
BEGIN { BEGIN {
# JSON preference order
$ENV{PERL_JSON_BACKEND} =
'Cpanel::JSON::XS,JSON::XS,JSON::PP,JSON::backportPP'
unless ( defined( $ENV{PERL_JSON_BACKEND} ) );
# Import from main:: # Import from main::
GP_Import( GP_Import(
qw( qw(
@ -1293,6 +1298,18 @@ m/(^#\s+(?:\d{1,2}\.\d{1,2}\.(?:\d{2}|\d{4})\s+)?[^v\d]*(v?(?:\d{1,3}\.\d{1,3}(?
import JSON::PP qw(decode_json encode_json); import JSON::PP qw(decode_json encode_json);
1; 1;
}; };
if ($@) {
$@ = undef;
# Fallback to JSON::backportPP in really rare cases
eval {
require JSON::backportPP;
import JSON::backportPP
qw(decode_json encode_json);
1;
};
}
} }
} }
} }
@ -3155,7 +3172,6 @@ sub __SetXVersion {
}, },
"recommends": { "recommends": {
"JSON": 0, "JSON": 0,
"JSON::MaybeXS": 0,
"Perl::PrereqScanner::NotQuiteLite": 0, "Perl::PrereqScanner::NotQuiteLite": 0,
"Time::Local": 0 "Time::Local": 0
}, },