Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working build on windows #42

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b4e4d17
Make it build on windows
IRooc Jan 4, 2023
591c05e
ignore all dependencies
IRooc Jan 4, 2023
f9677c8
Merge remote-tracking branch 'tsoding/master'
IRooc Jan 12, 2023
1d0ddea
fix build errors after merge
IRooc Jan 12, 2023
5606151
try to enable windows
IRooc Jan 12, 2023
f49f8ee
remove todo
IRooc Jan 12, 2023
1ab0383
fix build errors
IRooc Jan 12, 2023
7e32a9b
fix warning
IRooc Jan 12, 2023
4ff2e6f
just disable warning sigh
IRooc Jan 12, 2023
907aa75
only ded.* as binaries
IRooc Jan 12, 2023
8e7ca5b
revert change warning is disabled
IRooc Jan 12, 2023
fec693d
add required binaries
IRooc Jan 12, 2023
41d1257
doh! we have capacity....
IRooc Jan 12, 2023
21adf33
Merge remote-tracking branch 'tsoding/master'
IRooc Jan 13, 2023
a0c1997
upgrade runner to new version (old one is deprecated and didn't work …
IRooc Jan 13, 2023
74e9a3c
Merge remote-tracking branch 'tsoding/master'
IRooc Jan 15, 2023
a1223ae
Merge remote-tracking branch 'tsoding/master'
IRooc Jan 17, 2023
863c668
added lexer to build
IRooc Jan 17, 2023
b72a261
Merge remote-tracking branch 'tsoding/master'
IRooc Jan 18, 2023
5edc45a
Merge remote-tracking branch 'tsoding/master'
IRooc Jan 20, 2023
8c0a7d9
Merge remote-tracking branch 'tsoding/master'
IRooc Feb 9, 2023
6559a28
Merge remote-tracking branch 'tsoding/master'
IRooc Feb 9, 2023
fbabd0d
added quick type_of_file implementation
IRooc Feb 9, 2023
3129cfb
Merge remote-tracking branch 'tsoding/master'
IRooc Feb 9, 2023
d87ec3b
Merge remote-tracking branch 'tsoding/master'
IRooc Feb 10, 2023
0d12fad
Merge remote-tracking branch 'tsoding/master'
IRooc Feb 18, 2023
3516c86
add isalnum definition...
IRooc Feb 18, 2023
39a434f
just use ctype
IRooc Feb 18, 2023
3ae8da9
Merge remote-tracking branch 'tsoding/master'
IRooc Mar 12, 2023
0d399fc
float suffix
IRooc Mar 12, 2023
63f3b4e
wierd number thing in c
IRooc Mar 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 26 additions & 27 deletions .github/workflows/ci.yml
Expand Up @@ -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
Expand All @@ -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/
1 change: 1 addition & 0 deletions .gitignore
@@ -1,6 +1,7 @@
te
ded
SDL2
dependencies/*
*.exe
*.obj
*.pdb
Expand Down
7 changes: 4 additions & 3 deletions 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
2 changes: 2 additions & 0 deletions setup_dependencies.bat
Expand Up @@ -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
14 changes: 11 additions & 3 deletions src/common.c
Expand Up @@ -5,7 +5,8 @@

#ifdef _WIN32
# define MINIRENT_IMPLEMENTATION
# include <minirent.h>
# include <assert.h>
# include "minirent.h"
#else
# include <dirent.h>
# include <sys/types.h>
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/common.h
Expand Up @@ -6,6 +6,10 @@
#include <stdint.h>
#include "./la.h"

#ifdef _WIN32
# include <ctype.h> //currently for isalnum only
#endif // _WIN32

#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
#define FPS 60
Expand Down
2 changes: 1 addition & 1 deletion src/editor.c
Expand Up @@ -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);
Expand Down