kisslinux / kiss

KISS Linux - Package Manager
https://kisslinux.github.io
MIT License
465 stars 62 forks source link

Additional environment variables to expose to build files #235

Closed dylanaraps closed 3 years ago

dylanaraps commented 3 years ago

The idea is to reduce boilerplate in a generic way by exporting common variables into the environment. There are endless instances of DESTDIR, CC and CXX for example. This makes their use optional (without changing pre-existing behavior).

This is the list so far:

CC="${CC:-cc}" \
CXX="${CXX:-c++}" \
DESTDIR="$pkg_dir/$1" \
KISS_ROOT="$KISS_ROOT" \

Are there any other desirable environment variables to define? Leave suggestions below.

jedahan commented 3 years ago

Doing a little bit of research, I just ran this on my own repo, will run on all repositories when in the next day or so.

▲ rg '([A-Z_]+)=' --only-matching --no-filename */build | sort | uniq -c | sort -nr | rg -v ' 1 '                                                                                                                                                            kiss-hooks-executables 48m ⬢
  33 DESTDIR=
  11 DCMAKE_INSTALL_PREFIX=
   7 PREFIX=
   7 DCMAKE_BUILD_TYPE=
   4 _PROGRAMMERS=
   4 GOPATH=
   2 LIBDIR=
   2 INCLUDEDIR=
   2 DBUILD_SHARED_LIBS=
   2 CONFIG_ENABLE_LIBPCI_PROGRAMMERS=
   2 CGO_ENABLED=
jedahan commented 3 years ago

kiss-community/community

 △ rg '([A-Z_]+)=' --only-matching --no-filename */build | sort | uniq -c | sort -nr | rg -v ' 1 '                                                                                                                                                                             ⇡ main 1d ⬢
 331 DESTDIR=
  79 PREFIX=
  27 DCMAKE_INSTALL_PREFIX=
  23 CFLAGS=
  14 DCMAKE_BUILD_TYPE=
  13 DCMAKE_INSTALL_LIBDIR=
   7 GOPATH=
   6 SBINDIR=
   6 MODULE=
   6 INSTALL_ROOT=
   6 CC=
   5 DBUILD_SHARED_LIBS=
   4 PATH=
   3 MANPREFIX=
   3 MANDIR=
   3 LIBDIR=
   3 LDFLAGS=
   3 GOFLAGS=
   3 BINDIR=
   2 _PROGRAMMERS=
   2 UDEVDIR=
   2 SHARED=
   2 INSDIR=
   2 GOROOT_FINAL=
   2 GOROOT_BOOTSTRAP=
   2 GOROOT=
   2 DUSE_BUNDLED_ZLIB=
   2 CXX=
   2 CGO_LDFLAGS=
   2 CGO_CXXFLAGS=
   2 CGO_CPPFLAGS=
   2 CGO_CFLAGS=
dylanaraps commented 3 years ago

NOTE: Not all of these are read from the environment. We need figure this out to know the true benefit.

You should also strip -D<NAME> as these are insideCFLAGS/CXXFLAGS or cmake arguments.

Edit: Might also be handy to include their values in the data. Then we can see what a possible default could be for the package manager.

dylanaraps commented 3 years ago

Here's the kisslinux repository:

    122 DESTDIR=
     29 CFLAGS=
     19 CC=
     10 PREFIX=
      7 DCMAKE_INSTALL_PREFIX=
      7 DCMAKE_BUILD_TYPE=
      6 LDFLAGS=
      5 CXXFLAGS=
      4 CXX=
      3 LIBDIR=
      3 HOSTCC=
      2 PATH=
      2 NO_SVN_TESTS=
      2 MANDIR=
      2 DLLVM_ENABLE_RTTI=
      2 DCMAKE_INSTALL_LIBDIR=
      2 DBUILD_TESTING=
      2 CONFIG_PREFIX=
      2 BINDIR=
jedahan commented 3 years ago

jedahan/kiss-repo

 ▲ rg '\$([{}A-Z_]+)' --no-filename */build | sort | uniq -c | sort -nr                                                                                                                                                                                        kiss-hooks-executables 6m ⬡
   3 export GOPATH=$PWD/go
   1 export CXX="${CXX:-/usr/bin/c++}"
   1 export CFLAGS="$CFLAGS -fcommon"
   1 export CC="${CC:-/usr/bin/cc}"
   1 GOPATH=$PWD/go go build -v -modcacherw -ldflags "-s -w -X 'main.version=0.4.2'"

kiss-community/community (seemed to messy to include all the values as well)

▲ rg '\$([{}a-zA-Z_]+)' --only-matching --no-filename */build | sort | uniq -c | sort -nr 
  31 $CFLAGS
  20 $PWD
  13 $patch
  12 ${CC
   8 $LDFLAGS
   7 $dir
   4 $lib
   4 $PATH
   3 ${wpe
   3 ${CXX
   3 $shared
   3 $file
   3 $GOROOT
   3 $GOFLAGS
   3 $CPPFLAGS
   3 $BROWSER
   2 ${streaming
   2 ${PREFIX}
   2 $system
   2 $machine
   2 $font
   2 $bin
   2 $KISS_ROOT
   2 $CXXFLAGS
   2 $CC
   1 ${vaapi
   1 ${udev
   1 ${lib}_STATIC
   1 ${lib}_SHARED
   1 ${jpeg
   1 ${file
   1 ${config
   1 ${clang
   1 ${bindir}
   1 ${NM
   1 ${GOPATH
   1 ${DESTDIR}
   1 ${CFLAGS}
   1 ${AR
   1 $udev
   1 $tool
   1 $suffix
   1 $stuff
   1 $script
   1 $plugin
   1 $doc
   1 $crate_ver
   1 $config
   1 $conf
   1 $comp
   1 $action
   1 $ThisDir
   1 $QTWEBENGINE_ROOT
   1 $PYTHONPATH
   1 $LD_LIBRARY_PATH
   1 $DESTDIR
dilyn-corner commented 3 years ago

GOPATH, AR/NM/RANLIB are basically the only ones that 1) seem to matter and 2) get used, and AR et al. only show up for chromium. Though they are usually sane variables to have set, it's only necessary when someone is playing with a different e.g. ranlib, and they should certainly know that...

Setting PREFIX=/usr would also be nice, but some packages don't respect DESTDIR so PREFIX has to be specified as $1/usr anyways. I don't so much care about this one.

But GOPATH should ALWAYS be specified, and it should be specified to the same thing for EVERY package, so I think this should be added.

I've never come across having to set $YACC outside of the kernel.

dylanaraps commented 3 years ago

OK. This should be good for now.

Thanks for the suggestions.