1# -*- bazel-starlark -*- 2# Copyright 2023 The Chromium Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5"""Siso configuration for simple steps.""" 6 7load("@builtin//struct.star", "module") 8 9def __filegroups(ctx): 10 return {} 11 12def __copy(ctx, cmd): 13 input = cmd.inputs[0] 14 out = cmd.outputs[0] 15 ctx.actions.copy(input, out, recursive = ctx.fs.is_dir(input)) 16 ctx.actions.exit(exit_status = 0) 17 18# to reduce unnecessary local process and 19# unnecessary digest calculation of output file. 20def __copy_bundle_data(ctx, cmd): 21 input = cmd.inputs[0] 22 out = cmd.outputs[0] 23 ctx.actions.copy(input, out, recursive = ctx.fs.is_dir(input)) 24 ctx.actions.exit(exit_status = 0) 25 26def __stamp(ctx, cmd): 27 if len(cmd.outputs) > 1: 28 # run touch command as is? 29 # iOS build stamp after swiftc.py would try to touch 30 # dir and non-exist-in-hashfs file? 31 # TODO(b/300385880): fix this workaround. 32 return 33 34 # don't truncate if file exists. 35 out = cmd.outputs[0] 36 if ctx.fs.exists(out): 37 ctx.actions.write(out, ctx.fs.read(out)) 38 else: 39 ctx.actions.write(out) 40 ctx.actions.exit(exit_status = 0) 41 42__handlers = { 43 "copy": __copy, 44 "copy_bundle_data": __copy_bundle_data, 45 "stamp": __stamp, 46} 47 48def __step_config(ctx, step_config): 49 step_config["rules"].extend([ 50 { 51 "name": "simple/copy", 52 "action": "(.*_)?copy", 53 "handler": "copy", 54 }, 55 { 56 "name": "simple/copy_bundle_data", 57 "action": "(.*)?copy_bundle_data", 58 "handler": "copy_bundle_data", 59 }, 60 { 61 "name": "simple/stamp", 62 "action": "(.*_)?stamp", 63 "handler": "stamp", 64 "replace": True, 65 }, 66 ]) 67 return step_config 68 69simple = module( 70 "simple", 71 step_config = __step_config, 72 filegroups = __filegroups, 73 handlers = __handlers, 74) 75