Austin Schuh | b02d233 | 2023-09-05 22:18:35 -0700 | [diff] [blame] | 1 | def halide_library(name, src, function, args, visibility = None): |
| 2 | native.genrule( |
| 3 | name = name + "_build_generator", |
| 4 | outs = [ |
| 5 | name + "_generator", |
| 6 | ], |
| 7 | srcs = [ |
| 8 | src, |
| 9 | ], |
| 10 | cmd = "$(location //frc971:halide_generator_compile_script) $(OUTS) $(location " + src + ")", |
| 11 | tools = [ |
| 12 | "//frc971:halide_generator_compile_script", |
| 13 | ], |
| 14 | ) |
| 15 | native.genrule( |
| 16 | name = "generate_" + name, |
| 17 | srcs = [ |
| 18 | ":" + name + "_generator", |
| 19 | ], |
| 20 | outs = [ |
| 21 | name + ".h", |
| 22 | name + ".o", |
| 23 | name + ".stmt.html", |
| 24 | ], |
| 25 | # TODO(austin): Upgrade halide... |
| 26 | cmd = "$(location :" + name + "_generator) -g '" + function + "' -o $(RULEDIR) -f " + name + " -e 'o,h,html' " + select({ |
| 27 | "@platforms//cpu:x86_64": "target=host ", |
Austin Schuh | bffbe8b | 2023-11-22 21:32:05 -0800 | [diff] [blame] | 28 | "@platforms//cpu:aarch64": "target=arm-64-linux ", |
Austin Schuh | b02d233 | 2023-09-05 22:18:35 -0700 | [diff] [blame] | 29 | "//conditions:default": "", |
| 30 | }) + args, |
| 31 | target_compatible_with = select({ |
| 32 | "@platforms//cpu:x86_64": [], |
| 33 | "@platforms//cpu:arm64": [], |
| 34 | "//conditions:default": ["@platforms//:incompatible"], |
| 35 | }) + ["@platforms//os:linux"], |
| 36 | ) |
| 37 | |
| 38 | native.cc_library( |
| 39 | name = name, |
| 40 | srcs = [name + ".o"], |
| 41 | hdrs = [name + ".h"], |
| 42 | visibility = visibility, |
| 43 | target_compatible_with = select({ |
| 44 | "@platforms//cpu:x86_64": [], |
| 45 | "@platforms//cpu:arm64": [], |
| 46 | "//conditions:default": ["@platforms//:incompatible"], |
| 47 | }) + ["@platforms//os:linux"], |
| 48 | deps = [ |
| 49 | "//third_party:halide_runtime", |
| 50 | ], |
| 51 | ) |