From 80381b736a77bf895fcc66fb68157b9168222c59 Mon Sep 17 00:00:00 2001 From: Sam Mortimer Date: Tue, 18 Sep 2018 15:56:14 -0700 Subject: [PATCH] vendor/lineage: Add soong generator module type *) Similar to genrule but can be used to generate content when the output directory and file structure are not known ahead of time. *) An example use case is to build kernel headers. Change-Id: I10deb7ba8825393b0b5fdbf2d96b12ad37257e12 --- build/soong/Android.bp | 16 ++ build/soong/generator/generator.go | 307 +++++++++++++++++++++++++++++ 2 files changed, 323 insertions(+) create mode 100644 build/soong/generator/generator.go diff --git a/build/soong/Android.bp b/build/soong/Android.bp index 18e9a841..dca42cfa 100644 --- a/build/soong/Android.bp +++ b/build/soong/Android.bp @@ -6,3 +6,19 @@ bootstrap_go_package { "android/variable.go", ], } + +bootstrap_go_package { + name: "soong-lineage-generator", + pkgPath: "lineage/soong/generator", + deps: [ + "blueprint", + "blueprint-pathtools", + "soong", + "soong-android", + "soong-shared", + ], + srcs: [ + "generator/generator.go", + ], + pluginFor: ["soong_build"], +} diff --git a/build/soong/generator/generator.go b/build/soong/generator/generator.go new file mode 100644 index 00000000..06c383d5 --- /dev/null +++ b/build/soong/generator/generator.go @@ -0,0 +1,307 @@ +// Copyright 2015 Google Inc. All rights reserved. +// Copyright (C) 2018 The LineageOS 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. + +package generator + +import ( + "fmt" + "strings" + + "github.com/google/blueprint" + "github.com/google/blueprint/bootstrap" + "github.com/google/blueprint/proptools" + + "android/soong/android" + "android/soong/shared" + "path/filepath" +) + +func init() { + android.RegisterModuleType("lineage_generator", GeneratorFactory) + + pctx.HostBinToolVariable("sboxCmd", "sbox") +} + +var String = proptools.String + +var ( + pctx = android.NewPackageContext("android/soong/generator") +) + +type HostToolProvider interface { + HostToolPath() android.OptionalPath +} + +type hostToolDependencyTag struct { + blueprint.BaseDependencyTag +} + +var hostToolDepTag hostToolDependencyTag + +type generatorProperties struct { + // The command to run on one or more input files. Cmd supports substitution of a few variables + // (the actual substitution is implemented in GenerateAndroidBuildActions below) + // + // Available variables for substitution: + // + // $(location): the path to the first entry in tools or tool_files + // $(location