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

Commit 36d9558c authored by Liz Kammer's avatar Liz Kammer Committed by Automerger Merge Worker
Browse files

Merge "Do not sort after subtraction." am: 06f00c33

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1853858

Change-Id: Ia3269f2661633b9236aafbc11b529cf5bbaed367
parents 8169a368 06f00c33
Loading
Loading
Loading
Loading
+13 −25
Original line number Diff line number Diff line
@@ -164,23 +164,17 @@ func UniqueSortedBazelLabelList(originalLabelList LabelList) LabelList {
// Subtract needle from haystack
func SubtractStrings(haystack []string, needle []string) []string {
	// This is really a set
	remainder := make(map[string]bool)

	for _, s := range haystack {
		remainder[s] = true
	}
	needleMap := make(map[string]bool)
	for _, s := range needle {
		delete(remainder, s)
		needleMap[s] = true
	}

	var strings []string
	for s, _ := range remainder {
	for _, s := range haystack {
		if exclude := needleMap[s]; !exclude {
			strings = append(strings, s)
		}

	sort.SliceStable(strings, func(i, j int) bool {
		return strings[i] < strings[j]
	})
	}

	return strings
}
@@ -188,23 +182,17 @@ func SubtractStrings(haystack []string, needle []string) []string {
// Subtract needle from haystack
func SubtractBazelLabels(haystack []Label, needle []Label) []Label {
	// This is really a set
	remainder := make(map[Label]bool)

	for _, label := range haystack {
		remainder[label] = true
	}
	for _, label := range needle {
		delete(remainder, label)
	needleMap := make(map[Label]bool)
	for _, s := range needle {
		needleMap[s] = true
	}

	var labels []Label
	for label, _ := range remainder {
	for _, label := range haystack {
		if exclude := needleMap[label]; !exclude {
			labels = append(labels, label)
		}

	sort.SliceStable(labels, func(i, j int) bool {
		return labels[i].Label < labels[j].Label
	})
	}

	return labels
}
+4 −4
Original line number Diff line number Diff line
@@ -1669,21 +1669,21 @@ cc_library {
    srcs = ["base.cpp"] + select({
        "//build/bazel/platforms/os:android": [
            "android.cpp",
            "bionic.cpp",
            "linux.cpp",
            "bionic.cpp",
        ],
        "//build/bazel/platforms/os:darwin": ["darwin.cpp"],
        "//build/bazel/platforms/os:linux": [
            "linux.cpp",
            "linux_glibc.cpp",
            "linux.cpp",
        ],
        "//build/bazel/platforms/os:linux_bionic": [
            "bionic.cpp",
            "linux.cpp",
            "bionic.cpp",
        ],
        "//build/bazel/platforms/os:linux_musl": [
            "linux.cpp",
            "linux_musl.cpp",
            "linux.cpp",
        ],
        "//build/bazel/platforms/os:windows": ["windows.cpp"],
        "//conditions:default": [],
+23 −23
Original line number Diff line number Diff line
@@ -641,12 +641,12 @@ cc_library_static {
    name = "foo_static",
    srcs_c = ["common.c"] + select({
        "//build/bazel/platforms/arch:arm": [
            "for-arm.c",
            "not-for-x86.c",
            "for-arm.c",
        ],
        "//build/bazel/platforms/arch:x86": [
            "for-x86.c",
            "not-for-arm.c",
            "for-x86.c",
        ],
        "//conditions:default": [
            "not-for-arm.c",
@@ -691,28 +691,28 @@ cc_library_static {
    name = "foo_static",
    srcs_c = ["common.c"] + select({
        "//build/bazel/platforms/arch:arm": [
            "for-arm.c",
            "not-for-arm64.c",
            "not-for-x86.c",
            "not-for-x86_64.c",
            "for-arm.c",
        ],
        "//build/bazel/platforms/arch:arm64": [
            "for-arm64.c",
            "not-for-arm.c",
            "not-for-x86.c",
            "not-for-x86_64.c",
            "for-arm64.c",
        ],
        "//build/bazel/platforms/arch:x86": [
            "for-x86.c",
            "not-for-arm.c",
            "not-for-arm64.c",
            "not-for-x86_64.c",
            "for-x86.c",
        ],
        "//build/bazel/platforms/arch:x86_64": [
            "for-x86_64.c",
            "not-for-arm.c",
            "not-for-arm64.c",
            "not-for-x86.c",
            "for-x86_64.c",
        ],
        "//conditions:default": [
            "not-for-arm.c",
@@ -875,20 +875,20 @@ cc_library_static {
    name = "foo_static2",
    srcs_c = ["common.c"] + select({
        "//build/bazel/platforms/arch:arm": [
            "for-lib32.c",
            "not-for-lib64.c",
            "for-lib32.c",
        ],
        "//build/bazel/platforms/arch:arm64": [
            "for-lib64.c",
            "not-for-lib32.c",
            "for-lib64.c",
        ],
        "//build/bazel/platforms/arch:x86": [
            "for-lib32.c",
            "not-for-lib64.c",
            "for-lib32.c",
        ],
        "//build/bazel/platforms/arch:x86_64": [
            "for-lib64.c",
            "not-for-lib32.c",
            "for-lib64.c",
        ],
        "//conditions:default": [
            "not-for-lib32.c",
@@ -942,36 +942,36 @@ cc_library_static {
    name = "foo_static3",
    srcs_c = ["common.c"] + select({
        "//build/bazel/platforms/arch:arm": [
            "for-arm.c",
            "for-lib32.c",
            "not-for-arm64.c",
            "not-for-lib64.c",
            "not-for-x86.c",
            "not-for-x86_64.c",
            "for-arm.c",
            "for-lib32.c",
        ],
        "//build/bazel/platforms/arch:arm64": [
            "for-arm64.c",
            "for-lib64.c",
            "not-for-arm.c",
            "not-for-lib32.c",
            "not-for-x86.c",
            "not-for-x86_64.c",
            "for-arm64.c",
            "for-lib64.c",
        ],
        "//build/bazel/platforms/arch:x86": [
            "for-lib32.c",
            "for-x86.c",
            "not-for-arm.c",
            "not-for-arm64.c",
            "not-for-lib64.c",
            "not-for-x86_64.c",
            "for-x86.c",
            "for-lib32.c",
        ],
        "//build/bazel/platforms/arch:x86_64": [
            "for-lib64.c",
            "for-x86_64.c",
            "not-for-arm.c",
            "not-for-arm64.c",
            "not-for-lib32.c",
            "not-for-x86.c",
            "for-x86_64.c",
            "for-lib64.c",
        ],
        "//conditions:default": [
            "not-for-arm.c",
@@ -1066,19 +1066,19 @@ cc_library_static {
		expectedBazelTargets: []string{`cc_library_static(
    name = "foo_static3",
    srcs = [
        "//dep:generated_hdr_other_pkg",
        "//dep:generated_src_other_pkg",
        "common.cpp",
        ":generated_hdr",
        "//dep:generated_hdr_other_pkg",
        ":generated_src",
        "common.cpp",
        "//dep:generated_src_other_pkg",
    ] + select({
        "//build/bazel/platforms/arch:x86": [
            "//dep:generated_hdr_other_pkg_x86",
            "for-x86.cpp",
            "//dep:generated_hdr_other_pkg_x86",
        ],
        "//conditions:default": [
            ":generated_src_not_x86",
            "not-for-x86.cpp",
            ":generated_src_not_x86",
        ],
    }) + select({
        "//build/bazel/platforms/os:android": [
+2 −2
Original line number Diff line number Diff line
@@ -439,13 +439,13 @@ func TestCcObjectSelectOnLinuxAndBionicArchs(t *testing.T) {
    copts = ["-fno-addrsig"],
    srcs = ["base.cpp"] + select({
        "//build/bazel/platforms/os_arch:android_arm64": [
            "bionic_arm64.cpp",
            "linux_arm64.cpp",
            "bionic_arm64.cpp",
        ],
        "//build/bazel/platforms/os_arch:android_x86": ["linux_x86.cpp"],
        "//build/bazel/platforms/os_arch:linux_bionic_arm64": [
            "bionic_arm64.cpp",
            "linux_arm64.cpp",
            "bionic_arm64.cpp",
        ],
        "//build/bazel/platforms/os_arch:linux_glibc_x86": ["linux_x86.cpp"],
        "//build/bazel/platforms/os_arch:linux_musl_x86": ["linux_x86.cpp"],