gofed / go-macros

Rpm mechanics for Go packaging
4 stars 7 forks source link

The Go utilities used by the macros should accept arbitrary numbers of flags #5

Closed nim-nim closed 6 years ago

nim-nim commented 6 years ago

Real life is messy and excluding just the right bits of a Go project to make it work can take quite a lot of exclusion directives. Their number should not be limited

Also, since rpm does not like long flag names in macros, and to simplify the correspondance between the spec code and the Go code, single-letter flag names should be accepted

For example: -d exclude/ignore the content of a whole directory (not recursive, subdirectories are not ignored) -t exclude/ignore the content of a whole directory tree (recursive, subdirectories are ignored too -r exclude/ignore whatever marches the Go regexp -f exclude/ignore a specific file (though that is quite rare and can be done via regexes in the short term)

ingvagabund commented 6 years ago

I can imagine we create new macro (e.g. __go_ignore) that gets wired down to the golist binary.

With https://github.com/gofed/symbols-extractor/pull/140 merged, we can do something like:

%global __go_ignore -d DIR1 -d DIR2 -t TREE1 -t TREE2 -r REGEX1 -r REGEX2

In cases the %goinstall needs to ignore more resource, the same options can be used:

%goinstall -d DIR3 -t TREE3 ...

The %gochecks -d ... -t ... -r ... is currently not supported.

ingvagabund commented 6 years ago

Resolved as part of https://github.com/gofed/go-macros/commit/250bb2125e4aa8f86396cfaadba7854ac44bf921

ingvagabund commented 6 years ago

@nim-nim is it sufficient? So far I had to specify:

%global __go_ignore     -t %{gobaseipath}/_third_party
%global __go_ignore     -t %{gobaseipath}/examples
%global __go_ignore     -t %{gobaseipath}/examples
%global __go_ignore     -r /testdata
%global __go_ignore     -r /testdata -t %{gobaseipath}/_conformance
%global __go_ignore     -t %{gobaseipath}/examples -t %{gobaseipath}/revel
%global __go_ignore     -t %{gobaseipath}/examples
%global __go_ignore     -t examples
%global __go_ignore     -t %{gobaseipath}/_example
%global __go_ignore     -r /testdata

It sucks to use the %{gobaseipath} prefix for the trees and directories. However, the buildroot can contain more import path prefixes so it needs to be distinguished (though it is only a fraction of all Go packages).

ingvagabund commented 6 years ago

https://github.com/gofed/go-macros/commit/9ea4573c11c1872f9b40b2a3fb7067a327fd98a9