Stuart Henderson([email protected]) on 2017.12.01 14:26:06 +0000:
> On 2017/12/01 14:54, Klemens Nanni wrote:
> > On Thu, Nov 09, 2017 at 12:11:05AM +0100, Klemens Nanni wrote:
> > > Hey ports@,
> > >
> > > here's https://gitlab.com/esr/loccount/, from DESCR:
> > >
> > > loccount is a re-implementation of David A. Wheeler's sloccount tool in
> > > Go. It is faster and handles more different languages. Because it's one
> > > source file in Go, it is easier to maintain and extend than the
> > > multi-file, multi-language implementation of the original.
> > >
> > > The algorithms are largely unchanged and can be expected to produce
> > > identical numbers for languages supported by both tools. Python is an
> > > exception; loccount corrects buggy counting of single-quote multiline
> > > literals in sloccount 2.26.
> > >
> > > Tested on amd64, here's an example:
> > >
> > > $ time loccount /usr/src/sys
> > > all 2010138 (100.00%) in 5939 files
> > > c 1943636 (96.69%) in 2762 files
> > > asm 58178 (2.89%) in 254 files
> > > makefile 3023 (0.15%) in 207 files
> > > awk 2096 (0.10%) in 18 files
> > > yacc 1654 (0.08%) in 2 files
> > > shell 738 (0.04%) in 8 files
> > > lex 560 (0.03%) in 2 files
> > > m4 175 (0.01%) in 1 files
> > > perl 70 (0.00%) in 2 files
> > > ada 8 (0.00%) in 1 files
> > > 0m02.69s real 0m06.07s user 0m01.15s system
> > >
> > > Feedback, comments?
> > Anyone willing to commit this? It still works fine after the lang/go
> > 1.9.2 update, I'm using it regularily.
> >
>
> : # $OpenBSD: $
> :
> : COMMENT = Faster Go re-implementation of sloccount for more
> languages
>
> just describe what it does rather than say things like "faster
> reimplementation" and "more". in particular it's quite useless to
> have a package comparing itself with something else that isn't in
> packages.
>
> something like "count lines of code in various languages"?
fwiw here is the comment
COMMENT= counts physical Source Lines of Code (SLOC)
and DESCR from my port of sloccount which i never got around to finish
SLOCCount can count physical SLOC for a wide number of languages. It can
gracefully handle awkward situations in many languages, for example, it can
determine the syntax used in different assembly language files and adjust
appropriately, it knows about Python's use of string constants as comments,
and it can handle various Perl oddities (e.g., perlpods, here documents, and
Perl's __END__ marker). It even has a "generic" SLOC counter that you may be
able to use count the SLOC of other languages (depending on the language's
syntax).
SLOCCount can also take a large list of files and automatically categorize
them using a number of different heuristics. The heuristics automatically
determine if a file is a source code file or not, and if so, which language
it's written in. It will even examine file headers to attempt to accurately
determine the file's true type. As a result, you can analyze large systems
completely automatically.
Finally, SLOCCount has some report-generating tools to collect the data
generated, and then present it in several different formats and sorted
different ways. The report-generating tool can also generate simple tab-
separated files so data can be passed on to other analysis tools (such as
spreadsheets and database systems).
> : V = 1.1
> : DISTNAME = loccount-${V}
> : CATEGORIES = textproc
> :
> : HOMEPAGE = https://gitlab.com/esr/loccount
> :
> : DISTFILES = ${DISTNAME}{${V}/archive}${EXTRACT_SUFX}
> : WRKDIST =
> ${WRKDIR}/${DISTNAME}-a4b1199c68660884eb183aecd128102c0c1fbfb8
> :
> : MASTER_SITES = ${HOMEPAGE}/repository/
> :
> : # BSD
> : PERMIT_PACKAGE_CDROM = Yes
> :
> : WANTLIB = c pthread
>
> loccount-1.1(textproc/loccount):
> Extra: c.92 pthread.25
>
> if you're adding WANTLIB in the hope that it triggers an update in a
> statically
> linked program, add a comment explaining why, otherwise it is likely to be
> removed
> in a WANTLIB sync.
>
> : BUILD_DEPENDS = textproc/asciidoc
> :
> : MODULES = lang/go
>
> there doesn't seem much advantage to using the lang/go module when
> you're not using the go build scaffolding.
>
> : ALL_TARGET = ${HOMEPAGE:https://%=%}
>
> this is a bit obtuse, if you were actually using it, it would be simpler
> to just use the string.
>
> but you're not actually using it.
>
> : WRKSRC = ${MODGO_WORKSPACE}/src/${ALL_TARGET}
> :
> : do-build:
> : make -C ${WRKSRC} loccount{,.1}
> :
> : do-test:
> : make -C ${WRKSRC} check
>
> normally ${MAKE_PROGRAM} rather than calling make directly, but seems
> simpler to get rid of the MODULES and have something like this instead
>
> BUILD_DEPENDS = textproc/asciidoc \
> lang/go
>
> ALL_TARGET = loccount loccount.1
>
> do-install:
> ${INSTALL_PROGRAM} ${WRKSRC}/loccount-$V-* ${PREFIX}/bin/loccount
> ${INSTALL_MAN} ${WRKSRC}/loccount.1 ${PREFIX}/man/man1/
>
> ... there's a remaining problem of this package not being updated
> when the go compiler itself is updated (which likely results in changes
> in the built code), though this affects all go ports other than
> "MODGO_TYPE=lib" ones.
>
> :
> : do-install:
> : ${INSTALL_PROGRAM} ${WRKSRC}/loccount ${PREFIX}/bin/
> : ${INSTALL_MAN} ${WRKSRC}/loccount.1 ${PREFIX}/man/man1/
> :
> :
>
--