Create OUT_DIR before writing build_number.txt.

Change-Id: I6a84ec59194c48f4291480cb0c94db0da488518c
diff --git a/core/main.mk b/core/main.mk
index 7f22d76..f9b9d95 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -96,7 +96,7 @@
 # Write the build number to a file so it can be read back in
 # without changing the command line every time.  Avoids rebuilds
 # when using ninja.
-$(shell echo -n $(BUILD_NUMBER) > $(OUT_DIR)/build_number.txt)
+$(shell mkdir -p $(OUT_DIR) && echo -n $(BUILD_NUMBER) > $(OUT_DIR)/build_number.txt)
 BUILD_NUMBER_FROM_FILE := $$(cat $(OUT_DIR)/build_number.txt)
 
 # CTS-specific config.