diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..2d35c7f --- /dev/null +++ b/.clang-format @@ -0,0 +1,216 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +AttributeMacros: + - __capability +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +QualifierAlignment: Leave +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: BinPack +BasedOnStyle: '' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +AllowAllConstructorInitializersOnNextLine: true +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: BeforeHash +IndentExternBlock: AfterExternBlock +IndentRequiresClause: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertTrailingCommas: None +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +LambdaBodyIndentation: Signature +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: All +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PenaltyIndentedWhitespace: 0 +PointerAlignment: Right +PPIndentWidth: 1 +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RequiresClausePosition: OwnLine +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: CaseSensitive +SortJavaStaticImport: Before +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceAroundPointerQualifiers: Default +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +BitFieldColonSpacing: Both +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE + - NS_SWIFT_NAME + - CF_SWIFT_NAME +... + diff --git a/README.md b/README.md index 4cf9bda..dfbf107 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,143 @@ -# goff +# Goff Film Scanner Software -Software driver for Nikon Coolscan Scanners \ No newline at end of file +Goff is software application to work with the Nikon Coolscan line of scanners, +specifically (Coolscan IV LS-40ED, Coolscan LS-4000 ED, Coolscan LS-5000 ED / +Coolscan LS-50 ED, Coolscan LS-8000 ED, Coolscan LS-9000 ED). Its sole purpose +is to be a modern equivalent of the now discontinued NikonScan software. + +The primary plan for now is to be feature complete with NikonScan, with emphasis +on taking advantage of modern hardware capabilities to improve speed, and better +user experience compared to the OG NikonScan. + +## Guarantees +This application guarantees the following: + - x86-64 architecture support + - Support for Windows 10 and above. + - Complete support for the following Coolscan scanners: + - Coolscan IV LS-40ED + - Coolscan LS-4000 ED + - Coolscan LS-5000 ED / Coolscan LS-50 ED + - Coolscan LS-8000 ED + - Coolscan LS-9000 ED + +## Status +Goff is currently in the Pre-Alpha stage, meaning things it is not anywhere near +a useable product and things are expected to break and change without any notice. + + +## Development Setup Instructions + +**Note: Only x64 Windows development is supported.** + +### 1. Installing the Required Tools (MSVC & Windows SDK) + +In order to work with the codebase, you'll need the [Microsoft C/C++ Build Tools +v15 (2017) or later](https://aka.ms/vs/17/release/vs_BuildTools.exe), for both +the Windows SDK and the MSVC compiler and linker. + +If the Windows SDK is installed (e.g. via installation of the Microsoft C/C++ +Build Tools). At this time, support for other compilers like clang is not +supported. + +### 2. Build Environment Setup + +Building the codebase can be done in a terminal which is equipped with the +ability to call MSVC from command line. + +This is generally done by calling `vcvarsall.bat x64`, which is included in the +Microsoft C/C++ Build Tools. This script is automatically called by the `x64 +Native Tools Command Prompt for VS ` variant of the vanilla `cmd.exe`. If +you've installed the build tools, this command prompt may be easily located by +searching for `Native` from the Windows Start Menu search. Alternatively you +could run the following command in your preferred console emulator on windows + +``` +"C:\Program Files\Microsoft Visual Studio\\Community\VC\Auxiliary\Build\vcvars64.bat" +``` + +You can ensure that the MSVC compiler is accessible from your command line by +running: + +``` +cl +``` + +If everything is set up correctly, you should have output very similar to the +following: + +``` +Microsoft (R) C/C++ Optimizing Compiler Version 19.40.33811 for x64 +Copyright (C) Microsoft Corporation. All rights reserved. + +usage: cl [ option... ] filename... [ /link linkoption... ] +``` + +### 3. Building + +Within this terminal, `cd` to the root directory of the codebase, and just run +the `build.bat` script: + +``` +build +``` + +You should see the following output: +``` +[debug mode] +[msvc compile] +[default mode, assuming `goff` build] +goff_main.c +``` + +If everything worked as it should, the executable will be in the `run_tree` folder +in the root of the codebase, and it will contain a freshly-builth `Goff Scan.exe` + +## Top-Level Directory Descriptions +- `run_tree`: This directory contains everything that is needed for a debug build + of the application to run. +- `run_tree/data` Contains small binary files (i.e. .rc files, logo, fonts, etc) + used when building, to embed or package with the application. +- `src`: All the source code. + + +## Codebase Introduction + +The codebase is organized into *layers*. Layers are separated either to isolate +certain problems, and to allow inclusion into various builds without needing to +pull everything in the codebase into a build. Layers correspond with folders +inside of the `src` directory. Sometimes, one folder inside of the `src` +directory will include multiple sub-layers, but the structure is intended to be +fairly flat. + +Layers correspond roughly 1-to-1 with *namespaces*. The term "namespaces" in +this context does not refer to specific namespace language features, but rather +a naming convention for C-style namespaces, which are written in the codebase as +a short prefix, usually 1-3 characters, followed by an underscore. These +namespaces are used such that the layer to which certain code belongs may be +quickly understood by glancing at code. The namespaces are generally quite short +to ensure that they aren't much of a hassle to write. Sometimes, multiple sub- +layers will share a namespace. A few layers do not have a namespace, but most +do. Namespaces are either all-caps or lowercase depending on the context in +which they're used. For structs, enum values, and some macros, they are +capitalized. For functions and global variables, they are lowercase. + +Layers depend on other layers, but circular dependencies would break the +separability and isolation utility of layers (in effect, forming one big layer), +so in other words, layers are arranged into a directed acyclic graph. + +A list of layers in the codebase and their associated namespaces are below: +- `base` (no namespace): Universal, codebase-wide constructs. It contains + strings, math, memory allocators, threading, and logging. + It depends on no other codebase layers. +- `es/core` (`ES_`): Short for Engine Subsystem. Implements the +- `es/gfx` (`ES_`): Engine Subsystem graphical frontend. Builds on top of + `es/core` to provide graphical features such as windows, panels, and all + interfaces needed for using the scanner. It is the main user of `os/gfx`. +- `os/core` (`OS_`): An abstraction layer that provides core, non-graphical + functionality from the operating sytem under a general use abstraction API. + This is implemented per supported operating system. +- `os/gfx` (`OS_`): This layer builds on top of `os/core`, it provides + graphical operating functionalities under a general use abstraction API. +- `ui` (`UI_`): For building graphical user interfaces. Provides a core + immediate mode hierarchical user interface data structure building API, and + has helper layers for building higher level widgets. \ No newline at end of file diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..bb03a9d --- /dev/null +++ b/build.bat @@ -0,0 +1,74 @@ +@echo off +setlocal +cd /D "%~dp0" + +:: --- Unpack Arguments --------------------------------------------------------------- +for %%a in (%*) do set "%%a=1" +if not "%msvc%"=="1" if not "%clang%"=="1" set msvc=1 +if not "%release%"=="1" set debug=1 +if "%debug%"=="1" set release=0 && echo [debug mode] +if "%release%"=="1" set debug=0 && echo [release mode] +if "%msvc%"=="1" set clang=0 && echo [msvc compile] +if "%clang%"=="1" set msvc=0 && echo [clang compile] +if "%~1"=="" echo [default mode, assuming `goff` build] && set goff=1 + +:: --- Compile/Link Line Definitions ------------------------------------------------- +set cl_common= /I..\src\ /nologo /FC /Z7 +set cl_out= /out: +rem Add back resource.res to cl_link +set cl_link= /link /MANIFEST:EMBED /INCREMENTAL:NO resource.res +set cl_debug= call cl /Od /DBUILD_DEBUG=1 %cl_common% +set cl_release= call cl /O2 /DBUILD_DEBUG=0 %cl_common% + +set clang_common= +set clang_out= -o +set clang_link= +set clang_debug= call cl -g -O0 -DBUILD_DEBUG=1 %clang_common% +set clang_release= call cl -g -O2 -DBUILD_DEBUG=0 %clang_common% + +:: --- Per-Build Settings ---------------------------------------------------- +:: set link_dll=-DLL +if "%msvc%"=="1" set only_compile=/c +if "%msvc%"=="1" set EHsc=/EHsc +if "%msvc%"=="1" set rc=rc.exe + +if "%clang%"=="1" set EHsc= +if "%clang%"=="1" set only_compile=-c +if "%clang%"=="1" set rc=llvm-rc.exe + +:: --- Choose Compile/Link Lines --------------------------------------------- +if "%msvc%"=="1" set compile_debug=%cl_debug% +if "%msvc%"=="1" set compile_release=%cl_release% +if "%msvc%"=="1" set compile_link=%cl_link% +if "%msvc%"=="1" set out=%cl_out% +if "%debug%"=="1" set compile=%compile_debug% +if "%release%"=="1" set compile=%compile_release% + +rem :: --- Get Current SVN Revision ID --------------------------------------------- +rem for /f "tokens=2 delims==" %%i in ('svn info --show-item revision') do set compile=%compile% -DBUILD_SVN_REVISION=\"%%i\" + +:: --- Prep Directory -------------------------------------------------------- +if not exist run_tree ( + mkdir run_tree + echo "[WARNING] creating run_tree, data files may not exist." +) + +:: --- Produce Logo Icon File ------------------------------------------------ +pushd run_tree +%rc% /nologo /fo resource.res data\resource.rc || exit /b 1 +popd + +:: --- Build Everything (@build_targets) ------------------------------------- +pushd run_tree +if "%goff%"=="1" %compile% %gfx% ..\src\goff\goff_main.c %compile_link% %out%"Goff Scan.exe" || exit /b 1 +popd + +:: --- Unset ----------------------------------------------------------------- +for %%a in (%*) do set "%%a=0" +set goff= +set compile= +set compile_link= +set out= +set msvc= +set debug= +