xref: /aosp_15_r20/build/soong/cc/ndk_sysroot.go (revision 333d2b3687b3a337dbcca9d65000bca186795e39)
1*333d2b36SAndroid Build Coastguard Worker// Copyright 2016 Google Inc. All rights reserved.
2*333d2b36SAndroid Build Coastguard Worker//
3*333d2b36SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License");
4*333d2b36SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License.
5*333d2b36SAndroid Build Coastguard Worker// You may obtain a copy of the License at
6*333d2b36SAndroid Build Coastguard Worker//
7*333d2b36SAndroid Build Coastguard Worker//     http://www.apache.org/licenses/LICENSE-2.0
8*333d2b36SAndroid Build Coastguard Worker//
9*333d2b36SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
10*333d2b36SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS,
11*333d2b36SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*333d2b36SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and
13*333d2b36SAndroid Build Coastguard Worker// limitations under the License.
14*333d2b36SAndroid Build Coastguard Worker
15*333d2b36SAndroid Build Coastguard Workerpackage cc
16*333d2b36SAndroid Build Coastguard Worker
17*333d2b36SAndroid Build Coastguard Worker// The platform needs to provide the following artifacts for the NDK:
18*333d2b36SAndroid Build Coastguard Worker// 1. Bionic headers.
19*333d2b36SAndroid Build Coastguard Worker// 2. Platform API headers.
20*333d2b36SAndroid Build Coastguard Worker// 3. NDK stub shared libraries.
21*333d2b36SAndroid Build Coastguard Worker// 4. Bionic static libraries.
22*333d2b36SAndroid Build Coastguard Worker//
23*333d2b36SAndroid Build Coastguard Worker// TODO(danalbert): All of the above need to include NOTICE files.
24*333d2b36SAndroid Build Coastguard Worker//
25*333d2b36SAndroid Build Coastguard Worker// Components 1 and 2: Headers
26*333d2b36SAndroid Build Coastguard Worker// The bionic and platform API headers are generalized into a single
27*333d2b36SAndroid Build Coastguard Worker// `ndk_headers` rule. This rule has a `from` property that indicates a base
28*333d2b36SAndroid Build Coastguard Worker// directory from which headers are to be taken, and a `to` property that
29*333d2b36SAndroid Build Coastguard Worker// indicates where in the sysroot they should reside relative to usr/include.
30*333d2b36SAndroid Build Coastguard Worker// There is also a `srcs` property that is glob compatible for specifying which
31*333d2b36SAndroid Build Coastguard Worker// headers to include.
32*333d2b36SAndroid Build Coastguard Worker//
33*333d2b36SAndroid Build Coastguard Worker// Component 3: Stub Libraries
34*333d2b36SAndroid Build Coastguard Worker// The shared libraries in the NDK are not the actual shared libraries they
35*333d2b36SAndroid Build Coastguard Worker// refer to (to prevent people from accidentally loading them), but stub
36*333d2b36SAndroid Build Coastguard Worker// libraries with placeholder implementations of everything for use at build time
37*333d2b36SAndroid Build Coastguard Worker// only.
38*333d2b36SAndroid Build Coastguard Worker//
39*333d2b36SAndroid Build Coastguard Worker// Since we don't actually need to know anything about the stub libraries aside
40*333d2b36SAndroid Build Coastguard Worker// from a list of functions and globals to be exposed, we can create these for
41*333d2b36SAndroid Build Coastguard Worker// every platform level in the current tree. This is handled by the
42*333d2b36SAndroid Build Coastguard Worker// ndk_library rule.
43*333d2b36SAndroid Build Coastguard Worker//
44*333d2b36SAndroid Build Coastguard Worker// Component 4: Static Libraries
45*333d2b36SAndroid Build Coastguard Worker// The NDK only provides static libraries for bionic, not the platform APIs.
46*333d2b36SAndroid Build Coastguard Worker// Since these need to be the actual implementation, we can't build old versions
47*333d2b36SAndroid Build Coastguard Worker// in the current platform tree. As such, legacy versions are checked in
48*333d2b36SAndroid Build Coastguard Worker// prebuilt to development/ndk, and a current version is built and archived as
49*333d2b36SAndroid Build Coastguard Worker// part of the platform build. The platfrom already builds these libraries, our
50*333d2b36SAndroid Build Coastguard Worker// NDK build rules only need to archive them for retrieval so they can be added
51*333d2b36SAndroid Build Coastguard Worker// to the prebuilts.
52*333d2b36SAndroid Build Coastguard Worker//
53*333d2b36SAndroid Build Coastguard Worker// TODO(danalbert): Write `ndk_static_library` rule.
54*333d2b36SAndroid Build Coastguard Worker
55*333d2b36SAndroid Build Coastguard Workerimport (
56*333d2b36SAndroid Build Coastguard Worker	"android/soong/android"
57*333d2b36SAndroid Build Coastguard Worker	"fmt"
58*333d2b36SAndroid Build Coastguard Worker	"path/filepath"
59*333d2b36SAndroid Build Coastguard Worker	"strings"
60*333d2b36SAndroid Build Coastguard Worker
61*333d2b36SAndroid Build Coastguard Worker	"github.com/google/blueprint"
62*333d2b36SAndroid Build Coastguard Worker)
63*333d2b36SAndroid Build Coastguard Worker
64*333d2b36SAndroid Build Coastguard Workervar (
65*333d2b36SAndroid Build Coastguard Worker	verifyCCompat = pctx.AndroidStaticRule("verifyCCompat",
66*333d2b36SAndroid Build Coastguard Worker		blueprint.RuleParams{
67*333d2b36SAndroid Build Coastguard Worker			Command:     "$ccCmd -x c -fsyntax-only $flags $in && touch $out",
68*333d2b36SAndroid Build Coastguard Worker			CommandDeps: []string{"$ccCmd"},
69*333d2b36SAndroid Build Coastguard Worker		},
70*333d2b36SAndroid Build Coastguard Worker		"ccCmd",
71*333d2b36SAndroid Build Coastguard Worker		"flags",
72*333d2b36SAndroid Build Coastguard Worker	)
73*333d2b36SAndroid Build Coastguard Worker)
74*333d2b36SAndroid Build Coastguard Worker
75*333d2b36SAndroid Build Coastguard Workerfunc init() {
76*333d2b36SAndroid Build Coastguard Worker	RegisterNdkModuleTypes(android.InitRegistrationContext)
77*333d2b36SAndroid Build Coastguard Worker}
78*333d2b36SAndroid Build Coastguard Worker
79*333d2b36SAndroid Build Coastguard Workerfunc RegisterNdkModuleTypes(ctx android.RegistrationContext) {
80*333d2b36SAndroid Build Coastguard Worker	ctx.RegisterModuleType("ndk_headers", NdkHeadersFactory)
81*333d2b36SAndroid Build Coastguard Worker	ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
82*333d2b36SAndroid Build Coastguard Worker	ctx.RegisterModuleType("preprocessed_ndk_headers", preprocessedNdkHeadersFactory)
83*333d2b36SAndroid Build Coastguard Worker	ctx.RegisterParallelSingletonType("ndk", NdkSingleton)
84*333d2b36SAndroid Build Coastguard Worker}
85*333d2b36SAndroid Build Coastguard Worker
86*333d2b36SAndroid Build Coastguard Workerfunc getNdkInstallBase(ctx android.PathContext) android.OutputPath {
87*333d2b36SAndroid Build Coastguard Worker	return android.PathForNdkInstall(ctx)
88*333d2b36SAndroid Build Coastguard Worker}
89*333d2b36SAndroid Build Coastguard Worker
90*333d2b36SAndroid Build Coastguard Worker// Returns the main install directory for the NDK sysroot. Usable with --sysroot.
91*333d2b36SAndroid Build Coastguard Workerfunc getNdkSysrootBase(ctx android.PathContext) android.OutputPath {
92*333d2b36SAndroid Build Coastguard Worker	return getNdkInstallBase(ctx).Join(ctx, "sysroot")
93*333d2b36SAndroid Build Coastguard Worker}
94*333d2b36SAndroid Build Coastguard Worker
95*333d2b36SAndroid Build Coastguard Worker// The base timestamp file depends on the NDK headers and stub shared libraries,
96*333d2b36SAndroid Build Coastguard Worker// but not the static libraries. This distinction is needed because the static
97*333d2b36SAndroid Build Coastguard Worker// libraries themselves might need to depend on the base sysroot.
98*333d2b36SAndroid Build Coastguard Workerfunc getNdkBaseTimestampFile(ctx android.PathContext) android.WritablePath {
99*333d2b36SAndroid Build Coastguard Worker	return android.PathForOutput(ctx, "ndk_base.timestamp")
100*333d2b36SAndroid Build Coastguard Worker}
101*333d2b36SAndroid Build Coastguard Worker
102*333d2b36SAndroid Build Coastguard Worker// The headers timestamp file depends only on the NDK headers.
103*333d2b36SAndroid Build Coastguard Worker// This is used mainly for .tidy files that do not need any stub libraries.
104*333d2b36SAndroid Build Coastguard Workerfunc getNdkHeadersTimestampFile(ctx android.PathContext) android.WritablePath {
105*333d2b36SAndroid Build Coastguard Worker	return android.PathForOutput(ctx, "ndk_headers.timestamp")
106*333d2b36SAndroid Build Coastguard Worker}
107*333d2b36SAndroid Build Coastguard Worker
108*333d2b36SAndroid Build Coastguard Worker// The full timestamp file depends on the base timestamp *and* the static
109*333d2b36SAndroid Build Coastguard Worker// libraries.
110*333d2b36SAndroid Build Coastguard Workerfunc getNdkFullTimestampFile(ctx android.PathContext) android.WritablePath {
111*333d2b36SAndroid Build Coastguard Worker	return android.PathForOutput(ctx, "ndk.timestamp")
112*333d2b36SAndroid Build Coastguard Worker}
113*333d2b36SAndroid Build Coastguard Worker
114*333d2b36SAndroid Build Coastguard Worker// The list of all NDK headers as they are located in the repo.
115*333d2b36SAndroid Build Coastguard Worker// Used for ABI monitoring to track only structures defined in NDK headers.
116*333d2b36SAndroid Build Coastguard Workerfunc getNdkABIHeadersFile(ctx android.PathContext) android.WritablePath {
117*333d2b36SAndroid Build Coastguard Worker	return android.PathForOutput(ctx, "ndk_abi_headers.txt")
118*333d2b36SAndroid Build Coastguard Worker}
119*333d2b36SAndroid Build Coastguard Worker
120*333d2b36SAndroid Build Coastguard Workerfunc verifyNdkHeaderIsCCompatible(ctx android.SingletonContext,
121*333d2b36SAndroid Build Coastguard Worker	src android.Path, dest android.Path) android.Path {
122*333d2b36SAndroid Build Coastguard Worker	sysrootInclude := getCurrentIncludePath(ctx)
123*333d2b36SAndroid Build Coastguard Worker	baseOutputDir := android.PathForOutput(ctx, "c-compat-verification")
124*333d2b36SAndroid Build Coastguard Worker	installRelPath, err := filepath.Rel(sysrootInclude.String(), dest.String())
125*333d2b36SAndroid Build Coastguard Worker	if err != nil {
126*333d2b36SAndroid Build Coastguard Worker		ctx.Errorf("filepath.Rel(%q, %q) failed: %s", dest, sysrootInclude, err)
127*333d2b36SAndroid Build Coastguard Worker	}
128*333d2b36SAndroid Build Coastguard Worker	output := baseOutputDir.Join(ctx, installRelPath)
129*333d2b36SAndroid Build Coastguard Worker	ctx.Build(pctx, android.BuildParams{
130*333d2b36SAndroid Build Coastguard Worker		Rule:        verifyCCompat,
131*333d2b36SAndroid Build Coastguard Worker		Description: fmt.Sprintf("Verifying C compatibility of %s", src),
132*333d2b36SAndroid Build Coastguard Worker		Output:      output,
133*333d2b36SAndroid Build Coastguard Worker		Input:       dest,
134*333d2b36SAndroid Build Coastguard Worker		// Ensures that all the headers in the sysroot are already installed
135*333d2b36SAndroid Build Coastguard Worker		// before testing any of the headers for C compatibility, and also that
136*333d2b36SAndroid Build Coastguard Worker		// the check will be re-run whenever the sysroot changes. This is
137*333d2b36SAndroid Build Coastguard Worker		// necessary because many of the NDK headers depend on other NDK
138*333d2b36SAndroid Build Coastguard Worker		// headers, but we don't have explicit dependency tracking for that.
139*333d2b36SAndroid Build Coastguard Worker		Implicits: []android.Path{getNdkHeadersTimestampFile(ctx)},
140*333d2b36SAndroid Build Coastguard Worker		Args: map[string]string{
141*333d2b36SAndroid Build Coastguard Worker			"ccCmd": "${config.ClangBin}/clang",
142*333d2b36SAndroid Build Coastguard Worker			"flags": fmt.Sprintf(
143*333d2b36SAndroid Build Coastguard Worker				// Ideally we'd check each ABI, multiple API levels,
144*333d2b36SAndroid Build Coastguard Worker				// fortify/non-fortify, and a handful of other variations. It's
145*333d2b36SAndroid Build Coastguard Worker				// a lot more difficult to do that though, and would eat up more
146*333d2b36SAndroid Build Coastguard Worker				// build time. All the problems we've seen so far that this
147*333d2b36SAndroid Build Coastguard Worker				// check would catch have been in arch-generic and
148*333d2b36SAndroid Build Coastguard Worker				// minSdkVersion-generic code in frameworks though, so this is a
149*333d2b36SAndroid Build Coastguard Worker				// good place to start.
150*333d2b36SAndroid Build Coastguard Worker				"-target aarch64-linux-android%d --sysroot %s",
151*333d2b36SAndroid Build Coastguard Worker				android.FutureApiLevel.FinalOrFutureInt(),
152*333d2b36SAndroid Build Coastguard Worker				getNdkSysrootBase(ctx).String(),
153*333d2b36SAndroid Build Coastguard Worker			),
154*333d2b36SAndroid Build Coastguard Worker		},
155*333d2b36SAndroid Build Coastguard Worker	})
156*333d2b36SAndroid Build Coastguard Worker	return output
157*333d2b36SAndroid Build Coastguard Worker}
158*333d2b36SAndroid Build Coastguard Worker
159*333d2b36SAndroid Build Coastguard Workerfunc NdkSingleton() android.Singleton {
160*333d2b36SAndroid Build Coastguard Worker	return &ndkSingleton{}
161*333d2b36SAndroid Build Coastguard Worker}
162*333d2b36SAndroid Build Coastguard Worker
163*333d2b36SAndroid Build Coastguard Worker// Collect all NDK exported headers paths into a file that is used to
164*333d2b36SAndroid Build Coastguard Worker// detect public types that should be ABI monitored.
165*333d2b36SAndroid Build Coastguard Worker//
166*333d2b36SAndroid Build Coastguard Worker// Assume that we have the following code in exported header:
167*333d2b36SAndroid Build Coastguard Worker//
168*333d2b36SAndroid Build Coastguard Worker//	typedef struct Context Context;
169*333d2b36SAndroid Build Coastguard Worker//	typedef struct Output {
170*333d2b36SAndroid Build Coastguard Worker//	    ...
171*333d2b36SAndroid Build Coastguard Worker//	} Output;
172*333d2b36SAndroid Build Coastguard Worker//	void DoSomething(Context* ctx, Output* output);
173*333d2b36SAndroid Build Coastguard Worker//
174*333d2b36SAndroid Build Coastguard Worker// If none of public headers exported to end-users contain definition of
175*333d2b36SAndroid Build Coastguard Worker// "struct Context", then "struct Context" layout and members shouldn't be
176*333d2b36SAndroid Build Coastguard Worker// monitored. However we use DWARF information from a real library, which
177*333d2b36SAndroid Build Coastguard Worker// may have access to the definition of "string Context" from
178*333d2b36SAndroid Build Coastguard Worker// implementation headers, and it will leak to ABI.
179*333d2b36SAndroid Build Coastguard Worker//
180*333d2b36SAndroid Build Coastguard Worker// STG tool doesn't access source and header files, only DWARF information
181*333d2b36SAndroid Build Coastguard Worker// from compiled library. And the DWARF contains file name where a type is
182*333d2b36SAndroid Build Coastguard Worker// defined. So we need a rule to build a list of paths to public headers,
183*333d2b36SAndroid Build Coastguard Worker// so STG can distinguish private types from public and do not monitor
184*333d2b36SAndroid Build Coastguard Worker// private types that are not accessible to library users.
185*333d2b36SAndroid Build Coastguard Workerfunc writeNdkAbiSrcFilter(ctx android.BuilderContext,
186*333d2b36SAndroid Build Coastguard Worker	headerSrcPaths android.Paths, outputFile android.WritablePath) {
187*333d2b36SAndroid Build Coastguard Worker	var filterBuilder strings.Builder
188*333d2b36SAndroid Build Coastguard Worker	filterBuilder.WriteString("[decl_file_allowlist]\n")
189*333d2b36SAndroid Build Coastguard Worker	for _, headerSrcPath := range headerSrcPaths {
190*333d2b36SAndroid Build Coastguard Worker		filterBuilder.WriteString(headerSrcPath.String())
191*333d2b36SAndroid Build Coastguard Worker		filterBuilder.WriteString("\n")
192*333d2b36SAndroid Build Coastguard Worker	}
193*333d2b36SAndroid Build Coastguard Worker
194*333d2b36SAndroid Build Coastguard Worker	android.WriteFileRule(ctx, outputFile, filterBuilder.String())
195*333d2b36SAndroid Build Coastguard Worker}
196*333d2b36SAndroid Build Coastguard Worker
197*333d2b36SAndroid Build Coastguard Workertype ndkSingleton struct{}
198*333d2b36SAndroid Build Coastguard Worker
199*333d2b36SAndroid Build Coastguard Workertype srcDestPair struct {
200*333d2b36SAndroid Build Coastguard Worker	src  android.Path
201*333d2b36SAndroid Build Coastguard Worker	dest android.Path
202*333d2b36SAndroid Build Coastguard Worker}
203*333d2b36SAndroid Build Coastguard Worker
204*333d2b36SAndroid Build Coastguard Workerfunc (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
205*333d2b36SAndroid Build Coastguard Worker	var staticLibInstallPaths android.Paths
206*333d2b36SAndroid Build Coastguard Worker	var headerSrcPaths android.Paths
207*333d2b36SAndroid Build Coastguard Worker	var headerInstallPaths android.Paths
208*333d2b36SAndroid Build Coastguard Worker	var headersToVerify []srcDestPair
209*333d2b36SAndroid Build Coastguard Worker	var headerCCompatVerificationTimestampPaths android.Paths
210*333d2b36SAndroid Build Coastguard Worker	var installPaths android.Paths
211*333d2b36SAndroid Build Coastguard Worker	var licensePaths android.Paths
212*333d2b36SAndroid Build Coastguard Worker	ctx.VisitAllModules(func(module android.Module) {
213*333d2b36SAndroid Build Coastguard Worker		if m, ok := module.(android.Module); ok && !m.Enabled(ctx) {
214*333d2b36SAndroid Build Coastguard Worker			return
215*333d2b36SAndroid Build Coastguard Worker		}
216*333d2b36SAndroid Build Coastguard Worker
217*333d2b36SAndroid Build Coastguard Worker		if m, ok := module.(*headerModule); ok {
218*333d2b36SAndroid Build Coastguard Worker			headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
219*333d2b36SAndroid Build Coastguard Worker			headerInstallPaths = append(headerInstallPaths, m.installPaths...)
220*333d2b36SAndroid Build Coastguard Worker			if !Bool(m.properties.Skip_verification) {
221*333d2b36SAndroid Build Coastguard Worker				for i, installPath := range m.installPaths {
222*333d2b36SAndroid Build Coastguard Worker					headersToVerify = append(headersToVerify, srcDestPair{
223*333d2b36SAndroid Build Coastguard Worker						src:  m.srcPaths[i],
224*333d2b36SAndroid Build Coastguard Worker						dest: installPath,
225*333d2b36SAndroid Build Coastguard Worker					})
226*333d2b36SAndroid Build Coastguard Worker				}
227*333d2b36SAndroid Build Coastguard Worker			}
228*333d2b36SAndroid Build Coastguard Worker			installPaths = append(installPaths, m.installPaths...)
229*333d2b36SAndroid Build Coastguard Worker			licensePaths = append(licensePaths, m.licensePath)
230*333d2b36SAndroid Build Coastguard Worker		}
231*333d2b36SAndroid Build Coastguard Worker
232*333d2b36SAndroid Build Coastguard Worker		if m, ok := module.(*preprocessedHeadersModule); ok {
233*333d2b36SAndroid Build Coastguard Worker			headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
234*333d2b36SAndroid Build Coastguard Worker			headerInstallPaths = append(headerInstallPaths, m.installPaths...)
235*333d2b36SAndroid Build Coastguard Worker			if !Bool(m.properties.Skip_verification) {
236*333d2b36SAndroid Build Coastguard Worker				for i, installPath := range m.installPaths {
237*333d2b36SAndroid Build Coastguard Worker					headersToVerify = append(headersToVerify, srcDestPair{
238*333d2b36SAndroid Build Coastguard Worker						src:  m.srcPaths[i],
239*333d2b36SAndroid Build Coastguard Worker						dest: installPath,
240*333d2b36SAndroid Build Coastguard Worker					})
241*333d2b36SAndroid Build Coastguard Worker				}
242*333d2b36SAndroid Build Coastguard Worker			}
243*333d2b36SAndroid Build Coastguard Worker			installPaths = append(installPaths, m.installPaths...)
244*333d2b36SAndroid Build Coastguard Worker			licensePaths = append(licensePaths, m.licensePath)
245*333d2b36SAndroid Build Coastguard Worker		}
246*333d2b36SAndroid Build Coastguard Worker
247*333d2b36SAndroid Build Coastguard Worker		if m, ok := module.(*Module); ok {
248*333d2b36SAndroid Build Coastguard Worker			if installer, ok := m.installer.(*stubDecorator); ok && m.library.buildStubs() {
249*333d2b36SAndroid Build Coastguard Worker				installPaths = append(installPaths, installer.installPath)
250*333d2b36SAndroid Build Coastguard Worker			}
251*333d2b36SAndroid Build Coastguard Worker
252*333d2b36SAndroid Build Coastguard Worker			if library, ok := m.linker.(*libraryDecorator); ok {
253*333d2b36SAndroid Build Coastguard Worker				if library.ndkSysrootPath != nil {
254*333d2b36SAndroid Build Coastguard Worker					staticLibInstallPaths = append(
255*333d2b36SAndroid Build Coastguard Worker						staticLibInstallPaths, library.ndkSysrootPath)
256*333d2b36SAndroid Build Coastguard Worker				}
257*333d2b36SAndroid Build Coastguard Worker			}
258*333d2b36SAndroid Build Coastguard Worker
259*333d2b36SAndroid Build Coastguard Worker			if object, ok := m.linker.(*objectLinker); ok {
260*333d2b36SAndroid Build Coastguard Worker				if object.ndkSysrootPath != nil {
261*333d2b36SAndroid Build Coastguard Worker					staticLibInstallPaths = append(
262*333d2b36SAndroid Build Coastguard Worker						staticLibInstallPaths, object.ndkSysrootPath)
263*333d2b36SAndroid Build Coastguard Worker				}
264*333d2b36SAndroid Build Coastguard Worker			}
265*333d2b36SAndroid Build Coastguard Worker		}
266*333d2b36SAndroid Build Coastguard Worker	})
267*333d2b36SAndroid Build Coastguard Worker
268*333d2b36SAndroid Build Coastguard Worker	// Include only a single copy of each license file. The Bionic NOTICE is
269*333d2b36SAndroid Build Coastguard Worker	// long and is referenced by multiple Bionic modules.
270*333d2b36SAndroid Build Coastguard Worker	licensePaths = android.FirstUniquePaths(licensePaths)
271*333d2b36SAndroid Build Coastguard Worker
272*333d2b36SAndroid Build Coastguard Worker	combinedLicense := getNdkInstallBase(ctx).Join(ctx, "NOTICE")
273*333d2b36SAndroid Build Coastguard Worker	ctx.Build(pctx, android.BuildParams{
274*333d2b36SAndroid Build Coastguard Worker		Rule:        android.Cat,
275*333d2b36SAndroid Build Coastguard Worker		Description: "combine licenses",
276*333d2b36SAndroid Build Coastguard Worker		Output:      combinedLicense,
277*333d2b36SAndroid Build Coastguard Worker		Inputs:      licensePaths,
278*333d2b36SAndroid Build Coastguard Worker	})
279*333d2b36SAndroid Build Coastguard Worker
280*333d2b36SAndroid Build Coastguard Worker	baseDepPaths := append(installPaths, combinedLicense)
281*333d2b36SAndroid Build Coastguard Worker
282*333d2b36SAndroid Build Coastguard Worker	ctx.Build(pctx, android.BuildParams{
283*333d2b36SAndroid Build Coastguard Worker		Rule:       android.Touch,
284*333d2b36SAndroid Build Coastguard Worker		Output:     getNdkBaseTimestampFile(ctx),
285*333d2b36SAndroid Build Coastguard Worker		Implicits:  baseDepPaths,
286*333d2b36SAndroid Build Coastguard Worker		Validation: getNdkAbiDiffTimestampFile(ctx),
287*333d2b36SAndroid Build Coastguard Worker	})
288*333d2b36SAndroid Build Coastguard Worker
289*333d2b36SAndroid Build Coastguard Worker	ctx.Build(pctx, android.BuildParams{
290*333d2b36SAndroid Build Coastguard Worker		Rule:      android.Touch,
291*333d2b36SAndroid Build Coastguard Worker		Output:    getNdkHeadersTimestampFile(ctx),
292*333d2b36SAndroid Build Coastguard Worker		Implicits: headerInstallPaths,
293*333d2b36SAndroid Build Coastguard Worker	})
294*333d2b36SAndroid Build Coastguard Worker
295*333d2b36SAndroid Build Coastguard Worker	for _, srcDestPair := range headersToVerify {
296*333d2b36SAndroid Build Coastguard Worker		headerCCompatVerificationTimestampPaths = append(
297*333d2b36SAndroid Build Coastguard Worker			headerCCompatVerificationTimestampPaths,
298*333d2b36SAndroid Build Coastguard Worker			verifyNdkHeaderIsCCompatible(ctx, srcDestPair.src, srcDestPair.dest))
299*333d2b36SAndroid Build Coastguard Worker	}
300*333d2b36SAndroid Build Coastguard Worker
301*333d2b36SAndroid Build Coastguard Worker	writeNdkAbiSrcFilter(ctx, headerSrcPaths, getNdkABIHeadersFile(ctx))
302*333d2b36SAndroid Build Coastguard Worker
303*333d2b36SAndroid Build Coastguard Worker	fullDepPaths := append(staticLibInstallPaths, getNdkBaseTimestampFile(ctx))
304*333d2b36SAndroid Build Coastguard Worker
305*333d2b36SAndroid Build Coastguard Worker	// There's a phony "ndk" rule defined in core/main.mk that depends on this.
306*333d2b36SAndroid Build Coastguard Worker	// `m ndk` will build the sysroots for the architectures in the current
307*333d2b36SAndroid Build Coastguard Worker	// lunch target. `build/soong/scripts/build-ndk-prebuilts.sh` will build the
308*333d2b36SAndroid Build Coastguard Worker	// sysroots for all the NDK architectures and package them so they can be
309*333d2b36SAndroid Build Coastguard Worker	// imported into the NDK's build.
310*333d2b36SAndroid Build Coastguard Worker	ctx.Build(pctx, android.BuildParams{
311*333d2b36SAndroid Build Coastguard Worker		Rule:      android.Touch,
312*333d2b36SAndroid Build Coastguard Worker		Output:    getNdkFullTimestampFile(ctx),
313*333d2b36SAndroid Build Coastguard Worker		Implicits: append(fullDepPaths, headerCCompatVerificationTimestampPaths...),
314*333d2b36SAndroid Build Coastguard Worker	})
315*333d2b36SAndroid Build Coastguard Worker}
316