feat: add MSVC CI; remove Makefile (#9)
Co-authored-by: TaurusXin <i@taurusxin.com>
This commit is contained in:
parent
8185c430ee
commit
29273ff86f
|
@ -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
|
|
@ -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 .
|
||||
|
|
24
Makefile
24
Makefile
|
@ -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
|
36
main.cpp
36
main.cpp
|
@ -5,7 +5,7 @@
|
|||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
|
@ -47,15 +47,15 @@ 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
|
||||
#endif
|
||||
|
||||
if (argc <= 1) {
|
||||
displayHelp();
|
||||
|
@ -67,17 +67,17 @@ int main(int argc, char **argv)
|
|||
|
||||
bool folderProvided = false;
|
||||
|
||||
#ifdef _WIN32
|
||||
#define COMPARE_STR(s1, s2) (wcscmp(s1, s2) == 0)
|
||||
#define HELP_SHORT L"-h"
|
||||
#define HELP_LONG L"--help"
|
||||
#define FOLDER L"-d"
|
||||
#else
|
||||
#define COMPARE_STR(s1, s2) (strcmp(s1, s2) == 0)
|
||||
#define HELP_SHORT "-h"
|
||||
#define HELP_LONG "--help"
|
||||
#define FOLDER "-d"
|
||||
#endif
|
||||
#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"
|
||||
#define FOLDER L"-d"
|
||||
#else
|
||||
#define COMPARE_STR(s1, s2) (strcmp(s1, s2) == 0)
|
||||
#define HELP_SHORT "-h"
|
||||
#define HELP_LONG "--help"
|
||||
#define FOLDER "-d"
|
||||
#endif
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (COMPARE_STR(argv[i], HELP_SHORT) || COMPARE_STR(argv[i], HELP_LONG)) {
|
||||
|
@ -95,14 +95,14 @@ 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);
|
||||
fs::path path(multiByteStr);
|
||||
#else
|
||||
#else
|
||||
fs::path path(argv[i]);
|
||||
#endif
|
||||
#endif
|
||||
files.push_back(path);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue