Skip to content

Commit

Permalink
Add CI (#8)
Browse files Browse the repository at this point in the history
* ci: add github actions

* ci: fix invocation on linux

* more portable __thiscalls

* ci: unix does not have --verbose?

* ci: install latest cmake

* build: remove hardcoded cross compile settings from cmakelists

* deps: try ezxml without unistd

* ci: fix cmake generation step

* Fix call convention compiler compatibility

* ci: sigh

* build: set C version

* cmake: check if lto is supported

* try to make msvc happy

* hello msvc?

* build: is this how you disable warnings?

* these do not need to be thiscalls

* just cast the pointer

* use __declspec(dllexport) instead of a .def file

* ci: fix build step?

* use ISO C name for _strdup

* fix signed/unsigned mismatch

* Strip dbg_print in release build on msvc

* flip it
  • Loading branch information
goto-bus-stop authored Dec 17, 2019
1 parent 969e96c commit ac39f9c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 12 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI
on: [push]
jobs:
build:
name: Build on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: Prepare release DLL
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -A Win32
- name: Build release DLL
run: cmake --build build --verbose
- name: Make artifact
run: |
mkdir -p artifact
cp build/Debug/aoc-builtin-rms.dll artifact
- uses: actions/upload-artifact@master
with:
name: aoc-builtin-rms
path: artifact

cross-build:
name: Build on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: sudo apt-get update
- name: Install cross compiler
run: sudo apt-get install mingw-w64 cmake
- name: Run CMake
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=`which i686-w64-mingw32-gcc` -DCMAKE_CXX_COMPILER=`which i686-w64-mingw32-g++`
- name: Compile
run: cmake --build build
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ if (IPO_SUPPORTED)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

if (MSVC)
add_compile_options(/ignore:4996)
else()
if (NOT MSVC)
add_compile_options(-m32)
add_compile_options(-Wall)
endif()
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-DNOMINMAX)
add_definitions(-DEZXML_NOMMAP)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
if (NOT CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(-DNDEBUG)
endif()

include_directories(include/)

Expand All @@ -34,7 +35,6 @@ set(SOURCE_FILES
aoc-builtin-rms.c
hook.c
main.c
main.def
)

add_library(aoc-builtin-rms SHARED ${SOURCE_FILES})
Expand Down
2 changes: 1 addition & 1 deletion aoc-builtin-rms.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static void THISCALL(dropdown_add_line_hook, void* dd, int label, int value) {
THISCALL_CALL(aoc_text_add_line, text_panel, label, value);

if (additional_type == -CustomSection) {
for (int i = 0; i < num_custom_sections; i++) {
for (size_t i = 0; i < num_custom_sections; i++) {
THISCALL_CALL(aoc_text_add_line, text_panel, custom_sections[i].name, CustomSection + i);
}
} else if (additional_type >= 0) {
Expand Down
7 changes: 5 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@ static parse_section_result_t parse_section(ezxml_t node) {

const char* ai_symbol_prefix = ezxml_attr(node, "aiSymbolPrefix");
if (ai_symbol_prefix != NULL) {
custom_sections[i].ai_symbol_prefix = strdup(ai_symbol_prefix);
custom_sections[i].ai_symbol_prefix = _strdup(ai_symbol_prefix);
} else {
custom_sections[i].ai_symbol_prefix = NULL;
}

const char* ai_const_prefix = ezxml_attr(node, "aiConstPrefix");
if (ai_const_prefix != NULL) {
custom_sections[i].ai_const_prefix = strdup(ai_const_prefix);
custom_sections[i].ai_const_prefix = _strdup(ai_const_prefix);
} else {
custom_sections[i].ai_const_prefix = NULL;
}
Expand Down Expand Up @@ -330,11 +330,13 @@ static char* read_file(char* filename) {
return config;
}

__declspec(dllexport)
void mmm_load(mmm_mod_info* info) {
info->name = "Custom Builtin RMS";
info->version = AOC_BUILTIN_RMS_VERSION;
}

__declspec(dllexport)
void mmm_after_setup(mmm_mod_info* info) {
dbg_print("init()\n");
const char* mod_name = info->meta->mod_short_name;
Expand Down Expand Up @@ -369,6 +371,7 @@ void mmm_after_setup(mmm_mod_info* info) {
count_custom_maps());
}

__declspec(dllexport)
void mmm_unload(mmm_mod_info* info) {
dbg_print("deinit()\n");
for (size_t i = 0; custom_maps[i].id; i++) {
Expand Down
5 changes: 0 additions & 5 deletions main.def

This file was deleted.

0 comments on commit ac39f9c

Please sign in to comment.