Commit ea362d37 authored by agrieve's avatar agrieve Committed by Commit bot

Port //base/android/jni_generator/jni_generator.gyp to GN

BUG=573259,573250

Review URL: https://codereview.chromium.org/1557623002

Cr-Commit-Position: refs/heads/master@{#367189}
parent c2a7942a
...@@ -1891,6 +1891,7 @@ test("base_unittests") { ...@@ -1891,6 +1891,7 @@ test("base_unittests") {
deps += [ deps += [
":base_java", ":base_java",
":base_java_unittest_support", ":base_java_unittest_support",
"//base/android/jni_generator:jni_generator_tests",
] ]
# TODO(brettw) I think this should not be here, we should not be using # TODO(brettw) I think this should not be here, we should not be using
......
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/android/rules.gni")
import("//testing/test.gni")
# GYP: //base/android/jni_generator/jni_generator.gyp:jni_generator_py_tests
action("jni_generator_py_tests") {
_stamp = "$target_gen_dir/jni_generator_py_tests.stamp"
inputs = [
"jni_generator.py",
"jni_generator_tests.py",
"java/src/org/chromium/example/jni_generator/SampleForTests.java",
"golden_sample_for_tests_jni.h",
]
outputs = [
_stamp,
]
script = "jni_generator_tests.py"
args = [
"--stamp",
rebase_path(_stamp, root_build_dir),
]
}
# GYP: //base/android/jni_generator/jni_generator.gyp:jni_sample_header
generate_jni("jni_sample_header") {
sources = [
"java/src/org/chromium/example/jni_generator/SampleForTests.java",
]
jni_package = "example"
}
# GYP: //base/android/jni_generator/jni_generator.gyp:jni_sample_java
android_library("jni_sample_java") {
DEPRECATED_java_in_dir = "java/src"
deps = [
"//base:base_java",
]
}
# This executable doesn't actually run, but at least serves to test that
# generated bindings compile properly.
# GYP: //base/android/jni_generator/jni_generator.gyp:jni_generator_tests
executable("jni_generator_tests") {
deps = [
":jni_generator_py_tests",
":jni_sample_header",
":jni_sample_java",
"//base",
]
sources = [
"sample_for_tests.cc",
"sample_for_tests.h",
]
}
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
{ {
'targets': [ 'targets': [
# GYP: //base/android/jni_generator:jni_generator_tests
{ {
'target_name': 'jni_generator_py_tests', 'target_name': 'jni_generator_py_tests',
'type': 'none', 'type': 'none',
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
}, },
], ],
}, },
# GYP: //base/android/jni_generator:jni_sample_header
{ {
'target_name': 'jni_sample_header', 'target_name': 'jni_sample_header',
'type': 'none', 'type': 'none',
...@@ -40,6 +42,7 @@ ...@@ -40,6 +42,7 @@
}, },
'includes': [ '../../../build/jni_generator.gypi' ], 'includes': [ '../../../build/jni_generator.gypi' ],
}, },
# GYP: //base/android/jni_generator:jni_sample_java
{ {
'target_name': 'jni_sample_java', 'target_name': 'jni_sample_java',
'type': 'none', 'type': 'none',
...@@ -51,6 +54,7 @@ ...@@ -51,6 +54,7 @@
], ],
'includes': [ '../../../build/java.gypi' ], 'includes': [ '../../../build/java.gypi' ],
}, },
# GYP: //base/android/jni_generator:jni_generator_tests
{ {
'target_name': 'jni_generator_tests', 'target_name': 'jni_generator_tests',
'type': 'executable', 'type': 'executable',
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <iostream>
#include "base/android/jni_generator/sample_for_tests.h" #include "base/android/jni_generator/sample_for_tests.h"
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
...@@ -62,6 +64,7 @@ void CPPClass::IterateAndDoSomethingWithStructB( ...@@ -62,6 +64,7 @@ void CPPClass::IterateAndDoSomethingWithStructB(
it != map_.end(); ++it) { it != map_.end(); ++it) {
long key = it->first; long key = it->first;
std::string value = it->second; std::string value = it->second;
std::cout << key << value;
} }
map_.clear(); map_.clear();
} }
...@@ -97,10 +100,6 @@ static ScopedJavaLocalRef<jobject> GetNonPODDatatype( ...@@ -97,10 +100,6 @@ static ScopedJavaLocalRef<jobject> GetNonPODDatatype(
return ScopedJavaLocalRef<jobject>(); return ScopedJavaLocalRef<jobject>();
} }
static jint InnerFunction(JNIEnv*, jclass) {
return 0;
}
} // namespace android } // namespace android
} // namespace base } // namespace base
...@@ -118,6 +117,8 @@ int main() { ...@@ -118,6 +117,8 @@ int main() {
int bar = base::android::Java_SampleForTests_javaMethod( int bar = base::android::Java_SampleForTests_javaMethod(
env, my_java_object, 1, 2); env, my_java_object, 1, 2);
std::cout << foo << bar;
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
// Creates a "struct" that will then be used by the java side. // Creates a "struct" that will then be used by the java side.
ScopedJavaLocalRef<jobject> struct_a = ScopedJavaLocalRef<jobject> struct_a =
...@@ -127,5 +128,9 @@ int main() { ...@@ -127,5 +128,9 @@ int main() {
env, my_java_object, struct_a.obj()); env, my_java_object, struct_a.obj());
} }
base::android::Java_SampleForTests_iterateAndDoSomething(env, my_java_object); base::android::Java_SampleForTests_iterateAndDoSomething(env, my_java_object);
base::android::Java_SampleForTests_packagePrivateJavaMethod(env,
my_java_object);
base::android::Java_SampleForTests_methodThatThrowsException(env,
my_java_object);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment