From 2769640adfdfeb227a25dff8eb77ae6dc8196cad Mon Sep 17 00:00:00 2001 From: PS Date: Sat, 16 Jan 2021 23:01:08 -0800 Subject: [PATCH] updated the build system to get it to work out of the box on more systems --- build/_postbuild_win32.bat | 4 +- build/_prebuild_win32.bat | 6 +- build/build_app_clang_win32_debug.bat | 24 +++---- build/build_app_msvc_win32_debug.bat | 18 +++--- build/setup_cl.bat | 37 +++++++++++ .../foldhaus_panel_animation_timeline.h | 34 ++++------ .../editor/panels/foldhaus_panel_file_view.h | 64 ++++++++++++++----- .../editor/panels/foldhaus_panel_hierarchy.h | 1 + .../assembly/foldhaus_assembly_parser.cpp | 2 +- src/app/interface.h | 5 +- .../platform_win32/win32_foldhaus_fileio.h | 14 ++++ src/gs_libs/gs_types.h | 1 + 12 files changed, 144 insertions(+), 66 deletions(-) create mode 100644 build/setup_cl.bat diff --git a/build/_postbuild_win32.bat b/build/_postbuild_win32.bat index 32c9169..ebc3e0a 100644 --- a/build/_postbuild_win32.bat +++ b/build/_postbuild_win32.bat @@ -2,8 +2,8 @@ IF NOT "%PrebuildCalled%"=="1" GOTO error -C:\apps\ctime\ctime.exe -end %StatsPath%\%StatsFile% %LastError% -C:\apps\ctime\ctime.exe -stats %StatsPath%\%StatsFile% +IF EXIST %CTIMEPATH% ( call C:\apps\ctime\ctime.exe -end %StatsPath%\%StatsFile% %LastError% ) +IF EXIST %CTIMEPATH% ( call C:\apps\ctime\ctime.exe -stats %StatsPath%\%StatsFile% ) set PrebuildCalled=0 GOTO:eof diff --git a/build/_prebuild_win32.bat b/build/_prebuild_win32.bat index 9d8c31e..9680699 100644 --- a/build/_prebuild_win32.bat +++ b/build/_prebuild_win32.bat @@ -1,6 +1,6 @@ @echo off -REM This file takes two arguments +REM This file takes three arguments REM 1 = "app" or "meta" REM 2 = "debug" or "release" REM 3 = "msvc" or "clang" @@ -22,7 +22,9 @@ set StatsFile=%1_win32_%3_%2_build_time.ctm IF NOT EXIST %BuildPath% mkdir %BuildPath% IF NOT EXIST %StatsPath% mkdir %StatsPath% -C:\apps\ctime\ctime.exe -begin %StatsPath%\%StatsFile% +set CTimePath=C:\apps\ctime +IF EXIST %CTIMEPATH% ( call C:\apps\ctime\ctime.exe -begin %StatsPath%\%StatsFile% ) + echo. echo BUILDING TO %BuildPath% echo STATS IN %StatsPath%\%StatsFile% diff --git a/build/build_app_clang_win32_debug.bat b/build/build_app_clang_win32_debug.bat index 30c5b8b..20a1746 100644 --- a/build/build_app_clang_win32_debug.bat +++ b/build/build_app_clang_win32_debug.bat @@ -1,32 +1,26 @@ @echo off -set ProjectDevFolder=%~dp0 -set ProjectDevPath=%ProjectDevFolder:~0,-1% - -pushd %ProjectDevPath% - -IF NOT EXIST .\build_clang\ mkdir .\build_clang - -C:\programs\ctime\ctime.exe -begin %ProjectDevPath%\build\win32_foldhaus_clang_build_time.ctm +SET MyPath=%~dp0 +SET MyPath=%MyPath:~0,-1% +call %MyPath%\_prebuild_win32.bat app debug clang set CommonCompilerFlags=-std=c++11 -Wno-writable-strings -Wno-unused-value -Wno-varargs -Wno-switch -Wno-microsoft-enum-forward-reference -DDEBUG=1 -pushd .\build_clang\ +pushd %BuildPath% -REM Run the Preprocessor -foldhaus_meta.exe ..\src\foldhaus_app.cpp +del *.pdb > NUL 2> NUL echo WAITING FOR PDB TO WRITE > lock.tmp -clang %CommonCompilerFlags% ..\src\foldhaus_app.cpp -shared +clang++ %CommonCompilerFlags% %SourceCodePath%\foldhaus_app.cpp -shared -o set LastError=%ERRORLEVEL% del lock.tmp -clang %CommonCompilerFlags% ..\src\win32_foldhaus.cpp -o win32_foldhaus.exe user32.lib winmm.lib gdi32.lib opengl32.lib dsound.lib Ws2_32.lib Comdlg32.lib +clang++ -c %CommonCompilerFlags% %SourceCodePath%\platform_win32\win32_foldhaus.cpp +link win32_foldhaus.o user32.lib winmm.lib gdi32.lib opengl32.lib dsound.lib Ws2_32.lib Comdlg32.lib -C:\programs\ctime\ctime.exe -end %ProjectDevPath%\build\win32_foldhaus_clang_build_time.ctm %LastError% -REM C:\programs\ctime\ctime.exe -stats %ProjectDevPath%\build\win32_foldhaus_clang_build_time.ctm popd +call %MyPath%\_postbuild_win32.bat diff --git a/build/build_app_msvc_win32_debug.bat b/build/build_app_msvc_win32_debug.bat index 25c45bd..0819a48 100644 --- a/build/build_app_msvc_win32_debug.bat +++ b/build/build_app_msvc_win32_debug.bat @@ -3,30 +3,32 @@ SET MyPath=%~dp0 SET MyPath=%MyPath:~0,-1% call %MyPath%\_prebuild_win32.bat app debug msvc +call %MyPath%\setup_cl.bat -set CommonCompilerFlags=-nologo -DDEBUG=1 -DPLATFORM_WINDOWS -FC -WX -W4 -Z7 -Oi -GR- -EHsc -EHa- -MTd -fp:fast -fp:except- -IC:\programs-dev\gs_libs\src -set CommonCompilerFlags=-wd4127 -wd4702 -wd4101 -wd4505 -wd4100 -wd4189 -wd4244 -wd4201 -wd4996 -I%CommonLibs% -O2 %CommonCompilerFlags% +SET CommonCompilerFlags=-nologo -DDEBUG=1 -DPLATFORM_WINDOWS -FC -WX -W4 -Z7 -Oi -GR- -EHsc -EHa- -MTd -fp:fast -fp:except- -IC:\programs-dev\gs_libs\src -set CommonLinkerFlags= -opt:ref -incremental:no +SET CommonCompilerFlags=-wd4127 -wd4702 -wd4101 -wd4505 -wd4100 -wd4189 -wd4244 -wd4201 -wd4996 -I%CommonLibs% -O2 %CommonCompilerFlags% -set DLLExports=/EXPORT:InitializeApplication /EXPORT:UpdateAndRender /EXPORT:CleanupApplication /EXPORT:ReloadStaticData +SET CommonLinkerFlags= -opt:ref -incremental:no + +SET DLLExports=/EXPORT:InitializeApplication /EXPORT:UpdateAndRender /EXPORT:CleanupApplication /EXPORT:ReloadStaticData pushd %BuildPath% del *.pdb > NUL 2> NUL -REM Run the Preprocessor -REM %MetaProgramPath%\foldhaus_meta.exe %SourceCodePath%\foldhaus_app.cpp - echo WAITING FOR PDB TO WRITE > lock.tmp cl %CommonCompilerFlags% %SourceCodePath%\foldhaus_app.cpp /Fefoldhaus.dll /LD /link %CommonLinkerFlags% %DLLExports% -set LastError=%ERRORLEVEL% +SET LastError=%ERRORLEVEL% del lock.tmp cl %CommonCompilerFlags% %SourceCodePath%\platform_win32\win32_foldhaus.cpp /link %CommonLinkerFlags% user32.lib winmm.lib gdi32.lib opengl32.lib dsound.lib Ws2_32.lib Comdlg32.lib + +REM COMPILE UTILITY EXES + cl %CommonCompilerFlags% %ProjectDevPath%\src\serial_monitor\first.cpp /Feserial_monitor.exe /link %CommonLinkerFlags% user32.lib winmm.lib gdi32.lib cl %CommonCompilerFlags% %ProjectDevPath%\src\sculpture_gen\gen_blumen_lumen.cpp /Fegen_blumen_lumen.exe /link %CommonLinkerFlags% user32.lib winmm.lib gdi32.lib diff --git a/build/setup_cl.bat b/build/setup_cl.bat new file mode 100644 index 0000000..faf7fe6 --- /dev/null +++ b/build/setup_cl.bat @@ -0,0 +1,37 @@ +@echo off + +SET "LIB=" + +SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 12.0 +IF NOT DEFINED LIB (IF EXIST "%VC_PATH%" (call "%VC_PATH%\VC\vcvarsall.bat" x64)) + +SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 11.0 +IF NOT DEFINED LIB (IF EXIST "%VC_PATH%" (call "%VC_PATH%\VC\vcvarsall.bat" x64)) + +SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 10.0 +IF NOT DEFINED LIB (IF EXIST "%VC_PATH%" (call "%VC_PATH%\VC\vcvarsall.bat" x64)) + +SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 13.0 +IF NOT DEFINED LIB (IF EXIST "%VC_PATH%" (call "%VC_PATH%\VC\vcvarsall.bat" x64)) + +SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0 +IF NOT DEFINED LIB (IF EXIST "%VC_PATH%" (call "%VC_PATH%\VC\vcvarsall.bat" x64)) + +SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools +IF NOT DEFINED LIB (IF EXIST "%VC_PATH%" (call "%VC_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64)) + +SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community +IF NOT DEFINED LIB (IF EXIST "%VC_PATH%" (call "%VC_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64)) + +SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional +IF NOT DEFINED LIB (IF EXIST "%VC_PATH%" (call "%VC_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64)) + +SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools +IF NOT DEFINED LIB (IF EXIST "%VC_PATH%" (call "%VC_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64)) + +SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community +IF NOT DEFINED LIB (IF EXIST "%VC_PATH%" (call "%VC_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64)) + +SET VC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional +IF NOT DEFINED LIB (IF EXIST "%VC_PATH%" (call "%VC_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64)) + diff --git a/src/app/editor/panels/foldhaus_panel_animation_timeline.h b/src/app/editor/panels/foldhaus_panel_animation_timeline.h index b8f3ef3..1fb550a 100644 --- a/src/app/editor/panels/foldhaus_panel_animation_timeline.h +++ b/src/app/editor/panels/foldhaus_panel_animation_timeline.h @@ -900,30 +900,22 @@ AnimationTimeline_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* ui_FillRect(&State->Interface, PanelBounds, v4{.1f,.1f,.1f,1.f}); rect2 TimelineBounds, InfoBounds; - RectVSplit(PanelBounds, 300, &InfoBounds, &TimelineBounds); + RectVSplitAtDistanceFromLeft(PanelBounds, 300, &InfoBounds, &TimelineBounds); -#if 0 - rect2 AnimInfoBounds, SelectionInfoBounds; - RectHSplitAtPercent(InfoBounds, .65f, &AnimInfoBounds, &SelectionInfoBounds); -#endif + rect2 LayersPanelBounds, TimeRangePanelBounds; + RectVSplitAtDistanceFromLeft(TimelineBounds, 200, &LayersPanelBounds, &TimeRangePanelBounds); - { // Timeline - rect2 LayersPanelBounds, TimeRangePanelBounds; - RectVSplitAtDistanceFromLeft(TimelineBounds, 200, &LayersPanelBounds, &TimeRangePanelBounds); - - r32 TitleBarHeight = State->Interface.Style.RowHeight; - // These are the actual rects we will draw in - rect2 PlayBarBounds, FrameCountBounds; - rect2 LayersBounds, TimeRangeBounds; - RectHSplitAtDistanceFromTop(LayersPanelBounds, TitleBarHeight, &PlayBarBounds, &LayersBounds); - RectHSplitAtDistanceFromTop(TimeRangePanelBounds, TitleBarHeight, &FrameCountBounds, &TimeRangeBounds); - - PlayBar_Render(TimelineState, PlayBarBounds, Panel, RenderBuffer, State, Context); - FrameCount_Render(TimelineState, FrameCountBounds, RenderBuffer, State, Context); - LayerList_Render(TimelineState, LayersBounds, Panel, RenderBuffer, State, Context); - TimeRange_Render(TimelineState, TimeRangeBounds, RenderBuffer, State, Context); - } + r32 TitleBarHeight = State->Interface.Style.RowHeight; + // These are the actual rects we will draw in + rect2 PlayBarBounds, FrameCountBounds; + rect2 LayersBounds, TimeRangeBounds; + RectHSplitAtDistanceFromTop(LayersPanelBounds, TitleBarHeight, &PlayBarBounds, &LayersBounds); + RectHSplitAtDistanceFromTop(TimeRangePanelBounds, TitleBarHeight, &FrameCountBounds, &TimeRangeBounds); + PlayBar_Render(TimelineState, PlayBarBounds, Panel, RenderBuffer, State, Context); + FrameCount_Render(TimelineState, FrameCountBounds, RenderBuffer, State, Context); + LayerList_Render(TimelineState, LayersBounds, Panel, RenderBuffer, State, Context); + TimeRange_Render(TimelineState, TimeRangeBounds, RenderBuffer, State, Context); AnimInfoView_Render(TimelineState, InfoBounds, Panel, RenderBuffer, State, Context); } diff --git a/src/app/editor/panels/foldhaus_panel_file_view.h b/src/app/editor/panels/foldhaus_panel_file_view.h index fc3b4cd..eaf5013 100644 --- a/src/app/editor/panels/foldhaus_panel_file_view.h +++ b/src/app/editor/panels/foldhaus_panel_file_view.h @@ -5,8 +5,16 @@ // #ifndef FOLDHAUS_PANEL_FILE_VIEW_H +enum file_view_mode +{ + FileViewMode_Load, + FileViewMode_Save, +}; + struct file_view_state { + file_view_mode Mode; + gs_string WorkingDirectory; gs_memory_arena FileNamesArena; gs_file_info_array FileNames; @@ -14,9 +22,18 @@ struct file_view_state gs_file_info SelectedFile; }; +internal void +FileView_SetMode(panel* Panel, file_view_mode Mode) +{ + file_view_state* FileViewState = Panel_GetStateStruct(Panel, file_view_state); + FileViewState->Mode = Mode; +} + internal void FileView_Exit_(panel* FileViewPanel, app_state* State, context Context) { + // TODO(pjs): Free State->FileNamesArena + Assert(FileViewPanel->IsModalOverrideFor != 0); panel* ReturnTo = FileViewPanel->IsModalOverrideFor; if (ReturnTo->ModalOverrideCB) @@ -30,7 +47,7 @@ global input_command* FileView_Commands = 0; s32 FileView_CommandsCount = 0; internal void -FileViewUpdateWorkingDirectory(gs_const_string WorkingDirectory, file_view_state* State, context Context) +FileView_UpdateWorkingDirectory(gs_const_string WorkingDirectory, file_view_state* State, context Context) { ClearArena(&State->FileNamesArena); @@ -43,23 +60,20 @@ FileViewUpdateWorkingDirectory(gs_const_string WorkingDirectory, file_view_state u32 SecondLastSlashIndex = FindLast(SanitizedDirectory, LastSlashIndex - 1, '\\'); SanitizedDirectory = Substring(SanitizedDirectory, 0, SecondLastSlashIndex); } - else if (StringsEqual(LastDir, ConstString("."))) + else if (StringsEqual(LastDir, ConstString(".")) && LastDir.Length > 1) { SanitizedDirectory = Substring(SanitizedDirectory, 0, LastSlashIndex); } - State->WorkingDirectory = PushString(&State->FileNamesArena, WorkingDirectory.Length + 2); - PrintF(&State->WorkingDirectory, "%S", SanitizedDirectory); - if (State->WorkingDirectory.Str[State->WorkingDirectory.Length - 1] != '\\') + gs_file_info NewWorkingDirectory = GetFileInfo(Context.ThreadContext.FileHandler, SanitizedDirectory); + if (NewWorkingDirectory.IsDirectory) { - AppendPrintF(&State->WorkingDirectory, "\\"); + // NOTE(pjs): we might be printing from State->WorkingDirectory to State->WorkingDirectory + // in some cases. Shouldn't be a problem but it is unnecessary + PrintF(&State->WorkingDirectory, "%S", WorkingDirectory); + + State->FileNames = EnumerateDirectory(Context.ThreadContext.FileHandler, &State->FileNamesArena, State->WorkingDirectory.ConstString, EnumerateDirectory_IncludeDirectories); } - if (State->WorkingDirectory.Str[State->WorkingDirectory.Length - 1] != '*') - { - AppendPrintF(&State->WorkingDirectory, "*"); - } - - State->FileNames = EnumerateDirectory(Context.ThreadContext.FileHandler, &State->FileNamesArena, State->WorkingDirectory.ConstString, EnumerateDirectory_IncludeDirectories); } GSMetaTag(panel_init); @@ -71,7 +85,10 @@ FileView_Init(panel* Panel, app_state* State, context Context) file_view_state* FileViewState = PushStruct(&State->Permanent, file_view_state); Panel->StateMemory = StructToData(FileViewState, file_view_state); FileViewState->FileNamesArena = CreateMemoryArena(Context.ThreadContext.Allocator); - FileViewUpdateWorkingDirectory(ConstString("."), FileViewState, Context); + + // TODO(pjs): this shouldn't be stored in permanent + FileViewState->WorkingDirectory = PushString(&State->Permanent, 256); + FileView_UpdateWorkingDirectory(ConstString("."), FileViewState, Context); } GSMetaTag(panel_cleanup); @@ -88,6 +105,8 @@ internal void FileView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context) { file_view_state* FileViewState = Panel_GetStateStruct(Panel, file_view_state); + Assert(FileViewState->Mode == FileViewMode_Save); + ui_PushLayout(&State->Interface, PanelBounds, LayoutDirection_TopDown, MakeString("FileView Layout")); { if (ui_Button(&State->Interface, MakeString("Exit"))) @@ -96,7 +115,21 @@ FileView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBu } // Header - ui_Label(&State->Interface, FileViewState->WorkingDirectory); + if (ui_TextEntry(&State->Interface, MakeString("pwd"), &FileViewState->WorkingDirectory)) + { + // if last character is a slash, update pwd, and clear the filter string + // otherwise update the filter string + gs_string Pwd = FileViewState->WorkingDirectory; + char LastChar = Pwd.Str[Pwd.Length - 1]; + if (LastChar == '\\' || LastChar == '/') + { + FileView_UpdateWorkingDirectory(Pwd.ConstString, FileViewState, Context); + } + else + { + + } + } // File Display ui_BeginList(&State->Interface, MakeString("Files"), 10, FileViewState->FileNames.Count); @@ -113,7 +146,7 @@ FileView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBu { if (File.IsDirectory) { - FileViewUpdateWorkingDirectory(File.Path, FileViewState, Context); + FileView_UpdateWorkingDirectory(File.Path, FileViewState, Context); } else { @@ -128,6 +161,5 @@ FileView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBu } - #define FOLDHAUS_PANEL_FILE_VIEW_H #endif // FOLDHAUS_PANEL_FILE_VIEW_H \ No newline at end of file diff --git a/src/app/editor/panels/foldhaus_panel_hierarchy.h b/src/app/editor/panels/foldhaus_panel_hierarchy.h index 380596c..e19cbb0 100644 --- a/src/app/editor/panels/foldhaus_panel_hierarchy.h +++ b/src/app/editor/panels/foldhaus_panel_hierarchy.h @@ -60,6 +60,7 @@ HierarchyView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* Ren if (ui_Button(&State->Interface, MakeString("+ Add Assembly"))) { panel* FileBrowser = PanelSystem_PushPanel(&State->PanelSystem, PanelType_FileView, State, Context); + FileView_SetMode(FileBrowser, FileViewMode_Save); Panel_PushModalOverride(Panel, FileBrowser, LoadAssemblyCallback); } diff --git a/src/app/engine/assembly/foldhaus_assembly_parser.cpp b/src/app/engine/assembly/foldhaus_assembly_parser.cpp index ff2cbc0..26e4205 100644 --- a/src/app/engine/assembly/foldhaus_assembly_parser.cpp +++ b/src/app/engine/assembly/foldhaus_assembly_parser.cpp @@ -225,7 +225,7 @@ AssemblyParser_ReadSequence(parser* Parser, assembly* Assembly) internal strip_gen_data AssemblyParser_ReadStripGenData(parser* Parser, assembly* Assembly) { - strip_gen_data Result = {0}; + strip_gen_data Result = {}; if (Parser_ReadOpenStruct(Parser, AssemblyField_Segment)) { diff --git a/src/app/interface.h b/src/app/interface.h index 1c1b304..ee846c1 100644 --- a/src/app/interface.h +++ b/src/app/interface.h @@ -1141,7 +1141,7 @@ ui_TextEntrySetFlags(ui_widget* Widget, gs_string EditString) ui_WidgetSetFlag(Widget, UIWidgetFlag_Typable); } -internal void +internal bool ui_TextEntry(ui_interface* Interface, gs_string Identifier, gs_string* Value) { ui_widget* Widget = ui_CreateWidget(Interface, Identifier); @@ -1155,7 +1155,10 @@ ui_TextEntry(ui_interface* Interface, gs_string Identifier, gs_string* Value) ui_TextEntrySetFlags(Widget, State->EditString); ui_eval_result Result = ui_EvaluateWidget(Interface, Widget); + bool StringEdited = !StringsEqual(*Value, State->EditString); PrintF(Value, "%S", State->EditString); + + return StringEdited; } internal u64 diff --git a/src/app/platform_win32/win32_foldhaus_fileio.h b/src/app/platform_win32/win32_foldhaus_fileio.h index 2c4059c..bfb93ac 100644 --- a/src/app/platform_win32/win32_foldhaus_fileio.h +++ b/src/app/platform_win32/win32_foldhaus_fileio.h @@ -46,6 +46,20 @@ GET_FILE_INFO(Win32GetFileInfo) } CloseHandle(FileHandle); } + else + { + DWORD FileAttr = GetFileAttributes(Path.Str); + if (FileAttr != INVALID_FILE_ATTRIBUTES && + (FileAttr & FILE_ATTRIBUTE_DIRECTORY)) + { + Result.Path = Path; + Result.IsDirectory = true; + } + else + { + // Path is not a file or directory + } + } return Result; } diff --git a/src/gs_libs/gs_types.h b/src/gs_libs/gs_types.h index 82c9246..c9cfdbe 100644 --- a/src/gs_libs/gs_types.h +++ b/src/gs_libs/gs_types.h @@ -9,6 +9,7 @@ # pragma GCC diagnostic ignored "-Wunused-value" # pragma GCC diagnostic ignored "-Wvarargs" # pragma GCC diagnostic ignored "-Wwritable-strings" +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif #if defined(_MSC_VER)