Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 145 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,5 +1,146 @@
BasedOnStyle: LLVM
ReflowComments: false
---
# see: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
# maybe
AlignAfterOpenBracket: Align
#AlignAfterOpenBracket: DontAlign
AlignConsecutiveMacros: false
# maybe
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
# maybe -> add AlignAfterOperator
AlignOperands: false
# maybe -> true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeBraces: WebKit
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 79
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
# maybe
IndentCaseLabels: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
# maybe here
MaxEmptyLinesToKeep: 2
NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 1000000
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
# changed to 4
TabWidth: 4
UseCRLF: false
UseTab: Never
...

MacroBlockBegin: "^BEGIN_OPERATOR"
MacroBlockEnd: "^END_OPERATOR"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

.DS_Store
build

# Prerequisites
*.d

Expand Down
167 changes: 167 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
cmake_minimum_required(VERSION 3.19)

project(orca_project)

# options
option(BUILD_MACOS_UNIVERSAL "Build Universal Externals") # not supported (you're on your own! :-)
option(ENABLE_LTO "enable link-time / interprocedural optimization")
option(BUILD_STATIC "build static executable")

# use ccache if available
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Found ccache in ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()

if (ENABLE_LTO_IPO)
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_lto_supported OUTPUT check_lto_ipo_error)
if(ipo_lto_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
message(STATUS "IPO / LTO enabled")
else()
message(STATUS "IPO / LTO not supported: <${check_lto_ipo_error}>")
endif()
endif()

message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")

if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
if (${CMAKE_GENERATOR} MATCHES "Xcode")
if (${XCODE_VERSION} VERSION_LESS 10)
message(STATUS "Xcode 10 or higher is required. Please install from the Mac App Store.")
return ()
endif ()
endif ()

if (NOT CMAKE_OSX_ARCHITECTURES)
if(BUILD_MACOS_UNIVERSAL)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "macOS architecture" FORCE)
else()
set(CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "macOS architecture" FORCE)
endif()
message("CMAKE_OSX_ARCHITECTURES set to ${CMAKE_OSX_ARCHITECTURES}")
endif()

# i.e check if homebrew is used, set local prefix accordingly
set(local_prefix "/usr/local")
execute_process(
COMMAND brew --prefix
OUTPUT_VARIABLE homebrew_prefix
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(DEFINED homebrew_prefix)
set(HAS_HOMEBREW 1)
set(local_prefix ${homebrew_prefix})
execute_process(
COMMAND brew --prefix portmidi
OUTPUT_VARIABLE portmidi_prefix
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(DEFINED portmidi_prefix)
set(HAS_HOMEBREW_PORTMIDI)
endif()
execute_process(
COMMAND brew --prefix ncurses
OUTPUT_VARIABLE ncurses_prefix
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(DEFINED ncurses_prefix)
set(HAS_HOMEBREW_NCURSES)
endif()
endif()

endif()

# ------------------------------------------------------------------------------
# main

set(PROJECT_NAME orca)

set(PROJECT_SOURCES
gbuffer.c
field.c
vmio.c
sim.c
# livecoding
osc_out.c
term_util.c
sysmisc.c
thirdparty/oso.c
tui_main.c
)

set(THIRDPARTY_DIR
${CMAKE_SOURCE_DIR}/thirdparty
)

set(THIRDPARTY_SOURCES
${THIRDPARTY_DIR}/oso.c
)

if(BUILD_STATIC)
set(portmidi_prefix ${CMAKE_BINARY_DIR}/deps)
endif()


add_executable(
${PROJECT_NAME}
${PROJECT_SOURCES}
${THIRDPARTY_SOURCES}
)

target_include_directories(
${PROJECT_NAME}
PUBLIC
${THIRDPARTY_DIR}
${local_prefix}/include
${ncurses_prefix}/include
${portmidi_prefix}/include
)

target_compile_definitions(
${PROJECT_NAME}
PUBLIC
_XOPEN_SOURCE_EXTENDED=1
$<$<PLATFORM_ID:Darwin>:ORCA_OS_MAC>
)

target_compile_options(
${PROJECT_NAME}
PUBLIC
"-isystem thirdparty"
# common hardening
-O2
-Wall
-Wformat=2
-Wconversion
-Wimplicit-fallthrough
-U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE
-D_GLIBCXX_ASSERTIONS
-fstack-protector-strong
# executable hardening
-fPIE
)

target_link_directories(
${PROJECT_NAME}
PUBLIC
${local_prefix}/lib
${ncurses_prefix}/lib
${portmidi_prefix}/lib
)

target_link_options(
${PROJECT_NAME}
PUBLIC
)

target_link_libraries(
${PROJECT_NAME}
PUBLIC
$<IF:$<BOOL:${BUILD_STATIC}>,${ncurses_prefix}/lib/libncursesw.a,-lncursesw>
$<IF:$<BOOL:${BUILD_STATIC}>,${ncurses_prefix}/lib/libformw.a,-lformw>
$<IF:$<BOOL:${BUILD_STATIC}>,${portmidi_prefix}/lib/libportmidi.a,-lportmidi>
)
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ release:
@echo "To run it, simply execute it:" >&2
@echo "$$ build/orca" >&2

.PHONY: cmake static
cmake:
@mkdir -p build && cd build && cmake .. && make

static:
@scripts/get_portmidi.sh
@mkdir -p build && cd build && cmake .. -DBUILD_STATIC=ON && make


.PHONY: clean
clean:
@./tool clean
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ORCΛ

FORK NOTE: this fork adds cmake support to building orca and also improved static builds for macos. Otherwise its unchanged except for some clang-formatting of c files.

Orca is an [esoteric programming language](https://en.wikipedia.org/wiki/Esoteric_programming_language) and live editor designed to quickly create procedural sequencers. Every letter of the alphabet is an operation, lowercase letters execute on `*bang*`, and uppercase letters execute each frame.

This is the C implementation of the [ORCΛ](https://wiki.xxiivv.com/site/orca.html) language and terminal livecoding environment. It's designed to be power efficient. It can handle large files, even if your terminal is small.
Expand Down
Loading