📄 am_edit
字号:
my $KDE_DIST = ""; foreach $file (keys %foundfiles) { if ($foundfiles{$file} == 1) { $KDE_DIST .= "$file "; } } if ($KDE_DIST) { print "KDE_DIST $printname $KDE_DIST\n" if ($verbose); my $lookup = "DISTFILES *=(.*)"; if ($MakefileData =~ /\n$lookup\n/o) { substituteLine($lookup, "KDE_DIST=$KDE_DIST\n\nDISTFILES=$1 \$(KDE_DIST)\n"); } }}#-----------------------------------------------------------------------------# Returns 0 if the line was processed - 1 otherwise.# Errors are logged in the global $errorflagssub tag_DOCFILES (){# if ($MakefileData =~ /\nSUBDIRS\s*=/) { # subdirs# $MakefileData =~ /\n(.*-recursive:\s*)\n/;# my $orig_rules = $1;# my $rules = $orig_rules;# $rules =~ s/:\s*$//;# substituteLine($orig_rules, "$rules docs-recursive:");# appendLines("docs: docs-recursive docs-am\n");# } else {# appendLines("docs: docs-am\n");# } $target_adds{"all"} .= "docs-am "; my $lookup = 'KDE_DOCS\s*=\s*([^\n]*)'; goto nodocs if ($MakefileData !~ /\n$lookup/o); print STDOUT "KDE_DOCS processing <$1>\n" if ($verbose); my $tmp = $1; # Either find the files in the directory (AUTO) or use # only the specified po files. my $files = ""; my $appname = $tmp; $appname =~ s/^(\S*)\s*.*$/$1/; if ($appname =~ /AUTO/) { $appname = basename($makefileDir); if ("$appname" eq "en") { print STDERR "Error: KDE_DOCS = AUTO relies on the directory name. Yours is 'en' - you most likely want something else, e.g. KDE_DOCS = myapp\n"; exit(1); } } if ($tmp !~ / - /) { opendir (THISDIR, "."); foreach $entry (readdir(THISDIR)) { next if ($entry eq "CVS" || $entry =~ /^\./ || $entry =~ /^Makefile/ || $entry =~ /~$/ || $entry =~ /^\#.*\#$/); next if (! -f $entry); $files .= "$entry "; } closedir (THISDIR); print STDOUT "docfiles found = $files\n" if ($verbose); } else { $tmp =~ s/\034/ /g; $tmp =~ s/^\S*\s*-\s*//; $files = $tmp; } goto nodocs if (!$files); # Nothing to do if ($files =~ /(^| )index\.docbook($| )/) { my $lines = ""; my $lookup = 'MEINPROC\s*='; if ($MakefileData !~ /\n($lookup)/) { $lines = "MEINPROC=/\$(kde_bindir)/meinproc\n"; } $lookup = 'KDE_XSL_STYLESHEET\s*='; if ($MakefileData !~ /\n($lookup)/) { $lines .= "KDE_XSL_STYLESHEET=/\$(kde_datadir)/ksgmltools2/customization/kde-chunk.xsl\n"; } $lookup = '\nindex.cache.bz2:'; if ($MakefileData !~ /\n($lookup)/) { $lines .= "index.cache.bz2: \$(srcdir)/index.docbook \$(KDE_XSL_STYLESHEET) $files\n"; $lines .= "\t-\@if test -n \"\$(MEINPROC)\"; then echo \$(MEINPROC) --check --cache index.cache.bz2 \$(srcdir)/index.docbook; \$(MEINPROC) --check --cache index.cache.bz2 \$(srcdir)/index.docbook; fi\n"; $lines .= "\n"; } $lines .= "docs-am: index.cache.bz2\n"; $lines .= "\n"; $lines .= "install-docs: docs-am install-nls\n"; $lines .= "\t\$(mkinstalldirs) \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname\n"; $lines .= "\t\@if test -f index.cache.bz2; then \\\n"; $lines .= "\techo \$(INSTALL_DATA) index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n"; $lines .= "\t\$(INSTALL_DATA) index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n"; $lines .= "\tfi\n"; $lines .= "\t-rm -f \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/common\n"; $lines .= "\t\$(LN_S) \$(kde_libs_htmldir)/$kdelang/common \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/common\n"; $lines .= "\n"; $lines .= "uninstall-docs:\n"; $lines .= "\t-rm -rf \$(kde_htmldir)/$kdelang/$appname\n"; $lines .= "\n"; $lines .= "clean-docs:\n"; $lines .= "\t-rm -f index.cache.bz2\n"; $lines .= "\n"; $target_adds{"install-data-am"} .= "install-docs "; $target_adds{"uninstall"} .= "uninstall-docs "; $target_adds{"clean-am"} .= "clean-docs "; appendLines ($lines); } else { appendLines("docs-am: $files\n"); } $target_adds{"install-data-am"} .= "install-nls"; $target_adds{"uninstall"} .= "uninstall-nls "; $tmp = "install-nls:\n"; $tmp .= "\t\$(mkinstalldirs) \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname\n"; $tmp .= "\t\@for base in $files; do \\\n"; $tmp .= "\t echo \$(INSTALL_DATA) \$\$base \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$base ;\\\n"; $tmp .= "\t \$(INSTALL_DATA) \$(srcdir)/\$\$base \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$base ;\\\n"; $tmp .= "\tdone\n"; if ($appname eq 'common') { $tmp .= "\t\@echo \"merging common and language specific dir\" ;\\\n"; $tmp .= "\tif test ! -e \$(kde_htmldir)/en/common/kde-common.css; then echo 'no english docs found in \$(kde_htmldir)/en/common/'; exit 1; fi \n"; $tmp .= "\t\@com_files=`cd \$(kde_htmldir)/en/common && echo *` ;\\\n"; $tmp .= "\tcd \$(DESTDIR)\$(kde_htmldir)/$kdelang/common ;\\\n"; $tmp .= "\tif test -n \"\$\$com_files\"; then for p in \$\$com_files ; do \\\n"; $tmp .= "\t case \" $files \" in \\\n"; $tmp .= "\t *\" \$\$p \"*) ;; \\\n"; $tmp .= "\t *) test ! -e \$\$p && echo \$(LN_S) ../../en/common/\$\$p \$(DESTDIR)\$(kde_htmldir)/$kdelang/common/\$\$p && \$(LN_S) ../../en/common/\$\$p \$\$p ;; \\\n"; $tmp .= "\t esac ; \\\n"; $tmp .= "\tdone ; fi ; true\n"; } $tmp .= "\n"; $tmp .= "uninstall-nls:\n"; $tmp .= "\tfor base in $files; do \\\n"; $tmp .= "\t rm -f \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$base ;\\\n"; $tmp .= "\tdone\n\n"; appendLines ($tmp); $target_adds{"distdir"} .= "distdir-nls "; $tmp = "distdir-nls:\n"; $tmp .= "\tfor file in $files; do \\\n"; $tmp .= "\t cp \$(srcdir)/\$\$file \$(distdir); \\\n"; $tmp .= "\tdone\n"; appendLines ($tmp); return 0; nodocs: appendLines("docs-am:\n"); return 1;}#-----------------------------------------------------------------------------# Find headers in any of the source directories specified previously, that# are candidates for "moc-ing".sub findMocCandidates (){ foreach $dir (@headerdirs) { my @list = (); opendir (SRCDIR, "$dir"); @hFiles = grep { /.+\.$hExt$/o && !/^\./ } readdir(SRCDIR); closedir SRCDIR; foreach $hf (@hFiles) { next if ($hf =~ /^\.\#/); $hf =~ /(.*)\.[^\.]*$/; # Find name minus extension next if ($uiFiles{$1}); open (HFIN, "$dir/$hf") || die "Could not open $dir/$hf: $!\n"; my $hfsize = 0; seek(HFIN, 0, 2); $hfsize = tell(HFIN); seek(HFIN, 0, 0); read HFIN, $hfData, $hfsize; close HFIN; # push (@list, $hf) if(index($hfData, "Q_OBJECT") >= 0); ### fast but doesn't handle //Q_OBJECT if ( $hfData =~ /{([^}]*)Q_OBJECT/s ) { ## handle " { friend class blah; Q_OBJECT " push (@list, $hf) unless $1 =~ m://[^\n]*Q_OBJECT[^\n]*$:s; ## handle "// Q_OBJECT" } } # The assoc array of root of headerfile and header filename foreach $hFile (@list) { $hFile =~ /(.*)\.[^\.]*$/; # Find name minus extension if ($mocFiles{$1}) { print STDERR "Warning: Multiple header files found for $1\n"; next; # Use the first one } $mocFiles{$1} = "$dir\035$hFile"; # Add relative dir } } return 0;}#-----------------------------------------------------------------------------# The programmer has specified a moc list. Prune out the moc candidates# list that we found based on looking at the header files. This generates# a warning if the programmer gets the list wrong, but this doesn't have# to be fatal here.sub pruneMocCandidates ($){ my %prunedMoc = (); local @mocList = split(' ', $_[0]); foreach $mocname (@mocList) { $mocname =~ s/\.moc$//; if ($mocFiles{$mocname}) { $prunedMoc{$mocname} = $mocFiles{$mocname}; } else { my $print = $makefileDir; $print =~ s/^\Q$topdir\E\\//; # They specified a moc file but we can't find a header that # will generate this moc file. That's possible fatal! print STDERR "Warning: No moc-able header file for $print/$mocname\n"; } } undef %mocFiles; %mocFiles = %prunedMoc;}#-----------------------------------------------------------------------------# Finds the cpp files (If they exist).# The cpp files get appended to the header file separated by \035sub checkMocCandidates (){ my @cppFiles; my $cpp2moc; # which c++ file includes which .moc files my $moc2cpp; # which moc file is included by which c++ files return unless (keys %mocFiles); opendir(THISDIR, ".") || return; @cppFiles = grep { /.+\.$cppExt$/o && !/.+\.moc\.$cppExt$/o && !/.+\.all_$cppExt\.$cppExt$/o && !/^\./ } readdir(THISDIR); closedir THISDIR; return unless (@cppFiles); my $files = join (" ", @cppFiles); $cpp2moc = {}; $moc2cpp = {}; foreach $cxxf (@cppFiles) { open (CXXFIN, $cxxf) || die "Could not open $cxxf: $!\n"; seek(CXXFIN, 0, 2); my $cxxfsize = tell(CXXFIN); seek(CXXFIN, 0, 0); read CXXFIN, $cxxfData, $cxxfsize; close CXXFIN; while(($cxxfData =~ m/^[ \t]*\#include\s*[<\"](.*\.moc)[>\"]/gm)) { $cpp2moc->{$cxxf}->{$1} = 1; $moc2cpp->{$1}->{$cxxf} = 1; } } foreach my $mocFile (keys (%mocFiles)) { @cppFiles = keys %{$moc2cpp->{"$mocFile.moc"}}; if (@cppFiles == 1) { $mocFiles{$mocFile} .= "\035" . $cppFiles[0]; push(@deped, $mocFile); } elsif (@cppFiles == 0) { push (@newObs, $mocFile); # Produce new object file next if ($haveAutomocTag); # This is expected... # But this is an error we can deal with - let them know print STDERR "Warning: No c++ file that includes $mocFile.moc\n"; } else { # We can't decide which file to use, so it's fatal. Although as a # guess we could use the mocFile.cpp file if it's in the list??? print STDERR "Error: Multiple c++ files that include $mocFile.moc\n"; print STDERR "\t",join ("\t", @cppFiles),"\n"; $errorflag = 1; delete $mocFiles{$mocFile}; # Let's continue and see what happens - They have been told! } }}#-----------------------------------------------------------------------------# Add the rules for generating moc source from header files# For Automoc output *.moc.cpp but normally we'll output *.moc# (We must compile *.moc.cpp separately. *.moc files are included# in the appropriate *.cpp file by the programmer)sub addMocRules (){ my $cppFile; my $hFile; foreach $mocFile (keys (%mocFiles)) { undef $cppFile; ($dir, $hFile, $cppFile) = split ("\035", $mocFiles{$mocFile}, 3); $dir =~ s#^\.#\$(srcdir)#; if (defined ($cppFile)) { $target_adds{"\$(srcdir)/$cppFile"} .= "$mocFile.moc "; appendLines ("$mocFile.moc: $dir/$hFile\n\t\$(MOC) $dir/$hFile -o $mocFile.moc\n"); $cleanMoc .= " $mocFile.moc"; } else { appendLines ("$mocFile$mocExt: $dir/$hFile\n\t\$(MOC) $dir/$hFile -o $mocFile$mocExt\n"); $cleanMoc .= " $mocFile$mocExt"; } }}sub make_meta_classes (){ return if ($kdeopts{"qtonly"}); my $cppFile; my $hFile; my $moc_class_headers = ""; foreach $program (@programs) { my $mocs = ""; my @progsources = split(/[\s\034]+/, $sources{$program}); my @depmocs = split(' ', $depedmocs{$program}); my %shash = (), %mhash = (); @shash{@progsources} = 1; # we are only interested in the existence @mhash{@depmocs} = 1; print STDOUT "program=$program\n" if ($verbose); print STDOUT "psources=[".join(' ', keys %shash)."]\n" if ($verbose); print STDOUT "depmocs=[".join(' ', keys %mhash)."]\n" if ($verbose); print STDOUT "globalmocs=[".join(' ', keys(%globalmocs))."]\n" if ($verbose); foreach my $mocFile (keys (%globalmocs)) { undef $cppFile; ($dir, $hFile, $cppFile) = split ("\035", $globalmocs{$mocFile}, 3); $dir =~ s#^\.#\$(srcdir)#; if (defined ($cppFile)) { $mocs .= " $mocFile.moc" if exists $shash{$cppFile}; } else { # Bah. This is the case, if no C++ file includes the .moc # file. We make a .moc.cpp file for that. Unfortunately this # is not included in the %sources hash, but rather is mentioned # in %depedmocs. If the user wants to use AUTO he can't just # use an unspecific METAINCLUDES. Instead he must use # program_METAINCLUDES. Anyway, it's not working real nicely. # E.g. Its not clear what happens if user specifies two # METAINCLUDES=AUTO in the same Makefile.am. $mocs .= " $mocFile.moc.$cxxsuffix" if exists $mhash{$mocFile.".moc.$cxxsuffix"}; } } if ($mocs) { print STDOUT "==> mocs=[".$mocs."]\n" if ($verbose); my $sourcename = $program."_meta_unload"; my $ext = ($program =~ /_la$/) ? ".lo" : ".o"; my $srcfile = $sourcename.".$cxxsuffix"; my $objfile = $sourcename.$ext; $moc_class_headers .= " $srcfile"; my $appl; $appl = "$srcfile: $mocs\n"; $appl .= "\t\@echo 'creating $srcfile'\n"; $appl .= "\t\@-rm -f $srcfile\n"; $appl .= "\t\@if test \${kde_qtver} = 2; then \\\n"; $appl .= "\t\techo 'static const char * _metalist_$program\[\] = {' > $srcfile ;\\\n"; $appl .= "\t\tcat $mocs | grep 'char.*className' | "; $appl .= "sed -e 's/.*[^A-Za-z0-9_:]\\([A-Za-z0-9_:]*\\)::cl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -