Remove sdk.proto copy in derive_sdk dir

Make a separate dir for proto files and define libraries there.

Also remove some unnecessary options:
- Two were java-specific, and this proto is only used in cpp code
- The package name is not necessary as this proto is internal to this
  module.

Bug: 173188089
Test: presubmit
Change-Id: I1bfd29741898832e776aaf45ccf17eed598be267
diff --git a/Android.bp b/Android.bp
index 16a3611..be282ed 100644
--- a/Android.bp
+++ b/Android.bp
@@ -50,13 +50,8 @@
 
 python_binary_host {
     name: "gen_sdkinfo",
-    srcs: [
-        "sdk.proto",
-        "gen_sdkinfo.py",
-    ],
-    proto: {
-        canonical_path_from_root: false,
-    },
+    srcs: ["gen_sdkinfo.py"],
+    libs: ["sdk_proto_python"],
     version: {
         py3: {
             embedded_launcher: true,
diff --git a/derive_sdk/Android.bp b/derive_sdk/Android.bp
index dc4e352..ca80b9b 100644
--- a/derive_sdk/Android.bp
+++ b/derive_sdk/Android.bp
@@ -14,10 +14,6 @@
 
 cc_defaults {
     name: "derive_sdk-defaults",
-    proto: {
-        type: "lite",
-        static: true,
-    },
     min_sdk_version: "30",
     shared_libs: ["liblog"],
     // static c++/libbase for smaller size
@@ -26,15 +22,13 @@
         "libbase",
         "libmodules-utils-build",
         "libprotobuf-cpp-lite",
+        "libsdk_proto"
     ],
 }
 
 cc_library {
     name: "libderive_sdk",
-    srcs: [
-        "derive_sdk.cpp",
-        "sdk.proto",
-    ],
+    srcs: ["derive_sdk.cpp"],
     defaults: ["derive_sdk-defaults"],
     apex_available: ["com.android.sdkext"],
 }
@@ -66,10 +60,7 @@
 cc_test {
     name: "derive_sdk_test",
     defaults: ["derive_sdk-defaults"],
-    srcs: [
-        "derive_sdk_test.cpp",
-        "sdk.proto",
-    ],
+    srcs: ["derive_sdk_test.cpp"],
     require_root: true,
     static_libs: ["libderive_sdk"],
     test_suites: ["device-tests"],
diff --git a/derive_sdk/derive_sdk.cpp b/derive_sdk/derive_sdk.cpp
index fb5f1f5..c117120 100644
--- a/derive_sdk/derive_sdk.cpp
+++ b/derive_sdk/derive_sdk.cpp
@@ -29,9 +29,7 @@
 #include <iostream>
 #include <vector>
 
-#include "packages/modules/SdkExtensions/derive_sdk/sdk.pb.h"
-
-using com::android::sdkext::proto::SdkVersion;
+#include "packages/modules/SdkExtensions/proto/sdk.pb.h"
 
 namespace android {
 namespace derivesdk {
diff --git a/derive_sdk/derive_sdk_test.cpp b/derive_sdk/derive_sdk_test.cpp
index 72ff9ab..a0eb2a9 100644
--- a/derive_sdk/derive_sdk_test.cpp
+++ b/derive_sdk/derive_sdk_test.cpp
@@ -26,9 +26,7 @@
 
 #include <cstdlib>
 
-#include "packages/modules/SdkExtensions/derive_sdk/sdk.pb.h"
-
-using com::android::sdkext::proto::SdkVersion;
+#include "packages/modules/SdkExtensions/proto/sdk.pb.h"
 
 class DeriveSdkTest : public ::testing::Test {
  protected:
diff --git a/proto/Android.bp b/proto/Android.bp
new file mode 100644
index 0000000..f0fd95d
--- /dev/null
+++ b/proto/Android.bp
@@ -0,0 +1,40 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+python_library_host {
+    name: "sdk_proto_python",
+    version: {
+        py2: {
+            enabled: true,
+        },
+        py3: {
+            enabled: true,
+        },
+    },
+    srcs: ["sdk.proto"],
+    proto: {
+        canonical_path_from_root: false,
+    },
+}
+
+cc_library_static {
+    name: "libsdk_proto",
+    proto: {
+        export_proto_headers: true,
+        type: "lite",
+    },
+    srcs: ["sdk.proto"],
+    min_sdk_version: "30",
+    apex_available: ["com.android.sdkext"],
+}
diff --git a/derive_sdk/sdk.proto b/proto/sdk.proto
similarity index 85%
rename from derive_sdk/sdk.proto
rename to proto/sdk.proto
index d15b935..f030c61 100644
--- a/derive_sdk/sdk.proto
+++ b/proto/sdk.proto
@@ -15,10 +15,6 @@
  */
 
 syntax = "proto3";
-package com.android.sdkext.proto;
-
-option java_outer_classname = "SdkProto";
-option optimize_for = LITE_RUNTIME;
 
 message SdkVersion {
   int32 version = 1;
diff --git a/sdk.proto b/sdk.proto
deleted file mode 100644
index d15b935..0000000
--- a/sdk.proto
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-syntax = "proto3";
-package com.android.sdkext.proto;
-
-option java_outer_classname = "SdkProto";
-option optimize_for = LITE_RUNTIME;
-
-message SdkVersion {
-  int32 version = 1;
-}