Strange behavior of OMake's 0-ary functions
I've found strange behaviour of 0-ary functions in OMake 0.9.8.5. Maybe a bug. Try the following:
Here, arc.tar should contain extract/hoge.txt:
Extract()= println(extract tar archive) tar xvf arc.tar Extract2()= println(extract tar archive) tar xvf arc.tar return Extract3(d)= println(extract tar archive) tar xvf arc.tar Extract4(d)= println(extract tar archive) tar xvf arc.tar return extract/hoge.txt: arc.tar # Comment out one of them and try, omake clean; omake; omake. See what happens... # Extract() # Non digestable value: # $(Extract) # command not found in PATH: # Extract2() # Executed twice! # $(Extract2) # Looks ok... NO! Called even if extract/hoge.txt already exists! # X=$(Extract2) # Executed twice! # Extract3(dummy) # OK # $(Extract3 dummy) # command not found in PATH: # X=$(Extract3 dummy) # OK # Extract4(dummy) # OK # $(Extract4 dummy) # Called even if extract/hoge.txt already exists! # X=$(Extract4 dummy) # OK .PHONY: clean clean: rm -rf extract .DEFAULT: extract/hoge.txt
Golden rules (or dumb workaround)
- Do not define 0-ary function
- Better to end with return in function definitions
- Do not use $(Function args) if the result is not necessary, use Function(args)