Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions MAINTENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,37 @@ The "Developing odbc" vignette at `vignette("develop")` contains instructions on

The hardest part of maintaining odbc is often an issue only occurs with a specific database, and setting up the environment for that database usually takes a non-trivial amount of time.

## Vendored cctz

The vendored copy in `src/cctz` was last updated against `google/cctz`
commit `00fc77b843504f231f89c13eff86327c444094e8`.

Relative to that upstream commit, the odbc package intentionally keeps the
following deltas for R package inclusion:

- Upstream `.github/` is omitted from the vendored copy.
- Upstream `testdata/` is omitted from the vendored copy.
- `src/cctz/Makefile` is patched so recursive builds from `src/Makevars` keep
the cctz include path and PIC flags required for R shared-library builds.
- `src/cctz/Makefile` adds `time_zone_name_win.o` on Windows because upstream
now ships `src/time_zone_name_win.cc`, and omitting it breaks Windows
linking.
- `src/cctz/Makefile` add `-DNDEBUG` to `CPPFLAGS`.
- `src/cctz/src/time_zone_fixed.cc` keeps odbc-specific fixed-offset zone names
based on `Etc/GMT` rather than upstream `Fixed/UTC`, matching odbc timestamp
offset behavior.
- `src/cctz/src/time_zone_fixed.cc` also retains local formatting behavior for
fixed offsets, including compact hour formatting, omission of zero
minute/second components, and a runtime error in place of the upstream
assert.
- `src/cctz/src/time_zone_format.cc` keeps historical odbc compatibility
patches for Windows/MinGW-era behavior: forcing `HAS_STRPTIME`, disabling the
`tm_year` saturation branch for large positive values, and bypassing the
`strptime()` call in `ParseTM()`.

When updating cctz again, compare the vendored tree against upstream and carry
these deltas forward only if they are still required by odbc.

## Future directions

- Convert from using Rcpp to using cpp11.
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# odbc (development version)

* Update vendored cctz to current upstream, including local build compatibility
fixes retained for R package and Windows builds.

* SQL Server: Make it possible to write `POSIXct` data
to `DATETIMEOFFSET` targets (#985).

Expand Down
1 change: 1 addition & 0 deletions src/cctz/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ignore all files in the bazel directories
/bazel-*
MODULE.bazel.lock
# ignore non-bazel build products
/build
154 changes: 93 additions & 61 deletions src/cctz/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,46 @@
# 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
# https://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.

load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

package(
features = [
"header_modules",
"layering_check",
"parse_headers",
],
)

licenses(["notice"])

### libraries

cc_library(
name = "civil_time",
srcs = ["src/civil_time_detail.cc"],
hdrs = [
"include/civil_time.h",
"include/cctz/civil_time.h",
],
includes = ["include"],
textual_hdrs = ["include/civil_time_detail.h"],
textual_hdrs = ["include/cctz/civil_time_detail.h"],
visibility = ["//visibility:public"],
)

cc_library(
name = "time_zone",
srcs = [
"src/time_zone_fixed.cc",
"src/time_zone_fixed.h",
"src/time_zone_format.cc",
"src/time_zone_if.cc",
"src/time_zone_if.h",
Expand All @@ -40,65 +57,46 @@ cc_library(
"src/time_zone_posix.cc",
"src/time_zone_posix.h",
"src/tzfile.h",
],
"src/zone_info_source.cc",
] + select({
"@platforms//os:windows": [
"src/time_zone_name_win.cc",
"src/time_zone_name_win.h",
],
"//conditions:default": [],
}),
hdrs = [
"include/time_zone.h",
"include/cctz/time_zone.h",
"include/cctz/zone_info_source.h",
],
includes = ["include"],
linkopts = [
"-lm",
"-lpthread",
],
linkopts = select({
"@platforms//os:osx": ["-Wl,-framework,CoreFoundation"],
"@platforms//os:ios": ["-Wl,-framework,CoreFoundation"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [":civil_time"],
)

cc_library(
name = "cctz_v1",
hdrs = [
"src/cctz.h",
],
includes = ["include"],
visibility = ["//visibility:public"],
deps = [
":civil_time",
":time_zone",
],
)

### tests

# Builds the Google Test source that was fetched from another repository.
cc_library(
name = "gtest",
srcs = glob(
[
"google*/src/*.cc",
],
exclude = glob([
"google*/src/*-all.cc",
"googlemock/src/gmock_main.cc",
]),
),
hdrs = glob(["*/include/**/*.h"]),
includes = [
"googlemock/",
"googlemock/include",
"googletest/",
"googletest/include",
],
linkopts = ["-pthread"],
textual_hdrs = ["googletest/src/gtest-internal-inl.h"],
visibility = ["//visibility:public"],
name = "test_time_zone_names",
testonly = True,
srcs = ["src/test_time_zone_names.cc"],
hdrs = ["src/test_time_zone_names.h"],
visibility = ["//visibility:private"],
)

cc_test(
name = "civil_time_test",
size = "small",
srcs = ["src/civil_time_test.cc"],
deps = [
"@gtest//:gtest",
":civil_time",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)

Expand All @@ -107,9 +105,10 @@ cc_test(
size = "small",
srcs = ["src/time_zone_format_test.cc"],
deps = [
"@gtest//:gtest",
":civil_time",
":time_zone",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)

Expand All @@ -118,20 +117,54 @@ cc_test(
size = "small",
srcs = ["src/time_zone_lookup_test.cc"],
deps = [
"@gtest//:gtest",
":civil_time",
":test_time_zone_names",
":time_zone",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)

cc_test(
name = "cctz_v1_test",
size = "small",
srcs = ["src/cctz_v1_test.cc"],
defines = ["CCTZ_ACK_V1_DEPRECATION=1"],
name = "time_zone_fuzz_test",
srcs = [
"src/time_zone_fuzz_test.cc",
"src/time_zone_if.h",
"src/time_zone_impl.h",
"src/time_zone_info.h",
"src/tzfile.h",
],
tags = [
"fuzztest",
],
deps = [
"@gtest//:gtest",
":cctz_v1",
":civil_time",
":test_time_zone_names",
":time_zone",
"@fuzztest//fuzztest",
"@fuzztest//fuzztest:fuzztest_gtest_main",
"@googletest//:gtest",
],
)

### benchmarks

cc_test(
name = "cctz_benchmark",
srcs = [
"src/cctz_benchmark.cc",
"src/time_zone_if.h",
"src/time_zone_impl.h",
"src/time_zone_info.h",
"src/tzfile.h",
],
linkstatic = 1,
tags = ["benchmark"],
deps = [
":civil_time",
":test_time_zone_names",
":time_zone",
"@google_benchmark//:benchmark_main",
],
)

Expand All @@ -145,10 +178,6 @@ cc_binary(
cc_binary(
name = "epoch_shift",
srcs = ["examples/epoch_shift.cc"],
deps = [
":civil_time",
":time_zone",
],
)

cc_binary(
Expand All @@ -163,10 +192,7 @@ cc_binary(
cc_binary(
name = "example2",
srcs = ["examples/example2.cc"],
deps = [
":civil_time",
":time_zone",
],
deps = [":time_zone"],
)

cc_binary(
Expand Down Expand Up @@ -200,7 +226,13 @@ cc_binary(

cc_binary(
name = "time_tool",
srcs = ["src/time_tool.cc"],
srcs = [
"src/time_tool.cc",
"src/time_zone_if.h",
"src/time_zone_impl.h",
"src/time_zone_info.h",
"src/tzfile.h",
],
deps = [
":civil_time",
":time_zone",
Expand Down
Loading
Loading