# Copyright 2025 - The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """typenum bazel build rule""" load("@rules_rust//cargo:defs.bzl", "cargo_build_script") load("@rules_rust//rust:defs.bzl", "rust_library") package(default_visibility = ["//visibility:public"]) genrule( name = "build_script_srcs_gen", srcs = glob(["build/**/*.rs"]), outs = ["build_script_srcs_dir/main.rs", "build_script_srcs_dir/op.rs", "build_script_srcs_dir/consts.rs"], cmd = "touch $(@D)/build_script_srcs_dir/main.rs $(@D)/build_script_srcs_dir/op.rs $(@D)/build_script_srcs_dir/consts.rs && mkdir -p $(@D)/build_script_srcs_dir && cp -r $(SRCS) $(@D)/build_script_srcs_dir && sed -i '/mod tests;/d' $(@D)/build_script_srcs_dir/main.rs && sed -i '/tests::build_tests().unwrap();/d' $(@D)/build_script_srcs_dir/main.rs", ) cargo_build_script( name = "build_script", srcs = [":build_script_srcs_gen"], edition = "2021", ) rust_library( name = "typenum", srcs = glob(["src/**/*.rs"]), crate_name = "typenum", edition = "2018", deps = [":build_script"], )