Skip to content

Instantly share code, notes, and snippets.

@schwehr
Created January 10, 2023 15:18
Show Gist options
  • Select an option

  • Save schwehr/efa7f6db72e30e46938f1d703400a088 to your computer and use it in GitHub Desktop.

Select an option

Save schwehr/efa7f6db72e30e46938f1d703400a088 to your computer and use it in GitHub Desktop.
bazel build of hdf4
# SPDX-License-Identifier: Apache-2.0
# Copyright 2009 Google Inc. All Rights Reserved.
#
# Description:
# NCSA Hierarchical Data Format library
hdf4_copts = [
"-fomit-frame-pointer",
"-DHAVE_CONFIG_H",
"-DBIG_LONGS",
"-DNO_SYS_XDR_INC",
"-DSWAP",
"-Wno-bitwise-op-parentheses",
"-Wno-dangling-else",
"-Wno-incompatible-pointer-types-discards-qualifiers",
"-Wno-sometimes-uninitialized",
"-Wno-error",
"-Wno-format",
"-Wno-implicit-function-declaration",
"-Wno-missing-braces",
"-Wno-pointer-bool-conversion",
"-Wno-pointer-to-int-cast", # just barely harmless
"-Wno-self-assign",
"-Wno-tautological-compare",
"-Wno-unused-function",
"-Wno-unused-label",
"-Wno-unused-value",
"-Wno-unused-variable",
"-Wframe-larger-than=147456",
]
hdf4_nocopts = "-Wself-assign"
cc_library(
name = "config",
hdrs = [
"hdf/src/h4config.h",
],
copts = hdf4_copts,
)
cc_library(
name = "hdf4",
visibility = [
"//third_party/gdal:__subpackages__",
"//third_party/py/pyhdf:__subpackages__",
],
deps = [
":libdf",
":libmfhdf",
],
)
cc_library(
name = "libdf",
srcs = glob(
[
"hdf/src/*.c",
"hdf/src/*.h",
],
),
hdrs = [
"hdf/src/H4api_adpt.h",
"hdf/src/bitvect.h",
"hdf/src/hchunks.h",
"hdf/src/hdf.h",
"hdf/src/hdfi.h",
"hdf/src/herr.h",
"hdf/src/hfile.h",
"hdf/src/hlimits.h",
"hdf/src/mfgr.h",
"hdf/src/tbbt.h",
"hdf/src/vg.h",
],
copts = hdf4_copts,
includes = [
"hdf/src",
"mfhdf/libsrc",
],
nocopts = hdf4_nocopts,
deps = [
":config",
"//base",
"//third_party/libjpeg_turbo/src:jpeg",
"//third_party/zlib:zlibsystem",
],
)
cc_library(
name = "libmfhdf",
srcs = glob(
[
"mfhdf/libsrc/*.c",
"mfhdf/libsrc/*.h",
],
),
hdrs = [
"mfhdf/libsrc/hdf4_netcdf.h",
"mfhdf/libsrc/mfhdf.h",
# Do not include netcdf.h.
# It clashes with the actual netcdf settings in //third_party/netcdf.
# "mfhdf/libsrc/netcdf.h",
],
copts = hdf4_copts + [
"-DNDEBUG",
"-DHDF",
"-Ithird_party/libtirpc/tirpc/rpc",
"-Wno-error=implicit-function-declaration",
# TODO(b/242833278): Remove this after fixing the issues hidden by disabling the
# `incompatible-function-pointer-types` error.
"-Wno-error=incompatible-function-pointer-types",
],
includes = [
"hdf/src",
"mfhdf/libsrc",
],
nocopts = hdf4_nocopts,
deps = [
":config",
":libdf",
"//third_party/libtirpc",
],
)
cc_library(
name = "hdf_test_lib",
testonly = 1,
srcs = glob(
[
"hdf/test/*.c",
"hdf/test/*.h",
],
),
hdrs = ["hdf/test/testhdf.h"],
copts = hdf4_copts,
includes = ["hdf/src"],
nocopts = hdf4_nocopts,
deps = [
":libdf",
"//base",
"//file/base",
"//file/base:path",
"//testing/base/public:gunit_for_library_testonly",
"//third_party/libjpeg_turbo/src:jpeg",
],
)
cc_test(
name = "hdf_test",
srcs = ["hdf/test/hdf4_test.cc"],
copts = hdf4_copts,
data = glob(["hdf/test/test_files/*"]),
includes = ["hdf/src"],
nocopts = hdf4_nocopts,
deps = [
":hdf_test_lib",
"//base",
"//file/base",
"//file/base:path",
# TODO(schwehr): Fix leak in HAregister_atom.
"//testing/base/public:gunit_main_no_heapcheck",
"//third_party/absl/flags:flag",
],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment