load("//build-system:defines.bzl", "string_value", ) def _telegram_info_plist(ctx): output = ctx.outputs.out plist_string = """ CFBundleShortVersionString {app_version} CFBundleVersion {build_number} CFBundleURLTypes CFBundleTypeRole Viewer CFBundleURLName {bundle_id} CFBundleURLSchemes telegram CFBundleTypeRole Viewer CFBundleURLName {bundle_id}.ton CFBundleURLSchemes ton CFBundleTypeRole Viewer CFBundleURLName {app_name}.compatibility CFBundleURLSchemes {url_scheme} """.format( app_version = string_value(ctx, ctx.attr.app_version_define), build_number = string_value(ctx, ctx.attr.build_number_define), bundle_id = string_value(ctx, ctx.attr.bundle_id_define), app_name = ctx.attr.app_name, url_scheme = ctx.attr.url_scheme, ) ctx.actions.write( output = output, content = plist_string, ) telegram_info_plist = rule( implementation = _telegram_info_plist, attrs = { "app_name": attr.string(mandatory = True), "url_scheme": attr.string(mandatory = True), "bundle_id_define": attr.string(mandatory = True), "app_version_define": attr.string(mandatory = True), "build_number_define": attr.string(mandatory = True), }, outputs = { "out": "%{name}.plist" }, )