From acee0efe7059f48d676bb0501ffc516130ed6aae Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Wed, 10 Nov 2021 15:35:02 -0800 Subject: [PATCH] make: Simplify block building --- src/build/make.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/build/make.ts b/src/build/make.ts index 2b094e6..12957a3 100644 --- a/src/build/make.ts +++ b/src/build/make.ts @@ -36,6 +36,14 @@ export interface BoardMakefile { boardInfo?: string } +function startBlocks() { + return [MAKEFILE_HEADER] +} + +function finishBlocks(blocks: Array) { + return blocks.join('\n\n') + '\n' +} + export function sanitizeBasename(path: string) { return basename(path).replaceAll(/[^a-z0-9_\-.]/g, '_') } @@ -51,11 +59,11 @@ export function blobToFileCopy(entry: BlobEntry, proprietaryDir: string) { } export function serializeModulesMakefile(mk: ModulesMakefile) { - let blocks = [ - MAKEFILE_HEADER, + let blocks = startBlocks() + blocks.push( 'LOCAL_PATH := $(call my-dir)', `ifeq ($(TARGET_DEVICE),${mk.device})`, - ] + ) if (mk.radioFiles != undefined) { blocks.push(mk.radioFiles.map(img => `$(call add-radio-file,${img})`).join('\n')) @@ -82,7 +90,7 @@ $(LOCAL_BUILT_MODULE): } blocks.push('endif') - return blocks.join('\n\n') + return finishBlocks(blocks) } function addContBlock(blocks: Array, variable: String, items: Array | undefined) { @@ -93,7 +101,7 @@ function addContBlock(blocks: Array, variable: String, items: Array