Skip to content

Commit 493f6c9

Browse files
committed
Initial commit
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
0 parents  commit 493f6c9

File tree

610 files changed

+284977
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

610 files changed

+284977
-0
lines changed

.ackrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--ignore-dir=build
2+
--ignore-dir=vendor

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[Makefile]
13+
indent_style = tab
14+
15+
[*.mk]
16+
indent_style = tab

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/** linguist-generated=true

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CMakeLists.txt.user
2+
CMakeCache.txt
3+
CMakeFiles
4+
CMakeScripts
5+
Testing
6+
cmake_install.cmake
7+
install_manifest.txt
8+
compile_commands.json
9+
CTestTestfile.cmake
10+
_deps
11+
/build
12+
Brewfile.lock.json
13+
.DS_Store
14+
.cache
15+
/bindings/*/build
16+
node_modules

Brewfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
brew "cmake"
2+
brew "doxygen"
3+
brew "gcc@13"

CMakeLists.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(codegen VERSION 0.0.1 LANGUAGES CXX
3+
DESCRIPTION "The JSON Schema code generator"
4+
HOMEPAGE_URL "https://github.com/sourcemeta-research/codegen")
5+
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
6+
7+
# Options
8+
option(CODEGEN_IR "Build the Codegen IR library" ON)
9+
option(CODEGEN_TYPESCRIPT "Build the Codegen IR library" ON)
10+
option(CODEGEN_TESTS "Build the Codegen tests" OFF)
11+
option(CODEGEN_CONTRIB "Build the Codegen contrib programs" OFF)
12+
option(CODEGEN_DOCS "Build the Codegen docs" OFF)
13+
option(CODEGEN_INSTALL "Install the Codegen library" ON)
14+
option(CODEGEN_ADDRESS_SANITIZER "Build Codegen with an address sanitizer" OFF)
15+
option(CODEGEN_UNDEFINED_SANITIZER "Build Codegen with an undefined behavior sanitizer" OFF)
16+
17+
if(CODEGEN_INSTALL)
18+
include(GNUInstallDirs)
19+
include(CMakePackageConfigHelpers)
20+
configure_package_config_file(
21+
config.cmake.in
22+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
23+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
24+
write_basic_package_version_file(
25+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
26+
COMPATIBILITY SameMajorVersion)
27+
install(FILES
28+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
29+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
30+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
31+
COMPONENT sourcemeta_codegen_dev)
32+
endif()
33+
34+
find_package(Core REQUIRED)
35+
36+
# Don't force downstream consumers on it
37+
if(PROJECT_IS_TOP_LEVEL)
38+
sourcemeta_enable_simd()
39+
endif()
40+
41+
if(CODEGEN_IR)
42+
add_subdirectory(src/ir)
43+
endif()
44+
45+
if(CODEGEN_TYPESCRIPT)
46+
add_subdirectory(src/typescript)
47+
endif()
48+
49+
if(CODEGEN_CONTRIB)
50+
add_subdirectory(contrib)
51+
endif()
52+
53+
if(CODEGEN_ADDRESS_SANITIZER)
54+
sourcemeta_sanitizer(TYPE address)
55+
elseif(CODEGEN_UNDEFINED_SANITIZER)
56+
sourcemeta_sanitizer(TYPE undefined)
57+
endif()
58+
59+
if(CODEGEN_DOCS)
60+
sourcemeta_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in"
61+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/website")
62+
endif()
63+
64+
if(PROJECT_IS_TOP_LEVEL)
65+
sourcemeta_target_clang_format(SOURCES
66+
contrib/*.cc
67+
src/*.h src/*.cc
68+
test/*.h test/*.cc)
69+
endif()
70+
71+
# Testing
72+
if(CODEGEN_TESTS)
73+
enable_testing()
74+
75+
if(CODEGEN_IR)
76+
add_subdirectory(test/ir)
77+
endif()
78+
79+
if(CODEGEN_TYPESCRIPT)
80+
add_subdirectory(test/typescript)
81+
endif()
82+
83+
if(PROJECT_IS_TOP_LEVEL)
84+
# Otherwise we need the child project to link
85+
# against the sanitizers too.
86+
if(NOT CODEGEN_ADDRESS_SANITIZER AND NOT CODEGEN_UNDEFINED_SANITIZER)
87+
add_subdirectory(test/packaging)
88+
endif()
89+
endif()
90+
endif()

DEPENDENCIES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
2+
core https://github.com/sourcemeta/core 90d0082e6c61ed5f6f3106db4105c7822cc41838

LICENSE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
This software is dual-licensed: you can redistribute it and/or modify it under
2+
the terms of the GNU Affero General Public License as published by the Free
3+
Software Foundation, either version 3 of the License, or (at your option) any
4+
later version. For the terms of this license, see
5+
<http://www.gnu.org/licenses/>.
6+
7+
You are free to use this software under the terms of the GNU Affero General
8+
Public License WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10+
11+
Alternatively, you can use this software under a commercial license, as set out
12+
in <https://www.sourcemeta.com/licensing/>.

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Programs
2+
CMAKE = cmake
3+
CTEST = ctest
4+
5+
# Options
6+
PRESET = Debug
7+
SHARED = OFF
8+
9+
all: configure compile test
10+
11+
configure: .always
12+
$(CMAKE) -S . -B ./build \
13+
-DCMAKE_BUILD_TYPE:STRING=$(PRESET) \
14+
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON \
15+
-DCODEGEN_CONTRIB:BOOL=ON \
16+
-DCODEGEN_TESTS:BOOL=ON \
17+
-DCODEGEN_DOCS:BOOL=ON \
18+
-DBUILD_SHARED_LIBS:BOOL=$(SHARED)
19+
20+
compile: .always
21+
$(CMAKE) --build ./build --config $(PRESET) --target clang_format
22+
$(CMAKE) --build ./build --config $(PRESET) --parallel 4
23+
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
24+
--component sourcemeta_core
25+
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
26+
--component sourcemeta_core_dev
27+
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
28+
--component sourcemeta_codegen
29+
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
30+
--component sourcemeta_codegen_dev
31+
32+
test: .always
33+
$(CMAKE) -E env UBSAN_OPTIONS=print_stacktrace=1 \
34+
$(CTEST) --test-dir ./build --build-config $(PRESET) \
35+
--output-on-failure --parallel
36+
37+
clean: .always
38+
$(CMAKE) -E rm -R -f build
39+
40+
# For NMake, which doesn't support .PHONY
41+
.always:

cmake/FindCore.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
if(NOT Core_FOUND)
2+
if(CODEGEN_INSTALL)
3+
set(SOURCEMETA_CORE_INSTALL ON CACHE BOOL "enable installation")
4+
else()
5+
set(SOURCEMETA_CORE_INSTALL OFF CACHE BOOL "disable installation")
6+
endif()
7+
8+
9+
set(SOURCEMETA_CORE_EXTENSION_ALTERSCHEMA OFF CACHE BOOL "disable")
10+
set(SOURCEMETA_CORE_EXTENSION_EDITORSCHEMA OFF CACHE BOOL "disable")
11+
set(SOURCEMETA_CORE_EXTENSION_SCHEMACONFIG OFF CACHE BOOL "disable")
12+
set(SOURCEMETA_CORE_EXTENSION_BUILD OFF CACHE BOOL "disable")
13+
14+
set(SOURCEMETA_CORE_CONTRIB_GOOGLETEST ${CODEGEN_TESTS} CACHE BOOL "GoogleTest")
15+
set(SOURCEMETA_CORE_CONTRIB_GOOGLEBENCHMARK ${CODEGEN_BENCHMARK} CACHE BOOL "GoogleBenchmark")
16+
add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/core")
17+
include(Sourcemeta)
18+
set(Core_FOUND ON)
19+
endif()

0 commit comments

Comments
 (0)