Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,7 @@ Asymptote (asy)
AutoHotkey (ahk, ahkl)
awk (auk, awk, gawk, mawk, nawk)
Bazel (BUILD)
BitBake (bb, bbappend, bbclass)
BizTalk Orchestration (odx)
BizTalk Pipeline (btp)
Blade (blade, blade.php)
Expand Down Expand Up @@ -1259,7 +1260,7 @@ peggy (peggy)
Perl (ack, al, cpanfile, makefile.pl, perl, ph, plh, plx, pm, psgi, rexfile, pl, p6)
Pest (pest)
PHP (aw, ctp, phakefile, php, php3, php4, php5, php_cs, php_cs.dist, phps, phpt, phtml)
PHP/Pascal/Fortran/Pawn (inc)
PHP/Pascal/Fortran/Pawn/Bitbake (inc)
Pig Latin (pig)
PL/I (pl1)
PL/M (lit, plm)
Expand Down Expand Up @@ -1340,6 +1341,7 @@ Teamcenter mth (mth)
Templ (templ)
TeX (aux, bbx, bib, bst, cbx, dtx, ins, lbx, ltx, mkii, mkiv, mkvi, sty, tex, cls)
Text (text, txt)
Unknown/BitBake (conf)
Thrift (thrift)
TITAN Project File Information (tpd)
Titanium Style Sheet (tss)
Expand Down Expand Up @@ -1408,13 +1410,14 @@ These file extensions map to multiple languages:
* `cj` files could be Clojure or Cangjie
* `cl` files could be Lisp or OpenCL
* `cls` files could be Visual Basic, TeX or Apex Class
* `conf` files could be BitBake or plain text
* `cs` files could be C# or Smalltalk
* `d` files could be D or dtrace
* `f` files could be Fortran 77 or Forth
* `fnc` files could be Oracle PL or SQL
* `for` files could be Fortran 77 or Forth
* `fs` files could be F# or Forth
* `inc` files could be PHP or Pascal
* `inc` files could be PHP, Pascal or BitBake
* `itk` files could be Tcl or Tk
* `jl` files could be Lisp or Julia
* `lit` files could be PL or M
Expand Down
14 changes: 14 additions & 0 deletions Unix/t/00_C.t
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ my @Tests = (
'ref' => '../tests/outputs/BUILD.yaml',
'args' => '../tests/inputs/BUILD',
},
{
'name' => 'BitBake',
'ref' => '../tests/outputs/bitbake.yaml',
'args' => '../tests/inputs/hello_1.0.bb ' .
'../tests/inputs/cpp-example.inc ' .
'../tests/inputs/layer.conf ',
},
{
'name' => 'BizTalk Orchestration',
'ref' => '../tests/outputs/ProcessPO.odx.yaml',
Expand Down Expand Up @@ -1401,6 +1408,13 @@ my @Tests = (
'args' => '../tests/inputs/fractal.um',
},

{
'name' => 'Unknown',
# No result will be produced, result.yaml will stay like the previous test
'ref' => '../tests/outputs/fractal.um.yaml',
'args' => '../tests/inputs/xattr.conf',
},

{
'name' => 'USS',
'ref' => '../tests/outputs/USS.uss.yaml',
Expand Down
106 changes: 90 additions & 16 deletions cloc
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ my %Extension_Collision = (
'Pascal/Pawn' => [ 'p' ] ,
'Pascal/Puppet' => [ 'pp' ] ,
'Perl/Prolog' => [ 'pl', 'PL' ] ,
'PHP/Pascal/Fortran/Pawn' => [ 'inc' ] ,
'PHP/Pascal/Fortran/Pawn/BitBake' => [ 'inc' ] ,
'Raku/Prolog' => [ 'p6', 'P6' ] ,
'XML-Qt-GTK/Glade' => [ 'ui' ] ,
'TypeScript/Qt Linguist' => [ 'ts' ] ,
Expand All @@ -831,6 +831,7 @@ my %Extension_Collision = (
'Scheme/SaltStack' => [ 'sls' ] ,
'SKILL/.NET IL' => [ 'il' ] ,
'Clojure/Cangjie' => [ 'cj' ] ,
'Unknown/BitBake' => [ 'conf' ] ,
);
my @Autogen_to_ignore = no_autogen_files($list_no_autogen);
if ($opt_force_lang_def) {
Expand Down Expand Up @@ -6809,17 +6810,17 @@ sub classify_file { # {{{1
'failure in matlab_or_objective_C($full_file)';
return $language; # (unknown)
}
} elsif ($Language_by_Extension{$extension} eq 'PHP/Pascal/Fortran/Pawn') {
my $lang_F_or_P_or_P = "";
php_pascal_fortran_pawn($full_file ,
} elsif ($Language_by_Extension{$extension} eq 'PHP/Pascal/Fortran/Pawn/BitBake') {
my $lang_F_or_P_or_P_or_B = "";
php_pascal_fortran_pawn_bitbake($full_file ,
$rh_Err ,
$raa_errors,
\$lang_F_or_P_or_P);
if ($lang_F_or_P_or_P) {
return $lang_F_or_P_or_P;
} else { # an error happened in php_pascal_or_fortran()
\$lang_F_or_P_or_P_or_B);
if ($lang_F_or_P_or_P_or_B) {
return $lang_F_or_P_or_P_or_B;
} else { # an error happened in php_pascal_fortran_pawn_bitbake()
$rh_ignored->{$full_file} =
'failure in php_pascal_fortran_pawn($full_file)';
'failure in php_pascal_fortran_pawn_bitbake($full_file)';
return $language; # (unknown)
}
} elsif ($Language_by_Extension{$extension} eq 'Pascal/Puppet') {
Expand Down Expand Up @@ -6934,6 +6935,9 @@ sub classify_file { # {{{1
} else {
return $language; # (unknown)
}
} elsif ($Language_by_Extension{$extension} eq 'Unknown/BitBake') {
my $lang_t_or_b = "";
return really_is_BitBake($full_file, $rh_Err, $raa_errors);
} else {
return $Language_by_Extension{$extension};
}
Expand Down Expand Up @@ -9108,7 +9112,7 @@ sub set_constants { # {{{1
'ig' => 'Modula3' ,
'il' => 'SKILL/.NET IL' ,
'ils' => 'SKILL++' ,
'inc' => 'PHP/Pascal/Fortran/Pawn',
'inc' => 'PHP/Pascal/Fortran/Pawn/BitBake' ,
'ino' => 'Arduino Sketch' ,
'ipf' => 'Igor Pro' ,
#'pde' => 'Arduino Sketch' , # pre 1.0
Expand Down Expand Up @@ -9765,6 +9769,10 @@ sub set_constants { # {{{1
'zig' => 'Zig' ,
'zsh' => 'zsh' ,
'rego' => 'Rego' ,
'bb' => 'BitBake' ,
'bbappend' => 'BitBake' ,
'bbclass' => 'BitBake' ,
'conf' => 'Unknown/BitBake' ,
);
# 1}}}
%{$rh_Language_by_Script} = ( # {{{1
Expand Down Expand Up @@ -10815,7 +10823,7 @@ sub set_constants { # {{{1
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
],
'PHP/Pascal/Fortran/Pawn' => [ [ 'die' , ], ], # never called
'PHP/Pascal/Fortran/Pawn/BitBake' => [ [ 'die' , ], ], # never called
'Mako' => [
[ 'remove_matches' , '##.*$' ],
],
Expand Down Expand Up @@ -11667,6 +11675,10 @@ sub set_constants { # {{{1
[ 'remove_matches' , '^\s*#' ],
[ 'remove_inline' , '#.*$' ],
],
"BitBake" => [
[ 'remove_matches' , '^\s*#' ],
[ 'remove_inline' , '#.*$' ],
],
);
# 1}}}
%{$rh_EOL_continuation_re} = ( # {{{1
Expand Down Expand Up @@ -12269,14 +12281,15 @@ sub set_constants { # {{{1
'Yang' => 3.00,
'Zig' => 2.50,
"Rego" => 1.00,
"BitBake" => 1.00,
# aggregates; value is meaningless
'C#/Smalltalk' => 1.00,
'D/dtrace' => 1.00,
'F#/Forth' => 1.00,
'Fortran 77/Forth' => 1.00,
'Lisp/Julia' => 1.00,
'Lisp/OpenCL' => 1.00,
'PHP/Pascal/Fortran/Pawn' => 1.00,
'PHP/Pascal/Fortran/Pawn/Bitbake' => 1.00,
'Pascal/Puppet' => 1.00,
'Perl/Prolog' => 1.00,
'Raku/Prolog' => 1.00,
Expand All @@ -12285,6 +12298,7 @@ sub set_constants { # {{{1
'IDL/Qt Project/Prolog/ProGuard' => 1.00,
'SKILL/.NET IL' => 1.00,
'Clojure/Cangjie' => 1.00,
'Unknown/BitBake' => 1.00,
);
# 1}}}
%{$rh_Known_Binary_Archives} = ( # {{{1
Expand Down Expand Up @@ -12549,7 +12563,7 @@ printf "END LOOP obj C=% 2d matlab=% 2d mumps=% 2d mercury= % 2d\n", $obje
if $opt_v > 2;

} # 1}}}
sub php_pascal_fortran_pawn { # {{{1
sub php_pascal_fortran_pawn_bitbake { # {{{1
# Decide if code is Fortran, PHP, Pascal, Pawn
my ($file , # in
$rh_Err , # in hash of error codes
Expand Down Expand Up @@ -12577,6 +12591,13 @@ sub php_pascal_fortran_pawn { # {{{1
# lines ending with ;
# has /* ... */ style comments
# writeln
#
# BitBake:
# some lines start with variables: SRC_URI, SRC_REV, SUMMARY, LICENSE, DEPENDS, RDEPENDS, LIC_FILES_CHKSUM
# some lines start with tasks: do_compile, do_install, do_configure, python
# some lines start with include, require, inherit statements
# contains .=, =., ?=, ??= operators
# contains :... = assignments

${$rs_language} = "";
my $IN = open_file('<', $file, 1);
Expand All @@ -12592,6 +12613,7 @@ sub php_pascal_fortran_pawn { # {{{1
my $php_points = 0;
my $pascal_points = 0;
my $pawn_points = 0;
my $bitbake_points = 0;
while (<$IN>) {
if (/^\s*<\?php/i) {
$php_points += 100;
Expand Down Expand Up @@ -12630,13 +12652,25 @@ sub php_pascal_fortran_pawn { # {{{1
/^\s*(end\s+)?(interface|type|function|module)\b/i) {
++$fortran_90;
}
if (/^\s*(SRC_URI|SRC_REV|SUMMARY|LICENSE|DEPENDS|RDEPENDS|LIC_FILES_CHKSUM)\s*=/i or
/^\s*(do_compile|do_install|do_configure|python)\b/i or
/^\s*(inherit|include|require)\b/i) {
++$bitbake_points;
}
if (/\.=/i or /=\./i or /\?=/i or /\?\?=/i) {
++$bitbake_points;
}
if (/^[A-Z0-9_:-]+:[A-Za-z0-9_-]+\s*=/) {
++$bitbake_points;
}
}
$IN->close;

my %points = ( 'Fortran' => $fortran_points ,
'PHP' => $php_points ,
'Pascal' => $pascal_points ,
'Pawn' => $pawn_points , );
'Pawn' => $pawn_points ,
'BitBake' => $bitbake_points , );

${$rs_language} = (sort { $points{$b} <=> $points{$a} or $a cmp $b } keys %points)[0];
if (${$rs_language} eq 'Fortran') {
Expand All @@ -12647,8 +12681,8 @@ sub php_pascal_fortran_pawn { # {{{1
}
}

print "<- php_pascal_fortran_pawn($file: fortran=$fortran_points, php=$php_points, ",
"pascal=$pascal_points, pawn=$pawn_points) => ${$rs_language}\n"
print "<- php_pascal_fortran_pawn_bitbake($file: fortran=$fortran_points, php=$php_points, ",
"pascal=$pascal_points, pawn=$pawn_points, bitbake=$bitbake_points) => ${$rs_language}\n"
if $opt_v > 2;

} # 1}}}
Expand Down Expand Up @@ -13365,6 +13399,46 @@ sub Clojure_or_Cangjie { # {{{1
return "Cangjie";
}
} # 1}}}
sub really_is_BitBake { # {{{1
my ($file , # in
$rh_Err , # in hash of error codes
$raa_errors , # out
) = @_;

print "-> really_is_BitBake($file)\n" if $opt_v > 2;

my $lang = undef;
my $IN = open_file('<', $file, 1);
if (!defined $IN) {
push @{$raa_errors}, [$rh_Err->{'Unable to read'} , $file];
return $lang;
}
my $text = 3; # Text is assumed if no BitBake markers are found
my $bitbake = 0;
while (<$IN>) {
next if /^\s*$/;
if (/^\s*(SRC_URI|SRC_REV|SUMMARY|LICENSE|DEPENDS|RDEPENDS|LIC_FILES_CHKSUM)\s*=/i or
/^\s*(BBFILE|LAYER).*\s*=/i or
/^\s*(do_compile|do_install|do_configure|python)\b/i or
/^\s*(inherit|include|require)\b/i) {
++$bitbake;
}
if (/\.=/i or /=\./i or /\?=/i or /\?\?=/i) {
++$bitbake;
}
if (/^[A-Z0-9_:-]+:[A-Za-z0-9_-]+\s*=/) {
++$bitbake;
}
}
$IN->close;

print "<- really_is_BitBake($file: Text=$text, BitBake=$bitbake\n" if $opt_v > 2;
if ($text > $bitbake) {
return undef;
} else {
return "BitBake";
}
} # 1}}}
sub html_colored_text { # {{{1
# http://www.pagetutor.com/pagetutor/makapage/pics/net216-2.gif
my ($color, $text) = @_;
Expand Down
24 changes: 24 additions & 0 deletions tests/inputs/cpp-example.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

DEPENDS += "json-c"

PV = "1.0"

SRC_URI = "\
file://cpp-example.cpp \
file://cpp-example-lib.hpp \
file://cpp-example-lib.cpp \
file://test-cpp-example.cpp \
file://run-ptest \
"

S = "${WORKDIR}"

inherit ptest
18 changes: 18 additions & 0 deletions tests/inputs/hello_1.0.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Hello world from meta-skeleton
DESCRIPTION = "Simple helloworld application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://helloworld.c"

S = "${WORKDIR}"

do_compile() {
${CC} ${LDFLAGS} helloworld.c -o helloworld
}

do_install() {
install -d ${D}${bindir}
install -m 0755 helloworld ${D}${bindir}
}
17 changes: 17 additions & 0 deletions tests/inputs/layer.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"

# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "skeleton"
BBFILE_PATTERN_skeleton = "^${LAYERDIR}/"
BBFILE_PRIORITY_skeleton = "1"

# This should only be incremented on significant changes that will
# cause compatibility issues with other layers
LAYERVERSION_skeleton = "1"

LAYERDEPENDS_skeleton = "core"

LAYERSERIES_COMPAT_skeleton = "scarthgap"
22 changes: 22 additions & 0 deletions tests/inputs/xattr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# /etc/xattr.conf
#
# Format:
# <pattern> <action>
#
# Actions:
# permissions - copy when trying to preserve permissions.
# skip - do not copy.

system.nfs4_acl permissions
system.nfs4acl permissions
system.posix_acl_access permissions
system.posix_acl_default permissions
trusted.SGI_ACL_DEFAULT skip # xfs specific
trusted.SGI_ACL_FILE skip # xfs specific
trusted.SGI_CAP_FILE skip # xfs specific
trusted.SGI_DMI_* skip # xfs specific
trusted.SGI_MAC_FILE skip # xfs specific
xfsroot.* skip # xfs specific; obsolete
user.Beagle.* skip # ignore Beagle index data
security.evm skip # may only be written by kernel
afs.* skip # AFS metadata and ACLs
Loading