Skip to content

Commit 60a5b1b

Browse files
thrimborRyzee119
authored andcommitted
build: Introduce wrapper scripts
1 parent aa0aa27 commit 60a5b1b

File tree

12 files changed

+100
-35
lines changed

12 files changed

+100
-35
lines changed

.ci_build_samples.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22
set -e
33

4+
eval $(./bin/activate -s)
5+
46
if [ $(uname) = 'Darwin' ]; then
57
NUMCORES=$(sysctl -n hw.logicalcpu)
68
else

.github/workflows/build_samples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
HOMEBREW_NO_INSTALL_CLEANUP: 1
7474
run: |
7575
brew doctor || true
76-
brew update-reset && brew install llvm
76+
brew update-reset && brew install llvm coreutils
7777
- name: Build
7878
run: ./.ci_build_samples.sh
7979
ubuntu:

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ COPY ./ /usr/src/nxdk/
44
ENV NXDK_DIR=/usr/src/nxdk
55
RUN cd /usr/src/nxdk && make tools -j`nproc`
66
ARG buildparams
7-
RUN cd /usr/src/nxdk && make NXDK_ONLY=y $buildparams -j`nproc`
7+
RUN eval $(./usr/src/nxdk/bin/activate -s); cd /usr/src/nxdk && make NXDK_ONLY=y $buildparams -j`nproc`
88

99

1010
FROM ghcr.io/xboxdev/nxdk-runbase:git-2c3115b1
@@ -14,6 +14,8 @@ ENV NXDK_DIR=/usr/src/nxdk
1414

1515
WORKDIR /usr/src/app
1616

17+
ENTRYPOINT /usr/src/nxdk/docker_entry.sh
18+
1719
LABEL org.opencontainers.image.documentation='https://github.com/XboxDev/nxdk/wiki'
1820
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)'
1921
LABEL org.opencontainers.image.source='https://github.com/XboxDev/nxdk.git'

Makefile

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,26 @@ endif
1313
UNAME_S := $(shell uname -s)
1414
UNAME_M := $(shell uname -m)
1515

16+
LD = nxdk-link
17+
LIB = nxdk-lib
18+
AS = nxdk-as
19+
CC = nxdk-cc
20+
CXX = nxdk-cxx
21+
1622
ifeq ($(UNAME_S),Linux)
17-
LD = lld -flavor link
18-
LIB = llvm-lib
19-
AS = clang
20-
CC = clang
21-
CXX = clang++
2223
ifneq ($(UNAME_M),x86_64)
2324
CGC = $(NXDK_DIR)/tools/cg/linux/cgc.i386
2425
else
2526
CGC = $(NXDK_DIR)/tools/cg/linux/cgc
2627
endif #UNAME_M != x86_64
2728
endif
2829
ifeq ($(UNAME_S),Darwin)
29-
LD = /usr/local/opt/llvm/bin/lld -flavor link
30-
LIB = /usr/local/opt/llvm/bin/llvm-lib
31-
AS = /usr/local/opt/llvm/bin/clang
32-
CC = /usr/local/opt/llvm/bin/clang
33-
CXX = /usr/local/opt/llvm/bin/clang++
3430
CGC = $(NXDK_DIR)/tools/cg/mac/cgc
3531
endif
3632
ifneq (,$(findstring MSYS_NT,$(UNAME_S)))
3733
$(error Please use a MinGW64 shell)
3834
endif
3935
ifneq (,$(findstring MINGW,$(UNAME_S)))
40-
LD = lld-link
41-
LIB = llvm-lib
42-
AS = clang
43-
CC = clang
44-
CXX = clang++
4536
CGC = $(NXDK_DIR)/tools/cg/win/cgc
4637
endif
4738

@@ -51,19 +42,6 @@ VP20COMPILER = $(NXDK_DIR)/tools/vp20compiler/vp20compiler
5142
FP20COMPILER = $(NXDK_DIR)/tools/fp20compiler/fp20compiler
5243
EXTRACT_XISO = $(NXDK_DIR)/tools/extract-xiso/build/extract-xiso
5344
TOOLS = cxbe vp20compiler fp20compiler extract-xiso
54-
NXDK_CFLAGS = -target i386-pc-win32 -march=pentium3 \
55-
-ffreestanding -nostdlib -fno-builtin \
56-
-I$(NXDK_DIR)/lib -I$(NXDK_DIR)/lib/xboxrt/libc_extensions \
57-
-isystem $(NXDK_DIR)/lib/pdclib/include \
58-
-I$(NXDK_DIR)/lib/pdclib/platform/xbox/include \
59-
-I$(NXDK_DIR)/lib/winapi \
60-
-I$(NXDK_DIR)/lib/xboxrt/vcruntime \
61-
-DNXDK -D__STDC__=1
62-
NXDK_ASFLAGS = -target i386-pc-win32 -march=pentium3 \
63-
-nostdlib -I$(NXDK_DIR)/lib -I$(NXDK_DIR)/lib/xboxrt
64-
NXDK_CXXFLAGS = -I$(NXDK_DIR)/lib/libcxx/include $(NXDK_CFLAGS) -fno-exceptions
65-
NXDK_LDFLAGS = -subsystem:windows -fixed -base:0x00010000 \
66-
-stack:65536 -merge:.edata=.edataxb
6745

6846
ifeq ($(DEBUG),y)
6947
NXDK_ASFLAGS += -g -gdwarf-4

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
nxdk - *the new open source xdk*
22
================================
3-
nxdk is a software development kit for the original Xbox. nxdk is a revitalization of [OpenXDK](https://web.archive.org/web/20170624051336/http://openxdk.sourceforge.net:80/).
3+
nxdk is a software development kit for the original Xbox. nxdk is a revitalization of [OpenXDK](https://web.archive.org/web/20170624051336/http://openxdk.sourceforge.net:80/).
44
It is maintained by the [XboxDev](https://github.com/XboxDev/XboxDev) community.
55

66
Notable features:
@@ -40,13 +40,11 @@ OS-specific instructions for installing these prerequisites can be found in the
4040
git clone --recursive https://github.com/XboxDev/nxdk.git
4141

4242
### Build Samples
43-
Samples are easily built by running the Makefile in one of the sample directories. Details can be found in the [Wiki](https://github.com/XboxDev/nxdk/wiki/Build-a-Sample). nxdk also supports automatic [creation of ISO files](https://github.com/XboxDev/nxdk/wiki/Create-an-XISO).
43+
Samples are easily built by running the activation script `bin/activate`, which will spawn a shell that is fully set up to start using nxdk, and then running the Makefile in one of the sample directories. Details can be found in the [Wiki](https://github.com/XboxDev/nxdk/wiki/Build-a-Sample). nxdk also supports automatic [creation of ISO files](https://github.com/XboxDev/nxdk/wiki/Create-an-XISO).
4444

4545
Next Steps
4646
----------
47-
Copy one of the sample directories to get started. You can copy it anywhere you
48-
like, but make sure that the `NXDK_DIR` variable in the Makefile points to
49-
correct place. Then, in the directory, you can simply run `make`.
47+
Copy one of the sample directories to get started. You can copy it anywhere you like. Run nxdk's activation script `bin/activate`, then, in the directory of your program, you can simply run `make`.
5048

5149
Credits
5250
-------

bin/activate

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env sh
2+
3+
readlink_cmd="readlink"
4+
5+
if [ $(uname -s) = 'Darwin' ]; then
6+
export PATH=/usr/local/opt/llvm/bin/:$PATH
7+
readlink_cmd="greadlink"
8+
fi
9+
10+
export NXDK_DIR="${NXDK_DIR:-$(dirname $(dirname "$(${readlink_cmd} -f "$0")")../)}"
11+
export PATH=${NXDK_DIR}/bin:$PATH
12+
13+
if [ "$1" = "-s" ]; then cat <<- DONE
14+
export NXDK_DIR="$NXDK_DIR";
15+
export PATH="$PATH";
16+
DONE
17+
else
18+
exec "${@:-$SHELL}"
19+
fi

bin/nxdk-as

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env sh
2+
3+
clang \
4+
-target i386-pc-win32 \
5+
-march=pentium3 \
6+
-nostdlib \
7+
-I${NXDK_DIR}/lib \
8+
-I${NXDK_DIR}/lib/xboxrt \
9+
"$@"

bin/nxdk-cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env sh
2+
3+
clang \
4+
-target i386-pc-win32 \
5+
-march=pentium3 \
6+
-fuse-ld=nxdk-link \
7+
-ffreestanding \
8+
-nostdlib \
9+
-fno-builtin \
10+
-I${NXDK_DIR}/lib \
11+
-I${NXDK_DIR}/lib/xboxrt/libc_extensions \
12+
-isystem ${NXDK_DIR}/lib/pdclib/include \
13+
-I${NXDK_DIR}/lib/pdclib/platform/xbox/include \
14+
-I${NXDK_DIR}/lib/winapi \
15+
-I${NXDK_DIR}/lib/xboxrt/vcruntime \
16+
-DNXDK \
17+
-D__STDC__=1 \
18+
"$@"

bin/nxdk-cxx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env sh
2+
3+
clang \
4+
-target i386-pc-win32 \
5+
-march=pentium3 \
6+
-fuse-ld=nxdk-link \
7+
-ffreestanding \
8+
-nostdlib \
9+
-fno-builtin \
10+
-I${NXDK_DIR}/lib/libcxx/include \
11+
-I${NXDK_DIR}/lib \
12+
-I${NXDK_DIR}/lib/xboxrt/libc_extensions \
13+
-isystem ${NXDK_DIR}/lib/pdclib/include \
14+
-I${NXDK_DIR}/lib/pdclib/platform/xbox/include \
15+
-I${NXDK_DIR}/lib/winapi \
16+
-I${NXDK_DIR}/lib/xboxrt/vcruntime \
17+
-DNXDK \
18+
-D__STDC__=1 \
19+
-fno-exceptions \
20+
"$@"

bin/nxdk-lib

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
3+
llvm-lib \
4+
"$@"

0 commit comments

Comments
 (0)