Skip to content

Commit

Permalink
Merge branch 'master' into unmountsamples
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmas12 authored Sep 22, 2021
2 parents 6296f79 + f2c634f commit d4171ea
Show file tree
Hide file tree
Showing 141 changed files with 2,059 additions and 20,716 deletions.
5 changes: 2 additions & 3 deletions .ci_build_samples.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ else
NUMCORES=$(nproc)
fi

cd samples
for dir in */
for dir in samples/*/
do
cd "$dir"
make -j${NUMCORES}
cd ..
cd ../..
done
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ tools/cg/mac
tools/cg/win
lib/sdl/SDL2/test
lib/libcxx/test
samples/
22 changes: 19 additions & 3 deletions .github/workflows/build_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,28 @@ jobs:
if: github.repository_owner == 'XboxDev'
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
image-name: [nxdk, nxdk-debug, nxdk-lto]
include:
- image-name: nxdk
build-args: buildparams=CFLAGS=-O2 CXXFLAGS=-O2
- image-name: nxdk-debug
build-args: buildparams=DEBUG=y
- image-name: nxdk-lto
build-args: buildparams=LTO=y CFLAGS=-O2 CXXFLAGS=-O2
steps:
- name: Clone Tree
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: recursive
- name: Generate timestamp
id: timestamp
run: echo ::set-output name=timestamp::$(date --rfc-3339=seconds --utc)
- name: Generate tags
id: tags
run: |
DOCKER_IMAGE=xboxdev/nxdk
DOCKER_IMAGE=xboxdev/${{ matrix.image-name }}
TAGS="${DOCKER_IMAGE}:latest"
TAGS="$TAGS,${DOCKER_IMAGE}:git-${GITHUB_SHA::8}"
TAGS="$TAGS,ghcr.io/${DOCKER_IMAGE}:latest"
Expand All @@ -43,6 +55,10 @@ jobs:
with:
context: .
file: ./Dockerfile
build-args: ${{ matrix.build-args }}
platforms: linux/amd64,linux/386
push: true
tags: ${{ steps.tags.outputs.tags }}
labels: |
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ steps.timestamp.outputs.timestamp }}
53 changes: 34 additions & 19 deletions .github/workflows/build_samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,87 @@ jobs:
name: Docker
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
image-name: [nxdk, nxdk-debug, nxdk-lto]
include:
- image-name: nxdk
build-args: buildparams=CFLAGS=-O2 CXXFLAGS=-O2
- image-name: nxdk-debug
build-args: buildparams=DEBUG=y
- image-name: nxdk-lto
build-args: buildparams=LTO=y CFLAGS=-O2 CXXFLAGS=-O2
steps:
- name: Clone Tree
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: recursive
- name: Build Docker image
run: |
docker build -t nxdk ./
docker build --build-arg buildparams="${{ matrix.build-args }}" -t ${{ matrix.image-name }} ./
- name: Test Docker image
run: |
docker run nxdk sh -c "cd /usr/src/nxdk && sh ./.ci_build_samples.sh"
cd samples
for dir in */
do
cd "$dir"
docker run --rm -v `pwd`:/usr/src/app -t ${{ matrix.image-name }} make -j`nproc`
cd ..
done
windows:
name: Windows
runs-on: windows-latest
timeout-minutes: 20
env:
POWERSHELL_TELEMETRY_OPTOUT: 1
steps:
- name: Clone Tree
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: recursive
- name: Install MSYS2 & Dependencies
run: |
echo "Downloading MSYS2 environment..."
Invoke-WebRequest -Uri "https://github.com/XboxDev/nxdk-ci-environment-msys2/releases/latest/download/msys64.7z" -OutFile "msys64.7z"
curl -fLO "https://github.com/XboxDev/nxdk-ci-environment-msys2/releases/latest/download/msys64.7z"
echo "Extracting MSYS2 environment..."
7z x -y msys64.7z "-oC:\tools\"
echo "Updating MSYS2 environment..."
C:\tools\msys64\usr\bin\bash.exe -lc "pacman -Syu --noconfirm"
C:\tools\msys64\usr\bin\bash.exe -elc "pacman -Syu --noconfirm"
- name: Build
env:
MSYS2_ARCH: x86_64
MSYSTEM: MINGW64
run: C:\tools\msys64\usr\bin\bash.exe -lc "cd $(cygpath $env:GITHUB_WORKSPACE) && ./.ci_build_samples.sh"
run: C:\tools\msys64\usr\bin\bash.exe -elc "cd $(cygpath $env:GITHUB_WORKSPACE) && ./.ci_build_samples.sh"
macos:
name: macOS
runs-on: macOS-latest
timeout-minutes: 20
steps:
- name: Clone Tree
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: recursive
- name: Install Dependencies
env:
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
export HOMEBREW_NO_INSTALL_CLEANUP=1
brew doctor || true
brew update-reset && brew install llvm
- name: Build
run: sh ./.ci_build_samples.sh
run: ./.ci_build_samples.sh
ubuntu:
name: Ubuntu
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone Tree
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: recursive
- name: Install Dependencies
run: |
sudo apt-get update -y && sudo apt-get install -y flex bison clang lld
sudo apt-get -y update
sudo apt-get -y install llvm lld
- name: Build
run: |
export PATH=$PATH:/usr/lib/llvm-6.0/bin
sh ./.ci_build_samples.sh
run: ./.ci_build_samples.sh
13 changes: 8 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
path = lib/pdclib
url = https://github.com/XboxDev/nxdk-pdclib.git
branch = nxdk
[submodule "lib/sdl/SDL_ttf"]
path = lib/sdl/SDL_ttf
url = https://github.com/SDL-mirror/SDL_ttf
[submodule "lib/libcxx"]
path = lib/libcxx
url = https://github.com/XboxDev/nxdk-libcxx.git
Expand All @@ -28,6 +25,12 @@
[submodule "lib/libjpeg/libjpeg-turbo"]
path = lib/libjpeg/libjpeg-turbo
url = https://github.com/libjpeg-turbo/libjpeg-turbo.git
[submodule "lib/sdl/SDL_image"]
[submodule "lib/sdl/SDL_ttf"]
path = lib/sdl/SDL_ttf
url = https://github.com/libsdl-org/SDL_ttf.git
[submodule "lib/sdl/SDL2_image"]
path = lib/sdl/SDL2_image
url = https://github.com/SDL-mirror/SDL_image.git
url = https://github.com/libsdl-org/SDL_image.git
[submodule "lib/usb/libusbohci"]
path = lib/usb/libusbohci
url = https://github.com/XboxDev/libusbohci.git
16 changes: 15 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
FROM ghcr.io/xboxdev/nxdk-buildbase:git-39eb90d1
FROM ghcr.io/xboxdev/nxdk-buildbase:git-2c3115b1 AS builder

COPY ./ /usr/src/nxdk/
ENV NXDK_DIR=/usr/src/nxdk
RUN cd /usr/src/nxdk && make tools -j`nproc`
ARG buildparams
RUN cd /usr/src/nxdk && make NXDK_ONLY=y $buildparams -j`nproc`


FROM ghcr.io/xboxdev/nxdk-runbase:git-2c3115b1

COPY --from=builder /usr/src/nxdk/ /usr/src/nxdk/
ENV NXDK_DIR=/usr/src/nxdk

WORKDIR /usr/src/app

LABEL org.opencontainers.image.documentation='https://github.com/XboxDev/nxdk/wiki'
LABEL org.opencontainers.image.licenses='(Apache-2.0 AND BSD-3-Clause AND CC0-1.0 AND GPL-2.0-or-later AND LGPL-2.1-or-later AND MIT)'
LABEL org.opencontainers.image.source='https://github.com/XboxDev/nxdk.git'
LABEL org.opencontainers.image.url='https://github.com/XboxDev/nxdk.git'
LABEL org.opencontainers.image.vendor='XboxDev'
35 changes: 24 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ ifeq ($(OUTPUT_DIR),)
OUTPUT_DIR = bin
endif

ifeq ($(NXDK_STACKSIZE),)
NXDK_STACKSIZE = 65536
endif

UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)

Expand Down Expand Up @@ -58,17 +54,16 @@ TOOLS = cxbe vp20compiler fp20compiler extract-xiso
NXDK_CFLAGS = -target i386-pc-win32 -march=pentium3 \
-ffreestanding -nostdlib -fno-builtin \
-I$(NXDK_DIR)/lib -I$(NXDK_DIR)/lib/xboxrt/libc_extensions \
-I$(NXDK_DIR)/lib/hal \
-isystem $(NXDK_DIR)/lib/pdclib/include \
-I$(NXDK_DIR)/lib/pdclib/platform/xbox/include \
-I$(NXDK_DIR)/lib/winapi \
-I$(NXDK_DIR)/lib/xboxrt/vcruntime \
-Wno-ignored-attributes -DNXDK -D__STDC__=1
-DNXDK -D__STDC__=1
NXDK_ASFLAGS = -target i386-pc-win32 -march=pentium3 \
-nostdlib -I$(NXDK_DIR)/lib -I$(NXDK_DIR)/lib/xboxrt
NXDK_CXXFLAGS = -I$(NXDK_DIR)/lib/libcxx/include $(NXDK_CFLAGS) -fno-exceptions
NXDK_LDFLAGS = -subsystem:windows -fixed -base:0x00010000 -entry:XboxCRTEntry \
-stack:$(NXDK_STACKSIZE) -safeseh:no -include:__fltused -include:__xlibc_check_stack
NXDK_LDFLAGS = -subsystem:windows -fixed -base:0x00010000 \
-stack:65536 -merge:.edata=.edataxb

ifeq ($(DEBUG),y)
NXDK_ASFLAGS += -g -gdwarf-4
Expand All @@ -77,10 +72,23 @@ NXDK_CXXFLAGS += -g -gdwarf-4
NXDK_LDFLAGS += -debug
endif

ifeq ($(LTO),y)
NXDK_ASFLAGS += -flto
NXDK_CFLAGS += -flto
NXDK_CXXFLAGS += -flto
endif

ifneq ($(GEN_XISO),)
TARGET += $(GEN_XISO)
endif

ifneq ($(NXDK_ONLY),)
NXDK_CXX = y
NXDK_NET = y
NXDK_SDL = y
TARGET = main.exe
endif

all: $(TARGET)

include $(NXDK_DIR)/lib/Makefile
Expand Down Expand Up @@ -123,26 +131,31 @@ $(OUTPUT_DIR):
ifneq ($(GEN_XISO),)
$(GEN_XISO): $(OUTPUT_DIR)/default.xbe $(EXTRACT_XISO)
@echo "[ XISO ] $@"
$(VE) $(EXTRACT_XISO) -c $(OUTPUT_DIR) $(XISO_FLAGS) $@ $(QUIET)
$(VE) $(EXTRACT_XISO) -c $(OUTPUT_DIR) $(XISO_FLAGS) "$@" $(QUIET)
endif

$(SRCS): $(SHADER_OBJS)

ifneq ($(NXDK_ONLY),)
.PHONY: main.exe
main.exe: $(OBJS)
else
main.exe: $(OBJS) $(NXDK_DIR)/lib/xboxkrnl/libxboxkrnl.lib
@echo "[ LD ] $@"
$(VE) $(LD) $(NXDK_LDFLAGS) $(LDFLAGS) -out:'$@' $^
endif

%.lib:
@echo "[ LIB ] $@"
$(VE) $(LIB) -out:'$@' $^

%.obj: %.cpp
@echo "[ CXX ] $@"
$(VE) $(CXX) $(NXDK_CXXFLAGS) $(CXXFLAGS) -MD -MP -MT '$@' -MF '$(patsubst %.cpp,%.cpp.d,$<)' -c -o '$@' '$<'
$(VE) $(CXX) $(NXDK_CXXFLAGS) $(CXXFLAGS) -MD -MP -MT '$@' -MF '$(patsubst %.obj,%.cpp.d,$@)' -c -o '$@' '$<'

%.obj: %.c
@echo "[ CC ] $@"
$(VE) $(CC) $(NXDK_CFLAGS) $(CFLAGS) -MD -MP -MT '$@' -MF '$(patsubst %.c,%.c.d,$<)' -c -o '$@' '$<'
$(VE) $(CC) $(NXDK_CFLAGS) $(CFLAGS) -MD -MP -MT '$@' -MF '$(patsubst %.obj,%.c.d,$@)' -c -o '$@' '$<'

%.obj: %.s
@echo "[ AS ] $@"
Expand Down
1 change: 0 additions & 1 deletion lib/hal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ HAL_SRCS := \
$(NXDK_DIR)/lib/hal/audio.c \
$(NXDK_DIR)/lib/hal/debug.c \
$(NXDK_DIR)/lib/hal/fileio.c \
$(NXDK_DIR)/lib/hal/input.c \
$(NXDK_DIR)/lib/hal/io.c \
$(NXDK_DIR)/lib/hal/led.c \
$(NXDK_DIR)/lib/hal/video.c \
Expand Down
8 changes: 4 additions & 4 deletions lib/hal/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static BOOLEAN __stdcall ISR(PKINTERRUPT Interrupt, PVOID ServiceContext)
}


void XDumpAudioStatus()
void XDumpAudioStatus(void)
{
volatile AC97_DEVICE *pac97device = &ac97Device;
if (pac97device)
Expand Down Expand Up @@ -196,7 +196,7 @@ void XAudioInit(int sampleSizeInBits, int numChannels, XAudioCallback callback,
pac97device->mmio[0x170>>2] = MmGetPhysicalAddress((void *)spdifAddress);

// default to being silent...
XAudioPause(pac97device);
XAudioPause();

// reset buffer status
analogBufferCount = 0;
Expand All @@ -221,7 +221,7 @@ void XAudioInit(int sampleSizeInBits, int numChannels, XAudioCallback callback,
}

// tell the chip it is OK to play...
void XAudioPlay()
void XAudioPlay(void)
{
AC97_DEVICE *pac97device = &ac97Device;
volatile unsigned char *pb = (unsigned char *)pac97device->mmio;
Expand All @@ -230,7 +230,7 @@ void XAudioPlay()
}

// tell the chip it is paused.
void XAudioPause()
void XAudioPause(void)
{
AC97_DEVICE *pac97device = &ac97Device;
volatile unsigned char *pb = (unsigned char *)pac97device->mmio;
Expand Down
8 changes: 5 additions & 3 deletions lib/hal/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ typedef struct
int numChannels;
} AC97_DEVICE __attribute__ ((aligned (8)));

// note that I currently ignore sampleSizeInBits and numChannels. They
// The XAudio API is only supposed to be used as a backend. Using SDL2 for
// audio playback should be preferred for applications.
// Note that currently `sampleSizeInBits` and `numChannels` are ignored. Both
// are provided to cope with future enhancements. Currently supported samples
// are 16 bit, 2 channels (stereo)
void XAudioInit(int sampleSizeInBits, int numChannels, XAudioCallback callback, void *data);
void XAudioPlay();
void XAudioPause();
void XAudioPlay(void);
void XAudioPause(void);
void XAudioProvideSamples(unsigned char *buffer, unsigned short bufferLength, int isFinal);

#ifdef __cplusplus
Expand Down
8 changes: 4 additions & 4 deletions lib/hal/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void debugPrintNum(int i)
num[8] = n2c((i >> 4) & 0x0F);
num[9] = n2c((i >> 0) & 0x0F);
num[10] = 0;
debugPrint(num);
debugPrint("%s", num);
}

void debugPrintBinary( int num )
Expand All @@ -145,7 +145,7 @@ void debugPrintBinary( int num )
binNum[x++] = ' ';
}
binNum[x] = 0;
debugPrint( binNum );
debugPrint("%s", binNum);
}

void debugPrint(const char *format, ...)
Expand Down Expand Up @@ -260,7 +260,7 @@ void debugPrintHex(const char *buffer, int length)
char tmp[10];
for (int i = 0; i < length; i++)
{
sprintf(tmp, "%02x ", buffer[i]);
debugPrint(tmp);
sprintf(tmp, "%02x ", buffer[i] & 0xFF);
debugPrint("%s", tmp);
}
}
Loading

0 comments on commit d4171ea

Please sign in to comment.