diff --git a/.gitmodules b/.gitmodules index a8f29950..82ceaa66 100644 --- a/.gitmodules +++ b/.gitmodules @@ -68,3 +68,6 @@ [submodule "fmt"] path = fmt url = https://github.com/fmtlib/fmt.git +[submodule "nlohmann_json"] + path = nlohmann_json + url = https://github.com/nlohmann/json.git diff --git a/README.md b/README.md index 59eaa9a8..7892c849 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ both can be installed with `sdkmanager` command line tool. * `python`: build dep of `opencc` * `opencc`: for `opencc_dict` * `gperf`: build dep of `libiconv` +* `rustup`: build dep of `libchewing` ## Libraries @@ -40,6 +41,7 @@ both can be installed with `sdkmanager` command line tool. * yaml-cpp: [jbeder/yaml-cpp](https://github.com/jbeder/yaml-cpp) * leveldb: [google/leveldb](https://github.com/google/leveldb) * marisa-trie: [s-yata/marisa-trie](https://github.com/s-yata/marisa-trie) +* nlohmann_json: [nlohmann/json](https://github.com/nlohmann/json) * librime: [rime/librime](https://github.com/rime/librime) * librime-lua: [rime/librime-lua](https://github.com/hchunhui/librime-lua) * librime-octagram: [rime/librime-octagram](https://github.com/lotem/librime-octagram) diff --git a/nlohmann_json b/nlohmann_json new file mode 160000 index 00000000..55f93686 --- /dev/null +++ b/nlohmann_json @@ -0,0 +1 @@ +Subproject commit 55f93686c01528224f448c19128836e7df245f72 diff --git a/src/Main.hs b/src/Main.hs index 57f5db64..5d3440a2 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -29,6 +29,7 @@ import Rules.LibThai import Rules.LibUV import Rules.Lua import Rules.Marisa +import Rules.NlohmannJSON import Rules.OpenCC import Rules.RustToolchain import Rules.YAMLCpp @@ -68,6 +69,7 @@ main = do marisaSourceRule hostMarisaRule marisaRule + nlohmannJSONRule librimeRule libhangulRule libchewingRule @@ -94,6 +96,7 @@ main = do "yaml-cpp", "leveldb", "marisa", + "nlohmann_json", "librime", "libhangul", "chewing-dict", diff --git a/src/Rules/NlohmannJSON.hs b/src/Rules/NlohmannJSON.hs new file mode 100644 index 00000000..723e5afe --- /dev/null +++ b/src/Rules/NlohmannJSON.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE TypeFamilies #-} + +module Rules.NlohmannJSON (nlohmannJSONRule) where + +import Base +import CMakeBuilder + +data NlohmannJSON = NlohmannJSON + deriving stock (Eq, Show, Typeable, Generic) + deriving anyclass (Hashable, Binary, NFData) + +type instance RuleResult NlohmannJSON = () + +nlohmannJSONRule :: Rules () +nlohmannJSONRule = do + buildNlohmannJSON <- + useCMake + (cmakeBuilder "nlohmann_json") + { cmakeFlags = + const + [ "-DBUILD_TESTING=OFF", + "-DJSON_BuildTests=OFF", + -- install boost headers to parent directory, symlink it afterwards + "-DCMAKE_INSTALL_INCLUDEDIR=" <> "../include" + ], + -- symlink headers for each abi to reduce size + postBuildEachABI = BuildActionABI $ \_ env -> + liftIO $ do + let includePath = buildEnvOutPrefix env "include" + whenM (doesPathExist includePath) $ removePathForcibly includePath + createDirectoryLink (".." "include") includePath + } + "nlohmann_json" ~> buildWithAndroidEnv buildNlohmannJSON NlohmannJSON