Compare commits
5 Commits
1f423b1d9b
...
main
Author | SHA1 | Date | |
---|---|---|---|
90b5acd002 | |||
e8fbe275f7 | |||
ae61eef10a | |||
fb1d1697f1 | |||
2f3d8106ea |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,5 @@
|
|||||||
.cache
|
.cache
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
pckr
|
pckr
|
||||||
libpakrd.a
|
libpakrd.so
|
||||||
dist
|
dist
|
||||||
|
55
compile
55
compile
@@ -1,27 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#ESCAPE SEQUENCES
|
|
||||||
CLEAR="\033[0m"
|
|
||||||
BOLD="\033[1"
|
|
||||||
FG_BLACK="\033[30"
|
|
||||||
FG_RED="\033[31"
|
|
||||||
FG_GREEN="\033[32"
|
|
||||||
FG_YELLOW="\033[33"
|
|
||||||
FG_BLUE="\033[34"
|
|
||||||
FG_MAGENTA="\033[35"
|
|
||||||
FG_CYAN="\033[36"
|
|
||||||
FG_WHITE="\033[37"
|
|
||||||
FG_BR_BLACK="\033[90"
|
|
||||||
FG_BR_RED="\033[91"
|
|
||||||
FG_BR_GREEN="\033[92"
|
|
||||||
FG_BR_YELLOW="\033[93"
|
|
||||||
FG_BR_BLUE="\033[94"
|
|
||||||
FG_BR_MAGENTA="\033[95"
|
|
||||||
FG_BR_CYAN="\033[96"
|
|
||||||
FG_BR_WHITE="\033[97"
|
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
AR=ar
|
|
||||||
CFLAGS="-Wall -Werror -pedantic -Iinclude -Iintern/c-cpp-aliases -Iintern/cpath/include "
|
CFLAGS="-Wall -Werror -pedantic -Iinclude -Iintern/c-cpp-aliases -Iintern/cpath/include "
|
||||||
|
|
||||||
PCKR_SRC="\
|
PCKR_SRC="\
|
||||||
@@ -38,7 +17,7 @@ PAKRD_SRC="\
|
|||||||
src/io.c \
|
src/io.c \
|
||||||
src/darr.c \
|
src/darr.c \
|
||||||
src/pak.c"
|
src/pak.c"
|
||||||
PAKRD_FLAGS="-c -fPIC"
|
PAKRD_FLAGS="-fPIC -rdynamic -shared "
|
||||||
|
|
||||||
PCKR_TEST_SRC="\
|
PCKR_TEST_SRC="\
|
||||||
intern/cpath/src/cpath.c \
|
intern/cpath/src/cpath.c \
|
||||||
@@ -74,13 +53,13 @@ done
|
|||||||
if [[ $BUILD_TYPE == "debug" ]]; then
|
if [[ $BUILD_TYPE == "debug" ]]; then
|
||||||
CFLAGS+="-g "
|
CFLAGS+="-g "
|
||||||
PCKR_OUT="pckr"
|
PCKR_OUT="pckr"
|
||||||
PAKRD_OUT="libpakrd.a"
|
PAKRD_OUT="libpakrd.so"
|
||||||
else
|
else
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
cp ./include/pak.h dist
|
cp ./include/pak.h dist
|
||||||
CFLAGS+="-O3 -g "
|
CFLAGS+="-O3 "
|
||||||
PCKR_OUT="dist/pckr"
|
PCKR_OUT="dist/pckr"
|
||||||
PAKRD_OUT="dist/libpakrd.a"
|
PAKRD_OUT="dist/libpakrd.so"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -88,9 +67,8 @@ fi
|
|||||||
(set -x ; $CC $CFLAGS $PCKR_SRC -o $PCKR_OUT)
|
(set -x ; $CC $CFLAGS $PCKR_SRC -o $PCKR_OUT)
|
||||||
|
|
||||||
|
|
||||||
# Build pakrd static library
|
# Build pakrd shared library
|
||||||
(set -x ; $CC $CFLAGS $PAKRD_FLAGS $PAKRD_SRC ; $AR r $PAKRD_OUT *.o)
|
(set -x ; $CC $CFLAGS $PAKRD_FLAGS $PAKRD_SRC -o $PAKRD_OUT)
|
||||||
rm *.o
|
|
||||||
|
|
||||||
|
|
||||||
# Build pckr_test executable
|
# Build pckr_test executable
|
||||||
@@ -105,6 +83,27 @@ rm *.o
|
|||||||
./pckr ./test_assets ./assets
|
./pckr ./test_assets ./assets
|
||||||
|
|
||||||
|
|
||||||
|
#ESCAPE SEQUENCES
|
||||||
|
CLEAR="\033[0m"
|
||||||
|
BOLD="\033[1"
|
||||||
|
FG_BLACK="\033[30"
|
||||||
|
FG_RED="\033[31"
|
||||||
|
FG_GREEN="\033[32"
|
||||||
|
FG_YELLOW="\033[33"
|
||||||
|
FG_BLUE="\033[34"
|
||||||
|
FG_MAGENTA="\033[35"
|
||||||
|
FG_CYAN="\033[36"
|
||||||
|
FG_WHITE="\033[37"
|
||||||
|
FG_BR_BLACK="\033[90"
|
||||||
|
FG_BR_RED="\033[91"
|
||||||
|
FG_BR_GREEN="\033[92"
|
||||||
|
FG_BR_YELLOW="\033[93"
|
||||||
|
FG_BR_BLUE="\033[94"
|
||||||
|
FG_BR_MAGENTA="\033[95"
|
||||||
|
FG_BR_CYAN="\033[96"
|
||||||
|
FG_BR_WHITE="\033[97"
|
||||||
|
|
||||||
|
|
||||||
# Run pckr_test
|
# Run pckr_test
|
||||||
(./$PCKR_TEST_OUT && echo -e "\npckr_test [${FG_BR_GREEN}m${BOLD}m SUCCESS $CLEAR]") || echo -e "\npckr_test [${FG_BR_RED}m${BOLD}m FAILURE $CLEAR]"
|
(./$PCKR_TEST_OUT && echo -e "\npckr_test [${FG_BR_GREEN}m${BOLD}m SUCCESS $CLEAR]") || echo -e "\npckr_test [${FG_BR_RED}m${BOLD}m FAILURE $CLEAR]"
|
||||||
|
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
#ifndef ARGPARSE_H
|
#ifndef ARGPARSE_H
|
||||||
#define ARGPARSE_H
|
#define ARGPARSE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -17,4 +21,8 @@ typedef struct {
|
|||||||
|
|
||||||
argparser_t parse_args(i32 argc, char *argv[]);
|
argparser_t parse_args(i32 argc, char *argv[]);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#endif // !ARGPARSE_H
|
#endif // !ARGPARSE_H
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
#ifndef D_ARR_H
|
#ifndef D_ARR_H
|
||||||
#define D_ARR_H
|
#define D_ARR_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
@@ -13,4 +17,8 @@ i64 darr_add(darr_t **darr, void *item);
|
|||||||
void **darr_get_items(darr_t *darr);
|
void **darr_get_items(darr_t *darr);
|
||||||
void darr_free(darr_t **darr);
|
void darr_free(darr_t **darr);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#endif // !D_ARR_H
|
#endif // !D_ARR_H
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
#ifndef IO_H
|
#ifndef IO_H
|
||||||
#define IO_H
|
#define IO_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -21,4 +25,8 @@ u64 get_file_length(FILE *fp);
|
|||||||
void read_entire_file(void *dst, FILE *fp);
|
void read_entire_file(void *dst, FILE *fp);
|
||||||
dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath);
|
dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#endif // !IO_H
|
#endif // !IO_H
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
#ifndef PAK_H
|
#ifndef PAK_H
|
||||||
#define PAK_H
|
#define PAK_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
@@ -45,4 +49,8 @@ buf_t *read_file_from_pack(asset_pack_t *pack, const char *filename);
|
|||||||
void close_pack_file(buf_t **buf);
|
void close_pack_file(buf_t **buf);
|
||||||
void close_asset_pack(asset_pack_t **pack);
|
void close_asset_pack(asset_pack_t **pack);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#endif // !PAK_H
|
#endif // !PAK_H
|
||||||
|
@@ -1,8 +1,16 @@
|
|||||||
#ifndef PCKR_H
|
#ifndef PCKR_H
|
||||||
#define PCKR_H
|
#define PCKR_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
|
|
||||||
i32 run_pckr(i32 argc, char *argv[]);
|
i32 run_pckr(i32 argc, char *argv[]);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#endif // !PCKR_H
|
#endif // !PCKR_H
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
#ifndef TEST_UTILS_H
|
#ifndef TEST_UTILS_H
|
||||||
#define TEST_UTILS_H
|
#define TEST_UTILS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#define ARRLEN(ARR) (sizeof ARR / sizeof ARR[0])
|
#define ARRLEN(ARR) (sizeof ARR / sizeof ARR[0])
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -8,4 +12,8 @@ typedef struct {
|
|||||||
const char *contents;
|
const char *contents;
|
||||||
} asset_t;
|
} asset_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
#endif // !TEST_UTILS_H
|
#endif // !TEST_UTILS_H
|
||||||
|
Submodule intern/cpath updated: 833ee11a4e...076b1310e3
@@ -128,6 +128,8 @@ asset_pack_t *load_asset_pack(const char *filepath) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset((void *)pack, 0, sizeof(asset_pack_t));
|
||||||
|
|
||||||
pack->fp = fopen(full_path, "rb");
|
pack->fp = fopen(full_path, "rb");
|
||||||
if (!(pack->fp)) {
|
if (!(pack->fp)) {
|
||||||
close_asset_pack(&pack);
|
close_asset_pack(&pack);
|
||||||
|
Reference in New Issue
Block a user