| Serge Bazanski | 72c1f2b | 2024-06-04 13:42:48 +0000 | [diff] [blame] | 1 | From 3b2ea39444bf97d7847fdb1a3ca70f9d58ffe22a Mon Sep 17 00:00:00 2001 |
| 2 | From: Serge Bazanski <serge@monogon.tech> |
| 3 | Date: Tue, 4 Jun 2024 15:10:02 +0200 |
| 4 | Subject: [PATCH 4/4] bazel support: implement |
| 5 | |
| 6 | --- |
| 7 | .gitignore | 2 - |
| 8 | BUILD.bazel | 94 ++++++++++++++++++++++++++++++++++++++++++ |
| 9 | WORKSPACE | 0 |
| 10 | include/config.h | 8 ++++ |
| 11 | include/swtpm.h | 5 +++ |
| 12 | src/swtpm/main.c | 2 +- |
| 13 | src/utils/swtpm_conf.h | 22 ++++++++++ |
| 14 | 7 files changed, 130 insertions(+), 3 deletions(-) |
| 15 | create mode 100644 BUILD.bazel |
| 16 | create mode 100644 WORKSPACE |
| 17 | create mode 100644 include/config.h |
| 18 | create mode 100644 include/swtpm.h |
| 19 | create mode 100644 src/utils/swtpm_conf.h |
| 20 | |
| 21 | diff --git a/.gitignore b/.gitignore |
| 22 | index c669f06..9982dd0 100644 |
| 23 | --- a/.gitignore |
| 24 | +++ b/.gitignore |
| 25 | @@ -35,7 +35,6 @@ Makefile |
| 26 | /m4/* |
| 27 | /.pc/* |
| 28 | /patches/* |
| 29 | -/include/swtpm.h |
| 30 | /man/man3/*.3 |
| 31 | /man/man5/*.5 |
| 32 | /man/man8/*.8 |
| 33 | @@ -60,7 +59,6 @@ Makefile |
| 34 | /src/swtpm_ioctl/swtpm_ioctl |
| 35 | /src/swtpm_localca/swtpm_localca |
| 36 | /src/swtpm_setup/swtpm_setup |
| 37 | -/src/utils/swtpm_conf.h |
| 38 | /test-driver |
| 39 | tests/*.log |
| 40 | tests/*.trs |
| 41 | diff --git a/BUILD.bazel b/BUILD.bazel |
| 42 | new file mode 100644 |
| 43 | index 0000000..acddc0e |
| 44 | --- /dev/null |
| 45 | +++ b/BUILD.bazel |
| 46 | @@ -0,0 +1,94 @@ |
| 47 | +cc_binary( |
| 48 | + name = "swtpm", |
| 49 | + deps = [ |
| Tim Windelschmidt | e1420ab | 2024-08-27 01:53:16 +0200 | [diff] [blame] | 50 | + "@@//third_party/libtpms:libtpms_tpm2", |
| 51 | + "@@//third_party/glib", |
| Serge Bazanski | 72c1f2b | 2024-06-04 13:42:48 +0000 | [diff] [blame] | 52 | + ], |
| 53 | + srcs = glob([ |
| 54 | + "src/swtpm/*.h", |
| 55 | + "src/swtpm/*.c", |
| 56 | + "src/utils/*.h", |
| 57 | + "src/utils/*.c", |
| 58 | + "include/*.h", |
| 59 | + "include/swtpm/*.h", |
| 60 | + ], [ |
| 61 | + # No CUSE support. |
| 62 | + "src/swtpm/cuse_tpm.c", |
| 63 | + # Only used in utils. |
| 64 | + "src/utils/swtpm_utils.c", |
| 65 | + ]), |
| 66 | + copts = [ |
| Tim Windelschmidt | e1420ab | 2024-08-27 01:53:16 +0200 | [diff] [blame] | 67 | + "-Iexternal/_main~_repo_rules~swtpm/include", |
| 68 | + "-Iexternal/_main~_repo_rules~swtpm/include/swtpm", |
| 69 | + "-Iexternal/_main~_repo_rules~swtpm/src/utils", |
| Serge Bazanski | 72c1f2b | 2024-06-04 13:42:48 +0000 | [diff] [blame] | 70 | + ], |
| 71 | + visibility = [ |
| 72 | + "//visibility:public", |
| 73 | + ], |
| 74 | +) |
| 75 | + |
| 76 | +cc_binary( |
| 77 | + name = "swtpm_localca", |
| 78 | + deps = [ |
| Tim Windelschmidt | e1420ab | 2024-08-27 01:53:16 +0200 | [diff] [blame] | 79 | + "@@//third_party/libtpms:libtpms_tpm2", |
| 80 | + "@@//third_party/glib", |
| Serge Bazanski | 72c1f2b | 2024-06-04 13:42:48 +0000 | [diff] [blame] | 81 | + ], |
| 82 | + srcs = glob([ |
| 83 | + "src/swtpm_localca/*.h", |
| 84 | + "src/swtpm_localca/*.c", |
| 85 | + "include/*.h", |
| 86 | + "include/swtpm/*.h", |
| 87 | + "src/utils/*.h", |
| 88 | + "src/utils/*.c", |
| 89 | + ], []), |
| 90 | + copts = [ |
| Tim Windelschmidt | e1420ab | 2024-08-27 01:53:16 +0200 | [diff] [blame] | 91 | + "-Iexternal/_main~_repo_rules~swtpm/include", |
| 92 | + "-Iexternal/_main~_repo_rules~swtpm/include/swtpm", |
| 93 | + "-Iexternal/_main~_repo_rules~swtpm/src/utils", |
| Serge Bazanski | 72c1f2b | 2024-06-04 13:42:48 +0000 | [diff] [blame] | 94 | + ], |
| 95 | + visibility = [ |
| 96 | + "//visibility:public", |
| 97 | + ], |
| 98 | +) |
| 99 | + |
| 100 | +cc_binary( |
| 101 | + name = "swtpm_setup", |
| 102 | + deps = [ |
| Tim Windelschmidt | e1420ab | 2024-08-27 01:53:16 +0200 | [diff] [blame] | 103 | + "@@//third_party/libtpms:libtpms_tpm2", |
| 104 | + "@@//third_party/glib", |
| Serge Bazanski | 72c1f2b | 2024-06-04 13:42:48 +0000 | [diff] [blame] | 105 | + ], |
| 106 | + srcs = glob([ |
| 107 | + "src/swtpm_setup/*.h", |
| 108 | + "src/swtpm_setup/*.c", |
| 109 | + "include/*.h", |
| 110 | + "include/swtpm/*.h", |
| 111 | + "src/utils/*.h", |
| 112 | + "src/utils/*.c", |
| 113 | + ], []), |
| 114 | + copts = [ |
| Tim Windelschmidt | e1420ab | 2024-08-27 01:53:16 +0200 | [diff] [blame] | 115 | + "-Iexternal/_main~_repo_rules~swtpm/include", |
| 116 | + "-Iexternal/_main~_repo_rules~swtpm/include/swtpm", |
| 117 | + "-Iexternal/_main~_repo_rules~swtpm/src/utils", |
| Serge Bazanski | 72c1f2b | 2024-06-04 13:42:48 +0000 | [diff] [blame] | 118 | + ], |
| 119 | + visibility = [ |
| 120 | + "//visibility:public", |
| 121 | + ], |
| 122 | +) |
| 123 | + |
| 124 | +cc_binary( |
| 125 | + name = "swtpm_cert", |
| 126 | + deps = [ |
| 127 | + "@boringssl//:ssl", |
| 128 | + ], |
| 129 | + srcs = glob([ |
| 130 | + "src/swtpm_cert/*.h", |
| 131 | + "src/swtpm_cert/*.c", |
| 132 | + "include/*.h", |
| 133 | + ], []), |
| 134 | + copts = [ |
| Tim Windelschmidt | e1420ab | 2024-08-27 01:53:16 +0200 | [diff] [blame] | 135 | + "-Iexternal/_main~_repo_rules~swtpm/include", |
| Serge Bazanski | 72c1f2b | 2024-06-04 13:42:48 +0000 | [diff] [blame] | 136 | + ], |
| 137 | + visibility = [ |
| 138 | + "//visibility:public", |
| 139 | + ], |
| 140 | +) |
| 141 | diff --git a/WORKSPACE b/WORKSPACE |
| 142 | new file mode 100644 |
| 143 | index 0000000..e69de29 |
| 144 | diff --git a/include/config.h b/include/config.h |
| 145 | new file mode 100644 |
| 146 | index 0000000..d3829d6 |
| 147 | --- /dev/null |
| 148 | +++ b/include/config.h |
| 149 | @@ -0,0 +1,8 @@ |
| 150 | +#pragma once |
| 151 | +#define _GNU_SOURCE |
| 152 | + |
| 153 | +#define VERSION "0.8.2-monogon" |
| 154 | + |
| 155 | +// A bunch of files in swtpm depend on stdint types but never include them. |
| 156 | +// Just inject them through here. |
| 157 | +#include <stdint.h> |
| 158 | diff --git a/include/swtpm.h b/include/swtpm.h |
| 159 | new file mode 100644 |
| 160 | index 0000000..2eddeec |
| 161 | --- /dev/null |
| 162 | +++ b/include/swtpm.h |
| 163 | @@ -0,0 +1,5 @@ |
| 164 | +#pragma once |
| 165 | + |
| 166 | +#define SWTPM_VER_MAJOR 0 |
| 167 | +#define SWTPM_VER_MINOR 8 |
| 168 | +#define SWTPM_VER_MICRO 2 |
| 169 | diff --git a/src/swtpm/main.c b/src/swtpm/main.c |
| 170 | index 4864e85..633ca33 100644 |
| 171 | --- a/src/swtpm/main.c |
| 172 | +++ b/src/swtpm/main.c |
| 173 | @@ -83,7 +83,7 @@ int main(int argc, char **argv) |
| 174 | } else if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { |
| 175 | usage(stdout, argv[0]); |
| 176 | } else if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) { |
| 177 | - fprintf(stdout, "TPM emulator version %d.%d.%d, " |
| 178 | + fprintf(stdout, "TPM emulator version %d.%d.%d-monogon, " |
| 179 | "Copyright (c) 2014-2022 IBM Corp. and others\n", |
| 180 | SWTPM_VER_MAJOR, |
| 181 | SWTPM_VER_MINOR, |
| 182 | diff --git a/src/utils/swtpm_conf.h b/src/utils/swtpm_conf.h |
| 183 | new file mode 100644 |
| 184 | index 0000000..de8afdb |
| 185 | --- /dev/null |
| 186 | +++ b/src/utils/swtpm_conf.h |
| 187 | @@ -0,0 +1,22 @@ |
| 188 | +/* SPDX-License-Identifier: BSD-3-Clause */ |
| 189 | +/* |
| 190 | + * swtpm_conf.h: Compile-time constants |
| 191 | + * |
| 192 | + * Author: Stefan Berger, stefanb@linux.ibm.com |
| 193 | + * |
| 194 | + * Copyright (c) IBM Corporation, 2021,2023 |
| 195 | + */ |
| 196 | + |
| 197 | +#ifndef SWTPM_SETUP_CONF_H |
| 198 | +#define SWTPM_SETUP_CONF_H |
| 199 | + |
| 200 | +#define SWTPM_VER_MAJOR 0 |
| 201 | +#define SWTPM_VER_MINOR 8 |
| 202 | +#define SWTPM_VER_MICRO 2 |
| 203 | + |
| 204 | +#define SYSCONFDIR "/unused" |
| 205 | +#define BINDIR "/unused" |
| 206 | + |
| 207 | +#define DEFAULT_PCR_BANKS "sha256" |
| 208 | + |
| 209 | +#endif /* SWTPM_SETUP_CONF_H */ |
| 210 | -- |
| 211 | 2.42.0 |
| 212 | |