-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(stdlib) Add C++-based stdlib project (#407)
This commit also contains local modifications to the fmt lib. For the full details about these modifications, see the (now-squashed) separate commit in the original pull request: #407
- Loading branch information
Showing
20 changed files
with
10,170 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Generated from CLion C/C++ Code Style settings | ||
BasedOnStyle: LLVM | ||
AccessModifierOffset: -3 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: None | ||
AlignOperands: Align | ||
AllowAllArgumentsOnNextLine: false | ||
AllowAllConstructorInitializersOnNextLine: false | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortBlocksOnASingleLine: Always | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: None | ||
AllowShortIfStatementsOnASingleLine: Always | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortLoopsOnASingleLine: true | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakTemplateDeclarations: MultiLine | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: true | ||
AfterControlStatement: Never | ||
AfterEnum: true | ||
AfterFunction: true | ||
AfterNamespace: true | ||
AfterUnion: true | ||
BeforeCatch: false | ||
BeforeElse: true | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
BreakBeforeBinaryOperators: NonAssignment | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializers: BeforeColon | ||
BreakInheritanceList: BeforeColon | ||
ColumnLimit: 0 | ||
CompactNamespaces: false | ||
ContinuationIndentWidth: 4 | ||
IndentCaseLabels: false | ||
IndentPPDirectives: None | ||
IndentWidth: 4 | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: All | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PointerAlignment: Left | ||
ReflowComments: false | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 0 | ||
SpacesInAngles: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInContainerLiterals: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
TabWidth: 4 | ||
UseTab: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,3 +352,4 @@ _site/ | |
docfx/*.dll | ||
docfx/docfx.exe | ||
docfx/docfx.exe.config | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(stdlib VERSION 0.1.0) | ||
|
||
set(headers | ||
src/stdlib.hpp | ||
src/double-conversion/utils.h | ||
) | ||
|
||
add_library( | ||
stdlib | ||
src/Base64.cpp | ||
src/print.cpp | ||
) | ||
|
||
# Enable C++ 17 support. This is required on e.g. AppleClang 13 | ||
set_property(TARGET stdlib PROPERTY CXX_STANDARD 17) | ||
|
||
target_include_directories( | ||
stdlib PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> | ||
) | ||
|
||
include(GNUInstallDirs) | ||
|
||
install( | ||
TARGETS stdlib | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" | ||
) | ||
|
||
install( | ||
FILES ${headers} | ||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" | ||
) | ||
|
||
# The testing code is not yet ready for macOS, since it uses a different linker which doesnät support --wrap. We'll | ||
# live with only building/running the tests on other platforms for now. | ||
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
enable_testing() | ||
include(CTest) | ||
|
||
set(CCTEST_SRC | ||
test/print.cc | ||
test/double-conversion/cctest.cc | ||
) | ||
|
||
add_executable( | ||
cctest | ||
${CCTEST_SRC} | ||
) | ||
|
||
target_include_directories( | ||
cctest | ||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> | ||
) | ||
|
||
target_link_libraries(cctest stdlib) | ||
|
||
# We enable wrapping for fwrite(), to be able to capture its output in tests. The reason why we don't do this on | ||
# macOS is because it does not use GNU ld, so the --wrap linker option isn't available. | ||
target_link_options(cctest PRIVATE -Wl,--wrap=fwrite) | ||
|
||
add_test(NAME test_fast_dtoa | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
COMMAND $<TARGET_FILE:cctest> test-fast-dtoa) | ||
|
||
add_test(NAME test_print | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
COMMAND $<TARGET_FILE:cctest> print) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "stdlib.hpp" | ||
|
||
namespace perlang::stdlib | ||
{ | ||
const char *Base64::to_string() | ||
{ | ||
// Poor-man's FQCN. :-) | ||
return "Perlang.Stdlib.Base64"; | ||
} | ||
} |
Oops, something went wrong.