blob: 06735dfe38f5b7d0237fabe42df5f69507a0da1f [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.
6font_config := $(sort $(wildcard frameworks/base/data/fonts/*.xml))
7font_config := $(addprefix $(FONT_TEMP)/, $(notdir $(font_config)))
8
9$(font_config): $(FONT_TEMP)/%.xml: \
10 frameworks/base/data/fonts/%.xml
11 $(hide) mkdir -p $(dir $@)
12 $(hide) cp -vf $< $@
13
14# List of fonts on the device that we want to ship. This is all .ttf, .ttc and .otf fonts.
15fonts_device := $(filter $(TARGET_OUT)/fonts/%.ttf $(TARGET_OUT)/fonts/%.ttc $(TARGET_OUT)/fonts/%.otf, $(INTERNAL_SYSTEMIMAGE_FILES))
16fonts_device := $(addprefix $(FONT_TEMP)/, $(notdir $(fonts_device)))
17
18# TODO: If the font file is a symlink, reuse the font renamed from the symlink
19# target.
20$(fonts_device): $(FONT_TEMP)/%: $(TARGET_OUT)/fonts/%
21 $(hide) mkdir -p $(dir $@)
22 $(hide) cp -vf $< $@
23
Jerome Gaillardea9dab42023-10-25 00:05:12 +000024KEYBOARD_TEMP := $(call intermediates-dir-for,PACKAGING,keyboards,HOST,COMMON)
25
26# The key character map files needed for supporting KeyEvent
27keyboards := $(sort $(wildcard frameworks/base/data/keyboards/*.kcm))
28keyboards := $(addprefix $(KEYBOARD_TEMP)/, $(notdir $(keyboards)))
29
30$(keyboards): $(KEYBOARD_TEMP)/%.kcm: frameworks/base/data/keyboards/%.kcm
31 $(hide) mkdir -p $(dir $@)
32 $(hide) cp -vf $< $@
33
Jerome Gaillard0cc202e2024-11-11 19:35:55 +000034HYPHEN_TEMP := $(call intermediates-dir-for,PACKAGING,hyphen,HOST,COMMON)
35
36# The hyphenation pattern files needed to support text hyphenation
37hyphen := $(filter $(TARGET_OUT)/usr/hyphen-data/%.hyb, $(INTERNAL_SYSTEMIMAGE_FILES))
38hyphen := $(addprefix $(HYPHEN_TEMP)/, $(notdir $(hyphen)))
39
40$(hyphen): $(HYPHEN_TEMP)/%: $(TARGET_OUT)/usr/hyphen-data/%
41 $(hide) mkdir -p $(dir $@)
42 $(hide) cp -vf $< $@
43
44# List of all data files - font files, font configuration files, key character map files, hyphenation pattern files
45LAYOUTLIB_FILES := $(fonts_device) $(font_config) $(keyboards) $(hyphen)
Jerome Gaillardcf713d42019-10-23 11:43:26 +010046
47.PHONY: layoutlib layoutlib-tests
Jerome Gaillardea9dab42023-10-25 00:05:12 +000048layoutlib layoutlib-tests: $(LAYOUTLIB_FILES)
Jerome Gaillardcf713d42019-10-23 11:43:26 +010049
Jerome Gaillardea9dab42023-10-25 00:05:12 +000050$(call dist-for-goals, layoutlib, $(foreach m,$(fonts_device), $(m):layoutlib_native/fonts/$(notdir $(m))))
51$(call dist-for-goals, layoutlib, $(foreach m,$(font_config), $(m):layoutlib_native/fonts/$(notdir $(m))))
52$(call dist-for-goals, layoutlib, $(foreach m,$(keyboards), $(m):layoutlib_native/keyboards/$(notdir $(m))))
Jerome Gaillard0cc202e2024-11-11 19:35:55 +000053$(call dist-for-goals, layoutlib, $(foreach m,$(hyphen), $(m):layoutlib_native/hyphen-data/$(notdir $(m))))
Jerome Gaillardcf713d42019-10-23 11:43:26 +010054
55FONT_TEMP :=
56font_config :=
57fonts_device :=
58FONT_FILES :=
Wei Lic134b762023-10-17 23:52:30 -070059
60# The following build process of build.prop, layoutlib-res.zip is moved here from release_layoutlib.sh
61# so the SBOM of all platform neutral artifacts and Linux/Windows artifacts of layoutlib can be built in Make/Soong.
62# See go/layoutlib-sbom.
63
64# build.prop shipped with layoutlib
65LAYOUTLIB_BUILD_PROP := $(call intermediates-dir-for,PACKAGING,layoutlib-build-prop,HOST,COMMON)
66$(LAYOUTLIB_BUILD_PROP)/layoutlib-build.prop: $(INSTALLED_SDK_BUILD_PROP_TARGET)
67 rm -rf $@
68 cp $< $@
69 # Remove all the uncommon build properties
70 sed -i '/^ro\.\(build\|product\|config\|system\)/!d' $@
71 # Mark the build as layoutlib. This can be read at runtime by apps
72 sed -i 's|ro.product.brand=generic|ro.product.brand=studio|' $@
73 sed -i 's|ro.product.device=generic|ro.product.device=layoutlib|' $@
74
75$(call dist-for-goals,layoutlib,$(LAYOUTLIB_BUILD_PROP)/layoutlib-build.prop:layoutlib_native/build.prop)
76
77# Resource files from frameworks/base/core/res/res
78LAYOUTLIB_RES := $(call intermediates-dir-for,PACKAGING,layoutlib-res,HOST,COMMON)
79LAYOUTLIB_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 +010080EMULATED_OVERLAYS_FILES := $(shell find frameworks/base/packages/overlays/*/res/ | sort)
81DEVICE_OVERLAYS_FILES := $(shell find device/generic/goldfish/phone/overlay/frameworks/base/packages/overlays/*/AndroidOverlay/res/ | sort)
82$(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 -070083 rm -rf $@
Jerome Gaillardc97c0b42024-08-01 18:02:22 +010084 echo $(LAYOUTLIB_RES_FILES) > $(LAYOUTLIB_RES)/filelist_res.txt
85 $(SOONG_ZIP) -C frameworks/base/core/res -l $(LAYOUTLIB_RES)/filelist_res.txt -o $(LAYOUTLIB_RES)/temp_res.zip
86 echo $(EMULATED_OVERLAYS_FILES) > $(LAYOUTLIB_RES)/filelist_emulated_overlays.txt
87 $(SOONG_ZIP) -C frameworks/base/packages -l $(LAYOUTLIB_RES)/filelist_emulated_overlays.txt -o $(LAYOUTLIB_RES)/temp_emulated_overlays.zip
88 echo $(DEVICE_OVERLAYS_FILES) > $(LAYOUTLIB_RES)/filelist_device_overlays.txt
89 $(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
90 rm -rf $(LAYOUTLIB_RES)/data && unzip -q -d $(LAYOUTLIB_RES)/data $(LAYOUTLIB_RES)/temp_res.zip
91 unzip -q -d $(LAYOUTLIB_RES)/data $(LAYOUTLIB_RES)/temp_emulated_overlays.zip
92 unzip -q -d $(LAYOUTLIB_RES)/data $(LAYOUTLIB_RES)/temp_device_overlays.zip
Wei Lic134b762023-10-17 23:52:30 -070093 rm -rf $(LAYOUTLIB_RES)/compiled && mkdir $(LAYOUTLIB_RES)/compiled && $(HOST_OUT_EXECUTABLES)/aapt2 compile $(LAYOUTLIB_RES)/data/res/**/*.9.png -o $(LAYOUTLIB_RES)/compiled
94 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
95 $(HOST_OUT_EXECUTABLES)/aapt2 link -R $(LAYOUTLIB_RES)/compiled/* -o $(LAYOUTLIB_RES)/compiled.apk --manifest $(LAYOUTLIB_RES)/AndroidManifest.xml
96 rm -rf $(LAYOUTLIB_RES)/compiled_apk && unzip -q -d $(LAYOUTLIB_RES)/compiled_apk $(LAYOUTLIB_RES)/compiled.apk
97 for f in $(LAYOUTLIB_RES)/compiled_apk/res/*; do mv "$$f" "$${f/-v4/}";done
98 for f in $(LAYOUTLIB_RES)/compiled_apk/res/**/*.9.png; do mv "$$f" "$${f/.9.png/.compiled.9.png}";done
99 cp -r $(LAYOUTLIB_RES)/compiled_apk/res $(LAYOUTLIB_RES)/data
Jerome Gaillardc97c0b42024-08-01 18:02:22 +0100100 $(SOONG_ZIP) -C $(LAYOUTLIB_RES)/data -D $(LAYOUTLIB_RES)/data/ -o $@
Wei Lic134b762023-10-17 23:52:30 -0700101
102$(call dist-for-goals,layoutlib,$(LAYOUTLIB_RES)/layoutlib-res.zip:layoutlib_native/res.zip)
103
104# SBOM of layoutlib artifacts
105LAYOUTLIB_SBOM := $(call intermediates-dir-for,PACKAGING,layoutlib-sbom,HOST)
106_layoutlib_font_config_files := $(sort $(wildcard frameworks/base/data/fonts/*.xml))
107_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 -0700108_layoutlib_keyboard_files := $(sort $(wildcard frameworks/base/data/keyboards/*.kcm))
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
Wei Li94f0d122023-10-30 15:35:42 -0700138 $(foreach f,$(_layoutlib_files_disted_by_soong), \
139 $(eval _prebuilt_module_file := $(call word-colon,1,$f)) \
140 $(eval _dist_file := $(call word-colon,2,$f)) \
141 $(eval _dist_file := $(patsubst data/windows/%,data/win/lib64/%,$(patsubst layoutlib_native/%,data/%,$(_dist_file)))) \
142 $(eval _dist_file := $(subst layoutlib.jar,data/layoutlib.jar,$(_dist_file))) \
143 $(eval _module_name := $(strip $(foreach m,$(ALL_MODULES),$(if $(filter $(_prebuilt_module_file),$(ALL_MODULES.$m.CHECKED)),$m)))) \
144 $(eval _module_path := $(strip $(sort $(ALL_MODULES.$(_module_name).PATH)))) \
145 $(eval _soong_module_type := $(strip $(sort $(ALL_MODULES.$(_module_name).SOONG_MODULE_TYPE)))) \
146 echo $(patsubst layoutlib_native/%,%,$(_dist_file)),$(_module_path),$(_soong_module_type),,,,,$(_prebuilt_module_file),,, >> $@; \
147 )
148
Wei Lic134b762023-10-17 23:52:30 -0700149 $(foreach f,$(LAYOUTLIB_RES_FILES), \
150 $(eval _path := $(subst frameworks/base/core/res,data,$f)) \
151 echo $(_path),,,,,,Y,$f,,, >> $@; \
152 )
153
Jerome Gaillardc97c0b42024-08-01 18:02:22 +0100154 $(foreach f,$(EMULATED_OVERLAYS_FILES), \
155 $(eval _path := $(subst frameworks/base/packages,data,$f)) \
156 echo $(_path),,,,,,Y,$f,,, >> $@; \
157 )
158
159 $(foreach f,$(DEVICE_OVERLAYS_FILES), \
160 $(eval _path := $(subst device/generic/goldfish/phone/overlay/frameworks/base/packages,data,$f)) \
161 echo $(_path),,,,,,Y,$f,,, >> $@; \
162 )
163
Wei Lic134b762023-10-17 23:52:30 -0700164.PHONY: layoutlib-sbom
165layoutlib-sbom: $(LAYOUTLIB_SBOM)/layoutlib.spdx.json
Jerome Gaillardc97c0b42024-08-01 18:02:22 +0100166$(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_RES_FILES) $(EMULATED_OVERLAYS_FILES) $(DEVICE_OVERLAYS_FILES)
Wei Lic134b762023-10-17 23:52:30 -0700167 rm -rf $@
Wei Liee4ab532023-10-25 15:49:26 -0700168 $(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 -0700169
170$(call dist-for-goals,layoutlib,$(LAYOUTLIB_SBOM)/layoutlib.spdx.json:layoutlib_native/sbom/layoutlib.spdx.json)
171
172# Generate SBOM of framework_res.jar that is created in release_layoutlib.sh.
Jerome Gaillardc97c0b42024-08-01 18:02:22 +0100173# The generated SBOM contains placeholders for release_layoutlib.sh to substitute, and the placeholders include:
Wei Lic134b762023-10-17 23:52:30 -0700174# document name, document namespace, document creation info, organization and SHA1 value of framework_res.jar.
175GEN_SBOM_FRAMEWORK_RES := $(HOST_OUT_EXECUTABLES)/generate-sbom-framework_res
176.PHONY: layoutlib-framework_res-sbom
177layoutlib-framework_res-sbom: $(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json
178$(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json: $(LAYOUTLIB_SBOM)/layoutlib.spdx.json $(GEN_SBOM_FRAMEWORK_RES)
179 rm -rf $@
180 $(GEN_SBOM_FRAMEWORK_RES) --output_file $(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json --layoutlib_sbom $(LAYOUTLIB_SBOM)/layoutlib.spdx.json
181
182$(call dist-for-goals,layoutlib,$(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json:layoutlib_native/sbom/framework_res.jar.spdx.json)