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

Commit dfcdeec8 authored by Colin Cross's avatar Colin Cross Committed by android-build-merger
Browse files

Merge changes I6f7d40b7,I25654032

am: 83a49583

Change-Id: Ie7c908f45fcd7e9d8858e77035700d67cee009fe
parents 1ce7bf12 83a49583
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -323,6 +323,12 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
			flagsToBuilderFlags(flags), afterPrefixSymbols)
	}

	if Bool(binary.baseLinker.Properties.Use_version_lib) && ctx.Host() {
		versionedOutputFile := outputFile
		outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
		binary.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
	}

	linkerDeps = append(linkerDeps, deps.SharedLibsDeps...)
	linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...)
	linkerDeps = append(linkerDeps, objs.tidyFiles...)
+12 −0
Original line number Diff line number Diff line
cc_library_static {
    name: "libbuildversion",
    host_supported: true,
    srcs: ["libbuildversion.cpp"],
    export_include_dirs: ["include"],
    cflags: ["-fvisibility=hidden"],
    target: {
        windows: {
            enabled: true,
        },
    },
}
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef BUILD_VERSION_H
#define BUILD_VERSION_H

#include <string>

namespace android {
namespace build {

std::string GetBuildNumber();

} // namespace build
} // namespace android

#endif  // BUILD_VERSION_H
+55 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <build/version.h>

#ifdef __ANDROID__
#include <sys/system_properties.h>
#endif

namespace android {
namespace build {

#ifdef __ANDROID__

std::string GetBuildNumber() {
  const prop_info* pi = __system_property_find("ro.build.version.incremental");
  if (pi == nullptr) return "";

  std::string property_value;
  __system_property_read_callback(pi,
                                  [](void* cookie, const char*, const char* value, unsigned) {
                                    auto property_value = reinterpret_cast<std::string*>(cookie);
                                    *property_value = value;
                                  },
                                  &property_value);

  return property_value;
}

#else

extern "C" {
  char soong_build_number[128] = "SOONG BUILD NUMBER PLACEHOLDER";
}

std::string GetBuildNumber() {
  return soong_build_number;
}

#endif
}  // namespace build
}  // namespace android
+35 −0
Original line number Diff line number Diff line
cc_defaults {
    name: "build_version_test_defaults",
    use_version_lib: true,
    host_supported: true,
    target: {
        windows: {
            enabled: true,
        },
    },
}

cc_test {
    name: "build_version_test",
    defaults: ["build_version_test_defaults"],
    srcs: ["build_version_test.cpp"],
    target: {
        android: {
            shared_libs: ["libbuild_version_test"],
        },
        not_windows: {
            shared_libs: ["libbuild_version_test"],
        },
    },
}

cc_library_shared {
    name: "libbuild_version_test",
    defaults: ["build_version_test_defaults"],
    srcs: ["build_version_test_lib.cpp"],
    target: {
        windows: {
            enabled: false,
        },
    },
}
Loading