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
|
name: CI
|
||||||
|
env:
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
BUILD_PATH: build
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_on_windows:
|
build_on_windows_msys2:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
@ -22,16 +24,37 @@ jobs:
|
||||||
install: git mingw-w64-ucrt-x86_64-toolchain
|
install: git mingw-w64-ucrt-x86_64-toolchain
|
||||||
|
|
||||||
- name: Configure build
|
- 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
|
- name: Build
|
||||||
run: cmake --build build -j 4
|
run: cmake --build ${{ env.BUILD_PATH }} -j 4
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: Windows amd64 Build
|
name: Windows amd64 Build - MinGW
|
||||||
path: build/ncmdump.exe
|
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:
|
build_on_linux:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -48,16 +71,16 @@ jobs:
|
||||||
sudo apt-get install -y build-essential cmake
|
sudo apt-get install -y build-essential cmake
|
||||||
|
|
||||||
- name: Configure build
|
- 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
|
- name: Build
|
||||||
run: cmake --build build -j 4
|
run: cmake --build ${{ env.BUILD_PATH }} -j 4
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: Linux amd64 Build
|
name: Linux amd64 Build
|
||||||
path: build/ncmdump
|
path: ${{ env.BUILD_PATH }}/ncmdump
|
||||||
|
|
||||||
build_on_macos:
|
build_on_macos:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
@ -74,13 +97,13 @@ jobs:
|
||||||
brew install git cmake
|
brew install git cmake
|
||||||
|
|
||||||
- name: Configure build
|
- 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
|
- name: Build
|
||||||
run: cmake --build build -j 4
|
run: cmake --build ${{ env.BUILD_PATH }} -j 4
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: macOS amd64 Build
|
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 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
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 HEADERS ./*.h)
|
||||||
FILE(GLOB SOURCES ./*.cpp)
|
FILE(GLOB SOURCES ./*.cpp)
|
||||||
|
@ -13,22 +13,12 @@ add_executable(ncmdump
|
||||||
${HEADERS}
|
${HEADERS}
|
||||||
${SOURCES}
|
${SOURCES}
|
||||||
)
|
)
|
||||||
add_subdirectory(taglib)
|
|
||||||
target_link_libraries(ncmdump tag)
|
target_link_libraries(ncmdump tag)
|
||||||
target_include_directories(ncmdump PRIVATE taglib)
|
target_include_directories(ncmdump PRIVATE taglib)
|
||||||
target_include_directories(ncmdump PRIVATE taglib/taglib)
|
target_include_directories(ncmdump PRIVATE taglib/taglib)
|
||||||
target_include_directories(ncmdump PRIVATE taglib/taglib/toolkit)
|
target_include_directories(ncmdump PRIVATE taglib/taglib/toolkit)
|
||||||
target_include_directories(ncmdump PRIVATE taglib/taglib/mpeg/id3v2)
|
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)
|
include(GNUInstallDirs)
|
||||||
install(TARGETS ncmdump
|
install(TARGETS ncmdump
|
||||||
BUNDLE DESTINATION .
|
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 <vector>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) && defined(_MSC_VER)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#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[])
|
int wmain(int argc, wchar_t* argv[])
|
||||||
#else
|
#else
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) && defined(_MSC_VER)
|
||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
displayHelp();
|
displayHelp();
|
||||||
|
@ -67,17 +67,17 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
bool folderProvided = false;
|
bool folderProvided = false;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) && defined(_MSC_VER)
|
||||||
#define COMPARE_STR(s1, s2) (wcscmp(s1, s2) == 0)
|
#define COMPARE_STR(s1, s2) (wcscmp(s1, s2) == 0)
|
||||||
#define HELP_SHORT L"-h"
|
#define HELP_SHORT L"-h"
|
||||||
#define HELP_LONG L"--help"
|
#define HELP_LONG L"--help"
|
||||||
#define FOLDER L"-d"
|
#define FOLDER L"-d"
|
||||||
#else
|
#else
|
||||||
#define COMPARE_STR(s1, s2) (strcmp(s1, s2) == 0)
|
#define COMPARE_STR(s1, s2) (strcmp(s1, s2) == 0)
|
||||||
#define HELP_SHORT "-h"
|
#define HELP_SHORT "-h"
|
||||||
#define HELP_LONG "--help"
|
#define HELP_LONG "--help"
|
||||||
#define FOLDER "-d"
|
#define FOLDER "-d"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
if (COMPARE_STR(argv[i], HELP_SHORT) || COMPARE_STR(argv[i], HELP_LONG)) {
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) && defined(_MSC_VER)
|
||||||
int multiByteStrSize = WideCharToMultiByte(CP_UTF8, 0, argv[1], -1, NULL, 0, NULL, NULL);
|
int multiByteStrSize = WideCharToMultiByte(CP_UTF8, 0, argv[1], -1, NULL, 0, NULL, NULL);
|
||||||
char *multiByteStr = new char[multiByteStrSize];
|
char *multiByteStr = new char[multiByteStrSize];
|
||||||
WideCharToMultiByte(CP_UTF8, 0, argv[i], -1, multiByteStr, multiByteStrSize, NULL, NULL);
|
WideCharToMultiByte(CP_UTF8, 0, argv[i], -1, multiByteStr, multiByteStrSize, NULL, NULL);
|
||||||
fs::path path(multiByteStr);
|
fs::path path(multiByteStr);
|
||||||
#else
|
#else
|
||||||
fs::path path(argv[i]);
|
fs::path path(argv[i]);
|
||||||
#endif
|
#endif
|
||||||
files.push_back(path);
|
files.push_back(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue