Skip to content

Commit

Permalink
[WIP] Use TaskChampion 0.7.0, now via cxx instead of hand-rolled FFI
Browse files Browse the repository at this point in the history
TC 0.7.0 introduces a new `TaskData` type that maps to Taskwarrior's
`Task` type more cleanly. It also introduces the idea of gathering lists
of operations and "committing" them to a replica.

A consequence of this change is that TaskChampion no longer
automatically maintains dependency information, so Taskwarrior must do
so, with its `TDB2::dependency_sync` method. This method does a very
similar thing to what TaskChampion had been doing, so this is a shift of
responsibility but not a major performance difference.

Cxx is .. not great. It is missing a lot of useful things that make a
general-purpose bridge impractical:

 - no support for trait objects
 - no support for `Option<T>` (dtolnay/cxx#87)
 - no support for `Vec<Box<..>>`

As a result, some creativity is required in writing the bridge, for
example returning a `Vec<OptionTaskData>` from `all_task_data` to allow
individual `TaskData` values to be "taken" from the vector.

That said, Cxx is the current state-of-the-art, and does a good job of
ensuring memory safety, at the cost of some slightly awkward APIs.

Subsequent work can remove the "TDB2" layer and allow commands and other
parts of Taskwarrior to interface directly with the `Replica`.

TODO:
 - reference released `taskchampion 0.7.0`
  • Loading branch information
djmitche committed Aug 5, 2024
1 parent 5c6cc3e commit 35074cc
Show file tree
Hide file tree
Showing 58 changed files with 1,518 additions and 7,611 deletions.
1 change: 0 additions & 1 deletion .cargo/config.toml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,3 @@ jobs:
with:
command: fmt
args: --all -- --check

codegen:
runs-on: ubuntu-latest
name: "codegen"
steps:
- uses: actions/checkout@v4

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

- uses: actions-rs/toolchain@v1
with:
toolchain: "1.70.0" # MSRV
override: true

- uses: actions-rs/[email protected]
with:
command: xtask
args: codegen

- name: check for changes
run: |
if ! git diff; then
echo "Generated code not up-to-date;
run `cargo run --package xtask -- codegen` and commit the result";
exit 1;
fi
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "src/libshared"]
path = src/libshared
url = https://github.com/GothenburgBitFactory/libshared.git
[submodule "src/tc/corrosion"]
path = src/tc/corrosion
[submodule "src/taskchampion-cpp/corrosion"]
path = src/taskchampion-cpp/corrosion
url = https://github.com/corrosion-rs/corrosion.git
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ if (ENABLE_WASM)
endif (ENABLE_WASM)

message ("-- Looking for git submodules")
if (EXISTS ${CMAKE_SOURCE_DIR}/src/libshared/src AND EXISTS ${CMAKE_SOURCE_DIR}/src/tc/corrosion)
if (EXISTS ${CMAKE_SOURCE_DIR}/src/libshared/src AND EXISTS ${CMAKE_SOURCE_DIR}/src/taskchampion-cpp/corrosion)
message ("-- Found git submodules")
else (EXISTS ${CMAKE_SOURCE_DIR}/src/libshared/src)
message ("-- Cloning git submodules")
execute_process (COMMAND git submodule update --init
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif (EXISTS ${CMAKE_SOURCE_DIR}/src/libshared/src AND EXISTS ${CMAKE_SOURCE_DIR}/src/tc/corrosion)
endif (EXISTS ${CMAKE_SOURCE_DIR}/src/libshared/src AND EXISTS ${CMAKE_SOURCE_DIR}/src/taskchampion-cpp/corrosion)

message ("-- Looking for SHA1 references")
if (EXISTS ${CMAKE_SOURCE_DIR}/.git/index)
Expand Down Expand Up @@ -142,7 +142,7 @@ configure_file (

add_subdirectory (src)
add_subdirectory (src/commands)
add_subdirectory (src/tc)
add_subdirectory (src/taskchampion-cpp)
add_subdirectory (src/columns)
add_subdirectory (doc)
add_subdirectory (scripts)
Expand Down
Loading

0 comments on commit 35074cc

Please sign in to comment.