Skip to content

Commit 357115d

Browse files
committed
reimplement ADT/Polymorphic
This is a simpler design, with less differences in API wrt to std::polymorphic, though still with some differences, includinding nullability, and some unused features which are not important to us are left out. This avoids memory leaks facilitated by the previous design, and is a step towards making the project pass the LeakSanitizer.
1 parent f2ebf09 commit 357115d

35 files changed

+576
-1725
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,6 @@ jobs:
209209
fi
210210
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT
211211
212-
- name: Resolve Third-Party Directory
213-
id: resolve-third-party-dir
214-
run: |
215-
set -x
216-
cd ..
217-
third_party_dir=$(pwd)/third-party
218-
if [[ ${{ runner.os }} == 'Windows' ]]; then
219-
third_party_dir=$(echo "$third_party_dir" | sed 's/\\/\//g')
220-
third_party_dir=$(echo $third_party_dir | sed 's|^/d/|D:/|')
221-
echo "$third_party_dir"
222-
fi
223-
echo -E "third-party-dir=$third_party_dir" >> $GITHUB_OUTPUT
224-
225212
- name: Cached LLVM Binaries
226213
id: llvm-cache
227214
uses: actions/cache@v4
@@ -378,10 +365,10 @@ jobs:
378365
install-prefix: .local
379366
extra-args: |
380367
-D MRDOCS_BUILD_DOCS=OFF
381-
-D LLVM_ROOT=${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/llvm-project/install
382-
-D Clang_ROOT=${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/llvm-project/install
383-
-D duktape_ROOT=${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install
384-
-D Duktape_ROOT=${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install
368+
-D LLVM_ROOT=../third-party/llvm-project/install
369+
-D Clang_ROOT=../third-party/llvm-project/install
370+
-D duktape_ROOT=../third-party/duktape/install
371+
-D Duktape_ROOT=../third-party/duktape/install
385372
${{ runner.os == 'Windows' && '-D libxml2_ROOT=../third-party/libxml2/install' || '' }}
386373
${{ runner.os == 'Windows' && '-D LibXml2_ROOT=../third-party/libxml2/install' || '' }}
387374
export-compile-commands: true

CMakeLists.txt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,9 @@ target_compile_definitions(
224224
)
225225

226226
# Dependencies
227-
target_include_directories(mrdocs-core
228-
SYSTEM PUBLIC
229-
$<BUILD_INTERFACE:${LLVM_INCLUDE_DIRS}>
230-
$<BUILD_INTERFACE:${CLANG_INCLUDE_DIRS}>
231-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
232-
)
233-
target_include_directories(mrdocs-core
234-
SYSTEM PRIVATE
235-
$<BUILD_INTERFACE:${DUKTAPE_INCLUDE_DIRS}>
236-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
237-
)
227+
target_include_directories(mrdocs-core SYSTEM PUBLIC ${LLVM_INCLUDE_DIRS})
228+
target_include_directories(mrdocs-core SYSTEM PUBLIC ${CLANG_INCLUDE_DIRS})
229+
target_include_directories(mrdocs-core SYSTEM PRIVATE ${DUKTAPE_INCLUDE_DIRS})
238230
target_link_libraries(mrdocs-core PRIVATE ${DUKTAPE_LIBRARY})
239231

240232
# Clang

CMakeUserPresets.json.example

Lines changed: 60 additions & 102 deletions
Large diffs are not rendered by default.

bootstrap.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class InstallOptions:
8282
mrdocs_run_tests: bool = True
8383

8484
# Third-party dependencies
85-
third_party_src_dir: str = "<mrdocs-src-dir>/build/third-party"
85+
third_party_src_dir: str = "<mrdocs-src-dir>/../third-party"
8686

8787
# Duktape
8888
duktape_src_dir: str = "<third-party-src-dir>/duktape"
@@ -743,7 +743,7 @@ def setup_mrdocs_src_dir(self):
743743
f"Source directory '{self.options.mrdocs_src_dir}' does not exist. Create and clone MrDocs there?",
744744
True):
745745
print("Installation aborted by user.")
746-
exit(1)
746+
return
747747
self.prompt_option("mrdocs_branch")
748748
self.prompt_option("mrdocs_repo")
749749
self.clone_repo(self.options.mrdocs_repo, self.options.mrdocs_src_dir, branch=self.options.mrdocs_branch)
@@ -776,6 +776,14 @@ def prompt_dependency_path_option(self, name):
776776
value = getattr(self.options, name)
777777
value = os.path.abspath(value)
778778
setattr(self.options, name, value)
779+
while self.is_inside_mrdocs_dir(value):
780+
print(f"Error: {name} '{value}' cannot be inside mrdocs_src_dir '{self.options.mrdocs_src_dir}'.")
781+
if not self.prompt_boolean(f"Would you like to specify a different {name} directory."):
782+
print("Installation aborted by user.")
783+
return
784+
value = self.reprompt_option(name)
785+
setattr(self.options, name, value)
786+
779787
if not os.path.exists(value):
780788
if not self.prompt_boolean(f"'{value}' does not exist. Create it?", True):
781789
raise FileNotFoundError(f"'{value}' does not exist and user chose not to create it.")
@@ -1272,14 +1280,14 @@ def create_cmake_presets(self):
12721280
for key, value in new_preset["cacheVariables"].items():
12731281
if not isinstance(value, str):
12741282
continue
1275-
# Replace mrdocs-src-dir with ${sourceDir}
1276-
if self.options.mrdocs_src_dir and value.startswith(self.options.mrdocs_src_dir):
1277-
new_value = "${sourceDir}" + value[len(self.options.mrdocs_src_dir):]
1278-
new_preset["cacheVariables"][key] = new_value
12791283
# Replace mrdocs-src-dir parent with ${sourceParentDir}
1280-
elif mrdocs_src_dir_parent and value.startswith(mrdocs_src_dir_parent):
1284+
if mrdocs_src_dir_parent and value.startswith(mrdocs_src_dir_parent):
12811285
new_value = "${sourceParentDir}" + value[len(mrdocs_src_dir_parent):]
12821286
new_preset["cacheVariables"][key] = new_value
1287+
# Replace mrdocs-src-dir with ${sourceDir}
1288+
elif self.options.mrdocs_src_dir and value.startswith(self.options.mrdocs_src_dir):
1289+
new_value = "${sourceDir}" + value[len(self.options.mrdocs_src_dir):]
1290+
new_preset["cacheVariables"][key] = new_value
12831291
# Replace $HOME with $env{HOME}
12841292
elif home_dir and value.startswith(home_dir):
12851293
new_value = "$env{HOME}" + value[len(home_dir):]
@@ -1350,8 +1358,6 @@ def install_mrdocs(self):
13501358
if self.options.mrdocs_build_dir and self.prompt_option("mrdocs_run_tests"):
13511359
# Look for ctest path relative to the cmake path
13521360
ctest_path = os.path.join(os.path.dirname(self.options.cmake_path), "ctest")
1353-
if self.is_windows():
1354-
ctest_path += ".exe"
13551361
if not os.path.exists(ctest_path):
13561362
raise FileNotFoundError(
13571363
f"ctest executable not found at {ctest_path}. Please ensure CMake is installed correctly.")

0 commit comments

Comments
 (0)