Qt automatically add the resource file

Adding QML resources to do the project when we add a file, often forget to add the resource compiler, debugger lead to the deployment file not found error when it will appear. In particular partakers desktop version and machine engineering, in the desktop version obviously good debugging interface, the machine is deployed into error (when I first came to the company committed such a mistake). Then we created a script that automatically help us to add resources.


Language script using perl language, currently I do not understand this language, in order to retain only the record here and hope to be able to help you in need of help.


// Here is the script content


@all_Source_file = & find_all_file ( "DynavinQml", 1);
@ all_Source_file2 = & find_all_file ( "DynavinQml \ / MediaPlayer", 1);
@ all_Source_file3 = & find_all_file ( "DynavinQml \ / DiscPlayer", 1);
@ all_Source_file4 & find_all_file = ( "DynavinQml \ / PageMenu",. 1);






Open (OUT, "> os.qrc") || Die "CAN Not Open os.qrc:! $";
Print OUT '<the RCC>'; Print OUT "\ n-";
Print OUT '<qresource prefix = "/">';

if (
$ dir = ~ /.qml/ ||
$ dir = ~ /.bmp/ ||
$ dir = ~ /.gif/ ||
$ Dir = ~ /.png/
) { 
if ($dir =~ /DynavinQml\/MediaPlayer\//){ next; }
if ($dir =~ /DynavinQml\/DiscPlayer\//) { next; }
if ($dir =~ /DynavinQml\/PageMenu\//) { next; }


print OUT "        <file>$dir</file>\n";
}
}
print OUT '    </qresource>'; print OUT "\n";
print OUT '</RCC>';
close(OUT) || die "can't close DynavinInclude.pri:$!";


open(OUT, ">MediaRes.qrc") || die "can't open MediaRes.qrc:$!";
print OUT '<RCC>'; print OUT "\n";
print OUT '    <qresource prefix="/">'; print OUT "\n";
for $dir (@all_Source_file2){
if (
$ dir = ~ /.qml/ ||
$ dir = ~ /.bmp/ ||
$ dir = ~ /.gif/ ||
$ Dir = ~ /.png/
) { 
print OUT "        <file>$dir</file>\n";
}
}
print OUT '    </qresource>'; print OUT "\n";
print OUT '</RCC>';
close(OUT) || die "can't close DynavinInclude.pri:$!";



open(OUT, ">DiscRes.qrc") || die "can't open DiscRes.qrc:$!";
print OUT '<RCC>'; print OUT "\n";
print OUT '    <qresource prefix="/">'; print OUT "\n";
for $dir (@all_Source_file3){
if (
$ dir = ~ /.qml/ ||
$ dir = ~ /.bmp/ ||
$ dir = ~ /.gif/ ||
$ Dir = ~ /.png/
) { 
print OUT "        <file>$dir</file>\n";
}
}
print OUT '    </qresource>'; print OUT "\n";
print OUT '</RCC>';
close(OUT) || die "can't close DynavinInclude.pri:$!";






open(OUT, ">MenuRes.qrc") || die "can't open MenuRes.qrc:$!";
print OUT '<RCC>'; print OUT "\n";
print OUT '    <qresource prefix="/">'; print OUT "\n";
for $dir (@all_Source_file4){
if (
$ dir = ~ /.qml/ ||
$ dir = ~ /.bmp/ ||
$ dir = ~ /.gif/ ||
$ Dir = ~ /.png/
) { 
print OUT "        <file>$dir</file>\n";
}
}
print OUT '    </qresource>'; print OUT "\n";
print OUT '</RCC>';
close(OUT) || die "can't close DynavinInclude.pri:$!";







#parameter: @_ : folder position
sub find_all_dir() {
local($Source, $l_bInit) = @_;
if ($Source =~ /.git/) { return; }
opendir(DIR,"$Source" || die "can't open this $Source");
    local @files = readdir(DIR);
    closedir(DIR);
    for $file (@files){
        next if($file=~m/\.$/ || $file =~m/\.\.$/);
        if (-f "$Source/$file"){
            #print "$Source\/$file \n";
        }
        elsif(-d "$Source/$file"){
push(@dirs, "$Source\/$file");
            find_all_dir("$Source/$file", 0);
        }
    }
return @dirs;
}


#parameter: @_ : folder position
sub find_all_file() {
    local($dir, $l_bInit) = @_;
if ($l_bInit) { @files_out = (); }

if ($dir =~ /.git/) { 
#print "---------------------------------------------- $dir \n"; 
#return; 
}

opendir(DIR,"$dir" || die "can't open this $dir");
    local @files = readdir(DIR);
    closedir(DIR);
    for $file (@files){
        next if($file=~m/\.$/ || $file =~m/\.\.$/);
        if (-f "$dir/$file"){
            # print "$dir\/$file \n";
push(@files_out, "$dir\/$file");
        }
        elsif(-d "$dir/$file"){
           find_all_file("$dir/$file", 0);
        }
    }
return @files_out;
}


sub bDir_IsExist_File() {
local($Source, $string) = @_;
opendir(DIR,"$Source" || die "can't open this $Source");
    local @files = readdir(DIR);
    closedir(DIR);
    for $file (@files){
        next if($file=~m/\.$/ || $file =~m/\.\.$/);
        if (-f "$Source/$file"){
if(rindex($file, $string) == (length($file) - length($string)) ) {  #$string is $file`s end string
return 1; 
}
        }
    }


return 0;
}




// script material ends


@all_Source_file = & find_all_file ( "DynavinQml",. 1);
@ all_Source_file2 = & find_all_file ( "DynavinQml \ / the MediaPlayer",. 1);
@ all_Source_file3 = & find_all_file ( "DynavinQml \ / DiscPlayer",. 1) ;
@ all_Source_file4 = & find_all_file ( "DynavinQml \ / PageMenu", 1);
the above four points resource files, this depends on personal needs. A resource file is too large to compile may appear insufficient heap memory (the encounter)
Note that there is a corresponding resource files in the project.


The script file named qrc_make.pl (personal name)

Execute perl qrc_make.pl (I try Git tool to perform).


Guess you like

Origin blog.csdn.net/DreamSonGO/article/details/78052277