Skip to content

Commit 6a60a8a

Browse files
committed
Add Md5 beginning computation
1 parent 94b8d48 commit 6a60a8a

File tree

7 files changed

+884
-8
lines changed

7 files changed

+884
-8
lines changed

devserver/BUILD

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
filegroup(
22
name = "main",
3-
srcs = glob(["main.cc", "httplib/httplib.h", "argparse/argparse.h", "json/json.h"]),
3+
srcs = glob([
4+
"main.cc",
5+
"httplib/httplib.h",
6+
"argparse/argparse.h",
7+
"json/json.h",
8+
"md5/md5.h",
9+
]),
410
visibility = ["//visibility:public"],
511
)
612

devserver/defs.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ def devserver(name, port, static_file, workspace_name, data = []):
1414
data = data + [Label("@rules_devserver//devserver:devserver_loader")],
1515
deps = ["@bazel_tools//tools/cpp/runfiles"],
1616
linkopts = ["-lpthread"],
17+
copts = ["-fpermissive"],
1718
)

devserver/devserver_loader.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
console.log("inside devserver_loader.js");
1+
console.log("inside devserver_loader.js");
2+
3+
setInterval(() => {
4+
fetch("/devserver/manifest")
5+
.then(function (response) {
6+
return response.json();
7+
})
8+
.then(function (manifest) {
9+
console.warn(manifest);
10+
})
11+
}, 1000);

devserver/json/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2013-2022 Niels Lohmann
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

devserver/main.cc

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
// #include "external/rules_devserver/devserver/argparse/argparse.h"
44
// #include "external/rules_devserver/devserver/httplib/httplib.h"
55
// #include "external/rules_devserver/devserver/json/json.h"
6+
// #include "external/rules_devserver/devserver/md5/md5.h"
67

78
#include "devserver/argparse/argparse.h"
89
#include "devserver/httplib/httplib.h"
910
#include "devserver/json/json.h"
11+
#include "devserver/md5/md5.h"
1012
#include "tools/cpp/runfiles/runfiles.h"
1113

1214
using bazel::tools::cpp::runfiles::Runfiles;
15+
using ::nlohmann::json;
1316

1417
#define DEBUG true
1518
#define DEBUG_LOG(msg) \
@@ -33,6 +36,14 @@ std::string GetFileContents(const std::string &path) {
3336
return content;
3437
}
3538

39+
json ComputeManifest() {
40+
json manifest;
41+
42+
manifest["manifest"] = {{"/", "123"}};
43+
44+
return manifest;
45+
}
46+
3647
std::string GetDevserverLoaderScriptContents(
3748
const std::string &workspace_root) {
3849
const std::string devserver_loader_path =
@@ -49,7 +60,7 @@ std::string AddDevserverLoaderToStaticFileContents(
4960
const std::string &static_file_contents) {
5061
const std::regex re("<\\/head>");
5162
const std::string replacement =
52-
"<script src=\"/devserver_loader.js\"></script></head>";
63+
"<script src=\"/devserver/devserver_loader.js\"></script></head>";
5364
std::string static_file_contents_with_devserver_loader =
5465
std::regex_replace(static_file_contents, re, replacement);
5566

@@ -135,11 +146,17 @@ int main(int argc, char **argv) {
135146
res.set_content(static_file_contents, "text/html");
136147
});
137148

138-
svr.Get("/devserver_loader.js", [&workspace_root](const httplib::Request &req,
139-
httplib::Response &res) {
140-
res.set_content(GetDevserverLoaderScriptContents(workspace_root),
141-
"text/javascript");
142-
});
149+
svr.Get(
150+
"/devserver/devserver_loader.js",
151+
[&workspace_root](const httplib::Request &req, httplib::Response &res) {
152+
res.set_content(GetDevserverLoaderScriptContents(workspace_root),
153+
"text/javascript");
154+
});
155+
156+
svr.Get("/devserver/manifest",
157+
[](const httplib::Request &req, httplib::Response &res) {
158+
res.set_content(ComputeManifest().dump(), "application/json");
159+
});
143160

144161
svr.listen(kHost, port);
145162
}

devserver/md5/LICENSE

Whitespace-only changes.

0 commit comments

Comments
 (0)