Add --min_sdk_version flag to the compiler

The flag is used to set the minimum SDK version that the generated code
should support. This will allow the compiler to generate code that
makes use of newer platform features (e.g. new APIs) when it is
guaranteed that the generated code always runs on such platforms.

For now, this flag is no-op.

Bug: 175819535
Test: aidl_unittests
Change-Id: I5297f940b0327f3e057db984b6efb454266e4923
diff --git a/options.h b/options.h
index 3c4490f..98d818e 100644
--- a/options.h
+++ b/options.h
@@ -28,6 +28,15 @@
 using std::string;
 using std::vector;
 
+// The oldest SDK version that is supported for each backend. For non-Java backends, these are the
+// platform SDK version where the support for the backend was added. For Java backend, this should
+// ideally be 1, but is actually 23 as the generated code uses some APIs (like
+// `Parcel.writeTypedObject`) added in 23.
+constexpr uint32_t DEFAULT_SDK_VERSION_JAVA = 23;
+constexpr uint32_t DEFAULT_SDK_VERSION_CPP = 23;
+constexpr uint32_t DEFAULT_SDK_VERSION_NDK = 29;
+constexpr uint32_t DEFAULT_SDK_VERSION_RUST = 31;
+
 // A simple wrapper around ostringstream. This is just to make Options class
 // copiable by the implicit copy constructor. If ostingstream is not wrapped,
 // the implcit copy constructor is not generated because ostringstream isn't
@@ -103,6 +112,8 @@
 
   Stability GetStability() const { return stability_; }
 
+  uint32_t GetMinSdkVersion() const { return min_sdk_version_; }
+
   Language TargetLanguage() const { return language_; }
   bool IsCppOutput() const { return language_ == Language::CPP || language_ == Language::NDK; }
 
@@ -185,6 +196,7 @@
   bool dependency_file_ninja_ = false;
   bool structured_ = false;
   Stability stability_ = Stability::UNSPECIFIED;
+  uint32_t min_sdk_version_ = 0;  // invalid version
   string output_dir_;
   string output_header_dir_;
   bool fail_on_parcelable_ = false;