Commit b0cc0ea

mo khan <mo.khan@gmail.com>
2020-06-29 19:26:52
Create a separate executable for manually running the program
1 parent 4439443
Changed files (3)
src/01/01a/main.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+#include "priority_queue.h"
+
+int main(int argc, char *argv[])
+{
+  printf("hello world\n");
+  return 0;
+}
src/01/01a/Makefile
@@ -2,20 +2,27 @@
 SHELL=/bin/sh
 
 CC=gcc
-LIBS = -lcgreen
+TEST_LIBS = -lcgreen
 
 BUILDDIR := build
-OBJS := $(addprefix $(BUILDDIR)/,priority_queue.o priority_queue_test.o)
+OBJS := $(addprefix $(BUILDDIR)/,priority_queue.o)
+TEST_OBJS := $(addprefix $(BUILDDIR)/,priority_queue_test.o)
 
 $(BUILDDIR)/%.o : %.c
 	$(COMPILE.c) $(OUTPUT_OPTION) $<
 
 .PHONY: all
-all: $(OBJS)
-	$(CC) $(OBJS) $(LIBS) -o $(BUILDDIR)/program
+all: $(OBJS) $(BUILDDIR)/main.o
+	$(CC) $(OBJS) $(BUILDDIR)/main.o -o $(BUILDDIR)/program
+
+.PHONY: test
+test: $(OBJS) $(TEST_OBJS)
+	$(CC) $(OBJS) $(TEST_OBJS) $(TEST_LIBS) -o $(BUILDDIR)/test
 
 $(OBJS): | $(BUILDDIR)
 
+$(TEST_OBJS): | $(BUILDDIR)
+
 $(BUILDDIR):
 	mkdir $(BUILDDIR)
 
@@ -23,5 +30,8 @@ $(BUILDDIR):
 clean:
 	rm -fr build
 
-test : all
-	cgreen-runner -c -v $(BUILDDIR)/program
+run : all
+	./build/program
+
+run_test : test
+	cgreen-runner -c -v $(BUILDDIR)/test
src/01/01a/priority_queue.c
@@ -65,4 +65,3 @@ void destroy(PriorityQueue *queue) {
   }
   free(queue);
 }
-