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 18def __stamp(ctx, cmd): 19 if len(cmd.outputs) > 1: 20 # run touch command as is? 21 # iOS build stamp after swiftc.py would try to touch 22 # dir and non-exist-in-hashfs file? 23 # TODO(b/300385880): fix this workaround. 24 return 25 26 # don't truncate if file exists. 27 out = cmd.outputs[0] 28 if ctx.fs.exists(out): 29 ctx.actions.write(out, ctx.fs.read(out)) 30 else: 31 ctx.actions.write(out) 32 ctx.actions.exit(exit_status = 0) 33 34__handlers = { 35 "copy": __copy, 36 "stamp": __stamp, 37} 38 39def __step_config(ctx, step_config): 40 step_config["rules"].extend([ 41 { 42 "name": "simple/copy", 43 "action": "(.*_)?copy", 44 "handler": "copy", 45 }, 46 { 47 "name": "simple/stamp", 48 "action": "(.*_)?stamp", 49 "handler": "stamp", 50 "replace": True, 51 }, 52 ]) 53 return step_config 54 55simple = module( 56 "simple", 57 step_config = __step_config, 58 filegroups = __filegroups, 59 handlers = __handlers, 60) 61