Move to Weld as the build system.

Change-Id: I7c9704f3f310cf7e5410db148a9c4c589914b0f2
diff --git a/.gitignore b/.gitignore
index 1bbd63d..7a17acd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
-hello-world-ng
-t/greeting-test
 *~
 *.o
-/test-results
\ No newline at end of file
+/test-results
+/build
diff --git a/Jenkinsfile b/Jenkinsfile
index aa49804..00d0bb2 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -47,7 +47,7 @@
             sh """
               colormake test-junit -j4
             """
-            junit 'test-results/**/*.xml'
+            junit '**/*.xml'
           }
         }
       }
@@ -56,7 +56,7 @@
     stage('Archive artifacts') {
       steps {
         container('baker') {
-          archiveArtifacts 'exe/hello-world-ng'
+          archiveArtifacts 'build/unix/amd64/debug/bin/hello-world-ng'
         }
       }
     }
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..3e607bb
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,5 @@
+source_path        := .
+build_path         := ./build
+mode               ?= debug
+c_toolchain        := gcc
+compiler_flag_list := -std=c++17
diff --git a/exe/hello-world-ng/def.mk b/exe/hello-world-ng/def.mk
new file mode 100644
index 0000000..1a0ee1c
--- /dev/null
+++ b/exe/hello-world-ng/def.mk
@@ -0,0 +1,6 @@
+name := hello-world-ng
+lang := cpp
+type := bin
+
+source_list := hello-world-ng.cpp
+source_lib_list := greeting
diff --git a/exe/hello-world-ng.cpp b/exe/hello-world-ng/source/hello-world-ng.cpp
similarity index 81%
rename from exe/hello-world-ng.cpp
rename to exe/hello-world-ng/source/hello-world-ng.cpp
index f59229c..53a55ac 100644
--- a/exe/hello-world-ng.cpp
+++ b/exe/hello-world-ng/source/hello-world-ng.cpp
@@ -1,4 +1,4 @@
-#include <mod/greeting.hpp>
+#include <greeting/greeting.hpp>
 
 #include <iostream>
 #include <cstdlib>
diff --git a/makefile b/makefile
index 269e14e..50cb63a 100644
--- a/makefile
+++ b/makefile
@@ -1,44 +1,3 @@
-.PHONY: all clean
+config_file := ./config.mk
 
-CXX = c++
-LDFLAGS =
-CXXFLAGS = -I. -std=c++17
-MKDIR_P = mkdir -p
-
-EXE = exe/hello-world-ng
-TEST = t/greeting-test
-
-mod_OBJ = mod/greeting.o
-hello_world_ng_OBJ = exe/hello-world-ng.o
-greeting_test_OBJ = t/greeting-test.o
-
-OBJ = $(hello_world_ng_OBJ) $(mod_OBJ)
-
-all: $(EXE)
-
-test: $(TEST)
-	@for x in $^; do \
-		echo $$x; \
-		$$x; \
-	done
-
-test-junit: $(TEST)
-	$(MKDIR_P) test-results/t
-	@for x in $^; do \
-		echo $$x -r junit -o test-results/$$x.xml --success; \
-		$$x -r junit -o test-results/$$x.xml --success || :; \
-	done
-
-clean:
-	$(RM) $(OBJ)
-	$(RM) $(EXE)
-	$(RM) -r test-results
-
-exe/hello-world-ng: $(hello_world_ng_OBJ) $(mod_OBJ)
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
-
-t/greeting-test: $(greeting_test_OBJ) $(mod_OBJ)
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
-
-%.o: %.cpp
-	$(CXX) $(CXXFLAGS) -o $@ -c $<
+include weld/weld.mk
diff --git a/mod/catch/def.mk b/mod/catch/def.mk
new file mode 100644
index 0000000..4573bb0
--- /dev/null
+++ b/mod/catch/def.mk
@@ -0,0 +1,6 @@
+name := catch
+lang := cpp
+type := lib
+
+header_list := catch.hpp
+source_list := catch.cpp
diff --git a/mod/3rdparty/catch/catch.hpp b/mod/catch/include/catch.hpp
similarity index 100%
rename from mod/3rdparty/catch/catch.hpp
rename to mod/catch/include/catch.hpp
diff --git a/mod/catch/source/catch.cpp b/mod/catch/source/catch.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mod/catch/source/catch.cpp
diff --git a/mod/greeting/def.mk b/mod/greeting/def.mk
new file mode 100644
index 0000000..bd4a6cd
--- /dev/null
+++ b/mod/greeting/def.mk
@@ -0,0 +1,6 @@
+name := greeting
+lang := cpp
+type := lib
+
+header_list := greeting.hpp
+source_list := greeting.cpp
diff --git a/mod/greeting.hpp b/mod/greeting/include/greeting.hpp
similarity index 100%
rename from mod/greeting.hpp
rename to mod/greeting/include/greeting.hpp
diff --git a/mod/greeting.cpp b/mod/greeting/source/greeting.cpp
similarity index 88%
rename from mod/greeting.cpp
rename to mod/greeting/source/greeting.cpp
index 62ebb2d..0fb811d 100644
--- a/mod/greeting.cpp
+++ b/mod/greeting/source/greeting.cpp
@@ -1,4 +1,4 @@
-#include "greeting.hpp"
+#include <greeting/greeting.hpp>
 
 #include <sstream>
 
diff --git a/t/def.mk b/t/def.mk
new file mode 100644
index 0000000..bf943c6
--- /dev/null
+++ b/t/def.mk
@@ -0,0 +1,18 @@
+.PHONY: test test-junit
+
+TEST = greeting-test
+
+MKDIR_P = mkdir -p
+
+test: $(TEST)
+	@for x in $^; do \
+		echo $(bin_output_path)/$$x; \
+		$(bin_output_path)/$$x; \
+	done
+
+test-junit: $(TEST)
+	$(MKDIR_P) $(output_path)/test-results
+	@for x in $^; do \
+		echo $(bin_output_path)/$$x -r junit -o $(output_path)/test-results/$$x.xml --success; \
+		$(bin_output_path)/$$x -r junit -o $(output_path)/test-results/$$x.xml --success || :; \
+	done
diff --git a/t/greeting-test/def.mk b/t/greeting-test/def.mk
new file mode 100644
index 0000000..411cf94
--- /dev/null
+++ b/t/greeting-test/def.mk
@@ -0,0 +1,6 @@
+name := greeting-test
+lang := cpp
+type := bin
+
+source_list := greeting-test.cpp
+source_lib_list := catch greeting
diff --git a/t/greeting-test.cpp b/t/greeting-test/source/greeting-test.cpp
similarity index 78%
rename from t/greeting-test.cpp
rename to t/greeting-test/source/greeting-test.cpp
index 1719469..1853540 100644
--- a/t/greeting-test.cpp
+++ b/t/greeting-test/source/greeting-test.cpp
@@ -1,7 +1,7 @@
-#include <mod/greeting.hpp>
+#include <greeting/greeting.hpp>
 
 #define CATCH_CONFIG_MAIN
-#include <mod/3rdparty/catch/catch.hpp>
+#include <catch/catch.hpp>
 
 TEST_CASE("greeting generation") {
   using greeting::make_greeting;
diff --git a/weld/toolchain/gcc/compile.mk b/weld/toolchain/gcc/compile.mk
index 97dfd46..f07370c 100644
--- a/weld/toolchain/gcc/compile.mk
+++ b/weld/toolchain/gcc/compile.mk
@@ -155,10 +155,14 @@
                 $(link_flag_list)                                                                 \
                 $(addprefix -L,$(call path_to_native,$(lib_path_list)))                           \
                 $(call path_to_native,$(obj_goal_file_list))                                      \
-                -Wl,--start-group                                                                 \
+                                                                                                  \
                 $(addprefix -l,$(lib_list) $(source_lib_list))                                    \
                 $(addsuffix .a,$(addprefix -l:lib,$(static_lib_list)))                            \
-                -Wl,--end-group)
+                                                                                                  \
+#                -Wl,--start-group                                                                 \
+#                $(addprefix -l,$(lib_list) $(source_lib_list))                                    \
+#                $(addsuffix .a,$(addprefix -l:lib,$(static_lib_list)))                            \
+#                -Wl,--end-group)
     endif
 
 .PHONY : clean_$(name)_def_compile