Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4f9ad5d authored by LuK1337's avatar LuK1337
Browse files

sm8150-common: sensors: Move to AOSP Soong conditionals

Change-Id: I220357b268053463044e2780ae70dfff3bb5a301
parent 56ce6271
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -13,6 +13,26 @@
// See the License for the specific language governing permissions and
// limitations under the License.

soong_config_module_type {
    name: "oneplus_msmnile_sensors_hal_cc_defaults",
    module_type: "cc_defaults",
    config_namespace: "ONEPLUS_MSMNILE_SENSORS",
    value_variables: ["ALS_POS_X", "ALS_POS_Y"],
    properties: ["cppflags"],
}

oneplus_msmnile_sensors_hal_cc_defaults {
    name: "oneplus_msmnile_sensors_hal_defaults",
    soong_config_variables: {
        ALS_POS_X: {
            cppflags: ["-DALS_POS_X=%s"],
        },
        ALS_POS_Y: {
            cppflags: ["-DALS_POS_Y=%s"],
        },
    },
}

cc_binary {
    name: "android.hardware.sensors@2.0-service.oneplus_msmnile",
    stem: "android.hardware.sensors@2.0-service.multihal",
@@ -53,10 +73,13 @@ cc_binary {
    ],
}

oneplus_msmnile_sensors_hal_binary {
cc_binary {
    name: "als_correction_service.oneplus_msmnile",
    stem: "als_correction_service",
    init_rc: ["als_correction_service.rc"],
    defaults: [
        "oneplus_msmnile_sensors_hal_defaults",
    ],
    srcs: [
        "als_correction_service.cpp",
    ],

soong/Android.bp

deleted100644 → 0
+0 −17
Original line number Diff line number Diff line
bootstrap_go_package {
    name: "soong-oneplus-msmnile-plugins",
    pkgPath: "device/oneplus/sm8150-common",
    deps: [
        "blueprint",
        "blueprint-pathtools",
        "soong",
        "soong-android",
        "soong-cc",
        "soong-genrule",
    ],
    srcs: [
        "sensors.go",
        "main.go",
    ],
    pluginFor: ["soong_build"],
}

soong/main.go

deleted100644 → 0
+0 −9
Original line number Diff line number Diff line
package msmnile

import (
    "android/soong/android"
)

func init() {
    android.RegisterModuleType("oneplus_msmnile_sensors_hal_binary", sensorsHalBinaryFactory)
}

soong/sensors.go

deleted100644 → 0
+0 −39
Original line number Diff line number Diff line
package msmnile

import (
    "android/soong/android"
    "android/soong/cc"
    "strings"
)

func sensorsFlags(ctx android.BaseContext) []string {
    var cflags []string

    var config = ctx.AConfig().VendorConfig("ONEPLUS_MSMNILE_SENSORS")
    var posX = strings.TrimSpace(config.String("ALS_POS_X"))
    var posY = strings.TrimSpace(config.String("ALS_POS_Y"))

    cflags = append(cflags, "-DALS_POS_X=" + posX, "-DALS_POS_Y=" + posY)
    return cflags
}

func sensorsHalBinary(ctx android.LoadHookContext) {
    type props struct {
        Target struct {
            Android struct {
                Cflags []string
            }
        }
    }

    p := &props{}
    p.Target.Android.Cflags = sensorsFlags(ctx)
    ctx.AppendProperties(p)
}

func sensorsHalBinaryFactory() android.Module {
    module, _ := cc.NewBinary(android.HostAndDeviceSupported)
    newMod := module.Init()
    android.AddLoadHook(newMod, sensorsHalBinary)
    return newMod
}