'nothing to be done for' error with .PHONY rule - makefile

I have a wildcard rule to grab all of the files in a directory as tests and run them, and a .PHONY rule to make sure I can run all of the tests regardless of whether they've been previously run. When I run make tests/PA5obj.java or make test it returns with `make: Nothing to be done for 'test'.
Sometimes after I add new files to the tests/ dir, I have to run make clean before it will pick them up in make test, so I'm unsure if there's a caching issue or something, but that wouldn't explain why make test is also not working.
Here is the relevant section of the makefile:
PROG = Test
TESTS = $(wildcard tests/*.java)
.SUFFIXES: .java.class
#-------------------------
JCC = javac
JAR = jar
#-------------------------
all: $(PROG).jar
.PHONY:test $(TESTS)
test: $(TESTS)
tests/%.java: $(PROG).jar
#echo "#### testing $# ####"
#java -jar $(PROG).jar $#
#echo "> Passed"
$(PROG).jar: Main.class
$(JAR) cmf $(PROG)MainClass.txt $(PROG).jar $^
Main.class: Main.java
javac $^
The necessary files are:
TestMainClass.txt
Main-Class: Main
and Main.java
import java.util.Scanner;
import java.lang.System;
import java.io.File;
import java.io.FileNotFoundException;
class Main {
public static void main(String args[]) {
if (args.length < 1) {
throw new RuntimeException("Usage: Main <filename> ");
}
String filename = args[args.length-1];
try {
Scanner sc = new Scanner(new File(filename));
System.out.println("Contents of file: " + filename);
while (sc.hasNext()) {
System.out.println(sc.nextLine());
}
}
catch (FileNotFoundException e) {
System.out.println(e);
System.exit(1);
}
}
}
Running make test should simply read all of the files in the test dir (as a minimal example)

Make will execute the rule of a PHONY target, even if a file exists with that name.
But this does not apply to pattern rules, which is why you have this problem.
But it does apply to static pattern rules (at least in the version of GNU Make I'm using). So give this a try:
$(TESTS): tests/%.java: $(PROG).jar
...

You don't have any targets that depend on the test target. Since the test target depends on the jar target, you can change the all target to depend on the test target instead of the jar target.

Related

snakemake program not running all functions?

configfile: "config.yaml"
DATA = config['DATA_DIR']
BIN = config['BIN']
JASPAR = config['DATA_DIR']
RESULTS = config['RESULTS']
# JASPAR = "{0}/JASPAR2020".format(DATA)
JASPARS, ASSEMBLIES, BATCHES, TFS, BEDS = glob_wildcards(os.path.join(DATA, "{jaspar}", "{assembly}", "TFs", "{batch}", "{tf}", "{bed}.bed"))
rule all:
input:
expand (os.path.join(RESULTS, "{jaspar}", "{assembly}", "LOLA_dbs", "JASPAR2020_LOLA_{batch}.RDS"), jaspar = JASPARS, assembly = ASSEMBLIES, batch = BATCHES)
rule createdb:
input:
files = expand(os.path.join(RESULTS, "{jaspar}", "{assembly}", "data", "{batch}", "{tf}", "regions", "{bed}.bed"), zip, jaspar = JASPARS, assembly = ASSEMBLIES, batch = BATCHES, tf = TFS, bed = BEDS)
output:
os.path.join(RESULTS, "{jaspar}", "{assembly}", "LOLA_dbs", "JASPAR2020_LOLA_{batch}.RDS")
shell:
"""
R --vanilla --slave --silent -f {BIN}/create_lola_db.R \
--args {RESULTS}/{wildcards.jaspar}/{wildcards.assembly}/data/{wildcards.batch} \
{output};
"""
Why my snakemake program is not considering "createdb" rule. It is only considering "all". Can someone please help me with this?
"snakemake only runs the first rule in a Snakefile, by default." - SOURCE
If that first rule's input isn't clearly linked to createdb, it's not going to know to run createdb. Because the only rule it wants to run would have to depend on createdb.
I suspect your problem is the input to your rule createdb shouldn't have expand() used for all the wildcards already handled by rule all, just bed?. See here.
Also other avenues to consider for debugging is investigating what you unpacked glob_wildcards() to and what files is.

run a target always along with default target

I have a default target "all" but I want to initialize a few variables ever time I run the makefile . whatever is the target for make flow.
cat Makefile
all: last_step
initialize:
ifeq (,$(filter $(ps),0 1))
#$(eval override ps=0)
endif
step1:
<>
step2: step1
<>
....
last_step: second_last_step
<>
I want to initialize the variable every time a make file is run .
initialize target should be run in both the following flow styles.
make .
make nth-step
Nothing easier:
ifeq (,$(filter $(ps),0 1))
override ps=0
endif
all: last_step
...
step1:
...
...

Yocto/Bitbake recipe for adding empty directory to rootfs Embedded Linux

Is there any recipe for adding a new, empty directory to the rootfs? I tried adding this into one of my bbappend file:
do_install() {
install -d ${D}/tmp/myNewDir
}
FILES_${PN} += "/tmp/myNewDir"
but I am getting a non descriptive error, Function failed: do_install
There are several ways. The image command way is already described by StackedUser.
You can also try to extend some of your recipes (as you are doing in your question). I guess that you are seeing the error because you are overwriting the do_install task. You are probably wanting to extend it, so you should add _append to the task name, i.e.:
do_install_append () {
install -d ${D}/tmp/myNewDir
}
BTW, the error "Function failed: do_install" you are hitting usually show an error code or a problematic command. Maybe there is something.
Another way is to create a simple recipe and add it to the image, here is a stub:
SUMMARY = "XXX project directory structure"
# FIXME - add proper license below
LICENSE = "CLOSED"
PV = "1.0"
S = "${WORKDIR}"
inherit allarch
do_install () {
install -d ${D}/foo/bar
}
FILES_${PN} = "/foo/bar"
In our image recipe we have something like this to create a new directory:
create_data_dir() {
mkdir -p ${IMAGE_ROOTFS}/data
}
IMAGE_PREPROCESS_COMMAND += "create_data_dir;"

What is the proper way to refer to resource directory path in one source set in gradle?

In my build.gradle file, I have defined a separate sourceSet for integration tests:
sourceSets {
integtest {
java.srcDir 'src/integtest/java/io/attil/integration'
resources.srcDir 'src/integtest/resources'
}
}
I would like to use the path to resources of the integration tests in one of my manually defined tasks (a task that prefills the data-base for integration tests; the sql script is located in the mentioned resource folder).
I have now the following solution:
task prefillDatabase {
// ... snip!
String sqlString = new File(sourceSets.integtest.resources.srcDirs.iterator().next().toString() + '/setup_integration_tests.sql').text
// ... snip!
}
While this works, it is quite cumbersome.
Is there a better, shorter way to achieve the same? (I'm looking for something like sourceSets.integtest.resources.srcDir.)
I'm not sure this is less verbose, but I'd argue it's more correct
File file = sourceSets.integtest.resources.matching {
include 'setup_integration_tests.sql'
}.singleFile
String sqlString = file.text
See FileTree.matching(Closure) and FileCollection.getSingleFile()
Also, this looks wrong to me
java.srcDir 'src/integtest/java/io/attil/integration'
I'd think it would be
java.srcDir 'src/integtest/java'
java.include 'io/attil/integration/**'

GNU Make: How to perform second expansion with suffix-changing substitution

What I'm going for (what's failing)
I have a list of dependencies for each file:
point_deps =
bounds_deps = point
triangle_deps = point bounds
Image_deps = types bounds triangle
main_deps = Image triangle bounds point types
I'd like to write a rule to include the relevant dependencies. Here's my best attempt:
out/%.o: src/%.cpp src/%.h $$($$*_deps:%=src/%.h)
g++ -o $# -c $<
I expect $* to evaluate to, for instance, "main". Then the suffix-changing substitution should change each entry in the dependency list to begin with "src/" and end with ".h".
When I try to run the code above, I get an error (on the out/%.o line):
makefile:26: *** multiple target patterns. Stop.
What's working (non-optimal)
For now I have to create a separate variable for each file's header dependencies:
point_deps_h = $(point_deps:%=src/%.h)
bounds_deps_h = $(bounds_deps:%=src/%.h)
triangle_deps_h = $(triangle_deps:%=src/%.h)
Image_deps_h = $(Image_deps:%=src/%.h)
main_deps_h = $(main_deps:%=src/%.h)
Then I can use secondary-expansion to include the correct header files:
out/%.o: src/%.cpp src/%.h $$($$*_deps_h)
g++ -o $# -c $<

Resources