0

I want to compile my renderscript project with a .rs file on AOSP.

My AOSP SDK is 29 (Android Q).

My build directory for mm is

├── Android.bp
├── AndroidManifest.xml
├── java
├── lib
├── lib64
├── libs
├── res
└── rs
    └── histEq.rs

I have followed How to generate RenderScript ScriptC* files with Android.mk? and tried this corresponding change:

android_app {
    name: "MyAndroidApp",
    manifest: "AndroidManifest.xml",
    srcs: [
        "java/**/*.java",
        "rs/histEq.rs",
    ],

However, I am still getting this build error.

<path to code>/utils/RenderScriptImageEdit.java:11: error: cannot find symbol
import <package name>.ScriptC_histEq;
                            ^
  symbol:   class ScriptC_histEq
  location: package <package name>
<path to code>/utils/RenderScriptImageEdit.java:43: error: cannot find symbol
        ScriptC_histEq histEqScript = new ScriptC_histEq(rs);
        ^
  symbol:   class ScriptC_histEq
  location: class RenderScriptImageEdit
<path to code>/utils/RenderScriptImageEdit.java:43: error: cannot find symbol
        ScriptC_histEq histEqScript = new ScriptC_histEq(rs);
                                          ^
  symbol:   class ScriptC_histEq
  location: class RenderScriptImageEdit

Renaming .rs to .rscript also did not work.

How to compile .rs files on AOSP 29 with Android.bp?

zeitgeist
  • 852
  • 12
  • 19

1 Answers1

1

Try like this https://cs.android.com/android/platform/superproject/+/master:cts/tests/tests/renderscript/Android.bp

Seems, they are building using custom compiler-command, instead of adding rs file as src directly:

// Copyright (C) 2011 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
//

package {
    // See: http://go/android-license-faq
    default_applicable_licenses: ["Android-Apache-2.0"],
}

android_test {
    name: "CtsRenderscriptTestCases",
    defaults: ["cts_defaults"],
    // Include both the 32 and 64 bit versions
    compile_multilib: "both",
    static_libs: [
        "compatibility-device-util-axt",
        "ctstestrunner-axt",
        "xmp_toolkit",
    ],
    libs: ["android.test.base.stubs"],
    jni_libs: ["libcoremathtestcpp_jni"],
    srcs: [
        "src/**/*.java",
        ":CtsRenderscriptTestCases-rscript{CtsRenderscriptTestCases.srcjar}",
    ],
    resource_zips: [
        ":CtsRenderscriptTestCases-rscript{CtsRenderscriptTestCases.res.zip}",
    ],
    sdk_version: "current",
    // Tag this module as a cts test artifact
    test_suites: [
        "cts",
        "general-tests",
    ],
}

genrule {
    name: "CtsRenderscriptTestCases-rscript",
    srcs: [
        "src/**/*.rscript",
        "src/**/*.rsh",
        ":rs_script_api",
        ":rs_clang_headers",
    ],
    tools: [
        "llvm-rs-cc",
        "soong_zip",
    ],
    out: [
        "CtsRenderscriptTestCases.srcjar",
        "CtsRenderscriptTestCases.res.zip",
    ],
    cmd: "for f in $(locations src/**/*.rscript); do " +
        "  $(location llvm-rs-cc) -Wno-error=deprecated-declarations " +
        "  -o $(genDir)/res/raw -p $(genDir)/src " +
        "  -I $$(dirname $$(echo $(locations :rs_script_api) | awk '{ print $$1 }')) " +
        "  -I $$(dirname $$(echo $(locations :rs_clang_headers) | awk '{ print $$1 }')) $${f}; " +
        "done && " +
        "$(location soong_zip) -srcjar -o $(location CtsRenderscriptTestCases.srcjar) -C $(genDir)/src -D $(genDir)/src &&" +
        "$(location soong_zip) -o $(location CtsRenderscriptTestCases.res.zip) -C $(genDir)/res -D $(genDir)/res",
}
Top-Master
  • 7,611
  • 5
  • 39
  • 71
Ashok Mutyala
  • 89
  • 1
  • 4
  • Didn't work out for me on Android Q AOSP. I got `"module CtsRenderscriptTestCases-rscript missing dependencies: rs_script_api, rs_clang_headers"` – zeitgeist May 14 '22 at 05:50
  • Both dependencies are introduced in 2021. you can remove and try compile – Ashok Mutyala May 14 '22 at 10:17
  • I am now getting `"QMedia" depends on undefined module "CtsRenderscriptTestCases-rscript{CtsRenderscriptTestCases.srcjar}"` and `"QMedia" depends on undefined module "CtsRenderscriptTestCases-rscript{CtsRenderscriptTestCases.res.zip}"`. You can see the results at https://ideone.com/ZIr3dE – zeitgeist May 16 '22 at 14:28