diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 508fc72..89c2b2a 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -2,42 +2,28 @@ name: Build Check on: pull_request: permissions: - contents: write + contents: read jobs: build: strategy: matrix: platform: [ - {name: "Linux Debug", os: "ubuntu-22.04", ext: "tar.gz", config: "Debug"}, - {name: "Linux Release", os: "ubuntu-24.04", ext: "tar.gz", config: "Release"}, - {name: "Windows Debug", os: "windows-2022", ext: "zip", config: "Debug"}, - {name: "Windows Release", os: "windows-2022", ext: "zip", config: "Release"}, - {name: "macOS Debug", os: "macos-15", ext: "tar.gz", config: "Debug"}, - {name: "macOS Release", os: "macos-15", ext: "tar.gz", config: "Release"} + {name: "Linux Debug", os: "ubuntu-22.04", config: "Debug"}, + {name: "Linux Release", os: "ubuntu-24.04", config: "Release"}, + {name: "Windows Debug", os: "windows-2022", config: "Debug"}, + {name: "Windows Release", os: "windows-2022", config: "Release"}, + {name: "macOS Debug", os: "macos-15", config: "Debug"}, + {name: "macOS Release", os: "macos-15", config: "Release"} ] runs-on: ${{ matrix.platform.os }} name: ${{ matrix.platform.name }} steps: - - uses: actions/checkout@v4 - - name: Install macOS deps - if: runner.os == 'macOS' - run: brew install llvm - - name: Configure - run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.platform.config }} - - name: Build - working-directory: ./build - run: cmake --build . --config ${{ matrix.platform.config }} - - name: Package - shell: bash - run: | - mkdir -p build/install - cmake --install build --config ${{ matrix.platform.config }} --prefix build/install - cd build/install - if [ "${{ matrix.platform.ext }}" = "zip" ]; then - 7z a ../../fsminit-${{ matrix.platform.config }}-${{ matrix.platform.os }}.${{ matrix.platform.ext }} * - else - tar -czf ../../fsminit-${{ matrix.platform.config }}-${{ matrix.platform.os }}.${{ matrix.platform.ext }} . - fi - - uses: softprops/action-gh-release@v2 - with: - files: fsminit-${{ matrix.platform.config }}-${{ matrix.platform.os }}.* + - uses: actions/checkout@v4 + - name: Install macOS deps + if: runner.os == 'macOS' + run: brew install llvm + - name: Configure + run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.platform.config }} + - name: Build + working-directory: ./build + run: cmake --build . --config ${{ matrix.platform.config }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0fc74cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Build directories +build/ +bin/ +out/ +cmake-build-*/ + +# CMake +CMakeFiles/ +CMakeCache.txt +cmake_install.cmake +Makefile +compile_commands.json + +# IDE / editor +.vscode/ +.idea/ +*.swp +*~ + +# Tests +tests/ \ No newline at end of file diff --git a/include/def_type.h b/include/def_type.h index 700dab6..25716cc 100644 --- a/include/def_type.h +++ b/include/def_type.h @@ -3,6 +3,10 @@ #include #include +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + /* ======================= CLI Option Structure ======================= */ @@ -107,9 +111,15 @@ typedef struct FS_TABLES const char *name; } FS_TABLES; -/* ======================= - External Declarations - ======================= */ +typedef struct TABLE_FILE_LIST +{ + char **paths; + size_t count; +} TABLE_FILE_LIST; + + /* ======================= + External Declarations + ======================= */ extern const char *voice_subdirs[]; extern const size_t voice_subdirs_count; diff --git a/include/file_subsystem.h b/include/file_subsystem.h index 5032ad0..0bed0f1 100644 --- a/include/file_subsystem.h +++ b/include/file_subsystem.h @@ -6,4 +6,5 @@ void create_directories(OP *operation); void create_tbl_tables(OP *operation); void create_tbm_tables(OP *operation); void create_static_tables(OP *operation); -bool check_if_mod_structure_exists(const char *base_path); \ No newline at end of file +bool check_if_mod_structure_exists(const char *base_path); +bool path_is_dir(const char *path); \ No newline at end of file diff --git a/src/file_subsystem.c b/src/file_subsystem.c index 89fde7c..9fe23a4 100644 --- a/src/file_subsystem.c +++ b/src/file_subsystem.c @@ -1,4 +1,3 @@ -/* file_subsystem.c */ #include #include #include @@ -147,7 +146,7 @@ const size_t static_tables_count = 1; File & Directory Creation ===================================== */ -static bool path_is_dir(const char *path) +bool path_is_dir(const char *path) { struct stat st; if (stat(path, &st) != 0) diff --git a/src/main.c b/src/main.c index 2341152..9e185b5 100644 --- a/src/main.c +++ b/src/main.c @@ -1,22 +1,40 @@ -/* main.c */ #include #include #include +#include // for va_list / va_start / va_end #include #include #ifdef _WIN32 #include #include + #define isatty _isatty + +// Windows asprintf wrapper +#define asprintf(buf, fmt, ...) _asprintf(buf, fmt, __VA_ARGS__) +static int _asprintf(char **ret, const char *format, ...) +{ + va_list ap; + int size; + va_start(ap, format); + size = vsnprintf(NULL, 0, format, ap); + va_end(ap); + if (size < 0) + return -1; + *ret = malloc(size + 1); + if (!*ret) + return -1; + va_start(ap, format); + size = vsnprintf(*ret, size + 1, format, ap); + va_end(ap); + return size; +} + #else #include #endif -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif - #include "version.h" #include "def_type.h" #include "file_subsystem.h" @@ -91,7 +109,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "%s%sUsage:%s -stdm [-debug] [-dry-run]\n", TEX_BOLD, COL_YELLOW, COL_RESET); else - fprintf(stderr, "%s%sUsage:%s -stdmc <-tbl/-tbm> [prefix] [-debug] [-dry-run]\n", + fprintf(stderr, "%s%sUsage:%s -stdmc <-tbl/-tbm> [prefix] [-bpl] [-debug] [-dry-run]\n", TEX_BOLD, COL_YELLOW, COL_RESET); return 1; } @@ -123,9 +141,18 @@ int main(int argc, char *argv[]) for (int i = start_index; i < argc; ++i) { if (strcmp(argv[i], "-debug") == 0) + { operation.debug = 1; + } else if (strcmp(argv[i], "-dry-run") == 0) + { operation.dry_run = 1; + } + else + { + fprintf(stderr, "Unknown argument: %s\n", argv[i]); + return 1; + } } if (operation.debug)