feat: add MSVC CI; remove Makefile (#9)

Co-authored-by: TaurusXin <i@taurusxin.com>
This commit is contained in:
overwriter 2024-02-08 10:26:53 +08:00 committed by GitHub
parent 8185c430ee
commit 29273ff86f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 55 additions and 66 deletions

View File

@ -1,11 +1,13 @@
name: CI
env:
BUILD_TYPE: Release
BUILD_PATH: build
on:
push:
branches: [ main ]
jobs:
build_on_windows:
build_on_windows_msys2:
runs-on: windows-latest
steps:
@ -22,16 +24,37 @@ jobs:
install: git mingw-w64-ucrt-x86_64-toolchain
- name: Configure build
run: cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -B build
run: cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -B ${{ env.BUILD_PATH }}
- name: Build
run: cmake --build build -j 4
run: cmake --build ${{ env.BUILD_PATH }} -j 4
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Windows amd64 Build
path: build/ncmdump.exe
name: Windows amd64 Build - MinGW
path: ${{ env.BUILD_PATH }}/ncmdump.exe
build_on_windows_msvc:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure build
run: cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -B ${{ env.BUILD_PATH }}
- name: Build
run: cmake --build ${{ env.BUILD_PATH }} -j 4
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Windows amd64 Build - MSVC
path: ${{ env.BUILD_PATH }}/ncmdump.exe
build_on_linux:
runs-on: ubuntu-latest
@ -48,16 +71,16 @@ jobs:
sudo apt-get install -y build-essential cmake
- name: Configure build
run: cmake -DCMAKE_BUILD_TYPE=Release -B build
run: cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -B ${{ env.BUILD_PATH }}
- name: Build
run: cmake --build build -j 4
run: cmake --build ${{ env.BUILD_PATH }} -j 4
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Linux amd64 Build
path: build/ncmdump
path: ${{ env.BUILD_PATH }}/ncmdump
build_on_macos:
runs-on: macos-latest
@ -74,13 +97,13 @@ jobs:
brew install git cmake
- name: Configure build
run: cmake -DCMAKE_BUILD_TYPE=Release -B build
run: cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -B ${{ env.BUILD_PATH }}
- name: Build
run: cmake --build build -j 4
run: cmake --build ${{ env.BUILD_PATH }} -j 4
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: macOS amd64 Build
path: build/ncmdump
path: ${{ env.BUILD_PATH }}/ncmdump

View File

@ -5,7 +5,7 @@ project(ncmdump LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(BUILD_WIN32_STATIC "Build the program statically on Windows" ON)
add_subdirectory(taglib)
FILE(GLOB HEADERS ./*.h)
FILE(GLOB SOURCES ./*.cpp)
@ -13,22 +13,12 @@ add_executable(ncmdump
${HEADERS}
${SOURCES}
)
add_subdirectory(taglib)
target_link_libraries(ncmdump tag)
target_include_directories(ncmdump PRIVATE taglib)
target_include_directories(ncmdump PRIVATE taglib/taglib)
target_include_directories(ncmdump PRIVATE taglib/taglib/toolkit)
target_include_directories(ncmdump PRIVATE taglib/taglib/mpeg/id3v2)
if(WIN32)
if(CMAKE_COMPILER_IS_GNUCXX)
target_link_options(ncmdump PRIVATE -O2 -municode)
if(BUILD_WIN32_STATIC)
target_link_options(ncmdump PRIVATE -static)
endif()
endif()
endif()
include(GNUInstallDirs)
install(TARGETS ncmdump
BUNDLE DESTINATION .

View File

@ -1,24 +0,0 @@
default:
@echo "Please choose a platform: linux, macos-intel, macos-arm64, win32"
@echo "Or use 'make clean' to clean up the build files"
linux:
g++ main.cpp cJSON.cpp aes.cpp ncmcrypt.cpp -o ncmdump -ltag -std=c++17
strip ncmdump
macos-intel:
clang++ main.cpp cJSON.cpp aes.cpp ncmcrypt.cpp -o ncmdump -ltag -std=c++17
strip ncmdump
macos-arm64:export CPATH=/opt/homebrew/include
macos-arm64:export LIBRARY_PATH=/opt/homebrew/lib
macos-arm64:
clang++ main.cpp cJSON.cpp aes.cpp ncmcrypt.cpp -o ncmdump -ltag -std=c++17
strip ncmdump
win32:
g++ main.cpp cJSON.cpp aes.cpp ncmcrypt.cpp -o ncmdump -ltag -Ltaglib/lib -Itaglib/include -static -O -municode -std=c++17
strip ncmdump.exe
clean:
rm -f ncmdump ncmdump.exe

View File

@ -5,7 +5,7 @@
#include <vector>
#include <filesystem>
#ifdef _WIN32
#if defined(_WIN32) && defined(_MSC_VER)
#include <Windows.h>
#endif
@ -47,13 +47,13 @@ void processFilesInFolder(const fs::path& folderPath) {
}
}
#ifdef _WIN32
#if defined(_WIN32) && defined(_MSC_VER)
int wmain(int argc, wchar_t* argv[])
#else
int main(int argc, char **argv)
#endif
{
#ifdef _WIN32
#if defined(_WIN32) && defined(_MSC_VER)
SetConsoleOutputCP(CP_UTF8);
#endif
@ -67,7 +67,7 @@ int main(int argc, char **argv)
bool folderProvided = false;
#ifdef _WIN32
#if defined(_WIN32) && defined(_MSC_VER)
#define COMPARE_STR(s1, s2) (wcscmp(s1, s2) == 0)
#define HELP_SHORT L"-h"
#define HELP_LONG L"--help"
@ -95,7 +95,7 @@ int main(int argc, char **argv)
return 1;
}
} else {
#ifdef _WIN32
#if defined(_WIN32) && defined(_MSC_VER)
int multiByteStrSize = WideCharToMultiByte(CP_UTF8, 0, argv[1], -1, NULL, 0, NULL, NULL);
char *multiByteStr = new char[multiByteStrSize];
WideCharToMultiByte(CP_UTF8, 0, argv[i], -1, multiByteStr, multiByteStrSize, NULL, NULL);