blob: 7321c09b8aa6521a33c0d9885d84e12298a294c3 [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
34# List of all data files - font files, font configuration files, key character map files
35LAYOUTLIB_FILES := $(fonts_device) $(font_config) $(keyboards)
Jerome Gaillardcf713d42019-10-23 11:43:26 +010036
37.PHONY: layoutlib layoutlib-tests
Jerome Gaillardea9dab42023-10-25 00:05:12 +000038layoutlib layoutlib-tests: $(LAYOUTLIB_FILES)
Jerome Gaillardcf713d42019-10-23 11:43:26 +010039
Jerome Gaillardea9dab42023-10-25 00:05:12 +000040$(call dist-for-goals, layoutlib, $(foreach m,$(fonts_device), $(m):layoutlib_native/fonts/$(notdir $(m))))
41$(call dist-for-goals, layoutlib, $(foreach m,$(font_config), $(m):layoutlib_native/fonts/$(notdir $(m))))
42$(call dist-for-goals, layoutlib, $(foreach m,$(keyboards), $(m):layoutlib_native/keyboards/$(notdir $(m))))
Jerome Gaillardcf713d42019-10-23 11:43:26 +010043
44FONT_TEMP :=
45font_config :=
46fonts_device :=
47FONT_FILES :=
Wei Lic134b762023-10-17 23:52:30 -070048
49# The following build process of build.prop, layoutlib-res.zip is moved here from release_layoutlib.sh
50# so the SBOM of all platform neutral artifacts and Linux/Windows artifacts of layoutlib can be built in Make/Soong.
51# See go/layoutlib-sbom.
52
53# build.prop shipped with layoutlib
54LAYOUTLIB_BUILD_PROP := $(call intermediates-dir-for,PACKAGING,layoutlib-build-prop,HOST,COMMON)
55$(LAYOUTLIB_BUILD_PROP)/layoutlib-build.prop: $(INSTALLED_SDK_BUILD_PROP_TARGET)
56 rm -rf $@
57 cp $< $@
58 # Remove all the uncommon build properties
59 sed -i '/^ro\.\(build\|product\|config\|system\)/!d' $@
60 # Mark the build as layoutlib. This can be read at runtime by apps
61 sed -i 's|ro.product.brand=generic|ro.product.brand=studio|' $@
62 sed -i 's|ro.product.device=generic|ro.product.device=layoutlib|' $@
63
64$(call dist-for-goals,layoutlib,$(LAYOUTLIB_BUILD_PROP)/layoutlib-build.prop:layoutlib_native/build.prop)
65
66# Resource files from frameworks/base/core/res/res
67LAYOUTLIB_RES := $(call intermediates-dir-for,PACKAGING,layoutlib-res,HOST,COMMON)
68LAYOUTLIB_RES_FILES := $(shell find frameworks/base/core/res/res -type f -not -path 'frameworks/base/core/res/res/values-m[nc]c*' | sort)
69$(LAYOUTLIB_RES)/layoutlib-res.zip: $(SOONG_ZIP) $(HOST_OUT_EXECUTABLES)/aapt2 $(LAYOUTLIB_RES_FILES)
70 rm -rf $@
71 echo $(LAYOUTLIB_RES_FILES) > $(LAYOUTLIB_RES)/filelist.txt
72 $(SOONG_ZIP) -C frameworks/base/core/res -l $(LAYOUTLIB_RES)/filelist.txt -o $(LAYOUTLIB_RES)/temp.zip
73 rm -rf $(LAYOUTLIB_RES)/data && unzip -q -d $(LAYOUTLIB_RES)/data $(LAYOUTLIB_RES)/temp.zip
74 rm -rf $(LAYOUTLIB_RES)/compiled && mkdir $(LAYOUTLIB_RES)/compiled && $(HOST_OUT_EXECUTABLES)/aapt2 compile $(LAYOUTLIB_RES)/data/res/**/*.9.png -o $(LAYOUTLIB_RES)/compiled
75 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
76 $(HOST_OUT_EXECUTABLES)/aapt2 link -R $(LAYOUTLIB_RES)/compiled/* -o $(LAYOUTLIB_RES)/compiled.apk --manifest $(LAYOUTLIB_RES)/AndroidManifest.xml
77 rm -rf $(LAYOUTLIB_RES)/compiled_apk && unzip -q -d $(LAYOUTLIB_RES)/compiled_apk $(LAYOUTLIB_RES)/compiled.apk
78 for f in $(LAYOUTLIB_RES)/compiled_apk/res/*; do mv "$$f" "$${f/-v4/}";done
79 for f in $(LAYOUTLIB_RES)/compiled_apk/res/**/*.9.png; do mv "$$f" "$${f/.9.png/.compiled.9.png}";done
80 cp -r $(LAYOUTLIB_RES)/compiled_apk/res $(LAYOUTLIB_RES)/data
81 $(SOONG_ZIP) -C $(LAYOUTLIB_RES)/data -D $(LAYOUTLIB_RES)/data/res -o $@
82
83$(call dist-for-goals,layoutlib,$(LAYOUTLIB_RES)/layoutlib-res.zip:layoutlib_native/res.zip)
84
85# SBOM of layoutlib artifacts
86LAYOUTLIB_SBOM := $(call intermediates-dir-for,PACKAGING,layoutlib-sbom,HOST)
87_layoutlib_font_config_files := $(sort $(wildcard frameworks/base/data/fonts/*.xml))
88_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 -070089_layoutlib_keyboard_files := $(sort $(wildcard frameworks/base/data/keyboards/*.kcm))
Wei Lic134b762023-10-17 23:52:30 -070090$(LAYOUTLIB_SBOM)/sbom-metadata.csv:
91 rm -rf $@
92 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 >> $@
93 echo build.prop,,,,,,Y,$(LAYOUTLIB_BUILD_PROP)/layoutlib-build.prop,,, >> $@
94
95 $(foreach f,$(_layoutlib_font_config_files),\
96 echo data/fonts/$(notdir $f),frameworks/base/data/fonts,prebuilt_etc,,,,,$f,,, >> $@; \
97 )
98
99 $(foreach f,$(_layoutlib_fonts_files), \
100 $(eval _module_name := $(ALL_INSTALLED_FILES.$f)) \
101 $(eval _module_path := $(strip $(sort $(ALL_MODULES.$(_module_name).PATH)))) \
102 $(eval _soong_module_type := $(strip $(sort $(ALL_MODULES.$(_module_name).SOONG_MODULE_TYPE)))) \
103 echo data/fonts/$(notdir $f),$(_module_path),$(_soong_module_type),,,,,$f,,, >> $@; \
104 )
105
Wei Liee4ab532023-10-25 15:49:26 -0700106 $(foreach f,$(_layoutlib_keyboard_files), \
107 echo data/keyboards/$(notdir $f),frameworks/base/data/keyboards,prebuilt_etc,,,,,$f,,, >> $@; \
108 )
109
Wei Lic134b762023-10-17 23:52:30 -0700110 $(foreach f,$(LAYOUTLIB_RES_FILES), \
111 $(eval _path := $(subst frameworks/base/core/res,data,$f)) \
112 echo $(_path),,,,,,Y,$f,,, >> $@; \
113 )
114
115.PHONY: layoutlib-sbom
116layoutlib-sbom: $(LAYOUTLIB_SBOM)/layoutlib.spdx.json
Wei Liee4ab532023-10-25 15:49:26 -0700117$(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)
Wei Lic134b762023-10-17 23:52:30 -0700118 rm -rf $@
Wei Liee4ab532023-10-25 15:49:26 -0700119 $(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 -0700120
121$(call dist-for-goals,layoutlib,$(LAYOUTLIB_SBOM)/layoutlib.spdx.json:layoutlib_native/sbom/layoutlib.spdx.json)
122
123# Generate SBOM of framework_res.jar that is created in release_layoutlib.sh.
124# The generated SBOM contains placeholders for release_layotlib.sh to substitute, and the placeholders include:
125# document name, document namespace, document creation info, organization and SHA1 value of framework_res.jar.
126GEN_SBOM_FRAMEWORK_RES := $(HOST_OUT_EXECUTABLES)/generate-sbom-framework_res
127.PHONY: layoutlib-framework_res-sbom
128layoutlib-framework_res-sbom: $(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json
129$(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json: $(LAYOUTLIB_SBOM)/layoutlib.spdx.json $(GEN_SBOM_FRAMEWORK_RES)
130 rm -rf $@
131 $(GEN_SBOM_FRAMEWORK_RES) --output_file $(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json --layoutlib_sbom $(LAYOUTLIB_SBOM)/layoutlib.spdx.json
132
133$(call dist-for-goals,layoutlib,$(LAYOUTLIB_SBOM)/framework_res.jar.spdx.json:layoutlib_native/sbom/framework_res.jar.spdx.json)