Skip to content

Commit 664c98e

Browse files
committed
Speed up emscripten/wasm builds
Disable parts of quick-lint-js unused by our WebAssembly builds, including the LSP server and filesystem helpers. Note: For some reason, clang-format changed the formatting of src/quick-lint-js/configuration-loader.h and src/quick-lint-js/lsp-endpoint.h. This commit should not change behavior.
1 parent 81944eb commit 664c98e

19 files changed

+104
-9
lines changed

src/configuration-loader.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (C) 2020 Matthew "strager" Glazar
22
// See end of file for extended copyright information.
33

4+
#if !defined(__EMSCRIPTEN__)
5+
46
#include <quick-lint-js/assert.h>
57
#include <quick-lint-js/configuration-loader.h>
68
#include <quick-lint-js/configuration.h>
@@ -545,6 +547,8 @@ basic_configuration_filesystem::read_file(const canonical_path& path) {
545547
}
546548
}
547549

550+
#endif
551+
548552
// quick-lint-js finds bugs in JavaScript programs.
549553
// Copyright (C) 2020 Matthew "strager" Glazar
550554
//

src/file-canonical.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (C) 2020 Matthew "strager" Glazar
22
// See end of file for extended copyright information.
33

4+
#if !defined(__EMSCRIPTEN__)
5+
46
#include <algorithm>
57
#include <cerrno>
68
#include <climits>
@@ -750,6 +752,8 @@ std::string string_for_error_message(std::wstring_view s) {
750752
}
751753
}
752754

755+
#endif
756+
753757
// quick-lint-js finds bugs in JavaScript programs.
754758
// Copyright (C) 2020 Matthew "strager" Glazar
755759
//

src/file.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (C) 2020 Matthew "strager" Glazar
22
// See end of file for extended copyright information.
33

4+
#if !defined(__EMSCRIPTEN__)
5+
46
#include <algorithm>
57
#include <cerrno>
68
#include <cstddef>
@@ -310,6 +312,8 @@ void write_file(const char *path, string8_view content) {
310312
}
311313
}
312314

315+
#endif
316+
313317
// quick-lint-js finds bugs in JavaScript programs.
314318
// Copyright (C) 2020 Matthew "strager" Glazar
315319
//

src/lsp-error-reporter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (C) 2020 Matthew "strager" Glazar
22
// See end of file for extended copyright information.
33

4+
#if !defined(__EMSCRIPTEN__)
5+
46
#include <quick-lint-js/byte-buffer.h>
57
#include <quick-lint-js/error.h>
68
#include <quick-lint-js/json.h>
@@ -104,6 +106,8 @@ void lsp_error_formatter::write_after_message(severity sev,
104106
}
105107
}
106108

109+
#endif
110+
107111
// quick-lint-js finds bugs in JavaScript programs.
108112
// Copyright (C) 2020 Matthew "strager" Glazar
109113
//

src/lsp-message-parser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (C) 2020 Matthew "strager" Glazar
22
// See end of file for extended copyright information.
33

4+
#if !defined(__EMSCRIPTEN__)
5+
46
#include <algorithm>
57
#include <cstddef>
68
#include <optional>
@@ -121,6 +123,8 @@ bool lsp_message_parser_base::header_is(string8_view header_name,
121123
}
122124
}
123125

126+
#endif
127+
124128
// quick-lint-js finds bugs in JavaScript programs.
125129
// Copyright (C) 2020 Matthew "strager" Glazar
126130
//

src/lsp-pipe-writer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (C) 2020 Matthew "strager" Glazar
22
// See end of file for extended copyright information.
33

4+
#if !defined(__EMSCRIPTEN__)
5+
46
#include <algorithm>
57
#include <array>
68
#include <quick-lint-js/byte-buffer.h>
@@ -36,6 +38,8 @@ void lsp_pipe_writer::send_message(byte_buffer&& message) {
3638
}
3739
}
3840

41+
#endif
42+
3943
// quick-lint-js finds bugs in JavaScript programs.
4044
// Copyright (C) 2020 Matthew "strager" Glazar
4145
//

src/lsp-server.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (C) 2020 Matthew "strager" Glazar
22
// See end of file for extended copyright information.
33

4+
#if !defined(__EMSCRIPTEN__)
5+
46
#include <algorithm>
57
#include <cstddef>
68
#include <cstdlib>
@@ -622,6 +624,8 @@ int get_int(
622624
}
623625
}
624626

627+
#endif
628+
625629
// quick-lint-js finds bugs in JavaScript programs.
626630
// Copyright (C) 2020 Matthew "strager" Glazar
627631
//

src/pipe-writer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (C) 2020 Matthew "strager" Glazar
22
// See end of file for extended copyright information.
33

4+
#if !defined(__EMSCRIPTEN__)
5+
46
#include <algorithm>
57
#include <array>
68
#include <condition_variable>
@@ -211,6 +213,8 @@ void non_blocking_pipe_writer::write_as_much_as_possible_now_non_blocking(
211213
#endif
212214
}
213215

216+
#endif
217+
214218
// quick-lint-js finds bugs in JavaScript programs.
215219
// Copyright (C) 2020 Matthew "strager" Glazar
216220
//

src/quick-lint-js/configuration-loader.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#ifndef QUICK_LINT_JS_CONFIGURATION_LOADER_H
55
#define QUICK_LINT_JS_CONFIGURATION_LOADER_H
66

7+
#if defined(__EMSCRIPTEN__)
8+
// No filesystem on web.
9+
#else
10+
711
#include <optional>
812
#include <quick-lint-js/buffering-error-reporter.h>
913
#include <quick-lint-js/configuration.h>
@@ -140,7 +144,7 @@ class configuration_loader {
140144
std::string input_config_path;
141145
std::optional<canonical_path> actual_config_path;
142146
std::optional<std::variant<canonicalize_path_io_error, read_file_io_error,
143-
watch_io_error>>
147+
watch_io_error> >
144148
error;
145149
void* token;
146150
};
@@ -149,7 +153,7 @@ class configuration_loader {
149153
std::string input_path;
150154
std::optional<canonical_path> config_path;
151155
std::optional<std::variant<canonicalize_path_io_error, read_file_io_error,
152-
watch_io_error>>
156+
watch_io_error> >
153157
error;
154158
void* token;
155159
};
@@ -195,6 +199,8 @@ class basic_configuration_filesystem : public configuration_filesystem {
195199

196200
#endif
197201

202+
#endif
203+
198204
// quick-lint-js finds bugs in JavaScript programs.
199205
// Copyright (C) 2020 Matthew "strager" Glazar
200206
//

src/quick-lint-js/file-canonical.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#ifndef QUICK_LINT_JS_FILE_CANONICAL_H
55
#define QUICK_LINT_JS_FILE_CANONICAL_H
66

7+
#if defined(__EMSCRIPTEN__)
8+
// No canonicalize_path on the web.
9+
#else
10+
711
#include <cstddef>
812
#include <functional>
913
#include <optional>
@@ -128,6 +132,8 @@ struct hash<quick_lint_js::canonical_path> {
128132

129133
#endif
130134

135+
#endif
136+
131137
// quick-lint-js finds bugs in JavaScript programs.
132138
// Copyright (C) 2020 Matthew "strager" Glazar
133139
//

0 commit comments

Comments
 (0)