소스 검색

Merge pull request #1 from kolumb/ci

Add CI
Alexey Kutepov 4 년 전
부모
커밋
d4751dc206
4개의 변경된 파일73개의 추가작업 그리고 4개의 파일을 삭제
  1. 56 0
      .github/workflows/ci.yml
  2. 6 1
      .gitignore
  3. 8 0
      build_msvc.bat
  4. 3 3
      main.c

+ 56 - 0
.github/workflows/ci.yml

@@ -0,0 +1,56 @@
+name: CI
+on: [push, pull_request]
+
+jobs:
+  build-linux-gcc:
+    runs-on: ubuntu-18.04
+    steps:
+      - uses: actions/checkout@v1
+      - name: install dependencies
+        run: |
+          sudo apt-get update
+          sudo apt-get install -qq libsdl2-dev
+      - name: build te
+        run: |
+          make
+        env:
+          CC: gcc
+  build-linux-clang:
+    runs-on: ubuntu-18.04
+    steps:
+      - uses: actions/checkout@v1
+      - name: install dependencies
+        run: |
+          sudo apt-get update
+          sudo apt-get install -qq libsdl2-dev
+      - name: build te
+        run: |
+          make
+        env:
+          CC: clang
+  build-macos:
+    runs-on: macOS-latest
+    steps:
+      - uses: actions/checkout@v1
+      - name: install dependencies
+        run: brew install sdl2 pkg-config
+      - name: build te
+        run: |
+          make
+        env:
+          CC: clang
+  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: download sdl2
+        run: |
+          curl -fsSL -o SDL2-devel-2.0.14-VC.zip https://www.libsdl.org/release/SDL2-devel-2.0.14-VC.zip
+          tar -xf SDL2-devel-2.0.14-VC.zip
+          mv SDL2-2.0.14 SDL2
+      - name: build te
+        shell: cmd
+        run: |
+          ./build_msvc.bat

+ 6 - 1
.gitignore

@@ -1 +1,6 @@
-te
+te
+SDL2
+*.exe
+*.obj
+*.pdb
+*.ilk

+ 8 - 0
build_msvc.bat

@@ -0,0 +1,8 @@
+@echo off
+rem launch this from msvc-enabled console
+
+set CFLAGS=/W4 /WX /std:c11 /FC /TC /Zi /nologo
+set INCLUDES=/I SDL2\include
+set LIBS=SDL2\lib\x64\SDL2.lib SDL2\lib\x64\SDL2main.lib Shell32.lib
+
+cl.exe %CFLAGS% %INCLUDES% /Fete main.c la.c /link %LIBS% -SUBSYSTEM:windows

+ 3 - 3
main.c

@@ -86,8 +86,8 @@ Font font_load_from_file(SDL_Renderer *renderer, const char *file_path)
         const size_t col = index % FONT_COLS;
         const size_t row = index / FONT_COLS;
         font.glyph_table[index] = (SDL_Rect) {
-            .x = col * FONT_CHAR_WIDTH,
-            .y = row * FONT_CHAR_HEIGHT,
+            .x = (int) col * FONT_CHAR_WIDTH,
+            .y = (int) row * FONT_CHAR_HEIGHT,
             .w = FONT_CHAR_WIDTH,
             .h = FONT_CHAR_HEIGHT,
         };
@@ -148,7 +148,7 @@ size_t buffer_size = 0;
 void render_cursor(SDL_Renderer *renderer, Uint32 color)
 {
     const SDL_Rect rect = {
-        .x = (int) floorf(buffer_cursor * FONT_CHAR_WIDTH * FONT_SCALE),
+        .x = (int) floorf((float) buffer_cursor * FONT_CHAR_WIDTH * FONT_SCALE),
         .y = 0,
         .w = FONT_CHAR_WIDTH * FONT_SCALE,
         .h = FONT_CHAR_HEIGHT * FONT_SCALE,