The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | # 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 | |
| 15 | LOCAL_PATH := $(call my-dir) |
Mark Salyzyn | 073a9eb | 2015-04-15 12:53:39 -0700 | [diff] [blame] | 16 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 17 | include $(CLEAR_VARS) |
| 18 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 19 | LOCAL_SRC_FILES := fs_config.c |
| 20 | LOCAL_MODULE := fs_config |
Mark Salyzyn | 073a9eb | 2015-04-15 12:53:39 -0700 | [diff] [blame] | 21 | LOCAL_SHARED_LIBRARIES := libcutils libselinux |
Mark Salyzyn | 1c5f19e | 2015-04-01 12:54:46 -0700 | [diff] [blame] | 22 | LOCAL_CFLAGS := -Werror |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 23 | |
| 24 | include $(BUILD_HOST_EXECUTABLE) |
Mark Salyzyn | 06b91b9 | 2015-04-01 14:41:29 -0700 | [diff] [blame] | 25 | |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame^] | 26 | # 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 Salyzyn | 06b91b9 | 2015-04-01 14:41:29 -0700 | [diff] [blame] | 45 | ANDROID_FS_CONFIG_H := android_filesystem_config.h |
| 46 | |
| 47 | ifneq ($(TARGET_ANDROID_FILESYSTEM_CONFIG_H),) |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame^] | 48 | ifneq ($(TARGET_FS_CONFIG_GEN),) |
| 49 | $(error Cannot set TARGET_ANDROID_FILESYSTEM_CONFIG_H and TARGET_FS_CONFIG_GEN simultaneously) |
| 50 | endif |
William Roberts | 78626c4 | 2016-02-11 10:35:07 -0800 | [diff] [blame] | 51 | |
| 52 | # One and only one file can be specified. |
| 53 | ifneq ($(words $(TARGET_ANDROID_FILESYSTEM_CONFIG_H)),1) |
| 54 | $(error Multiple fs_config files specified, \ |
| 55 | see "$(TARGET_ANDROID_FILESYSTEM_CONFIG_H)".) |
| 56 | endif |
| 57 | |
Mark Salyzyn | 06b91b9 | 2015-04-01 14:41:29 -0700 | [diff] [blame] | 58 | ifeq ($(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))".) |
| 61 | endif |
| 62 | |
| 63 | my_fs_config_h := $(TARGET_ANDROID_FILESYSTEM_CONFIG_H) |
| 64 | else ifneq ($(wildcard $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H)),) |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame^] | 65 | |
| 66 | ifneq ($(TARGET_FS_CONFIG_GEN),) |
| 67 | $(error Cannot provide $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H) and set TARGET_FS_CONFIG_GEN simultaneously) |
| 68 | endif |
Mark Salyzyn | 06b91b9 | 2015-04-01 14:41:29 -0700 | [diff] [blame] | 69 | my_fs_config_h := $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H) |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame^] | 70 | |
Mark Salyzyn | 06b91b9 | 2015-04-01 14:41:29 -0700 | [diff] [blame] | 71 | else |
| 72 | my_fs_config_h := $(LOCAL_PATH)/default/$(ANDROID_FS_CONFIG_H) |
| 73 | endif |
| 74 | |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame^] | 75 | ################################## |
Mark Salyzyn | 06b91b9 | 2015-04-01 14:41:29 -0700 | [diff] [blame] | 76 | include $(CLEAR_VARS) |
| 77 | LOCAL_SRC_FILES := fs_config_generate.c |
| 78 | LOCAL_MODULE := fs_config_generate_$(TARGET_DEVICE) |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame^] | 79 | LOCAL_MODULE_CLASS := EXECUTABLES |
Mark Salyzyn | 06b91b9 | 2015-04-01 14:41:29 -0700 | [diff] [blame] | 80 | LOCAL_SHARED_LIBRARIES := libcutils |
| 81 | LOCAL_CFLAGS := -Werror -Wno-error=\#warnings |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame^] | 82 | |
| 83 | ifneq ($(TARGET_FS_CONFIG_GEN),) |
| 84 | gen := $(local-generated-sources-dir)/$(ANDROID_FS_CONFIG_H) |
| 85 | $(gen): PRIVATE_LOCAL_PATH := $(LOCAL_PATH) |
| 86 | $(gen): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN) |
| 87 | $(gen): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/fs_config_generator.py $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@ |
| 88 | $(gen): $(TARGET_FS_CONFIG_GEN) $(LOCAL_PATH)/fs_config_generator.py |
| 89 | $(transform-generated-source) |
| 90 | |
| 91 | LOCAL_GENERATED_SOURCES := $(gen) |
| 92 | my_fs_config_h := $(gen) |
| 93 | gen := |
| 94 | endif |
| 95 | |
Mark Salyzyn | 06b91b9 | 2015-04-01 14:41:29 -0700 | [diff] [blame] | 96 | LOCAL_C_INCLUDES := $(dir $(my_fs_config_h)) |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame^] | 97 | |
Mark Salyzyn | 06b91b9 | 2015-04-01 14:41:29 -0700 | [diff] [blame] | 98 | include $(BUILD_HOST_EXECUTABLE) |
| 99 | fs_config_generate_bin := $(LOCAL_INSTALLED_MODULE) |
| 100 | |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame^] | 101 | ################################## |
Mark Salyzyn | 06b91b9 | 2015-04-01 14:41:29 -0700 | [diff] [blame] | 102 | # Generate the system/etc/fs_config_dirs binary file for the target |
| 103 | # Add fs_config_dirs to PRODUCT_PACKAGES in the device make file to enable |
| 104 | include $(CLEAR_VARS) |
| 105 | |
| 106 | LOCAL_MODULE := fs_config_dirs |
| 107 | LOCAL_MODULE_CLASS := ETC |
| 108 | include $(BUILD_SYSTEM)/base_rules.mk |
| 109 | $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin) |
| 110 | @mkdir -p $(dir $@) |
| 111 | $< -D -o $@ |
| 112 | |
William Roberts | c950a35 | 2016-03-04 18:12:29 -0800 | [diff] [blame^] | 113 | ################################## |
Mark Salyzyn | 06b91b9 | 2015-04-01 14:41:29 -0700 | [diff] [blame] | 114 | # Generate the system/etc/fs_config_files binary file for the target |
| 115 | # Add fs_config_files to PRODUCT_PACKAGES in the device make file to enable |
| 116 | include $(CLEAR_VARS) |
| 117 | |
| 118 | LOCAL_MODULE := fs_config_files |
| 119 | LOCAL_MODULE_CLASS := ETC |
| 120 | include $(BUILD_SYSTEM)/base_rules.mk |
| 121 | $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin) |
| 122 | @mkdir -p $(dir $@) |
| 123 | $< -F -o $@ |
| 124 | |
| 125 | ANDROID_FS_CONFIG_H := |
| 126 | my_fs_config_h := |
| 127 | fs_config_generate_bin := |