make: Fix symlink generation

TODO: fix ninja warning
This commit is contained in:
Danny Lin 2021-11-18 20:48:33 -08:00
parent 7237186561
commit dba9b12ef9
2 changed files with 20 additions and 16 deletions

View file

@ -111,7 +111,7 @@ export async function generateBuild(
} }
let buildPackages = Array.from(namedModules.keys()) let buildPackages = Array.from(namedModules.keys())
buildPackages.push(...symlinks.map(l => l.moduleName)) buildPackages.push('device_symlinks')
return { return {
blueprint: { blueprint: {

View file

@ -1,4 +1,4 @@
import { basename } from 'path' import { basename, dirname } from 'path'
import { BlobEntry } from '../blobs/entry' import { BlobEntry } from '../blobs/entry'
import { PartitionProps } from '../blobs/props' import { PartitionProps } from '../blobs/props'
import { SelinuxPartResolutions } from '../sepolicy/contexts' import { SelinuxPartResolutions } from '../sepolicy/contexts'
@ -87,24 +87,28 @@ export function serializeModulesMakefile(mk: ModulesMakefile) {
blocks.push(mk.radioFiles.map(img => `$(call add-radio-file,${img})`).join('\n')) blocks.push(mk.radioFiles.map(img => `$(call add-radio-file,${img})`).join('\n'))
} }
if (mk.symlinks.length > 0) {
let mkdirCmds = new Set<string>()
let linkCmds = []
for (let link of mk.symlinks) { for (let link of mk.symlinks) {
let destPath = partPathToMakePath(link.linkPartition, link.linkSubpath) let destPath = `$(PRODUCT_OUT)/${link.linkPartition}/${link.linkSubpath}`
mkdirCmds.add(`mkdir -p ${dirname(destPath)};`)
linkCmds.push(`ln -sf ${link.targetPath} ${destPath};`)
}
blocks.push(`include $(CLEAR_VARS) blocks.push(`include $(CLEAR_VARS)
LOCAL_MODULE := ${link.moduleName} LOCAL_MODULE := device_symlinks
LOCAL_MODULE_CLASS := FAKE LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_OWNER := ${mk.vendor} LOCAL_MODULE_OWNER := ${mk.vendor}
include $(BUILD_SYSTEM)/base_rules.mk LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC)
$(LOCAL_BUILT_MODULE): TARGET := ${link.targetPath} LOCAL_MODULE_STEM := .device_symlinks
$(LOCAL_BUILT_MODULE): SYMLINK := ${destPath} LOCAL_SRC_FILES := Android.mk
$(LOCAL_BUILT_MODULE): LOCAL_POST_INSTALL_CMD := \\
\t$(hide) mkdir -p $(dir $@) ${Array.from(mkdirCmds).join(CONT_SEPARATOR)} \\
\t$(hide) mkdir -p $(dir $(SYMLINK)) ${linkCmds.join(CONT_SEPARATOR)} \\
\t$(hide) rm -rf $@ rm -f $(TARGET_OUT_VENDOR_ETC)/.device_symlinks
\t$(hide) rm -rf $(SYMLINK) include $(BUILD_PREBUILT)`)
\t$(hide) ln -sf $(TARGET) $(SYMLINK)
\t$(hide) touch $@`)
} }
blocks.push('endif') blocks.push('endif')