Browse Source

Don't try to create a nif if n wasn't provided

Loïc Hoguin 6 years ago
parent
commit
a63a34077c
2 changed files with 13 additions and 0 deletions
  1. 3 0
      plugins/c_src.mk
  2. 10 0
      test/plugin_c_src.mk

+ 3 - 0
plugins/c_src.mk

@@ -226,6 +226,9 @@ endif
 ifneq ($(wildcard src/$n.erl),)
 	$(error Error: src/$n.erl already exists)
 endif
+ifndef n
+	$(error Usage: $(MAKE) new-nif n=NAME [in=APP])
+endif
 ifdef in
 	$(verbose) $(MAKE) -C $(APPS_DIR)/$(in)/ new-nif n=$n in=
 else

+ 10 - 0
test/plugin_c_src.mk

@@ -86,3 +86,13 @@ endif
 
 	$i "Check that all files were removed"
 	$t test ! -e $(APP)/c_src/env.mk
+
+c-src-nif-missing-name: build clean
+
+	$i "Bootstrap a new OTP library named $(APP)"
+	$t mkdir $(APP)/
+	$t cp ../erlang.mk $(APP)/
+	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
+
+	$i "Try to generate a NIF without giving it a name"
+	$t ! $(MAKE) -C $(APP) new-nif $v