Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthurSonzogni <sonzogniarthur@gmail.com>2022-01-09 11:56:45 +0300
committerArthurSonzogni <sonzogniarthur@gmail.com>2022-01-09 23:02:05 +0300
commitdc45651b764897beace5371b1845d80bf57787e0 (patch)
tree3c1bb290611491a834874fd18fcaefb69e366de5
parentf253e9664d6a0628fa779c858a05a5aaf05e9cb4 (diff)
Update script for >=v3.10.5
Starting from v3.10.5, the update script will directly take the CMakeLists and a few other files directly from the upstream repository.
-rw-r--r--README.md2
-rwxr-xr-xupdate.py83
2 files changed, 51 insertions, 34 deletions
diff --git a/README.md b/README.md
index c4342f2..5b2a5ac 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,8 @@ include(FetchContent)
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
+ GIT_PROGRESS TRUE
+ GIT_SHALLOW TRUE
GIT_TAG v3.10.4)
FetchContent_GetProperties(json)
diff --git a/update.py b/update.py
index e80a1e2..e55e6ac 100755
--- a/update.py
+++ b/update.py
@@ -27,44 +27,59 @@ print("Releases already contained in this repository are " + str(tags))
# Go over the release_url_map in reverse order; if a release is not yet a Git
# tag, download the file, commit and add a tag
-did_update = False
for tag, url, body in release_url_map[::-1]:
- if not tag in tags:
- print("Downloading release " + tag + " from " + url)
- os.makedirs('./include', mode=0o777, exist_ok=True)
- os.makedirs('./include/nlohmann', mode=0o777, exist_ok=True)
- data = urllib.request.urlopen(url).read();
- with open('./include/nlohmann/json.hpp', 'wb') as f:
- f.write(data)
+ if tag in tags:
+ continue
- # Try to download the json_fwd.hpp header -- only exists since release
- # v3.1.0
- has_json_fwd = False
- try:
- json_fwd_url = 'https://github.com/nlohmann/json/raw/{}/include/nlohmann/json_fwd.hpp'.format(tag);
- print("Trying to download " + json_fwd_url)
- data = urllib.request.urlopen(json_fwd_url).read();
- with open('./include/nlohmann/json_fwd.hpp', 'wb') as f:
+ print("Downloading release " + tag)
+ if tag >= "v3.10.5":
+ os.system("rm -rf ./tmp")
+ os.system("rm -rf ./include")
+ os.system("git clone https://github.com/nlohmann/json ./tmp --depth 1 --branch {}".format(tag));
+ os.system("cp -rf ./tmp/single_include .")
+ os.system("cp -rf ./tmp/include/nlohmann/json_fwd.hpp ./single_include/nlohmann/")
+ os.system("cp -rf ./tmp/cmake .")
+ os.system("cp -rf ./tmp/CMakeLists.txt .")
+ os.system("cp -rf ./tmp/meson.build .")
+ os.system("cp -rf ./tmp/LICENSE.MIT .")
+ os.system("rm -rf ./tmp")
+ os.makedirs('./cmake', mode=0o777, exist_ok=True)
+ os.makedirs('./test', mode=0o777, exist_ok=True)
+ with open("./cmake/ci.cmake", "w") as f:
+ f .write("message(FATAL_ERROR \"The JSON_CI option is not available" \
+ "when using the nlohmann_json_cmake_fetchcontent repository.\")")
+ with open("./test/CMakeLists.txt", "w") as f:
+ f.write("message(FATAL_ERROR \"The JSON_CI option is not available" \
+ "when using the nlohmann_json_cmake_fetchcontent repository.\")")
+ os.system("git add .")
+ else:
+ os.makedirs('./include', mode=0o777, exist_ok=True)
+ os.makedirs('./include/nlohmann', mode=0o777, exist_ok=True)
+ data = urllib.request.urlopen(url).read();
+ with open('./include/nlohmann/json.hpp', 'wb') as f:
f.write(data)
- has_json_fwd = True
- except:
- pass
- subprocess.call(['git', 'add', './include/nlohmann/json.hpp'])
- if has_json_fwd:
- subprocess.call(['git', 'add', './include/nlohmann/json_fwd.hpp'])
+ # Try to download the json_fwd.hpp header -- only exists since release
+ # v3.1.0
+ has_json_fwd = False
+ try:
+ json_fwd_url = 'https://github.com/nlohmann/json/raw/{}/include/nlohmann/json_fwd.hpp'.format(tag);
+ print("Trying to download " + json_fwd_url)
+ data = urllib.request.urlopen(json_fwd_url).read();
+ with open('./include/nlohmann/json_fwd.hpp', 'wb') as f:
+ f.write(data)
+ has_json_fwd = True
+ except:
+ pass
- # Update the README.md:
- subprocess.call([ 'sed', '-i', '-e', 's/GIT_TAG .*)/GIT_TAG '+ tag + ')/g', './README.md'])
- subprocess.call(['git', 'add', './README.md'])
+ subprocess.call(['git', 'add', './include/nlohmann/json.hpp'])
+ if has_json_fwd:
+ subprocess.call(['git', 'add', './include/nlohmann/json_fwd.hpp'])
- # Commit:
- subprocess.call(['git', 'commit', '-m', 'Upstream release ' + tag])
- subprocess.call(['git', 'tag', '-a', tag, '-m', body])
+ # Update the README.md:
+ subprocess.call([ 'sed', '-i', '-e', 's/GIT_TAG .*)/GIT_TAG '+ tag + ')/g', './README.md'])
+ subprocess.call(['git', 'add', './README.md'])
- did_update = True
-
-# Push the updated Git repository
-if did_update:
- subprocess.call(['git', 'push', '--tags'])
- subprocess.call(['git', 'push'])
+ # Commit:
+ subprocess.call(['git', 'commit', '-m', 'Upstream release ' + tag])
+ subprocess.call(['git', 'tag', '-a', tag, '-m', body])