Skip to content

Commit 85c49e4

Browse files
committed
init
0 parents  commit 85c49e4

File tree

10 files changed

+174
-0
lines changed

10 files changed

+174
-0
lines changed

Diff for: .github/workflows/build.yaml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CMake Build
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
name: Build
8+
runs-on: ubuntu-24.04
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: awalsh128/cache-apt-pkgs-action@latest
12+
with:
13+
packages: libc++-18-dev clang-18
14+
- name: Cache Build
15+
id: restore-cache-build
16+
uses: actions/cache/restore@v4
17+
with:
18+
path: build
19+
key: ${{ runner.os }}-build
20+
- name: CMake Action
21+
uses: threeal/[email protected]
22+
with:
23+
args: -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS='-D__cpp_concepts=202002L' -DCMAKE_EXE_LINKER_FLAGS='-static'
24+
run-build: true
25+
c-compiler: clang-18
26+
cxx-compiler: clang++-18
27+
- uses: actions/cache/save@v3
28+
name: Save build cache
29+
with:
30+
path: build
31+
key: ${{ runner.os }}-build
32+
- name: Run tests
33+
working-directory: ./build
34+
run: ctest --rerun-failed --output-on-failure .
35+
- uses: actions/upload-artifact@v4
36+
with:
37+
name: 'ubuntu-cli'
38+
path: build/bin/ts-compiler
39+
if-no-files-found: error
40+
retention-days: 90
41+
compression-level: 6
42+
overwrite: true

Diff for: .gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build
2+
.cache
3+
cases-lock.ls
4+
CMakeUserPresets.json
5+
.clangd
6+
.DS_Store

Diff for: CMakeLists.txt

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
cmake_minimum_required(VERSION 3.28.1)
2+
project(ts-compiler VERSION 0.0.1 LANGUAGES C CXX)
3+
mark_as_advanced(CMAKE_MAKE_PROGRAM)
4+
include(GNUInstallDirs)
5+
include(CMakePrintHelpers)
6+
include(FetchContent)
7+
8+
set(CMAKE_CXX_STANDARD 23)
9+
set(CMAKE_C_EXTENSIONS OFF)
10+
set(CMAKE_CXX_EXTENSIONS OFF)
11+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
12+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
13+
set(THREADS_PREFER_PTHREAD_FLAG ON)
14+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
15+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
16+
add_compile_options(-fexperimental-library)
17+
18+
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
19+
set(IS_ROOT_PROJECT ON)
20+
else()
21+
set(IS_ROOT_PROJECT OFF)
22+
endif()
23+
24+
option(TS_COMPILER_BUILD_CLI "build cli" ${IS_ROOT_PROJECT})
25+
26+
include("${CMAKE_CURRENT_SOURCE_DIR}/CMakeUtils.txt")
27+
include("${CMAKE_CURRENT_SOURCE_DIR}/vendor/rapidjson.cmake")
28+
add_subdirectory("src/libtypescript")
29+
if (TS_COMPILER_BUILD_CLI)
30+
add_subdirectory("src/ts-cli")
31+
endif()

Diff for: CMakeUtils.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Remove strings matching given regular expression from a list.
2+
# @param(in,out) aItems Reference of a list variable to filter.
3+
# @param aRegEx Value of regular expression to match.
4+
function (filter_items aItems aRegEx)
5+
# For each item in our list
6+
foreach (item ${${aItems}})
7+
# Check if our items matches our regular expression
8+
if ("${item}" MATCHES ${aRegEx})
9+
# Remove current item from our list
10+
list (REMOVE_ITEM ${aItems} ${item})
11+
endif ("${item}" MATCHES ${aRegEx})
12+
endforeach(item)
13+
# Provide output parameter
14+
set(${aItems} ${${aItems}} PARENT_SCOPE)
15+
endfunction (filter_items)

Diff for: src/libtypescript/CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
file(GLOB_RECURSE TS_LIB_HEADERS src/*.hpp src/*.h)
2+
file(GLOB_RECURSE TS_LIB_SOURCES src/*.cpp src/*.c)
3+
4+
add_library(
5+
libtypescript
6+
${TS_LIB_SOURCES}
7+
)
8+
add_dependencies(libtypescript RapidJSON)
9+
target_include_directories(
10+
libtypescript
11+
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src/
12+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/
13+
PRIVATE SYSTEM ${RAPIDJSON_INCLUDE_DIR}
14+
)
15+
get_target_property(LIBB_INCLUDES libtypescript INCLUDE_DIRECTORIES)

Diff for: src/libtypescript/src/check.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void check() {};

Diff for: src/ts-cli/CMakeLists.txt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
include("${CMAKE_CURRENT_SOURCE_DIR}/vendor/cli11.cmake")
2+
3+
file(GLOB_RECURSE TS_CLI_SOURCES src/*.cpp src/*.c)
4+
add_executable(
5+
ts-compiler
6+
src/main.cpp
7+
${TS_CLI_SOURCES}
8+
)
9+
add_dependencies(ts-compiler RapidJSON)
10+
target_link_libraries(
11+
ts-compiler
12+
PRIVATE CLI11::CLI11
13+
PRIVATE libtypescript
14+
)
15+
target_include_directories(
16+
ts-compiler
17+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/
18+
PRIVATE SYSTEM ${CLI11_INCLUDE_DIR}
19+
PRIVATE SYSTEM ${RAPIDJSON_INCLUDE_DIR}
20+
)

Diff for: src/ts-cli/src/main.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <CLI/App.hpp>
2+
#include <CLI/Error.hpp>
3+
#include <CLI/Option.hpp>
4+
5+
#include <cstdlib>
6+
7+
int main(int argc, char **argv) {
8+
CLI::App app;
9+
argv = app.ensure_utf8(argv);
10+
CLI11_PARSE(app, argc, argv);
11+
return EXIT_SUCCESS;
12+
}

Diff for: src/ts-cli/vendor/cli11.cmake

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
include(FetchContent)
2+
set(CLI11_BUILD_DOCS OFF)
3+
set(CLI11_BUILD_TESTS OFF)
4+
set(CLI11_BUILD_EXAMPLES OFF)
5+
set(CLI11_PRECOMPILED ON)
6+
FetchContent_Declare(
7+
cli11_proj
8+
GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git
9+
GIT_TAG v2.4.1
10+
)
11+
12+
FetchContent_MakeAvailable(cli11_proj)
13+
set(CLI11_INCLUDE_DIR ${cli11_proj_SOURCE_DIR}/include/)

Diff for: vendor/rapidjson.cmake

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
include(FetchContent)
2+
set(RAPIDJSON_BUILD_DOC OFF CACHE INTERNAL "")
3+
set(RAPIDJSON_BUILD_EXAMPLES OFF CACHE INTERNAL "")
4+
set(RAPIDJSON_BUILD_TESTS OFF CACHE INTERNAL "")
5+
set(RAPIDJSON_BUILD_CXX20 ON CACHE INTERNAL "")
6+
FetchContent_Declare(
7+
rapidjson
8+
GIT_REPOSITORY https://github.com/Tencent/rapidjson.git
9+
GIT_TAG ab1842a2dae061284c0a62dca1cc6d5e7e37e346
10+
GIT_SUBMODULES ""
11+
CMAKE_ARGS
12+
-DCMAKE_COMPILER_ARGS="-D RAPIDJSON_HAS_CXX11_RVALUE_REFS 1"
13+
CONFIGURE_COMMAND ""
14+
BUILD_COMMAND ""
15+
INSTALL_COMMAND ""
16+
UPDATE_COMMAND ""
17+
)
18+
FetchContent_MakeAvailable(rapidjson)
19+
set(RAPIDJSON_INCLUDE_DIR ${rapidjson_SOURCE_DIR}/include)

0 commit comments

Comments
 (0)