I have a default.nix file that looks like this:
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "tsm";
src = ./.;
enableParallelBuilding = true;
cmakeFlags = ["-DGTEST_INCLUDE_DIR=${gtest}/include -DBUILD_COVERAGE=ON"];
buildInputs = [gcc cmake gtest glog lcov graphviz doxygen];
When I build, I need to invoke make doc coverage as well. How do I make additional targets?
After scouring google, I tried makeFlagsArray = ("doc" "coverage") and makeFlagsArray = ("doc coverage"). Neither worked.docandcoverage` should not be built every time. That is why I had them build only on explicit invocation from make.
Adding
buildPhase = ''
make all doc coverage
'';
does the trick. Not sure if this is the ideal approach.
You probably want to run in postBuild those make targets.
postBuild = ''
make doc coverage
'';
makeTargets or makeFlags only work when using make but that is replaced by cmake.
Related
I am building a library (using Autotools) that looks like the following. The building of the library works fine when I add a *.cpp file to libmytest_la_SOURCES.
lib_LTLIBRARIES = libmytest.la
libmytest_la_SOURCES = test.capnp.c++
libmytest_la_CXXFLAGS = -I/usr/include -I$(top_srcdir)/src/includes
libmytest_la_LDFLAGS = -version-info 0:0:0 -L/usr/lib64
libmytest_la_LIBADD = -lcapnp
The problem is that I need to call a third-party compiler to generate code before doing the normal compile process. The following capnp tool will generate a c++ output file named test.capnp.c++.
capnp compile -oc++ test.capnp
And if I plug the output of that (test.capnp.c++) into the makefile above, my library is built. What I don't get is how to invoke that command into the Makefile.am to generate the needed source file and plug it into the libmytest_la_SOURCES variable.
Any thoughts?
Automake does not have direct support for capnp, and adding support for a new language or tool would involve hacking the program. But you can provide ordinary make rules in your Makefile.am file, and these will be carried through to the final generated Makefile. This is Automake's primary extension point.
Thus, you might add this to your Makefile:
test.capnp.c++ : test.capnp
capnp compile -oc++ $<
# or
# $(CAPNP) compile -oc++ $<
# where $(CAPNP) is the capnp binary as discovered by configure
You would want to also designate test.capnp as an additional file to distribute:
EXTRA_DIST = test.capnp
You should also consider whether you want the .c++ file to be included in distribution packages, to relieve the build-time dependency on capnp. If not, then instead of listing it in libmytest_la_SOURCES you should list it in nodist_libmytest_la_SOURCES, plus also in CLEANFILES:
#
# test.capnp.c++ is a built file that we choose not to distribute
#
nodist_libmytest_la_SOURCES = test.capnp.c++
CLEANFILES = test.capnp.c++
# or: CLEANFILES = $(nodist_libmytest_la_SOURCES)
I am trying to compile c code using rake compiler in a windows 10 environment. I am having a problem with the paths that the Makefile is generating because they have "/C/ instead of "C:". Mingw that was installed as part of the dev-kit, cannot handle this format of abs paths, I have to change it to a windows format.
Please note topdir and prefix.
Makefile:
srcdir = ../../../../ext/hello_world
topdir = /C/Ruby/include/ruby-2.6.0
hdrdir = $(topdir)
arch_hdrdir = C:/Ruby/include/ruby-2.6.0/x64-mingw32
PATH_SEPARATOR = :
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
prefix = $(DESTDIR)/C/Ruby
I am able to modify the value for 'prefix' doing this in the extconf.rb file:
CONFIG['prefix'] = '$(DESTDIR)C:/Ruby'
But for any reason if I try to change the value for 'topdir', the value doesn't get overridden. Any ideas what I am missing?
Bazel says that best practice is to not use binary dependencies, but to build the dependency from source using Bazel. I have a dependency - xgboost - that builds using Makefiles, and I was wondering what the canonical strategy is to convert Makefiles to Bazel - as well as if there are any standard tools that programmers use as part of the conversion.
There is no "canonical way" to do it right now. The easiest way is probably to just shell out to make in a non-hermetic generule and declare the needed output of the rule, e.g.:
genrule(
name = "xgboost",
srcs = glob(["xgboost/**"]),
cmd = "\n".join([
"DIR=$$(mktemp -d $${TMPDIR-/tmp}/tmp.XXXXXXX)",
"(cd $(execution_root)/xgboost && cp -fr . \"$${DIR}\")",
"(cd \"$${DIR}\" && make target)",
"cp $${DIR}/output $#",
]),
outs = ["xgboost-output"],
local = 1,
)
Of course, target, output and xgboost-output are to be replaced by what works for you.
I'm trying to learn automake (Autotools by John Calcotte) and am stumped on creating a check program to test my C++ library. A partial listing of the program is given below. The example in the text shows creation of a test program using a shell script testing the output of the test program. I have a program, linked to the library, which when executed tests the library functionality. Do I have to create the test program using noinst and then execute using a shell script? Any scripting examples or references to examples would help.
Thanks
The errors are:
src/Makefile.am:27: warning: variable 'check_SOURCES' is defined but no program or
src/Makefile.am:27: library has 'check' as canonical name (possible typo)
# Create a library
lib_LIBRARIES = libslip.a
libslip_a_SOURCES = $(sources) $(privateHeaders)
# Header files for testing SLIP
testHead=TestGlobal.h TestHeader.hp TestIO.h TestMisc.h TestOperators.h TestReader.h TestReplace.h TestSequencer.h TestUtilities.h
# Source files for testing SLIP
testCPP=Test.cpp TestGlobal.cpp TestHeader.cpp TestIO.cpp TestMisc.cpp TestOperators.cpp TestReader.cpp TestReplace.cpp TestSequencer.cpp TestUtilities.cpp
# Test Program
check_PROGRAMS = Test
check_SOURCES = $(testHead) $(testCPP)
TESTS = $(check_PROGRAMS)
It's just a slight misunderstanding: check_PROGRAMS = Test is fine, but just as with the libslip sources, Test is used as a prefix:
Test_SOURCES = TestGlobal.h TestHeader.hp TestIO.h TestMisc.h TestOperators.h \
TestReader.h TestReplace.h TestSequencer.h TestUtilities.h Test.cpp \
TestGlobal.cpp TestHeader.cpp TestIO.cpp TestMisc.cpp TestOperators.cpp \
TestReader.cpp TestReplace.cpp TestSequencer.cpp TestUtilities.cpp
In this case, it's fine to include headers in SOURCES. Each new line after the line break should start with a TAB character. Of course, you can continue using $(testHead) and $(testCPP) variables if you prefer. To link with libslip:
Test_LDADD = libslip.a
or simply:
LDADD = libslip.a
if linking libslip with all programs in this Makefile. check_PROGRAMS targets are implicitly noinst.
You might also find the Autotools Mythbuster a useful resource.
I'm writing some simple tests for my library, and I'm trying to keep my Makefile.am file as tidy as I can, so I'm trying to rely on the default _SOURCES functionality. This is my current Makefile.am:
AM_CPPFLAGS = $(MYLIB_CFLAGS) -I..
AM_DEFAULT_SOURCE_EXT = .vala
AM_LDFLAGS = $(MYLIB_LIBS)
VALAFLAGS = -D GLIB_2_32 --vapidir=../ --pkg mylib_internal --pkg libsoup-2.4 --pkg json-glib-1.0 --pkg gee-1.0
TESTS = autocomplete
check_PROGRAMS = autocomplete
autocomplete_LDADD = ../mylib.la
autocomplete_SOURCES = autocomplete.vala common.vala
CLEANFILES = *.c
If I leave out the autocomplete_SOURCES variable, autocomplete.vala is automatically used, and that's great (as per the default _SOURCES functionality), but I need to include common.vala as well. In fact, every test program I am going to write will want to have this common.vala in their source file list. Is there a way for me to not having to specify the *_SOURCES for every single test program I write?
Bonus: They will all want to have mylib.la in their *_LDADD as well, so again, is there a way for me to accomplish this globally, instead of having to have it specified for every test program?
EDIT: I figured out that you can just use LDADD without the prefix to get it to apply to every compiled program. That helps a bit... now to figure out the *_SOURCES...
There isn't a way to do this.
You can introduce a variable that you use everywhere, if you want:
general_stuff = whatever.vala
x_SOURCES = $(general_stuff) ...
y_SOURCES = $(general_stuff) ...