diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6dae18..fdfacc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: env: CC: clang build-macos: - runs-on: macOS-latest + runs-on: macos-latest steps: - uses: actions/checkout@v1 - name: install dependencies @@ -42,29 +42,28 @@ jobs: ./build.sh env: CC: clang - # TODO(#29): build-windows-msvc is broken - # --- - # build-windows-msvc: - # runs-on: windows-2019 - # steps: - # - uses: actions/checkout@v1 - # # this runs vcvarsall for us, so we get the MSVC toolchain in PATH. - # - uses: seanmiddleditch/gha-setup-vsdevenv@master - # - name: Install dependencies - # run: | - # ./setup_dependencies.bat - # - name: build ded - # shell: cmd - # run: | - # ./build_msvc.bat - # - name: Prepare WindowsBinaries artifacts - # shell: cmd - # run: | - # mkdir winbin - # copy /B *.exe winbin - # copy /B *.png winbin - # - name: Upload WindowsBinaries artifacts - # uses: actions/upload-artifact@v2 - # with: - # name: WindowsBinaries - # path: ./winbin/ + build-windows-msvc: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v1 + # this runs vcvarsall for us, so we get the MSVC toolchain in PATH. + - uses: seanmiddleditch/gha-setup-vsdevenv@master + - name: Install dependencies + run: | + ./setup_dependencies.bat + - name: build ded + shell: cmd + run: | + ./build_msvc.bat + - name: Prepare WindowsBinaries artifacts + shell: cmd + run: | + mkdir winbin + copy /B ded.* winbin + copy /B dependencies\SDL2\lib\x64\SDL2.dll winbin + copy /B "dependencies\freetype2\release dll\win64\freetype.dll" winbin + - name: Upload WindowsBinaries artifacts + uses: actions/upload-artifact@v2 + with: + name: WindowsBinaries + path: ./winbin/ diff --git a/.gitignore b/.gitignore index 62061e7..9ce7599 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ te ded SDL2 +dependencies/* *.exe *.obj *.pdb diff --git a/build_msvc.bat b/build_msvc.bat index d3a8774..7d0d036 100644 --- a/build_msvc.bat +++ b/build_msvc.bat @@ -1,12 +1,13 @@ @echo off rem launch this from msvc-enabled console -set CFLAGS=/W4 /WX /std:c11 /wd4996 /wd5105 /FC /TC /Zi /nologo -set INCLUDES=/I dependencies\SDL2\include /I dependencies\GLFW\include /I dependencies\GLEW\include +set CFLAGS=/W4 /WX /std:c11 /wd4996 /wd5105 /wd4459 /wd4267 /wd4244 /wd4200 /wd4090 /wd4702 /FC /TC /Zi /nologo +set INCLUDES=/I dependencies\SDL2\include /I dependencies\GLFW\include /I dependencies\GLEW\include /I dependencies\freetype2\include set LIBS=dependencies\SDL2\lib\x64\SDL2.lib ^ dependencies\SDL2\lib\x64\SDL2main.lib ^ dependencies\GLFW\lib\glfw3.lib ^ dependencies\GLEW\lib\glew32s.lib ^ + "dependencies\freetype2\release dll\win64\freetype.lib" ^ opengl32.lib User32.lib Gdi32.lib Shell32.lib -cl.exe %CFLAGS% %INCLUDES% /Feded src\main.c src\la.c src\editor.c src\file_browser.c src\free_glyph.c src\simple_renderer.c src\common.c /link %LIBS% -SUBSYSTEM:windows +cl.exe %CFLAGS% %INCLUDES% /Feded src\main.c src\la.c src\editor.c src\file_browser.c src\free_glyph.c src\simple_renderer.c src\common.c src\free_glyph.c src\simple_renderer.c src\lexer.c /link %LIBS% -SUBSYSTEM:console diff --git a/setup_dependencies.bat b/setup_dependencies.bat index 9fbc6b8..540cc88 100644 --- a/setup_dependencies.bat +++ b/setup_dependencies.bat @@ -26,3 +26,5 @@ if not exist dependencies\GLEW\include\GL\ mkdir dependencies\GLEW\include\GL\ move glew-2.1.0\include\GL\glew.h dependencies\GLEW\include\GL\glew.h del glew-2.1.0-win32.zip rmdir /s /q glew-2.1.0 + +git clone https://github.com/ubawurinna/freetype-windows-binaries.git dependencies/freetype2 \ No newline at end of file diff --git a/src/common.c b/src/common.c index 46bcfc5..432f35a 100644 --- a/src/common.c +++ b/src/common.c @@ -5,7 +5,8 @@ #ifdef _WIN32 # define MINIRENT_IMPLEMENTATION -# include +# include +# include "minirent.h" #else # include # include @@ -106,7 +107,7 @@ Errno read_entire_file(const char *file_path, String_Builder *sb) sb->items = realloc(sb->items, sb->capacity*sizeof(*sb->items)); assert(sb->items != NULL && "Buy more RAM lol"); } - + memset(sb->items,0,sb->capacity); fread(sb->items, size, 1, f); if (ferror(f)) return_defer(errno); sb->count = size; @@ -133,7 +134,14 @@ Vec4f hex_to_vec4f(uint32_t color) Errno type_of_file(const char *file_path, File_Type *ft) { #ifdef _WIN32 -#error "TODO: type_of_file() is not implemented for Windows" + wchar_t* wString[4096]; + MultiByteToWideChar(CP_ACP, 0, file_path, -1, (LPWSTR)wString, 4096); + DWORD attr = GetFileAttributesW((LPWSTR)wString); + if (attr & FILE_ATTRIBUTE_DIRECTORY) { + *ft = FT_DIRECTORY; + } else { + *ft = FT_REGULAR; + } #else struct stat sb = {0}; if (stat(file_path, &sb) < 0) return errno; diff --git a/src/common.h b/src/common.h index 761b093..f157d94 100644 --- a/src/common.h +++ b/src/common.h @@ -6,6 +6,10 @@ #include #include "./la.h" +#ifdef _WIN32 +# include //currently for isalnum only +#endif // _WIN32 + #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 600 #define FPS 60 diff --git a/src/editor.c b/src/editor.c index 1aaeee7..d7337d4 100644 --- a/src/editor.c +++ b/src/editor.c @@ -323,7 +323,7 @@ void editor_render(SDL_Window *window, Free_Glyph_Atlas *atlas, Simple_Renderer { if (editor->searching) { simple_renderer_set_shader(sr, SHADER_FOR_COLOR); - Vec4f selection_color = vec4f(.10, .10, .25, 1); + Vec4f selection_color = vec4f(.10f, .10f, .25, 1); Vec2f p1 = cursor_pos; Vec2f p2 = p1; free_glyph_atlas_measure_line_sized(editor->atlas, editor->search.items, editor->search.count, &p2);