sanitycheck: support ninja builder

Add an option to support building with ninja instead of make.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
diff --git a/scripts/sanitycheck b/scripts/sanitycheck
index 51fcb3f..52fbd98 100755
--- a/scripts/sanitycheck
+++ b/scripts/sanitycheck
@@ -753,6 +753,7 @@
 
     MAKE_RULE_TMPL = """\t@echo sanity_test_{phase} {goal} >&2
 \tcmake  \\
+\t\t-G"{generator}"\\
 \t\t-H{directory}\\
 \t\t-B{outdir}\\
 \t\t-DEXTRA_CFLAGS="-Werror {cflags}"\\
@@ -760,8 +761,8 @@
 \t\t-DEXTRA_LDFLAGS="{ldflags}"\\
 \t\t{args}\\
 \t\t>{logfile} 2>&1
-\t$(MAKE) -C {outdir}\\
-\t\tVERBOSE={verb} {make_args}\\
+\t{generator_cmd} -C {outdir}\\
+\t\t{verb} {make_args}\\
 \t\t>>{logfile} 2>&1
 """
 
@@ -796,7 +797,6 @@
         @param      args Arguments given to CMake
         @param make_args Arguments given to the Makefile generated by CMake
         """
-        verb = "1" if VERBOSE else "0"
         args = " ".join(["-D{}".format(a) for a in args])
         ldflags = ""
 
@@ -811,7 +811,18 @@
         if not "native_posix" in args:
             ldflags="-Wl,--fatal-warnings"
 
+        if options.ninja:
+            generator = "Ninja"
+            generator_cmd = "ninja"
+            verb = "-v" if VERBOSE else ""
+        else:
+            generator = "Unix Makefiles"
+            generator_cmd = "$(MAKE)"
+            verb = "VERBOSE=1" if VERBOSE else "VERBOSE=0"
+
         return MakeGenerator.MAKE_RULE_TMPL.format(
+            generator=generator,
+            generator_cmd=generator_cmd,
             phase=phase,
             goal=name,
             outdir=outdir,
@@ -2046,6 +2057,11 @@
         "3/5 means run the 3rd fifth of the total. "
         "This option is useful when running a large number of tests on "
         "different hosts to speed up execution time.")
+
+    parser.add_argument(
+        "-N", "--ninja", action="store_true",
+        help="Use the Ninja generator with CMake")
+
     parser.add_argument(
         "-y", "--dry-run", action="store_true",
         help="Create the filtered list of test cases, but don't actually "