Extract common code into //lib package

This commit is contained in:
Dietrich Epp 2022-03-25 01:45:55 -04:00
parent 66d46452ab
commit 617bf831d8
10 changed files with 27 additions and 11 deletions

View File

@ -28,15 +28,15 @@ cc_library(
"convert.c", "convert.c",
"convert_1f.c", "convert_1f.c",
"convert_1r.c", "convert_1r.c",
"toolbox.c",
], ],
hdrs = [ hdrs = [
"convert.h", "convert.h",
"data.h", "data.h",
"defs.h",
"test.h",
], ],
copts = COPTS, copts = COPTS,
deps = [
"//lib",
],
) )
cc_test( cc_test(
@ -47,5 +47,6 @@ cc_test(
copts = COPTS, copts = COPTS,
deps = [ deps = [
":convert", ":convert",
"//lib",
], ],
) )

View File

@ -2,7 +2,7 @@
#define convert_h #define convert_h
/* convert.h - character set conversion routines. */ /* convert.h - character set conversion routines. */
#include "convert/defs.h" #include "lib/defs.h"
/* Error codes. */ /* Error codes. */
enum enum

View File

@ -1,6 +1,6 @@
/* convert_1f.c - Forward conversion from extended ASCII to UTF-8. */ /* convert_1f.c - Forward conversion from extended ASCII to UTF-8. */
#include "convert/convert.h" #include "convert/convert.h"
#include "convert/defs.h" #include "lib/defs.h"
struct Convert1fData { struct Convert1fData {
/* Unicode characters, encoded in UTF-8, and packed MSB first. Always either /* Unicode characters, encoded in UTF-8, and packed MSB first. Always either

View File

@ -1,6 +1,6 @@
/* convert_1r.c - Reverse conversion from UTF-8 to extended ASCII. */ /* convert_1r.c - Reverse conversion from UTF-8 to extended ASCII. */
#include "convert/convert.h" #include "convert/convert.h"
#include "convert/defs.h" #include "lib/defs.h"
enum enum
{ {

View File

@ -3,7 +3,7 @@
#include "convert/convert.h" #include "convert/convert.h"
#include "convert/data.h" #include "convert/data.h"
#include "convert/test.h" #include "lib/test.h"
#include <errno.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -1,7 +1,7 @@
#ifndef data_h #ifndef data_h
#define data_h #define data_h
/* data.h - charmap data, not used for classic Mac OS builds */ /* data.h - charmap data, not used for classic Mac OS builds */
#include "convert/defs.h" #include "lib/defs.h"
/* Get the ID of the given character map. Return NULL if no such character map /* Get the ID of the given character map. Return NULL if no such character map
exists. */ exists. */

15
lib/BUILD.bazel Normal file
View File

@ -0,0 +1,15 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//bazel:copts.bzl", "COPTS")
cc_library(
name = "lib",
srcs = [
"toolbox.c",
],
hdrs = [
"defs.h",
"test.h",
],
copts = COPTS,
visibility = ["//visibility:public"],
)

View File

@ -2,7 +2,7 @@
#define test_h #define test_h
/* test.h - unit testing definitions. */ /* test.h - unit testing definitions. */
#include "convert/defs.h" #include "lib/defs.h"
/* Print an error message and exit. */ /* Print an error message and exit. */
void Dief(const char *msg, ...) __attribute__((noreturn, format(printf, 1, 2))); void Dief(const char *msg, ...) __attribute__((noreturn, format(printf, 1, 2)));

View File

@ -3,8 +3,8 @@
This is used to run conversion tests on non-Mac OS systems to make This is used to run conversion tests on non-Mac OS systems to make
development easier. These are not intended to make it possible to port the development easier. These are not intended to make it possible to port the
converter to non-Mac OS systems. */ converter to non-Mac OS systems. */
#include "convert/defs.h" #include "lib/defs.h"
#include "convert/test.h" #include "lib/test.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>