blob: 7f216d20c1276475281385a61b126e9f6519f1f0 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Copyright (C) 2008 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15LOCAL_PATH := $(call my-dir)
Mark Salyzyn073a9eb2015-04-15 12:53:39 -070016
The Android Open Source Project88b60792009-03-03 19:28:42 -080017include $(CLEAR_VARS)
18
The Android Open Source Project88b60792009-03-03 19:28:42 -080019LOCAL_SRC_FILES := fs_config.c
20LOCAL_MODULE := fs_config
Mark Salyzyn073a9eb2015-04-15 12:53:39 -070021LOCAL_SHARED_LIBRARIES := libcutils libselinux
Mark Salyzyn1c5f19e2015-04-01 12:54:46 -070022LOCAL_CFLAGS := -Werror
The Android Open Source Project88b60792009-03-03 19:28:42 -080023
24include $(BUILD_HOST_EXECUTABLE)
Mark Salyzyn06b91b92015-04-01 14:41:29 -070025
William Robertsc950a352016-03-04 18:12:29 -080026# One can override the default android_filesystem_config.h file in one of two ways:
27#
28# 1. The old way:
29# To Build the custom target binary for the host to generate the fs_config
30# override files. The executable is hard coded to include the
31# $(TARGET_ANDROID_FILESYSTEM_CONFIG_H) file if it exists.
32# Expectations:
33# device/<vendor>/<device>/android_filesystem_config.h
34# fills in struct fs_path_config android_device_dirs[] and
35# struct fs_path_config android_device_files[]
36# device/<vendor>/<device>/device.mk
37# PRODUCT_PACKAGES += fs_config_dirs fs_config_files
38# If not specified, check if default one to be found
39#
40# 2. The new way:
41# set TARGET_FS_CONFIG_GEN to contain a list of intermediate format files
42# for generating the android_filesystem_config.h file.
43#
44# More information can be found in the README
Mark Salyzyn06b91b92015-04-01 14:41:29 -070045ANDROID_FS_CONFIG_H := android_filesystem_config.h
46
47ifneq ($(TARGET_ANDROID_FILESYSTEM_CONFIG_H),)
William Robertsc950a352016-03-04 18:12:29 -080048ifneq ($(TARGET_FS_CONFIG_GEN),)
49$(error Cannot set TARGET_ANDROID_FILESYSTEM_CONFIG_H and TARGET_FS_CONFIG_GEN simultaneously)
50endif
William Roberts78626c42016-02-11 10:35:07 -080051
52# One and only one file can be specified.
53ifneq ($(words $(TARGET_ANDROID_FILESYSTEM_CONFIG_H)),1)
54$(error Multiple fs_config files specified, \
55 see "$(TARGET_ANDROID_FILESYSTEM_CONFIG_H)".)
56endif
57
Mark Salyzyn06b91b92015-04-01 14:41:29 -070058ifeq ($(filter %/$(ANDROID_FS_CONFIG_H),$(TARGET_ANDROID_FILESYSTEM_CONFIG_H)),)
59$(error TARGET_ANDROID_FILESYSTEM_CONFIG_H file name must be $(ANDROID_FS_CONFIG_H), \
60 see "$(notdir $(TARGET_ANDROID_FILESYSTEM_CONFIG_H))".)
61endif
62
63my_fs_config_h := $(TARGET_ANDROID_FILESYSTEM_CONFIG_H)
64else ifneq ($(wildcard $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H)),)
William Robertsc950a352016-03-04 18:12:29 -080065
66ifneq ($(TARGET_FS_CONFIG_GEN),)
67$(error Cannot provide $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H) and set TARGET_FS_CONFIG_GEN simultaneously)
68endif
Mark Salyzyn06b91b92015-04-01 14:41:29 -070069my_fs_config_h := $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H)
William Robertsc950a352016-03-04 18:12:29 -080070
Mark Salyzyn06b91b92015-04-01 14:41:29 -070071else
72my_fs_config_h := $(LOCAL_PATH)/default/$(ANDROID_FS_CONFIG_H)
73endif
74
William Robertsc950a352016-03-04 18:12:29 -080075##################################
Mark Salyzyn06b91b92015-04-01 14:41:29 -070076include $(CLEAR_VARS)
77LOCAL_SRC_FILES := fs_config_generate.c
78LOCAL_MODULE := fs_config_generate_$(TARGET_DEVICE)
William Robertsc950a352016-03-04 18:12:29 -080079LOCAL_MODULE_CLASS := EXECUTABLES
Mark Salyzyn06b91b92015-04-01 14:41:29 -070080LOCAL_SHARED_LIBRARIES := libcutils
81LOCAL_CFLAGS := -Werror -Wno-error=\#warnings
William Robertsc950a352016-03-04 18:12:29 -080082
83ifneq ($(TARGET_FS_CONFIG_GEN),)
William Roberts64edf5b2016-04-11 17:12:47 -070084system_android_filesystem_config := system/core/include/private/android_filesystem_config.h
William Robertscfc51f52016-04-12 08:51:13 -070085
86# Generate the "generated_oem_aid.h" file
87oem := $(local-generated-sources-dir)/generated_oem_aid.h
88$(oem): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
89$(oem): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
90$(oem): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
91$(oem): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/fs_config_generator.py oemaid --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
92$(oem): $(TARGET_FS_CONFIG_GEN) $(LOCAL_PATH)/fs_config_generator.py
93 $(transform-generated-source)
94
95# Generate the fs_config header
William Robertsc950a352016-03-04 18:12:29 -080096gen := $(local-generated-sources-dir)/$(ANDROID_FS_CONFIG_H)
97$(gen): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
98$(gen): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
William Roberts64edf5b2016-04-11 17:12:47 -070099$(gen): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
100$(gen): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/fs_config_generator.py fsconfig --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
101$(gen): $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config) $(LOCAL_PATH)/fs_config_generator.py
William Robertsc950a352016-03-04 18:12:29 -0800102 $(transform-generated-source)
103
William Robertscfc51f52016-04-12 08:51:13 -0700104LOCAL_GENERATED_SOURCES := $(oem) $(gen)
105
William Robertsc950a352016-03-04 18:12:29 -0800106my_fs_config_h := $(gen)
William Robertscfc51f52016-04-12 08:51:13 -0700107my_gen_oem_aid := $(oem)
William Roberts64edf5b2016-04-11 17:12:47 -0700108system_android_filesystem_config :=
William Robertsc950a352016-03-04 18:12:29 -0800109gen :=
William Robertscfc51f52016-04-12 08:51:13 -0700110oem :=
William Robertsc950a352016-03-04 18:12:29 -0800111endif
112
William Robertscfc51f52016-04-12 08:51:13 -0700113LOCAL_C_INCLUDES := $(dir $(my_fs_config_h)) $(dir $(my_gen_oem_aid))
William Robertsc950a352016-03-04 18:12:29 -0800114
Mark Salyzyn06b91b92015-04-01 14:41:29 -0700115include $(BUILD_HOST_EXECUTABLE)
116fs_config_generate_bin := $(LOCAL_INSTALLED_MODULE)
117
William Robertsc950a352016-03-04 18:12:29 -0800118##################################
Mark Salyzyn06b91b92015-04-01 14:41:29 -0700119# Generate the system/etc/fs_config_dirs binary file for the target
120# Add fs_config_dirs to PRODUCT_PACKAGES in the device make file to enable
121include $(CLEAR_VARS)
122
123LOCAL_MODULE := fs_config_dirs
124LOCAL_MODULE_CLASS := ETC
125include $(BUILD_SYSTEM)/base_rules.mk
126$(LOCAL_BUILT_MODULE): $(fs_config_generate_bin)
127 @mkdir -p $(dir $@)
128 $< -D -o $@
129
William Robertsc950a352016-03-04 18:12:29 -0800130##################################
Mark Salyzyn06b91b92015-04-01 14:41:29 -0700131# Generate the system/etc/fs_config_files binary file for the target
132# Add fs_config_files to PRODUCT_PACKAGES in the device make file to enable
133include $(CLEAR_VARS)
134
135LOCAL_MODULE := fs_config_files
136LOCAL_MODULE_CLASS := ETC
137include $(BUILD_SYSTEM)/base_rules.mk
138$(LOCAL_BUILT_MODULE): $(fs_config_generate_bin)
139 @mkdir -p $(dir $@)
140 $< -F -o $@
141
William Robertscfc51f52016-04-12 08:51:13 -0700142ifneq ($(TARGET_FS_CONFIG_GEN),)
143
144##################################
145# Build the oemaid library when fs config files are present.
146# Intentionally break build if you require generated AIDS
147# header file, but are not using any fs config files.
148include $(CLEAR_VARS)
149LOCAL_MODULE := liboemaids
150LOCAL_EXPORT_C_INCLUDE_DIRS := $(dir $(my_gen_oem_aid))
151LOCAL_EXPORT_C_INCLUDE_DEPS := $(my_gen_oem_aid)
152include $(BUILD_STATIC_LIBRARY)
153
154endif
155
Mark Salyzyn06b91b92015-04-01 14:41:29 -0700156ANDROID_FS_CONFIG_H :=
157my_fs_config_h :=
158fs_config_generate_bin :=
William Robertscfc51f52016-04-12 08:51:13 -0700159my_gen_oem_aid :=