blob: f228ef65b64811f4dda67d0a1fba6abe5599f037 [file] [log] [blame]
Jerome Gaillardea9dab42023-10-25 00:05:12 +00001# Data files for layoutlib
Jerome Gaillardcf713d42019-10-23 11:43:26 +01002
3FONT_TEMP := $(call intermediates-dir-for,PACKAGING,fonts,HOST,COMMON)
4
5# The font configuration files - system_fonts.xml, fallback_fonts.xml etc.
Jerome Gaillardb414f052024-10-23 12:14:51 +01006font_config := $(filter $(TARGET_OUT)/etc/font%.xml, $(INTERNAL_SYSTEMIMAGE_FILES))
Jerome Gaillardcf713d42019-10-23 11:43:26 +01007font_config := $(addprefix $(FONT_TEMP)/, $(notdir $(font_config)))
8
Jerome Gaillardb414f052024-10-23 12:14:51 +01009$(font_config): $(FONT_TEMP)/%: $(TARGET_OUT)/etc/%
Jerome Gaillardcf713d42019-10-23 11:43:26 +010010 $(hide) mkdir -p $(dir $@)
11 $(hide) cp -vf $< $@
12
13# List of fonts on the device that we want to ship. This is all .ttf, .ttc and .otf fonts.
14fonts_device := $(filter $(TARGET_OUT)/fonts/%.ttf $(TARGET_OUT)/fonts/%.ttc $(TARGET_OUT)/fonts/%.otf, $(INTERNAL_SYSTEMIMAGE_FILES))
15fonts_device := $(addprefix $(FONT_TEMP)/, $(notdir $(fonts_device)))
16
17# TODO: If the font file is a symlink, reuse the font renamed from the symlink
18# target.
19$(fonts_device): $(FONT_TEMP)/%: $(TARGET_OUT)/fonts/%
20 $(hide) mkdir -p $(dir $@)
21 $(hide) cp -vf $< $@
22
Jerome Gaillardea9dab42023-10-25 00:05:12 +000023KEYBOARD_TEMP := $(call intermediates-dir-for,PACKAGING,keyboards,HOST,COMMON)
24
25# The key character map files needed for supporting KeyEvent
26keyboards := $(sort $(wildcard frameworks/base/data/keyboards/*.kcm))
27keyboards := $(addprefix $(KEYBOARD_TEMP)/, $(notdir $(keyboards)))
28
29$(keyboards): $(KEYBOARD_TEMP)/%.kcm: frameworks/base/data/keyboards/%.kcm
30 $(hide) mkdir -p $(dir $@)
31 $(hide) cp -vf $< $@
32
Jerome Gaillard0cc202e2024-11-11 19:35:55 +000033HYPHEN_TEMP := $(call intermediates-dir-for,PACKAGING,hyphen,HOST,COMMON)
34
35# The hyphenation pattern files needed to support text hyphenation
36hyphen := $(filter $(TARGET_OUT)/usr/hyphen-data/%.hyb, $(INTERNAL_SYSTEMIMAGE_FILES))
37hyphen := $(addprefix $(HYPHEN_TEMP)/, $(notdir $(hyphen)))
38
39$(hyphen): $(HYPHEN_TEMP)/%: $(TARGET_OUT)/usr/hyphen-data/%
40 $(hide) mkdir -p $(dir $@)
41 $(hide) cp -vf $< $@
42
43# List of all data files - font files, font configuration files, key character map files, hyphenation pattern files
44LAYOUTLIB_FILES := $(fonts_device) $(font_config) $(keyboards) $(hyphen)
Jerome Gaillardcf713d42019-10-23 11:43:26 +010045
46.PHONY: layoutlib layoutlib-tests
Jerome Gaillardea9dab42023-10-25 00:05:12 +000047layoutlib layoutlib-tests: $(LAYOUTLIB_FILES)
Jerome Gaillardcf713d42019-10-23 11:43:26 +010048
Jerome Gaillardea9dab42023-10-25 00:05:12 +000049$(call dist-for-goals, layoutlib, $(foreach m,$(fonts_device), $(m):layoutlib_native/fonts/$(notdir $(m))))
50$(call dist-for-goals, layoutlib, $(foreach m,$(font_config), $(m):layoutlib_native/fonts/$(notdir $(m))))
51$(call dist-for-goals, layoutlib, $(foreach m,$(keyboards), $(m):layoutlib_native/keyboards/$(notdir $(m))))
Jerome Gaillard0cc202e2024-11-11 19:35:55 +000052$(call dist-for-goals, layoutlib, $(foreach m,$(hyphen), $(m):layoutlib_native/hyphen-data/$(notdir $(m))))
Jerome Gaillardcf713d42019-10-23 11:43:26 +010053
54FONT_TEMP :=
55font_config :=
56fonts_device :=
57FONT_FILES :=
Wei Lic134b762023-10-17 23:52:30 -070058
59# The following build process of build.prop, layoutlib-res.zip is moved here from release_layoutlib.sh
60# so the SBOM of all platform neutral artifacts and Linux/Windows artifacts of layoutlib can be built in Make/Soong.
61# See go/layoutlib-sbom.
62
63# build.prop shipped with layoutlib
64LAYOUTLIB_BUILD_PROP := $(call intermediates-dir-for,PACKAGING,layoutlib-build-prop,HOST,COMMON)
65$(LAYOUTLIB_BUILD_PROP)/layoutlib-build.prop: $(INSTALLED_SDK_BUILD_PROP_TARGET)
66 rm -rf $@
67 cp $< $@
68 # Remove all the uncommon build properties
69 sed -i '/^ro\.\(build\|product\|config\|system\)/!d' $@
70 # Mark the build as layoutlib. This can be read at runtime by apps
71 sed -i 's|ro.product.brand=generic|ro.product.brand=studio|' $@
72 sed -i 's|ro.product.device=generic|ro.product.device=layoutlib|' $@
73
74$(call dist-for-goals,layoutlib,$(LAYOUTLIB_BUILD_PROP)/layoutlib-build.prop:layoutlib_native/build.prop)
75
76# Resource files from frameworks/base/core/res/res
77LAYOUTLIB_RES := $(call intermediates-dir-for,PACKAGING,layoutlib-res,HOST,COMMON)
78LAYOUTLIB_RES_FILES := $(shell find frameworks/base/core/res/res -type f -not -path 'frameworks/base/core/res/res/values-m[nc]c*' | sort)
Jerome Gaillardc97c0b42024-08-01 18:02:22 +010079EMULATED_OVERLAYS_FILES := $(shell find frameworks/base/packages/overlays/*/res/ | sort)
80DEVICE_OVERLAYS_FILES := $(shell find device/generic/goldfish/phone/overlay/frameworks/base/packages/overlays/*/AndroidOverlay/res/ | sort)
81$(LAYOUTLIB_RES)/layoutlib-res.zip: $(SOONG_ZIP) $(HOST_OUT_EXECUTABLES)/aapt2 $(LAYOUTLIB_RES_FILES) $(EMULATED_OVERLAYS_FILES) $(DEVICE_OVERLAYS_FILES)
Wei Lic134b762023-10-17 23:52:30 -070082 rm -rf $@
Jerome Gaillardc97c0b42024-08-01 18:02:22 +010083 echo $(LAYOUTLIB_RES_FILES) > $(LAYOUTLIB_RES)/filelist_res.txt
84 $(SOONG_ZIP) -C frameworks/base/core/res -l $(LAYOUTLIB_RES)/filelist_res.txt -o $(LAYOUTLIB_RES)/temp_res.zip
85 echo $(EMULATED_OVERLAYS_FILES) > $(LAYOUTLIB_RES)/filelist_emulated_overlays.txt
86 $(SOONG_ZIP) -C frameworks/base/packages -l $(LAYOUTLIB_RES)/filelist_emulated_overlays.txt -o $(LAYOUTLIB_RES)/temp_emulated_overlays.zip
87 echo $(DEVICE_OVERLAYS_FILES) > $(LAYOUTLIB_RES)/filelist_device_overlays.txt
88 $(SOONG_ZIP) -C device/generic/goldfish/phone/overlay/frameworks/base/packages -l $(LAYOUTLIB_RES)/filelist_device_overlays.txt -o $(LAYOUTLIB_RES)/temp_device_overlays.zip
89 rm -rf $(LAYOUTLIB_RES)/data && unzip -q -d $(LAYOUTLIB_RES)/data $(LAYOUTLIB_RES)/temp_res.zip
90 unzip -q -d $(LAYOUTLIB_RES)/data $(LAYOUTLIB_RES)/temp_emulated_overlays.zip
91 unzip -q -d $(LAYOUTLIB_RES)/data $(LAYOUTLIB_RES)/temp_device_overlays.zip
Wei Lic134b762023-10-17 23:52:30 -070092 rm -rf $(LAYOUTLIB_RES)/compiled && mkdir $(LAYOUTLIB_RES)/compiled && $(HOST_OUT_EXECUTABLES)/aapt2 compile $(LAYOUTLIB_RES)/data/res/**/*.9.png -o $(LAYOUTLIB_RES)/compiled
93 printf '<?xml version="1.0" encoding="utf-8"?>\n<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.google.android.layoutlib" />' > $(LAYOUTLIB_RES)/AndroidManifest.xml
94 $(HOST_OUT_EXECUTABLES)/aapt2 link -R $(LAYOUTLIB_RES)/compiled/* -o $(LAYOUTLIB_RES)/compiled.apk --manifest $(LAYOUTLIB_RES)/AndroidManifest.xml
95 rm -rf $(LAYOUTLIB_RES)/compiled_apk && unzip -q -d $(LAYOUTLIB_RES)/compiled_apk $(LAYOUTLIB_RES)/compiled.apk
96 for f in $(LAYOUTLIB_RES)/compiled_apk/res/*; do mv "$$f" "$${f/-v4/}";done
97 for f in $(LAYOUTLIB_RES)/compiled_apk/res/**/*.9.png; do mv "$$f" "$${f/.9.png/.compiled.9.png}";done
98 cp -r $(LAYOUTLIB_RES)/compiled_apk/res $(LAYOUTLIB_RES)/data
Jerome Gaillardc97c0b42024-08-01 18:02:22 +010099 $(SOONG_ZIP) -C $(LAYOUTLIB_RES)/data -D $(LAYOUTLIB_RES)/data/ -o $@
Wei Lic134b762023-10-17 23:52:30 -0700100
101$(call dist-for-goals,layoutlib,$(LAYOUTLIB_RES)/layoutlib-res.zip:layoutlib_native/res.zip)
102
103# SBOM of layoutlib artifacts
104LAYOUTLIB_SBOM := $(call intermediates-dir-for,PACKAGING,layoutlib-sbom,HOST)
105_layoutlib_font_config_files := $(sort $(wildcard frameworks/base/data/fonts/*.xml))
106_layoutlib_fonts_files := $(filter $(TARGET_OUT)/fonts/%.ttf $(TARGET_OUT)/fonts/%.ttc $(TARGET_OUT)/fonts/%.otf, $(INTERNAL_SYSTEMIMAGE_FILES))
Wei Liee4ab532023-10-25 15:49:26 -0700107_layoutlib_keyboard_files := $(sort $(wildcard frameworks/base/data/keyboards/*.kcm))
Jerome Gaillardd5403172024-11-14 16:54:27 +0000108_layoutlib_hyphen_files := $(filter $(TARGET_OUT)/usr/hyphen-data/%.hyb, $(INTERNAL_SYSTEMIMAGE_FILES))
Wei Li94f0d122023-10-30 15:35:42 -0700109
110# Find out files disted with layoutlib in Soong.
111### Filter out static libraries for Windows and files already handled in make.
112_layoutlib_filter_out_disted := $(addprefix layoutlib_native/,fonts/% keyboards/% build.prop res.zip windows/%.a)
113_layoutlib_files_disted_by_soong := \
114 $(strip \
115 $(foreach p,$(_all_dist_src_dst_pairs), \
116 $(if $(filter-out $(_layoutlib_filter_out_disted),$(filter layoutlib_native/% layoutlib.jar,$(call word-colon,2,$p))),$p)))
117
Wei Lic134b762023-10-17 23:52:30 -0700118$(LAYOUTLIB_SBOM)/sbom-metadata.csv:
119 rm -rf $@
120 echo installed_file,module_path,soong_module_type,is_prebuilt_make_module,product_copy_files,kernel_module_copy_files,is_platform_generated,build_output_path,static_libraries,whole_static_libraries,is_static_lib >> $@
121 echo build.prop,,,,,,Y,$(LAYOUTLIB_BUILD_PROP)/layoutlib-build.prop,,, >> $@
122
123 $(foreach f,$(_layoutlib_font_config_files),\
124 echo data/fonts/$(notdir $f),frameworks/base/data/fonts,prebuilt_etc,,,,,$f,,, >> $@; \
125 )
126
127 $(foreach f,$(_layoutlib_fonts_files), \
128 $(eval _module_name := $(ALL_INSTALLED_FILES.$f)) \
129 $(eval _module_path := $(strip $(sort $(ALL_MODULES.$(_module_name).PATH)))) \
130 $(eval _soong_module_type := $(strip $(sort $(ALL_MODULES.$(_module_name).SOONG_MODULE_TYPE)))) \
131 echo data/fonts/$(notdir $f),$(_module_path),$(_soong_module_type),,,,,$f,,, >> $@; \
132 )
133
Wei Liee4ab532023-10-25 15:49:26 -0700134 $(foreach f,$(_layoutlib_keyboard_files), \
135 echo data/keyboards/$(notdir $f),frameworks/base/data/keyboards,prebuilt_etc,,,,,$f,,, >> $@; \
136 )
137
Jerome Gaillardd5403172024-11-14 16:54:27 +0000138 $(foreach f,$(_layoutlib_hyphen_files), \
139 $(eval _module_name := $(ALL_INSTALLED_FILES.$f)) \
140 $(eval _module_path := $(strip $(sort $(ALL_MODULES.$(_module_name).PATH)))) \
141 $(eval _soong_module_type := $(strip $(sort $(ALL_MODULES.$(_module_name).SOONG_MODULE_TYPE)))) \
142 echo data/hyphen-data/$(notdir $f),$(_module_path),$(_soong_module_type),,,,,$f,,, >> $@; \
143 )
144
Wei Li94f0d122023-10-30 15:35:42 -0700145 $(foreach f,$(_layoutlib_files_disted_by_soong), \
146 $(eval _prebuilt_module_file := $(call word-colon,1,$f)) \
147 $(eval _dist_file := $(call word-colon,2,$f)) \
148 $(eval _dist_file := $(patsubst data/windows/%,data/win/lib64/%,$(patsubst layoutlib_native/%,data/%,$(_dist_file)))) \
149 $(eval _dist_file := $(subst layoutlib.jar,data/layoutlib.jar,$(_dist_file))) \
150 $(eval _module_name := $(strip $(foreach m,$(ALL_MODULES),$(if $(filter $(_prebuilt_module_file),$(ALL_MODULES.$m.CHECKED)),$m)))) \
151 $(eval _module_path := $(strip $(sort $(ALL_MODULES.$(_module_name).PATH)))) \
152 $(eval _soong_module_type := $(strip $(sort $(ALL_MODULES.$(_module_name).SOONG_MODULE_TYPE)))) \
153 echo $(patsubst layoutlib_native/%,%,$(_dist_file)),$(_module_path),$(_soong_module_type),,,,,$(_prebuilt_module_file),,, >> $@; \
154 )
155
Wei Lic134b762023-10-17 23:52:30 -0700156 $(foreach f,$(LAYOUTLIB_RES_FILES), \
157 $(eval _path := $(subst frameworks/base/core/res,data,$f)) \
158 echo $(_path),,,,,,Y,$f,,, >> $@; \
159 )
160
Jerome Gaillardc97c0b42024-08-01 18:02:22 +0100161 $(foreach f,$(EMULATED_OVERLAYS_FILES), \
162 $(eval _path := $(subst frameworks/base/packages,data,$f)) \
163 echo $(_path),,,,,,Y,$f,,, >> $@; \
164 )
165
166 $(foreach f,$(DEVICE_OVERLAYS_FILES), \
167 $(eval _path := $(subst device/generic/goldfish/phone/overlay/frameworks/base/packages,data,$f)) \
168 echo $(_path),,,,,,Y,$f,,, >> $@; \
169 )
170
Wei Lic134b762023-10-17 23:52:30 -0700171.PHONY: layoutlib-sbom
172layoutlib-sbom: $(LAYOUTLIB_SBOM)/layoutlib.spdx.json
Jerome Gaillardd5403172024-11-14 16:54:27 +0000173$(LAYOUTLIB_SBOM)/layoutlib.spdx.json: $(PRODUCT_OUT)/always_dirty_file.txt $(GEN_SBOM) $(LAYOUTLIB_SBOM)/sbom-metadata.csv $(_layoutlib_font_config_files) $(_layoutlib_fonts_files) $(LAYOUTLIB_BUILD_PROP)/layoutlib-build.prop $(_layoutlib_keyboard_files) $(_layoutlib_hyphen_files) $(LAYOUTLIB_RES_FILES) $(EMULATED_OVERLAYS_FILES) $(DEVICE_OVERLAYS_FILES)
Wei Lic134b762023-10-17 23:52:30 -0700174 rm -rf $@
Wei Liee4ab532023-10-25 15:49:26 -0700175 $(GEN_SBOM) --output_file $@ --metadata $(LAYOUTLIB_SBOM)/sbom-metadata.csv --build_version $(BUILD_FINGERPRINT_FROM_FILE) --product_mfr "$(PRODUCT_MANUFACTURER)" --module_name "layoutlib" --json
Wei Lic134b762023-10-17 23:52:30 -0700176
177$(call dist-for-goals,layoutlib,$(LAYOUTLIB_SBOM)/layoutlib.spdx.json:layoutlib_native/sbom/layoutlib.spdx.json)
178
179# Generate SBOM of framework_res.jar that is created in release_layoutlib.sh.
Jerome Gaillardc97c0b42024-08-01 18:02:22 +0100180# The generated SBOM contains placeholders for release_layoutlib.sh to substitute, and the placeholders include:
Wei Lic134b762023-10-17 23:52:30 -0700181# document name, document namespace, document creation info, organization and SHA1 value of framework_res.jar.
182GEN_SBOM_FRAMEWORK_RES := $(HOST_OUT_EXECUTABLES)/generate-sbom-framework_res
183.PHONY: layoutlib-framework_res-sbom
184layoutlib-framework_res-sbom: $(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json
185$(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json: $(LAYOUTLIB_SBOM)/layoutlib.spdx.json $(GEN_SBOM_FRAMEWORK_RES)
186 rm -rf $@
187 $(GEN_SBOM_FRAMEWORK_RES) --output_file $(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json --layoutlib_sbom $(LAYOUTLIB_SBOM)/layoutlib.spdx.json
188
189$(call dist-for-goals,layoutlib,$(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json:layoutlib_native/sbom/framework_res.jar.spdx.json)