374 lines
8.9 KiB
Perl
Executable File
374 lines
8.9 KiB
Perl
Executable File
#!/usr/bin/perl -W
|
|
# SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
|
#
|
|
# Copyright (c) 2024 Amlogic, Inc. All rights reserved.
|
|
#
|
|
|
|
my $arm64_dts = "arch/arm64/boot/dts/amlogic/";
|
|
my $arm_dts = "arch/arm/boot/dts/amlogic/";
|
|
my $err_cnt = 0;
|
|
my $exit = 0;
|
|
my $count64 = 0;
|
|
my $count32 = 0;
|
|
|
|
my $git_format_link="http://wiki-china.amlogic.com/Platform/Bootloader/Bootloader_commit_message_format";
|
|
my $config1 = "arch/arm64/configs/meson64_a64_smarthome_defconfig";
|
|
my $skip = 0;
|
|
my $make_build_link = "https://confluence.amlogic.com/display/SW/kernel+build";
|
|
my $make_defconfig_link = "https://confluence.amlogic.com/display/SW/01+kernel+config";
|
|
my $env_common = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
|
|
|
|
#Check mesonxx_defconfig
|
|
sub check_defconfig
|
|
{
|
|
my $arm64_config = `git diff HEAD --name-only arch/arm64/configs | grep -E 'smarthome_defconfig'`;
|
|
my @arm_config = `git diff HEAD --name-only arch/arm/configs | grep -E 'smarthome_defconfig|zapper_defconfig|C3_mini_defconfig'`;
|
|
#print "@arm_config\n";
|
|
my $is_common_drivers = `pwd | grep -E *common_drivers*`;
|
|
if ((!$arm64_config && !@arm_config) || !$is_common_drivers)
|
|
{
|
|
return 0;
|
|
}
|
|
my $err = 0;
|
|
#print "2. Check meson_defconfig: \n";
|
|
if( -e $config1 && $arm64_config )
|
|
{
|
|
`cd ../common/ && mkdir -p out/kernel-6.12/common`;
|
|
`cd ../common/ && export CROSS_COMPILE=/opt/arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-`;
|
|
`cd ../common/ && cp -rf ../common_drivers/$config1 arch/arm64/configs/`;
|
|
`cd ../common/ && make ARCH=arm64 -C ./ O=./out/kernel-6.12/common/ meson64_a64_smarthome_defconfig`;
|
|
`cd ../common/ && make ARCH=arm64 -C ./ O=./out/kernel-6.12/common/ savedefconfig`;
|
|
my $diff = `diff ../common/out/kernel-6.12/common/defconfig $config1`;
|
|
`cd ../common/ && rm -rf $config1`;
|
|
`cd ../common/ && rm -rf ./out`;
|
|
if(length($diff))
|
|
{
|
|
$err_cnt += 1;
|
|
$err = 1;
|
|
$err_msg .= " $err_cnt: meson64_a64_smarthome_defconfig not generated by savedefconfig\n";
|
|
}
|
|
}
|
|
|
|
if (@arm_config) {
|
|
foreach my $_arm_config (@arm_config) {
|
|
chomp $_arm_config;
|
|
if ($_arm_config =~ m{/([^/]*)$}) {
|
|
#print "$1\n";
|
|
$_arm_defconfig = $1;
|
|
}
|
|
#print "$_arm_config\n";
|
|
#print "$_arm_defconfig\n";
|
|
if( -e $_arm_config ) {
|
|
`cd ../common/ && mkdir -p out/kernel-6.12/common`;
|
|
`cd ../common/ && export CROSS_COMPILE=/opt/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-`;
|
|
`cd ../common/ && cp -rf ../common_drivers/$_arm_config arch/arm/configs/`;
|
|
`cd ../common/ && make ARCH=arm -C ./ O=./out/kernel-6.12/common/ $_arm_defconfig`;
|
|
`cd ../common/ && make ARCH=arm -C ./ O=./out/kernel-6.12/common/ savedefconfig`;
|
|
my $diff = `diff ../common/out/kernel-6.12/common/defconfig $_arm_config`;
|
|
`cd ../common/ && rm -rf $_arm_config`;
|
|
`cd ../common/ && rm -rf ./out`;
|
|
if(length($diff))
|
|
{
|
|
$err_cnt += 1;
|
|
$err = 1;
|
|
$err_msg .= " $err_cnt: $_arm_defconfig not generated by savedefconfig\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if($err)
|
|
{
|
|
$err_msg .= " Please refer to:\n";
|
|
$err_msg .= " $make_defconfig_link \n";
|
|
$err_msg .= " $make_build_link\n";
|
|
}
|
|
#print $err ? "fail\n" : "success\n";
|
|
}
|
|
|
|
sub boards_check
|
|
{
|
|
my $diff = `git diff HEAD --name-only | grep -E *dts\$`;
|
|
if(!$diff)
|
|
{
|
|
return 0;
|
|
}
|
|
my @diff_str = split /[\n]/, $diff;
|
|
my $dts64 = "";
|
|
my $dts = "";
|
|
my @dts64_str = ("");
|
|
my @dts_str = ("");
|
|
my %modified_boards;
|
|
my $all64_dts = `find $arm64_dts -name "*dts"`;
|
|
my $all_dts = `find $arm_dts -name "*dts"`;
|
|
my @all64_files = split(/\n/, $all64_dts);
|
|
my @all_files = split(/\n/, $all_dts);
|
|
|
|
for (@diff_str)
|
|
{
|
|
$_=~m/^(.*?)\_/;
|
|
if($1 =~ (/arch\/arm\/boot\/dts\/amlogic\//))
|
|
{
|
|
my $arch = "arm";
|
|
my $board = $';
|
|
$dts64 = `find $arm64_dts -name $board*`;
|
|
@dts64_str = split /[\n]/, $dts64;
|
|
$count32++;
|
|
$modified_boards{$board}{$arch}++;
|
|
}
|
|
elsif($1 =~ (/arch\/arm64\/boot\/dts\/amlogic\//))
|
|
{
|
|
my $arch = "arm64";
|
|
my $board = $';
|
|
$dts = `find $arm_dts -name $board*`;
|
|
@dts_str = split /[\n]/, $dts;
|
|
$count64++;
|
|
$modified_boards{$board}{$arch}++;
|
|
}
|
|
}
|
|
for my $board (keys %modified_boards) {
|
|
my $cnt64 = 0;
|
|
my $cnt = 0;
|
|
my $arms_modified = $modified_boards{$board}{'arm'} || 0;
|
|
my $arm64s_modified = $modified_boards{$board}{'arm64'} || 0;
|
|
for my $dts (@all64_files) {
|
|
if ($dts =~ $board) {
|
|
$cnt64 = 1;
|
|
}
|
|
}
|
|
for my $dts (@all_files) {
|
|
if ($dts =~ $board) {
|
|
$cnt = 1;
|
|
}
|
|
}
|
|
print $board;
|
|
if ($arm64s_modified > 0 && $arms_modified == 0 && $cnt == 1) {
|
|
$err_cnt += 1;
|
|
$err_msg .= " $err_cnt: Please confirm should you modify the same boards in arch/arm/boot/dts/amlogic/ too?\n";
|
|
}
|
|
elsif ($arms_modified > 0 && $arm64s_modified == 0 && $cnt64 == 1) {
|
|
$err_cnt += 1;
|
|
$err_msg .= " $err_cnt: Please confirm should you modify the same boards in arch/arm64/boot/dts/amlogic/ too?\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
sub dts_check
|
|
{
|
|
my @dts_path = @_;
|
|
my $dts_diff = "";
|
|
my $diff = `git diff HEAD --name-only @dts_path | grep -E *dts\$`;
|
|
if (!$diff)
|
|
{
|
|
return 0;
|
|
}
|
|
my $all_dts = `find @dts_path -name "*dts"`;
|
|
my @diff_str = split /[\n]/, $diff;
|
|
my @all_dts_str = split /[\n]/, $all_dts;
|
|
my $diff_count = 0;
|
|
my $all_dts_count = 0;
|
|
my $count = 0;
|
|
my $t = 0;
|
|
my $board = "";
|
|
my @diff_arry = ("");
|
|
my @board_arry = ("");
|
|
|
|
@diff_str = grep { !/pxp\.dts/ } @diff_str;
|
|
@all_dts_str = grep { !/pxp\.dts/ } @all_dts_str;
|
|
for (@diff_str)
|
|
{
|
|
$re = $_;
|
|
if ($re=~m/^(.*?)\_/)
|
|
{
|
|
$dts_diff = $1;
|
|
$dts_diff =~ /@dts_path/;
|
|
$board=$';
|
|
$dts_diff = $dts_diff."_";
|
|
}
|
|
for (@diff_str)
|
|
{
|
|
if ($_ =~ $dts_diff)
|
|
{
|
|
$_ =~ /@dts_path/;
|
|
$diff_arry->[$diff_count] = $';
|
|
$diff_count = $diff_count+1;
|
|
}
|
|
}
|
|
for (@all_dts_str)
|
|
{
|
|
if ($_ =~ $dts_diff)
|
|
{
|
|
$_ =~ /@dts_path/;
|
|
$all_dts_count=$all_dts_count+1;
|
|
}
|
|
}
|
|
if ($diff_count != $all_dts_count)
|
|
{
|
|
$count=$count+1;
|
|
}
|
|
if(($t == 0) && ($count ==0))
|
|
{
|
|
$diff_count = 0;
|
|
$all_dts_count = 0;
|
|
next;
|
|
}
|
|
if($t != 0)
|
|
{
|
|
if ($board_arry->[$t-1] =~ $board)
|
|
{
|
|
$count=0;
|
|
$diff_count = 0;
|
|
$all_dts_count = 0;
|
|
}
|
|
}
|
|
if ($count != 0)
|
|
{
|
|
$err_cnt += 1;
|
|
$err_msg .= " $err_cnt: Please confirm should you modify other boards for $board in @dts_path too? \n";
|
|
$err_msg .= " Now you have modified dts is ";
|
|
while($diff_count > 0)
|
|
{
|
|
$err_msg .= "$diff_arry->[$diff_count-1] ";
|
|
$diff_count=$diff_count-1;
|
|
}
|
|
$err_msg .= "\n";
|
|
$count = 0;
|
|
$diff_count = 0;
|
|
$all_dts_count = 0;
|
|
$board_arry->[$t]=$board;
|
|
$t=$t+1;
|
|
}
|
|
}
|
|
}
|
|
|
|
sub check_dtsi
|
|
{
|
|
my $arm64_file = `git diff HEAD --name-only $arm64_dts| grep -E *dtsi\$`;
|
|
my $arm_file = `git diff HEAD --name-only $arm_dts| grep -E *dtsi\$`;
|
|
my $all64_dtsi = `find $arm64_dts -name "*dtsi"`;
|
|
my $all_dtsi = `find $arm_dts -name "*dtsi"`;
|
|
my @all64_str = split /[\n]/, $all64_dtsi;
|
|
my @all_str = split /[\n]/, $all_dtsi;
|
|
my @diff64_str = split /[\n]/, $arm64_file;
|
|
my @diff_str = split /[\n]/, $arm_file;
|
|
my $count=0;
|
|
|
|
for(@diff_str)
|
|
{
|
|
$_ =~ (/arch\/arm\/boot\/dts\/amlogic\//);
|
|
$dtsi_diff = $';
|
|
$count = 0;
|
|
for(@all64_str)
|
|
{
|
|
$_ =~ (/arch\/arm64\/boot\/dts\/amlogic\//);
|
|
if ($' eq $dtsi_diff)
|
|
{
|
|
if(!$arm64_file)
|
|
{
|
|
$err_cnt += 1;
|
|
$err_msg .= " $err_cnt: maybe should modify $dtsi_diff in arm64\n";
|
|
last;
|
|
}
|
|
for(@diff64_str)
|
|
{
|
|
$_ =~ (/arch\/arm64\/boot\/dts\/amlogic\//);
|
|
if($' eq $dtsi_diff)
|
|
{
|
|
$count +=1;
|
|
}
|
|
}
|
|
if($count == 0)
|
|
{
|
|
$err_cnt += 1;
|
|
$err_msg .= " $err_cnt: maybe should modify $dtsi_diff in arm64\n";
|
|
last;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for(@diff64_str)
|
|
{
|
|
$_ =~ (/arch\/arm64\/boot\/dts\/amlogic\//);
|
|
$dtsi_diff64 = $';
|
|
$count = 0;
|
|
for(@all_str)
|
|
{
|
|
$_ =~ (/arch\/arm\/boot\/dts\/amlogic\//);
|
|
if ($' eq $dtsi_diff64)
|
|
{
|
|
if(!$arm_file)
|
|
{
|
|
$err_cnt += 1;
|
|
$err_msg .= " $err_cnt: maybe should modify $dtsi_diff64 in arm\n";
|
|
last;
|
|
}
|
|
for(@diff_str)
|
|
{
|
|
$_ =~ (/arch\/arm\/boot\/dts\/amlogic\//);
|
|
if($' eq $dtsi_diff64)
|
|
{
|
|
$count +=1;
|
|
}
|
|
}
|
|
if($count == 0)
|
|
{
|
|
$err_cnt += 1;
|
|
$err_msg .= " $err_cnt: maybe should modify $dtsi_diff64 in arm\n";
|
|
last;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
# check module_param number
|
|
sub check_module_param
|
|
{
|
|
# my $num = `git format-patch -1 --stdout | grep -c "module_param("`;
|
|
my $num = `git diff HEAD | grep -c "module_param("`;
|
|
my $MAX_NUM = 5;
|
|
|
|
if( $num > $MAX_NUM )
|
|
{
|
|
$err_cnt += 1;
|
|
$err_msg .= " $err_cnt: the number of module_param too much\n";
|
|
}
|
|
}
|
|
|
|
sub out_review
|
|
{
|
|
my $out_msg = "";
|
|
my $out_file = "../output/review.txt";
|
|
|
|
if ($err_cnt)
|
|
{
|
|
$out_msg = <<END;
|
|
\$ git reset HEAD^ | ./scripts/amlogic/merge_check.pl
|
|
total $err_cnt errors.
|
|
${err_msg}
|
|
|
|
END
|
|
|
|
$exit = 1;
|
|
print $out_msg;
|
|
}
|
|
else
|
|
{
|
|
print "";
|
|
}
|
|
}
|
|
check_defconfig();
|
|
boards_check();
|
|
if($count64)
|
|
{
|
|
dts_check($arm64_dts);
|
|
}
|
|
if($count32)
|
|
{
|
|
dts_check($arm_dts);
|
|
}
|
|
check_dtsi();
|
|
check_module_param();
|
|
out_review();
|
|
exit $exit;
|