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

Commit 3afdc719 authored by Cole Faust's avatar Cole Faust
Browse files

Use modern_python_path_defaults

The python path for soong-built modules used to automatically
include all the subdirectories of the root package, and also
the package of the entrypoint script. Soong is being updated
to remove that, to match bazel's behavior and soong's behavior
with embedded_launcher: true, so update these scripts to work
with the new behavior.

Bug: 245583294
Test: m pdl_python_generator_test pdl_python_parser_test && /ssd/aosp-master/out/host/linux-x86/nativetest64/pdl_python_generator_test/pdl_python_generator_test && /ssd/aosp-master/out/host/linux-x86/nativetest64/pdl_python_parser_test/pdl_python_parser_test
Change-Id: I6b64c0ed77e41348992cf266ce601977ac754f20
parent fa91bb06
Loading
Loading
Loading
Loading
+7 −17
Original line number Diff line number Diff line
@@ -33,12 +33,6 @@ rust_binary_host {
    defaults: ["pdl_defaults"],
}

python_binary_host {
    name: "pypdl",
    main: "scripts/pdl/parser.py",
    srcs: ["scripts/pdl/parser.py"],
}

rust_test_host {
    name: "pdl_inline_tests",
    defaults: ["pdl_defaults"],
@@ -84,17 +78,6 @@ rust_test_host {
    ],
}

// Python generator.
python_binary_host {
    name: "pdl_python_generator",
    main: "scripts/generate_python_backend.py",
    srcs: [
        "scripts/generate_python_backend.py",
        "scripts/pdl/ast.py",
        "scripts/pdl/core.py",
    ]
}

// Defaults for PDL python backend generation.
genrule_defaults {
    name: "pdl_python_generator_defaults",
@@ -146,6 +129,7 @@ genrule {
// pre-generated binary inputs.
python_test_host {
    name: "pdl_python_generator_test",
    defaults: ["modern_python_path_defaults"],
    main: "tests/python_generator_test.py",
    srcs: [
        "tests/python_generator_test.py",
@@ -163,12 +147,18 @@ python_test_host {
    test_options: {
        unit_test: true,
    },
    version: {
        py3: {
            embedded_launcher: true,
        },
    },
}

// Test the python parser against the rust parser
// on selected PDL source files.
python_test_host {
    name: "pdl_python_parser_test",
    defaults: ["modern_python_path_defaults"],
    main: "tests/python_parser_test.py",
    srcs: ["tests/python_parser_test.py"],
    data: [
+27 −0
Original line number Diff line number Diff line
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "system_bt_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["system_bt_license"],
}

python_binary_host {
    name: "pypdl",
    defaults: ["modern_python_path_defaults"],
    main: "pdl/parser.py",
    srcs: ["pdl/parser.py"],
}

// Python generator.
python_binary_host {
    name: "pdl_python_generator",
    defaults: ["modern_python_path_defaults"],
    main: "generate_python_backend.py",
    srcs: [
        "generate_python_backend.py",
        "pdl/ast.py",
        "pdl/core.py",
    ]
}
+5 −4
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import json
import typing
import typing_extensions
import unittest
from importlib import resources

# (le|be)_pdl_test are the names of the modules generated from the canonical
# little endian and big endian test grammars. The purpose of this module
@@ -68,7 +69,7 @@ class PacketParserTest(unittest.TestCase):
       vectors in canonical/(le|be)_test_vectors.json"""

    def testLittleEndian(self):
        with open('tests/canonical/le_test_vectors.json') as f:
        with resources.files('tests.canonical').joinpath('le_test_vectors.json').open('r') as f:
            reference = json.load(f)

        for item in reference:
@@ -87,7 +88,7 @@ class PacketParserTest(unittest.TestCase):
                    match_object(self, result, test['unpacked'])

    def testBigEndian(self):
        with open('tests/canonical/be_test_vectors.json') as f:
        with resources.files('tests.canonical').joinpath('be_test_vectors.json').open('r') as f:
            reference = json.load(f)

        for item in reference:
@@ -111,7 +112,7 @@ class PacketSerializerTest(unittest.TestCase):
       vectors in canonical/(le|be)_test_vectors.json"""

    def testLittleEndian(self):
        with open('tests/canonical/le_test_vectors.json') as f:
        with resources.files('tests.canonical').joinpath('le_test_vectors.json').open('r') as f:
            reference = json.load(f)

        for item in reference:
@@ -131,7 +132,7 @@ class PacketSerializerTest(unittest.TestCase):
                    self.assertEqual(result, bytes.fromhex(test['packed']))

    def testBigEndian(self):
        with open('tests/canonical/be_test_vectors.json') as f:
        with resources.files('tests.canonical').joinpath('be_test_vectors.json').open('r') as f:
            reference = json.load(f)

        for item in reference: