Add a master Makefile with docker dev env support and address compiler warning that showed up in the Docker dev env
This commit is contained in:
+3
-1
@@ -1,2 +1,4 @@
|
||||
build
|
||||
build/gba
|
||||
build/debug
|
||||
build/release
|
||||
tags
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ if(NOT MSVC)
|
||||
-fno-rtti
|
||||
-Wsign-compare
|
||||
-Wunused-variable
|
||||
#-Werror
|
||||
-Werror
|
||||
#--analyze
|
||||
#-Os # GCC size optimization flag
|
||||
)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
||||
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${DEVENV} 2>&1),running)
|
||||
ENV_RUN=docker exec --user $(shell id -u ${USER}) ${DEVENV}
|
||||
endif
|
||||
|
||||
make:
|
||||
${ENV_RUN} make -j -C build
|
||||
preinstall:
|
||||
${ENV_RUN} make -j -C build ARGS="preinstall"
|
||||
install:
|
||||
${ENV_RUN} make -j -C build ARGS="install"
|
||||
clean:
|
||||
${ENV_RUN} make -j -C build ARGS="clean"
|
||||
purge:
|
||||
${ENV_RUN} rm -rf $(find build -mindepth 1 -maxdepth 1 -type d)
|
||||
test:
|
||||
${ENV_RUN} make -j -C build ARGS="test"
|
||||
run: make
|
||||
./build/current/src/wombat/wombat -debug
|
||||
debug: make
|
||||
gdb ./build/current/src/wombat/wombat
|
||||
devenv:
|
||||
docker pull wombatant/devenv
|
||||
docker run -d -v $(shell pwd):/usr/src/project \
|
||||
-e LOCAL_USER_ID=$(shell id -u ${USER}) \
|
||||
--name ${DEVENV} -t wombatant/devenv bash
|
||||
devenv-destroy:
|
||||
docker rm -f ${DEVENV}
|
||||
|
||||
native:
|
||||
${ENV_RUN} rm -rf build/release
|
||||
${ENV_RUN} ./scripts/setup_build
|
||||
${ENV_RUN} rm -f build/current
|
||||
${ENV_RUN} ln -s release build/current
|
||||
|
||||
native_debug:
|
||||
${ENV_RUN} rm -rf build/debug
|
||||
${ENV_RUN} ./scripts/setup_build_debug
|
||||
${ENV_RUN} rm -f build/current
|
||||
${ENV_RUN} ln -s debug build/current
|
||||
|
||||
gba:
|
||||
${ENV_RUN} rm -rf build/gba
|
||||
${ENV_RUN} ./scripts/setup_build_gba
|
||||
${ENV_RUN} rm -f build/current
|
||||
${ENV_RUN} ln -s gba build/current
|
||||
@@ -0,0 +1,16 @@
|
||||
all: gba_build native_build native_debug_build
|
||||
|
||||
gba_build:
|
||||
@if [ -d gba ]; then \
|
||||
make -C gba ${ARGS}; \
|
||||
fi
|
||||
|
||||
native_build:
|
||||
@if [ -d release ]; then \
|
||||
make -C release ${ARGS}; \
|
||||
fi
|
||||
|
||||
native_debug_build:
|
||||
@if [ -d debug ]; then \
|
||||
make -C debug ${ARGS}; \
|
||||
fi
|
||||
+27
-25
@@ -179,41 +179,43 @@ int write(int argc, char **args) {
|
||||
if (fsFile) {
|
||||
fseek(fsFile, 0, SEEK_END);
|
||||
|
||||
const auto fsSize = (::size_t) ftell(fsFile);
|
||||
const auto fsSize = (size_t) ftell(fsFile);
|
||||
rewind(fsFile);
|
||||
auto fsBuff = (char*) malloc(fsSize);
|
||||
fread(fsBuff, fsSize, 1, fsFile);
|
||||
auto itemsRead = fread(fsBuff, fsSize, 1, fsFile);
|
||||
fclose(fsFile);
|
||||
|
||||
auto srcBuff = loadFileBuff(srcPath, &srcSize);
|
||||
if (srcBuff) {
|
||||
auto fs = createFileSystem(fsBuff);
|
||||
if (fs) {
|
||||
err |= fs->write(inode, srcBuff, srcSize);
|
||||
if (err) {
|
||||
fprintf(stderr, "Could not write to file system.\n");
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Invalid file system type: %d.\n", *(uint32_t*) fsBuff);
|
||||
err = 1;
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
fsFile = fopen(fsPath, "wb");
|
||||
|
||||
if (fsFile) {
|
||||
err = fwrite(fsBuff, fsSize, 1, fsFile) != 1;
|
||||
err |= fclose(fsFile);
|
||||
if (itemsRead) {
|
||||
auto srcBuff = loadFileBuff(srcPath, &srcSize);
|
||||
if (srcBuff) {
|
||||
auto fs = createFileSystem(fsBuff);
|
||||
if (fs) {
|
||||
err |= fs->write(inode, srcBuff, srcSize);
|
||||
if (err) {
|
||||
fprintf(stderr, "Could not write to file system file.\n");
|
||||
fprintf(stderr, "Could not write to file system.\n");
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Invalid file system type: %d.\n", *(uint32_t*) fsBuff);
|
||||
err = 1;
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
fsFile = fopen(fsPath, "wb");
|
||||
|
||||
if (fsFile) {
|
||||
err = fwrite(fsBuff, fsSize, 1, fsFile) != 1;
|
||||
err |= fclose(fsFile);
|
||||
if (err) {
|
||||
fprintf(stderr, "Could not write to file system file.\n");
|
||||
}
|
||||
} else {
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err = 1;
|
||||
fprintf(stderr, "Could not load source file.\n");
|
||||
}
|
||||
} else {
|
||||
err = 1;
|
||||
fprintf(stderr, "Could not load source file.\n");
|
||||
}
|
||||
|
||||
free(fsBuff);
|
||||
|
||||
Reference in New Issue
Block a user