Compare commits

...

9 Commits
audio ... chuck

Author SHA1 Message Date
Ehmry - 991ccf8215 !WiP ChucK port 2019-07-01 17:09:35 +02:00
Ehmry - 63fd1b60ba fixup! Add Nix port tooling 2019-07-01 15:19:25 +02:00
Ehmry - 2e975e3c16 Update Libretro submodules 2019-07-01 14:02:54 +02:00
Ehmry - 1f67d81ab8 Add Nix port tooling 2019-07-01 13:56:43 +02:00
Ehmry - 43e7b28f4c Tidy ARMv8 config 2019-07-01 13:54:44 +02:00
Ehmry - 1c3c81d85d Add Yabause submodule 2019-06-29 17:09:40 +02:00
Ehmry - 1e8c758030 Build variants 2019-06-29 11:46:02 +02:00
Ehmry - 72908d75c3 Update Libretro submodules 2019-06-29 01:12:20 +02:00
Ehmry - bb46fb3a28 Tup refactor 2019-06-28 23:09:13 +02:00
48 changed files with 2637 additions and 78 deletions

12
.gitignore vendored
View File

@ -1,16 +1,6 @@
/toolchain-*
/sdk-*
/.gitignore
result
/build-*
##### TUP GITIGNORE #####
##### Lines below automatically generated by Tup.
##### Do not edit.
.tup
/.gitignore
/Makefile
/bin-list
/depot
/pkg.sed
/public
/raw-list
/versions.sed

23
.gitmodules vendored
View File

@ -27,22 +27,22 @@
url = https://github.com/libretro/libretro-2048
[submodule "libretro/cores/4do/core"]
path = libretro/cores/4do/upstream
url = https://github.com/libretro/4do-libretro
url = https://github.com/libretro/4do-libretro.git
[submodule "libretro/cores/fceumm/core"]
path = libretro/cores/fceumm/upstream
url = https://github.com/libretro/libretro-fceumm
url = https://github.com/libretro/libretro-fceumm.git
[submodule "libretro/cores/mgba/core"]
path = libretro/cores/mgba/upstream
url = https://github.com/libretro/mgba
url = https://github.com/libretro/mgba.git
[submodule "libretro/cores/nxengine/core"]
path = libretro/cores/nxengine/upstream
url = git://depot.h4ck.me/srv/git/nxengine
[submodule "libretro/cores/oberon/core"]
path = libretro/cores/oberon/upstream
url = https://github.com/pdewacht/oberon-risc-emu.git
url = git@github.com:ehmry/oberon-risc-libretro.git
[submodule "libretro/cores/snes9x/core"]
path = libretro/cores/snes9x/upstream
url = https://github.com/libretro/snes9x
url = git@github.com:ehmry/snes9x.git
[submodule "libretro/cores/tyrquake/core"]
path = libretro/cores/tyrquake/upstream
url = https://github.com/libretro/tyrquake
@ -54,10 +54,10 @@
url = https://github.com/libretro/dosbox-libretro
[submodule "libretro/cores/mrboom/core"]
path = libretro/cores/mrboom/upstream
url = https://github.com/libretro/mrboom-libretro.git
url = git@github.com:ehmry/mrboom-libretro.git
[submodule "libretro/cores/gambatte/core"]
path = libretro/cores/gambatte/upstream
url = https://github.com/libretro/gambatte-libretro
url = git@github.com:github.com/ehmry/gambatte-libretro.git
[submodule "libretro/cores/dinothawr/core"]
path = libretro/cores/dinothawr/core
url = https://github.com/libretro/Dinothawr
@ -69,10 +69,10 @@
url = https://github.com/libretro/scummvm.git
[submodule "libretro/cores/lutro/upstream"]
path = libretro/cores/lutro/upstream
url = https://github.com/libretro/libretro-lutro.git
url = git@github.com:ehmry/libretro-lutro.git
[submodule "libretro/cores/bluemsx/upstream"]
path = libretro/cores/bluemsx/upstream
url = https://github.com/libretro/blueMSX-libretro.git
url = git@github.com:ehmry/blueMSX-libretro.git
[submodule "nimble/fetch_and_copy"]
path = nim/fetch_and_copy
url = git@github.com:ehmry/fetch_and_copy.git
@ -93,7 +93,7 @@
url = https://github.com/meepingsnesroms/Mu.git
[submodule "libretro/cores/dosbox-svn/upstream"]
path = libretro/cores/dosbox-svn/upstream
url = https://github.com/fr500/dosbox-svn
url = https://github.com/libretro/dosbox-svn.git
[submodule "nim/xspf_view"]
path = nim/xspf_view
url = git://depot.h4ck.me/srv/git/xspf_view
@ -103,3 +103,6 @@
[submodule "nim/blobbot"]
path = nim/blobbot
url = git://depot.h4ck.me/srv/git/blobbot
[submodule "libretro/cores/yabause/upstream"]
path = libretro/cores/yabause/upstream
url = https://github.com/libretro/yabause.git

View File

@ -1,8 +1,13 @@
.gitignore
ifndef TOOL_CHAIN_PREFIX
error TOOL_CHAIN_PREFIX not configured, missing variant?
endif
ifeq (@(TUP_ARCH),i386)
CC_MARCH = -march=i686 -m32
LD_MARCH = -melf_i386
AS_MARCH = -march=i686 --32
endif
ifeq (@(TUP_ARCH),x86_64)
@ -10,7 +15,31 @@ CC_MARCH = -m64 -mcmodel=large
LD_MARCH = -melf_x86_64
endif
ifeq (@(TUP_ARCH),arm_v8)
CC_MARCH = -march=armv8-a
endif
GENODE_DIR = $(TUP_CWD)/upstream
STUB_DIR = $(TUP_CWD)/stub
export NIX_PATH
NIX_BUILD = nix-build --option substitute false
&STUB_DIR = upstream/stub
LIBGCC = `$(CC) $(CC_MARCH) -print-libgcc-file-name`
!prg = | $(GENODE_DIR)/<stub> $(GENODE_DIR)/<pkg-config> \
|> ^o LD %o^ \
$(LD) $(LD_MARCH) $(LDFLAGS) \
-L&(STUB_DIR) \
`$(PKG_CONFIG) --libs $(LIBS) genode-prg` \
%f \
$(LIBGCC) \
-o %o \
|>
!lib = | $(GENODE_DIR)/<stub> $(GENODE_DIR)/<pkg-config> |> ^o LD %o^ $(LD) $(LD_MARCH) %f $(LDFLAGS) `$(PKG_CONFIG) --libs genode-lib $(LIBS)` -L&(STUB_DIR) -o %o |>
ifeq ($(RAW_NAME),)
RAW_NAME = $(TARGET_NAME)
@ -51,12 +80,12 @@ BIN_DIR = $(DEPOT_BIN_DIR)/$(BIN_NAME)/current
PKG_DIR = $(DEPOT_BIN_DIR)/$(BIN_NAME)/current
# Destination for locally defined runtime package
!raw = |> ^ COLLECT %o^ \
!raw = |> ^ generate raw metadata^ \
echo $(RAW_DEPENDS) local/raw/$(RAW_NAME)/$(RAW_VERSION) | tr ' ' '\n' > %o; \
echo local/raw/$(RAW_NAME)/$(RAW_VERSION) > %o \
|> $(RAW_DIR)/.ARCHIVES $(DEPOT_DIR)/<raw-archives>
!bin = |> ^ COLLECT %o^ \
!bin = |> ^ generate bin metadata^ \
echo $(BIN_DEPENDS) local/src/$(BIN_NAME)/$(BIN_VERSION) | tr ' ' '\n' > %o; \
|> $(BIN_DIR)/.ARCHIVES $(DEPOT_DIR)/<bin-archives>
# Macro invoked in BIN_RULES
@ -74,12 +103,12 @@ AWK_LOCAL_ARCHIVES = awk -F '/' \
!pkg = |> |>
!collect_raw = |> ^ COLLECT %o^ \
!collect_raw = |> ^ COLLECT %b^ \
cp %f %o \
|> $(RAW_DIR)/%b
!collect_bin = |> ^ COLLECT %o^ \
strip -o %o %f \
!collect_bin = |> ^ COLLECT %b^ \
@(TOOL_CHAIN_PREFIX)strip -o %o %f \
|> $(DEPOT_BIN_DIR)/$(BIN_NAME)/current/%b
!collect_pkg_runtime = | $(VERSIONS_SED_FILE) |> ^ package %f^ \
@ -91,12 +120,12 @@ AWK_LOCAL_ARCHIVES = awk -F '/' \
sed -f $(VERSIONS_SED_FILE) $(DEPOT_PKG_DIR)/$(PKG_NAME)/current/archives \
> $(DEPOT_PKG_DIR)/$(PKG_NAME)/current/.ARCHIVES; \
|> \
$(DEPOT_PKG_DIR)/$(PKG_NAME)/current/runtime \
$(DEPOT_PKG_DIR)/$(PKG_NAME)/current/archives \
$(DEPOT_PKG_DIR)/$(PKG_NAME)/current/.ARCHIVES \
$(DEPOT_PKG_DIR)/$(PKG_NAME)/current/runtime \
$(DEPOT_DIR)/<packages>
!collect_pkg = |> ^ COLLECT %o^ cp %f %o \
!collect_pkg = |> ^ COLLECT %b^ cp %f %o \
|> $(DEPOT_PKG_DIR)/$(PKG_NAME)/current/%b \
$(DEPOT_DIR)/<packages>
@ -112,18 +141,60 @@ SDK_INCLUDE = $(TUP_CWD)/sdk.tup
ERRATA_DIR = $(TUP_CWD)/errata
export PKG_CONFIG_PATH
PKG_CONFIG = PKG_CONFIG_PATH=$(GENODE_DIR)/pkg-config:$PKG_CONFIG_PATH pkg-config
ifndef TOOL_CHAIN_PREFIX
error TOOL_CHAIN_PREFIX not configured
endif
PKG_CONFIG = PKG_CONFIG_PATH=$(GENODE_DIR)/upstream:pkg-config:$PKG_CONFIG_PATH pkg-config
CC = @(TOOL_CHAIN_PREFIX)gcc
CXX = @(TOOL_CHAIN_PREFIX)g++
LD= @(TOOL_CHAIN_PREFIX)ld
AR = @(TOOL_CHAIN_PREFIX)ar
AS = @(TOOL_CHAIN_PREFIX)as
OBJCOPY = @(TOOL_CHAIN_PREFIX)objcopy
!cc = |> ^ CC %f^ $(CC) $(DEFINES) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) -c %f -o %o |>
!cxx = | $(GENODE_DIR)/<pkg-config> |> ^ CC %f^ $(CC) $(DEFINES) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) -c %f -o %o |>
!ld = |> ^ LD %o^ $(LD) $(LDFLAGS) %f -o %o |>
AS_OPT += $(AS_MARCH)
LIBGCC = `$(CC) $(CC_MARCH) -print-libgcc-file-name`
PKG_CONFIG_DIR = $(TUP_CWD)/pkg-config
PKG_CONFIG_PATH = $(PKG_CONFIG_DIR)
PKG_CONFIG = PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config
!asm = |> ^ CC %b^ @(CC_WRAPPER) $(CC) $(DEFINES) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) -D__ASSEMBLY__ $(INCLUDES) -c %f -o %o |> %B.o
!cc = | $(GENODE_DIR)/<pkg-config> |> ^o CC %f^ @(CC_WRAPPER) $(CC) $(DEFINES) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) `$(PKG_CONFIG) --cflags $(LIBS) $(LIBS_CFLAGS)` $(INCLUDES) -c %f -o %o |> %B.o
!cc_port = | $(GENODE_DIR)/<pkg-config> |> ^o CC %o^ @(CC_WRAPPER) $(CC) -c $(DEFINES) $(CFLAGS) $(CFLAGS_%o) $(INCLUDES) `$(PKG_CONFIG) --cflags $(LIBS) $(LIBS_CFLAGS)` -o %o |> %B.o
!cxx = | $(GENODE_DIR)/<pkg-config> |> ^o CXX %b^ @(CC_WRAPPER) $(CXX) $(DEFINES) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) `$(PKG_CONFIG) --cflags $(LIBS)` $(INCLUDES) -c %f -o %o |> %B.o
!cxx_port = | $(GENODE_DIR)/<pkg-config> |> ^o CXX %o^ @(CC_WRAPPER) $(CXX) -c $(DEFINES) $(CXXFLAGS) $(CXXFLAGS_%f) `$(PKG_CONFIG) --cflags $(LIBS)` $(INCLUDES) -o %o |> %B.o
!ld = | $(GENODE_DIR)/<lib> $(GENODE_DIR)/<pkg-config> |> ^o LD %o^ $(LD) $(LDFLAGS) `$(PKG_CONFIG) --libs $(LIBS)` %f -o %o |>
!strip = |> strip -o %o %f |>
&LD_SCRIPT_SO = upstream/repos/base/src/ld/genode_rel.ld
ifeq (@(TUP_ARCH),x86_64)
ASM_SYM_DEPENDENCY = movq \1@GOTPCREL(%rip), %rax
else
ASM_SYM_DEPENDENCY = .long \1
endif
!abi_stub = |> ^ STUB %o^\
sed \
-e "s/^\(\w\+\) D \(\w\+\)\$/.data; .global \1; .type \1,%%object; .size \1,\2; \1:/p" \
-e "s/^\(\w\+\) V/.data; .weak \1; .type \1,%%object; \1:/p" \
-e "s/^\(\w\+\) T/.text; .global \1; .type \1,%%function; \1:/p" \
-e "s/^\(\w\+\) R \(\w\+\)\$/.section .rodata; .global \1; .type \1,%%object; .size \1,\2; \1:/p" \
-e "s/^\(\w\+\) W/.text; .weak \1; .type \1,%%function; \1:/p" \
-e "s/^\(\w\+\) B \(\w\+\)\$/.bss; .global \1; .type \1,%%object; .size \1,\2; \1:/p" \
-e "s/^\(\w\+\) U/.text; .global \1; $(ASM_SYM_DEPENDENCY)/p" \
%f \
| $(CC) -x assembler -c - -o tmp.o; \
$(LD) -o %o \
-shared \
-T &(LD_SCRIPT_SO) \
tmp.o; \
rm tmp.o; \
|> $(STUB_DIR)/%B.lib.so $(GENODE_DIR)/<stub>

View File

@ -1 +0,0 @@
/.gitignore

12
configs/arm_v8.config Normal file
View File

@ -0,0 +1,12 @@
CONFIG_TUP_ARCH=arm64
CONFIG_TOOL_CHAIN_PREFIX=genode-aarch64-
CONFIG_CC_WRAPPER=ccache
CONFIG_CXX_WRAPPER=ccache
CONFIG_OFFLINE=
CONFIG_NO_NETWORK=
CONFIG_SCULPT_VERSION=19.05
CONFIG_PUBLIC_USER=ehmry
CONFIG_PUBLIC_KEY=6E10414EE7160781F5FEE8FFB14D043A26B3D2C7

15
configs/i386.config Normal file
View File

@ -0,0 +1,15 @@
CONFIG_TUP_ARCH=x86_64
CONFIG_x86=
CONFIG_TOOL_CHAIN_PREFIX=genode-x86-
CONFIG_CC_WRAPPER=ccache
CONFIG_CXX_WRAPPER=ccache
CONFIG_OFFLINE=
CONFIG_NO_NETWORK=
CONFIG_BUILD_NOVA=y
CONFIG_SCULPT_VERSION=19.05
CONFIG_PUBLIC_USER=ehmry
CONFIG_PUBLIC_KEY=6E10414EE7160781F5FEE8FFB14D043A26B3D2C7

View File

@ -1,16 +1,15 @@
CONFIG_TUP_ARCH=x86_64
CONFIG_x86=
CONFIG_TOOL_CHAIN_PREFIX=genode-x86-
CONFIG_SCULPT_VERSION=19.05
CONFIG_PKG_CONFIG_PATH=/opt/genode/sdk-19.05/pkgconfig/x86_64
CONFIG_TOOLCHAIN_PATH=/opt/genode/toolchain-19.05/bin
CONFIG_CC_WRAPPER=ccache
CONFIG_CXX_WRAPPER=ccache
#CONFIG_NO_NETWORK=
CONFIG_SKIP_INCOMPATIBLE=
CONFIG_OFFLINE=
CONFIG_BUILD_NOVA=y
CONFIG_SCULPT_VERSION=19.05
CONFIG_PUBLIC_USER=ehmry
CONFIG_PUBLIC_KEY=6E10414EE7160781F5FEE8FFB14D043A26B3D2C7

@ -1 +1 @@
Subproject commit 714a81b5c7c05dc2e2c5956efe04698e1c723056
Subproject commit 8c2b1cf0ccd8ea8a36ae1ed7aa09ae7c2b3dc1cd

View File

@ -5,7 +5,7 @@ PKG_DEPENDS += \
_/src/$(BIN_NAME) \
_/src/retro_frontend \
!libretro_cc = |> ^ CC %f^ \
!libretro_cc = | $(GENODE_DIR)/<pkg-config> |> ^ CC %f^ \
$(CC) \
$(DEFINES) \
`$(PKG_CONFIG) --cflags $(CORE_PKGS)` \
@ -14,7 +14,7 @@ PKG_DEPENDS += \
-c %f -o %o \
|> %f.$(TARGET_NAME).o
!libretro_cxx = |> ^ CXX %f^ \
!libretro_cxx = | $(GENODE_DIR)/<pkg-config> |> ^ CXX %f^ \
$(CXX) \
$(DEFINES) \
`$(PKG_CONFIG) --cflags $(CORE_PKGS)` \
@ -23,15 +23,16 @@ PKG_DEPENDS += \
-c %f -o %o \
|> %f.$(TARGET_NAME).o
!libretro_core_link = |> ^o LD %d^ \
!libretro_core_link = | $(GENODE_DIR)/<pkg-config> $(GENODE_DIR)/<stub> |> ^o LD %d^ \
$(LD) %f -o %o \
-shared --version-script=$(LINK_T) $(NO_UNDEFINED) \
$(LDFLAGS) \
`$(PKG_CONFIG) --libs $(CORE_PKGS)` \
`$(PKG_CONFIG) --libs genode-lib` \
-L$(GENODE_DIR)/stub \
|> libretro.so
LINK_T = $(TUP_CWD)/link.T
DEFINES += -D__LIBRETRO__ -DFRONTEND_SUPPORTS_RGB565
DEFINES += -fPIC -D__LIBRETRO__ -DFRONTEND_SUPPORTS_RGB565
DEFINES += -DGIT_VERSION=\"$(GIT_VERSION)\"
NO_UNDEFINED = --no-undefined

@ -1 +1 @@
Subproject commit 386d7d9114234475221e72d2cdfdb8ee74d987eb
Subproject commit 4e1bdaaed021b0f6587c61f18de081bc3876f887

@ -1 +1 @@
Subproject commit 9f88b26c77c93e4f2f0254ec6d20b29b4c49610e
Subproject commit 5fd9a1fb1dc2ae259f9f0edd7fce1549465f4fe9

@ -1 +1 @@
Subproject commit a9ed4a40cfe0b607f753d444fa633240b716c886
Subproject commit ceab569d88da6846bc632a79961fb30b1aa8c186

@ -1 +1 @@
Subproject commit 03c7fac5b733d5eb7f2de59929b840333a4c553c
Subproject commit 22c7ae749b9b46fb0343d8f25238db62ca6156ef

@ -1 +1 @@
Subproject commit 5dfb5f2a2d1a56c6240dfdc60212be479b9ce5c3
Subproject commit 148b9f7301db2aebfc3b9190526ebde43eba170b

@ -1 +1 @@
Subproject commit 94909c68720719f87fdd68fa02df3c72c2a8b179
Subproject commit 41aa3d5ecaab3c4dc68be3857af89c36053b02c6

View File

@ -84,7 +84,7 @@ endif
ifeq ($(TARGET_NAME),testgl_compute_shaders)
CORE_PKGS += mesa
CFLAGS += -Igl -DNDEBUG -fPIC -DHAVE_ZIP_DEFLATE
CFLAGS += -Igl -DNDEBUG -DHAVE_ZIP_DEFLATE
SOURCES_CXX += libretro/libretro.cpp
SOURCES_CXX += gl/*.cpp
SOURCES_CXX += app/boxes.cpp

@ -1 +1 @@
Subproject commit fd6547e86fae1bd35606f19ddc8caa00596d509d
Subproject commit 32aa98eeaad66cc3318d6e821a7a83de75603831

@ -1 +1 @@
Subproject commit a07fbf660e29be2db9f6f9b051514dfd546cef26
Subproject commit 5c2e090566e2ac31428570beed71149fce4f3e22

@ -1 +1 @@
Subproject commit 627c96be59e4abc9f26bfd0e65a18a973205f886
Subproject commit d058fb7e58137d92f148f1b81a8b2eb147090aab

View File

@ -0,0 +1,29 @@
CORE_PKGS += libc libm
# TODO: enable dynamic recompiler
include upstream/libretro/Makefile.common
CFLAGS += $(INCFLAGS)
CFLAGS += -DSIZEOF_DOUBLE=8
CFLAGS += -DUSE_16BPP=1
CFLAGS += -DUSE_RGB_565=1
CFLAGS += -DUSE_SCSP2=1
CFLAGS += -DNO_CLI
CFLAGS += -DHAVE_SYS_TIME_H
CFLAGS += -DHAVE_GETTIMEOFDAY
CFLAGS += -DVERSION=\"0.9.12\"
CFLAGS += -DHAVE_STRCASECMP
CFLAGS += -DINLINE="inline"
CFLAGS += -O3 -DNDEBUG
: foreach $(C68KEXEC_SOURCE) |> !libretro_cc -O0 -DNDEBUG |> %B.o {obj}
: foreach $(SOURCES_C) |> !libretro_cc |> {obj}
: {obj} |> !libretro_core_link |> {core}
: {core} |> !collect_bin |>
: |> !bin |>
: $(TUP_CWD)/runtime |> !collect_pkg_runtime |>
: |> !pkg |>

View File

@ -0,0 +1,45 @@
<runtime ram="64M" caps="128" binary="retro_frontend">
<requires>
<audio_out/>
<file_system/>
<nitpicker/>
<rm/>
</requires>
<content>
<rom label="ld.lib.so"/>
<rom label="libc.lib.so"/>
<rom label="libm.lib.so"/>
<rom label="libretro.so"/>
<rom label="retro_frontend"/>
<rom label="vfs.lib.so"/>
</content>
<config>
<libc stdout="/dev/log" stderr="/dev/log"/>
<game/>
<vfs>
<fs/>
<dir name="dev"> <log label="core"/> </dir>
</vfs>
<default-controller port="0" device="1">
<map from="KEY_LEFT" to="LEFT"/>
<map from="KEY_RIGHT" to="RIGHT"/>
<map from="KEY_UP" to="UP"/>
<map from="KEY_DOWN" to="DOWN"/>
<map from="KEY_Z" to="Y"/>
<map from="KEY_X" to="B"/>
<map from="KEY_C" to="A"/>
<map from="KEY_A" to="X"/>
<map from="KEY_S" to="L"/>
<map from="KEY_D" to="R"/>
<map from="KEY_ENTER" to="START"/>
<map from="KEY_RIGHTSHIFT" to="SELECT"/>
</default-controller>
</config>
</runtime>

@ -0,0 +1 @@
Subproject commit 7bb35b865af74282d69f4ecc35ce3a1e0f2d0099

View File

@ -20,6 +20,6 @@ PKG_DEPENDS += \
: runtime |> !collect_pkg_runtime |>
include &RAW_RULES)
include &(RAW_RULES)
endif

@ -1 +1 @@
Subproject commit 855c69a8917e9ea0013819dbaee8ac0d12b5a469
Subproject commit 7437ccc0fb92c8177a980b8b45e2a3e995f98f8c

@ -1 +1 @@
Subproject commit 8cff8361ac42b15a93be2c6d97d01c05be8d6f74
Subproject commit 90e1d41b851cb812ab841344a21c4e61f5ff4232

0
pkg-config/.keep Normal file
View File

39
ports/chuck/Tupfile Normal file
View File

@ -0,0 +1,39 @@
TARGET_NAME = chuck
LIBS += sndfile stdcxx libc posix
LEX=flex
YACC=bison
include_rules
SOURCE_LINK = port-source
# : |> $(NIX_BUILD) .. --out-link port --attr %d.source |> $(SOURCE_LINK) {port}
: |> ln -s /home/repo/chuck/src %o |> $(SOURCE_LINK) {port}
DEFINES += \
-D__PLATFORM_GENODE__ \
-D__GENODE_AUDIO__ \
-D__DISABLE_MIDI__ \
-DCPU_IS_LITTLE_ENDIAN=1 \
-D__CK_SNDFILE_NATIVE__ \
-DHAVE_SYS_SOCKET_H \
-DHAVE_POLL \
-Dloff_t=off_t \
-DPATH_MAX=1024 \
-DHAVE_UNISTD_H \
-DMAX_PATH=1024 \
INCLUDES += -I.
INCLUDES += -I$(SOURCE_LINK)/core
: $(SOURCE_LINK) |> \
$(YACC) -dv -b chuck %f/core/chuck.y \
|> chuck.output chuck.tab.c chuck.tab.h {port}
run ./port_rules.sh $(SOURCE_LINK) core.files
run ./port_rules.sh $(SOURCE_LINK) host.files
LDFLAGS += -L$(STUB_DIR)
: {obj} |> !prg |> %d {bin}
: {bin} |> !collect_bin |>
include &(BIN_RULES)

133
ports/chuck/core.files Normal file
View File

@ -0,0 +1,133 @@
core/ugen_osc.cpp
core/chuck_symbol.h
core/util_buffers.cpp
core/lo/lo_lowlevel.h
core/lo/lo_throw.h
core/lo/blob.c
core/lo/message.c
core/lo/lo_types_internal.h
core/lo/lo_macros.h
core/lo/lo_types.h
core/lo/lo_osc_types.h
core/lo/send.c
core/lo/bundle.c
core/lo/timetag.c
core/lo/lo_errors.h
core/lo/config.h
core/lo/pattern_match.c
core/lo/server_thread.c
core/lo/lo_endian.h
core/lo/address.c
core/lo/lo_internal.h
core/lo/lo.h
core/lo/server.c
core/lo/method.c
core/chuck_utils.cpp
core/chuck_lang.cpp
core/util_network.h
core/util_sndfile.h
core/ulib_regex.cpp
core/chuck_table.h
core/util_opsc.cpp
core/rtmidi.h
core/chuck_frame.cpp
core/ugen_stk.h
core/util_serial.h
core/chuck_ugen.h
core/util_raw.h
core/makefile
core/ulib_machine.cpp
core/chuck_compile.h
core/ulib_opsc.cpp
core/dirent_win32.h
core/chuck_symbol.cpp
core/ulib_math.cpp
core/util_opsc.h
core/chuck_oo.cpp
core/util_math.c
core/util_hid.cpp
core/ulib_math.h
core/chuck_parse.h
core/ugen_xxx.cpp
core/util_thread.h
core/chuck_vm.cpp
core/chuck_errmsg.h
core/chuck_stats.cpp
core/chuck_scan.cpp
core/util_string.h
core/ulib_regex.h
core/util_hid.h
core/ugen_xxx.h
core/rtmidi.cpp
core/uana_extract.cpp
core/chuck_instr.h
core/chuck_otf.cpp
core/chuck_carrier.cpp
core/chuck_dl.h
core/ugen_osc.h
core/chuck_type.h
core/chuck_dl.cpp
core/ugen_filter.cpp
core/makefile.x/makefile.alsa
core/makefile.x/makefile.jack
core/makefile.x/makefile.audicle
core/makefile.x/makefile.rl
core/makefile.x/makefile.osx
core/makefile.x/makefile.pulse
core/makefile.x/makefile.win32
core/util_network.c
core/chuck_emit.h
core/util_console.cpp
core/chuck_win32.c
core/chuck_absyn.cpp
core/chuck_stats.h
core/ugen_stk.cpp
core/ulib_std.cpp
#core/util_console.h
core/chuck.y
core/util_sndfile.c
core/ulib_opsc.h
core/midiio_rtmidi.h
core/chuck_instr.cpp
core/chuck_carrier.h
core/chuck_absyn.h
core/uana_xform.h
core/util_string.cpp
core/util_xforms.h
core/chuck_otf.h
core/util_xforms.c
core/chuck.cpp
core/util_math.h
core/chuck_parse.cpp
core/chuck_errmsg.cpp
core/util_buffers.h
core/chuck.lex
core/chuck_ugen.cpp
core/chuck_oo.h
core/ulib_machine.h
core/midiio_rtmidi.cpp
core/ugen_filter.h
core/chuck_win32.h
core/chuck.h
core/hidio_sdl.cpp
core/chuck_scan.h
core/chuck_table.cpp
core/chuck_shell.h
core/chuck_type.cpp
core/chuck_emit.cpp
core/chuck_def.h
core/uana_extract.h
core/util_serial.cpp
core/ulib_std.h
core/chuck_io.h
core/chuck_frame.h
core/util_thread.cpp
core/chuck_compile.cpp
core/hidio_sdl.h
core/chuck_io.cpp
core/chuck_vm.h
core/chuck_lang.h
core/chuck_shell.cpp
core/chuck_utils.h
core/uana_xform.cpp
core/util_raw.c

22
ports/chuck/default.nix Normal file
View File

@ -0,0 +1,22 @@
{ preparePort, fetchFromGitHub }:
preparePort rec {
name = "chuck";
src = fetchFromGitHub {
owner = "ccrma";
repo = "chuck";
rev = "cedce61a1218bd165dfc6b9e9b32413a89f51014";
sha256 = "1hxxh3rin76mbl2gymcb8z7v7s66vsl92g38s56i8ygcy1gr5lkw";
};
outputs = [ "source" ];
sourceRoot = "source/src";
installPhase =
''
mkdir -p $source
cp -r core host scripts $source
'';
}

4
ports/chuck/host.files Normal file
View File

@ -0,0 +1,4 @@
host/RtAudio/RtAudio.cpp
host/chuck_audio.cpp
host/chuck_console.cpp
host/chuck_main.cpp

16
ports/chuck/port_rules.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
LINK=$1
shift
for LIST in $@
do
grep '[[:alnum:]].*\.c$' ${LIST} | while read f
do
echo ": {port} |> !cc_port ${LINK}/${f} |> ${f}.o {obj}"
done
grep '[[:alnum:]].*\.cpp$' ${LIST} | while read f
do
echo ": {port} |> !cxx_port ${LINK}/${f} |> ${f}.o {obj}"
done
done

28
ports/chuck/regex.files Normal file
View File

@ -0,0 +1,28 @@
core/regex/tre-ast.c
core/regex/tre-match-backtrack.c
core/regex/tre-match-parallel.c
core/regex/tre-mem.c
core/regex/tre-compile.c
core/regex/tre-stack.c
core/regex/tre-internal.h
core/regex/regex.h
core/regex/tre-compile.h
core/regex/tre-filter.h
core/regex/tre-config.h
core/regex/LICENSE.txt
core/regex/xmalloc.h
core/regex/tre-match-approx.c
core/regex/config.h
core/regex/tre-parse.c
core/regex/tre-ast.h
core/regex/tre-match-utils.h
core/regex/regcomp.c
core/regex/tre-parse.h
core/regex/tre-mem.h
core/regex/tre-stack.h
core/regex/tre-filter.c
core/regex/regexec.c
core/regex/regerror.c
core/regex/tre.h
core/regex/README.txt
core/regex/xmalloc.c

23
ports/default.nix Normal file
View File

@ -0,0 +1,23 @@
{ tool ? import ../tool { } }:
let
importPort = path:
let f = (import path);
in f (builtins.intersectAttrs (builtins.functionArgs f) (tool.nixpkgs // tool) );
hasSuffixNix = tool.hasSuffix ".nix";
dir = builtins.readDir ../ports;
in
builtins.listToAttrs (
builtins.filter
(x: x != null)
(map
(name:
if (builtins.getAttr name dir) != "directory" then null else
{ inherit name;
value = importPort (../ports + "/${name}");
}
)
(builtins.attrNames dir)
)
)

9
ports/libsndfile/Tupfile Normal file
View File

@ -0,0 +1,9 @@
include_rules
: |> $(NIX_BUILD) .. --out-link port \
--attr %d.source --attr %d.include |> port-source port-include {port}
: port-source |> cp %f/sndfile.pc %o \
|> $(PKG_CONFIG_DIR)/sndfile.pc $(GENODE_DIR)/<pkg-config>
: sndfile.symbols |> !abi_stub |>

View File

@ -0,0 +1,25 @@
{ preparePort, libsndfile }:
preparePort rec {
inherit (libsndfile) name src;
outputs = [ "source" "include" ];
buildPhase =
''
sed \
-e "s|@includedir@|$include|" \
-e 's/@VERSION@/${(builtins.parseDrvName name).version}/' \
-e 's/^Libs:.*/Libs: -l:sndfile.lib.so/' \
-e '/@/d' \
< sndfile.pc.in > src/sndfile.pc
sed \
-e 's/@TYPEOF_SF_COUNT_T@/size_t/' \
-e 's/@SF_COUNT_MAX@/9223372036854775807/' \
< src/sndfile.h.in > src/sndfile.h
'';
installPhase =
''
cp -rv src $source
mkdir $include
cp src/sndfile.h $include/
'';
}

View File

@ -0,0 +1,316 @@
BitBufferAdvance T
BitBufferByteAlign T
BitBufferGetPosition T
BitBufferInit T
BitBufferPeek T
BitBufferPeekOne T
BitBufferRead T
BitBufferReadOne T
BitBufferReadSmall T
BitBufferReset T
BitBufferRewind T
BitBufferUnpackBERSize T
BitBufferWrite T
Gsm_Coder T
Gsm_Decoder T
Gsm_LPC_Analysis T
Gsm_Long_Term_Predictor T
Gsm_Long_Term_Synthesis_Filtering T
Gsm_Preprocess T
Gsm_RPE_Decoding T
Gsm_RPE_Encoding T
Gsm_Short_Term_Analysis_Filter T
Gsm_Short_Term_Synthesis_Filter T
adpcm_decode T
adpcm_encode T
aiff_caf_find_channel_layout_tag T
aiff_caf_of_channel_layout_tag T
aiff_ima_init T
aiff_open T
alac_decode T
alac_decoder_init T
alac_encode T
alac_encoder_init T
alac_get_desc_chunk_items T
alac_get_magic_cookie T
alac_get_magic_cookie_size T
alac_get_source_format T
alac_init T
alac_set_fastmode T
alaw_init T
append_snprintf T
au_open T
audio_detect T
avr_open T
broadcast_var_alloc T
broadcast_var_get T
broadcast_var_set T
caf_open T
cart_var_alloc T
cart_var_get T
cart_var_set T
copyPredictorTo20 T
copyPredictorTo24 T
copyPredictorTo24Shift T
copyPredictorTo32 T
copyPredictorTo32Shift T
copy_coefs T
dither_init T
double64_be_read T
double64_be_write T
double64_init T
double64_le_read T
double64_le_write T
dwd_open T
dwvw_init T
dyn_comp T
dyn_decomp T
flac_init T
flac_open T
float32_be_read T
float32_be_write T
float32_init T
float32_le_read T
float32_le_write T
g721_decoder T
g721_encoder T
g723_16_decoder T
g723_16_encoder T
g723_24_decoder T
g723_24_encoder T
g723_40_decoder T
g723_40_encoder T
g72x_decode_block T
g72x_encode_block T
g72x_init T
g72x_reader_init T
g72x_writer_init T
gsm610_init T
gsm_A D 16
gsm_B D 16
gsm_DLB D 8
gsm_FAC D 16
gsm_H D 22
gsm_INVA D 16
gsm_L_add T
gsm_L_asl T
gsm_L_asr T
gsm_L_mult T
gsm_L_sub T
gsm_MAC D 16
gsm_MIC D 16
gsm_NRFAC D 16
gsm_QLB D 8
gsm_abs T
gsm_add T
gsm_asl T
gsm_asr T
gsm_create T
gsm_decode T
gsm_destroy T
gsm_div T
gsm_encode T
gsm_init T
gsm_mult T
gsm_mult_r T
gsm_norm T
gsm_option T
gsm_sub T
htk_open T
id3_skip T
ima_oki_adpcm_decode_block T
ima_oki_adpcm_encode_block T
ima_oki_adpcm_init T
init_coefs T
interleave_init T
ircam_open T
kALACEncoderMagic R 4
kDefaultMixBits R 4
kDefaultMixRes R 4
kDefaultNumUV R 4
kMaxBitDepth R 4
kMaxRes R 4
kMaxSampleSize R 4
kMaxUV R 4
kMinUV R 4
macos_guess_file_type T
mat4_open T
mat5_open T
mix16 T
mix20 T
mix24 T
mix32 T
mpc2k_open T
nist_open T
ogg_open T
ogg_opus_open T
ogg_pcm_open T
ogg_speex_open T
ogg_vorbis_open T
paf_open T
pc_block T
pcm_init T
predictor_pole T
predictor_zero T
private_init_state T
psf_allocate T
psf_asciiheader_printf T
psf_binheader_readf T
psf_binheader_writef T
psf_calc_max_all_channels T
psf_calc_signal_max T
psf_close_rsrc T
psf_cues_alloc T
psf_cues_dup T
psf_d2i_array T
psf_d2i_clip_array T
psf_d2s_array T
psf_d2s_clip_array T
psf_decode_frame_count T
psf_default_seek T
psf_f2i_array T
psf_f2i_clip_array T
psf_f2s_array T
psf_f2s_clip_array T
psf_fclose T
psf_fgets T
psf_file_valid T
psf_find_read_chunk_iterator T
psf_find_read_chunk_m32 T
psf_find_read_chunk_str T
psf_fopen T
psf_fread T
psf_fseek T
psf_fsync T
psf_ftell T
psf_ftruncate T
psf_fwrite T
psf_get_chunk_iterator T
psf_get_cues T
psf_get_date_str T
psf_get_filelen T
psf_get_format_info T
psf_get_format_major T
psf_get_format_major_count T
psf_get_format_simple T
psf_get_format_simple_count T
psf_get_format_subtype T
psf_get_format_subtype_count T
psf_get_max_all_channels T
psf_get_signal_max T
psf_get_string T
psf_hexdump T
psf_init_files T
psf_instrument_alloc T
psf_is_pipe T
psf_location_string_count T
psf_log_SF_INFO T
psf_log_printf T
psf_memset T
psf_next_chunk_iterator T
psf_open_file T
psf_open_rsrc T
psf_open_tmpfile T
psf_rand_int32 T
psf_sanitize_string T
psf_save_write_chunk T
psf_set_file T
psf_set_stdio T
psf_set_string T
psf_store_read_chunk_str T
psf_store_read_chunk_u32 T
psf_store_string T
psf_strlcpy_crlf T
psf_use_rsrc T
pvf_open T
quantize T
raw_open T
reconstruct T
rf64_open T
rx2_open T
s_bitwidth_to_subformat T
sd2_open T
sds_open T
set_ag_params T
set_standard_ag_params T
sf_close T
sf_command T
sf_current_byterate T
sf_errno B 4
sf_error T
sf_error_number T
sf_error_str T
sf_format_check T
sf_get_chunk_data T
sf_get_chunk_iterator T
sf_get_chunk_size T
sf_get_string T
sf_next_chunk_iterator T
sf_open T
sf_open_fd T
sf_open_virtual T
sf_perror T
sf_read_double T
sf_read_float T
sf_read_int T
sf_read_raw T
sf_read_short T
sf_readf_double T
sf_readf_float T
sf_readf_int T
sf_readf_short T
sf_seek T
sf_set_chunk T
sf_set_string T
sf_strerror T
sf_version_string T
sf_write_double T
sf_write_float T
sf_write_int T
sf_write_raw T
sf_write_short T
sf_write_sync T
sf_writef_double T
sf_writef_float T
sf_writef_int T
sf_writef_short T
step_size T
str_of_endianness T
str_of_major_format T
str_of_minor_format T
str_of_open_mode T
subformat_to_bytewidth T
svx_open T
txw_open T
u_bitwidth_to_subformat T
ulaw_init T
unmix16 T
unmix20 T
unmix24 T
unmix32 T
unpc_block T
update T
voc_open T
vox_adpcm_init T
w64_open T
wav_open T
wavlike_analyze T
wavlike_format_str T
wavlike_gen_channel_mask T
wavlike_ima_init T
wavlike_msadpcm_init T
wavlike_msadpcm_write_adapt_coeffs T
wavlike_read_bext_chunk T
wavlike_read_cart_chunk T
wavlike_read_fmt_chunk T
wavlike_read_peak_chunk T
wavlike_srate2blocksize T
wavlike_subchunk_parse T
wavlike_write_bext_chunk T
wavlike_write_cart_chunk T
wavlike_write_custom_chunks T
wavlike_write_guid T
wavlike_write_peak_chunk T
wavlike_write_strings T
wve_open T
xi_open T

7
ports/rtaudio/Tupfile Normal file
View File

@ -0,0 +1,7 @@
include_rules
: |> $(NIX_BUILD) .. --out-link port \
--attr %d.source --attr %d.include |> port-source port-include {port}
: port-source |> cp %f/%d.pc %o \
|> $(PKG_CONFIG_DIR)/%d.pc $(GENODE_DIR)/<pkg-config>

25
ports/rtaudio/default.nix Normal file
View File

@ -0,0 +1,25 @@
{ preparePort, rtaudio }:
preparePort rec {
inherit (rtaudio) name version src;
outputs = [ "source" "include" ];
buildPhase =
''
mkdir $source $include
sed \
-e "s|^includedir.*|include=$include|" \
-e 's/@PACKAGE_VERSION@/${version}/' \
-e 's/@req@/stdcxx/' \
-e 's/^Libs:.*/Libs: -l:rtaudio.lib.so/' \
-e '/pthread/d' \
-e 's/@api@/-D__GENODE_AUDIO__/' \
-e '/@/d' \
-e '/prefix/d' \
< rtaudio.pc.in > $source/rtaudio.pc
'';
installPhase =
''
cp -rv RtAudio.cpp rtaudio_c.cpp include $source
cp RtAudio.h rtaudio_c.h $include
'';
}

1
src/Tuprules.tup Normal file
View File

@ -0,0 +1 @@
LDFLAGS += -L$(GENODE_DIR)/stub

View File

@ -1,20 +1,20 @@
TARGET_NAME = show_input
include_rules
PKG_CONFIGS = vfs genode-gems genode-os genode-prg
CXXFLAGS += `$(PKG_CONFIG) -cflags $(PKG_CONFIGS)`
LDFLAGS += `$(PKG_CONFIG) -libs $(PKG_CONFIGS)`
PKG_CONFIGS = vfs genode-gems genode-os genode-base genode-prg
CXXFLAGS += `$(PKG_CONFIG) --cflags $(PKG_CONFIGS)`
LDFLAGS += `$(PKG_CONFIG) --libs $(PKG_CONFIGS)`
: foreach *.cc |> !cxx |> %B.o {objs}
: {objs} |> !ld |> %d {binary}
: {binary} |> !collect_bin |>
include $(BIN_RULES)
include &(BIN_RULES)
PKG_DEPENDS += \
@(PUBLIC_SRC_VFS) \
_/src/$(BIN_NAME) \
: runtime |> !collect_pkg_runtime |>
include $(PKG_RULES)
include &(PKG_RULES)

View File

@ -1,4 +1,4 @@
ifndef SKIP_INCOMPATIBLE
ifdef BUILD_BROKEN
TARGET_NAME = fs_block
include_rules

View File

@ -1,17 +1,14 @@
TARGET_NAME = nic_bus
PKG_DEPENDS += _/src/$(TARGET_NAME)
include_rules
PKGS = genode-os genode-prg
CXXFLAGS += `$(PKG_CONFIG) --cflags $(PKGS)`
LIBS = genode-os genode-prg
: foreach *.cc |> !cxx |> %B.o {objs}
: {objs} |> ^o LD %o^ \
$(LD) `$(PKG_CONFIG) --libs $(PKGS)` %f -o %o |> %d {binary}
: {objs} |> !ld |> %d {binary}
: {binary} |> !collect_bin |>
include $(BIN_RULES)
PKG_DEPENDS += _/src/$(TARGET_NAME)
: runtime |> !collect_pkg_runtime |>
include &(BIN_RULES)
include &(PKG_RULES)

477
tool/default.nix Normal file
View File

@ -0,0 +1,477 @@
/*
* \brief Tools and utility functions
* \author Emery Hemingway
* \date 2014-09-30
*/
{ nixpkgs ? import <nixpkgs> { } }:
with builtins;
rec {
inherit nixpkgs;
inherit (nixpkgs) fetchurl;
##
# Add a prefix to a list of strings.
addPrefix = prefix: map (s: prefix+s);
##
# Determine if any of the following libs are shared.
anyShared = libs:
let h = head libs; in
if libs == [] then false else
if h.shared or false then true else anyShared (tail libs);
##
# Drop a suffix from the end of a string.
dropSuffix = suf: str:
let
strL = stringLength str;
sufL = stringLength suf;
in
if lessThan strL sufL || substring (sub strL sufL) strL str != suf
then abort "${str} does not have suffix ${suf}"
else substring 0 (sub strL sufL) str;
##
# Generate a list of file paths from a directory and
# filenames.
fromDir = dir: map (s: dir+("/"+s));
##
# Utility functions for gathering sources.
fromGlob =
dir: glob:
let
dirName = dir.name or baseNameOf (toString dir);
in
import (shellDerivation {
name = "${dirName}-glob.nix";
script = ./from-glob.sh;
#PATH="${nixpkgs.coreutils}/bin";
inherit dir glob;
});
fromPath = path: [ [ path (baseNameOf (toString path)) ] ];
fromPaths = paths: map (p: [ p (baseNameOf (toString p)) ]) paths;
##
# Filter out libs that are not derivations
filterFakeLibs = libs: filter (lib: hasAttr "shared" lib) libs;
##
# Test if a string ends in '.h'.
hasDotH = s: substring (sub (stringLength s) 2) 2 s == ".h";
hasDotHH = s: substring (sub (stringLength s) 3) 3 s == ".hh";
hasDotHPP = s: substring (sub (stringLength s) 4) 4 s == ".hpp";
##
# Filter out everything but *.h on a path.
# Prevents files that exist alongside headers from changing header path hash.
filterHeaders = dir: filterSource
(path: type: hasDotH path || hasDotHH path || hasDotHPP path || type == "directory")
dir;
##
# Find a filename in a search path.
findFile = fn: searchPath:
if searchPath == [] then []
else
let
sp = head searchPath;
fn' = sp + "/${fn}";
in
if builtins.typeOf fn' != "path" then [] else
if pathExists fn' then
[ { key = fn'; relative = fn; } ]
else findFile fn (tail searchPath);
findIncludes = main: path:
map (x: [ x.key x.relative ]) (genericClosure {
startSet = [ { key = main; relative = baseNameOf (toString main); } ];
operator =
{ key, ... }:
let
includes = import (includesOf key);
includesFound =
nixpkgs.lib.concatMap
(fn: findFile fn ([ (dirOf main) ] ++ path))
includes;
in includesFound;
});
##
# Recursively find libraries.
findLibraries = libs:
let
list = map (lib: { key = lib.name; inherit lib; });
in
map (x: x.lib) (genericClosure {
startSet = list libs;
operator = { key, lib }: list lib.libs or [];
});
##
# Recursively find libraries to link.
findLinkLibraries = libs:
let
list = libs: map
(lib: { key = lib.name; inherit lib; })
(filter (lib: hasAttr "drvPath" lib) libs);
in
map (x: x.lib) (genericClosure {
startSet = list libs;
operator =
{ key, lib }:
if lib.shared then []
else list lib.libs or [];
});
findLocalIncludes = main: path:
let path' = [ (dirOf main) ] ++ path; in
map (x: [ x.key x.relative ]) (genericClosure {
startSet = [ { key = main; relative = baseNameOf (toString main); } ];
operator =
{ key, ... }:
let
includes = import (localIncludesOf key);
includesFound =
nixpkgs.lib.concatMap
(fn: findFile fn path')
includes;
in includesFound;
});
##
# Recursively find shared libraries.
findRuntimeLibraries = libs:
let
filter = libs: builtins.filter (lib: lib.shared) libs;
list = libs:
map (lib: { key = lib.name; inherit lib; }) libs;
in
filter (map (x: x.lib) (genericClosure {
startSet = list libs;
operator =
{ key, lib }:
list ([lib ] ++ lib.libs);
}));
##
# Determine if a string has the given suffix.
hasSuffix = suf: str:
let
strL = stringLength str;
sufL = stringLength suf;
in
if lessThan strL sufL then false else
substring (sub strL sufL) strL str == suf;
includesOf = file:
import (derivation {
name =
if typeOf file == "path"
then "${baseNameOf (toString file)}-includes"
else "includes";
system = currentSystem;
preferLocalBuild = true;
builder = "${nixpkgs.perl}/bin/perl";
args = [ ./find-includes.pl ];
inherit file;
});
##
# Create a bootable ISO.
iso =
{ name, contents, kernel, kernelArgs }:
shellDerivation {
name = "${name}.iso";
script = ./iso.sh;
PATH="${nixpkgs.coreutils}/bin:${nixpkgs.cdrkit}/bin:${nixpkgs.binutils}/bin";
inherit kernel kernelArgs;
inherit (nixpkgs) syslinux cdrkit;
sources = map (x: x.source) contents;
targets = map (x: x.target) contents;
};
##
# Generate a contents list of runtime libraries for a package.
# This will go away as tool.runtime matures.
libContents = contents: builtins.concatLists (map (
content:
map (source: { target = "/"; inherit source; }) content.source.runtime.libs or []
) contents);
localIncludesOf = main: derivation {
name =
if typeOf main == "path"
then "${baseNameOf (toString main)}-local-includes"
else "local-includes";
system = currentSystem;
preferLocalBuild = true;
builder = "${nixpkgs.perl}/bin/perl";
args = [ ./find-local-includes.pl ];
inherit main;
};
##
# Merge an attr between two sets.
mergeAttr =
name: s1: s2:
let
a1 = getAttr name s1;
a2 = getAttr name s2;
type1 = typeOf a1;
type2 = typeOf a2;
in
if type1 == "null" then a2 else if type2 == "null" then a1 else
if type1 != type2 then abort "cannot merge ${name}s of type ${type1} and ${type2}" else
if type1 == "set" then mergeSet a1 a2 else
if type1 == "list" then a1 ++ a2 else
if type1 == "string" then "${a1} ${a2}" else
#if type1 == "int" then add a1 a2 else
abort "cannot merge ${type1} ${name} ${toString a1} ${toString a2}";
##
# Merge two sets together.
mergeSet = s1: s2:
s1 // s2 // (listToAttrs (map
(name: { inherit name; value = mergeAttr name s1 s2; })
(attrNames (intersectAttrs s1 s2))
));
##
# Merge a list of sets.
mergeSets =
sets:
if sets == [] then {} else
mergeSet (head sets) (mergeSets (tail sets));
newDir =
name: contents:
derivation {
inherit name contents;
system = builtins.currentSystem;
preferLocalBuild = true;
builder = shell;
PATH="${nixpkgs.coreutils}/bin";
args = [ "-e" "-c" ''
mkdir -p $out ; \
for i in $contents; do cp -Hr $i $out; done
'' ];
};
##
# Generate a list of paths from a path and a shell glob.
pathsFromGlob = dir: glob:
let path = toString dir; in
import (derivation {
name = "${baseNameOf path}-glob.nix";
args = [ "-e" "-O" "nullglob" ./path-from-glob.sh ];
inherit dir glob path;
preferLocalBuild = true;
});
preparePort = import ./prepare-port { inherit nixpkgs; };
# Concatenate the named attr found in pkgs.
propagate = attrName: pkgs:
let
pkg = head pkgs;
in
if pkgs == [] then [] else
( if hasAttr attrName pkg
then getAttr attrName pkg
else []
) ++
(propagate attrName (tail pkgs));
##
# Replace substring a with substring b in string s.
replaceInString =
a: b: s:
let
al = stringLength a;
bl = stringLength b;
sl = stringLength s;
in
if al == 0 then s else
if sl == 0 then "" else
if ((substring 0 al s) == a) then
b+(replaceInString a b (substring al sl s))
else
(substring 0 1 s) + (replaceInString a b (substring 1 sl s));
shell = nixpkgs.bash + "/bin/sh";
# Save some typing when creating derivation that use our shell.
shellDerivation = { script, ... } @ args:
derivation ( (removeAttrs args [ "script" ]) //
{ system = builtins.currentSystem;
builder = shell;
args = [ "-e" script ];
}
);
singleton = x: [x];
# Bootability is not assured, so its really system image.
systemImage = import ./system-image { inherit nixpkgs; };
bootImage = systemImage; # get rid of this
wildcard =
path: glob:
let
relativePaths = import (shellDerivation {
name = "files.nix";
PATH="${nixpkgs.coreutils}/bin";
script = ./wildcard.sh;
inherit path glob;
});
in
map (rp: (path+"/${rp}")) relativePaths;
# Appends string context from another string
addContextFrom = a: b: substring 0 0 a + b;
# Compares strings not requiring context equality
# Obviously, a workaround but works on all Nix versions
eqStrings = a: b: addContextFrom b a == addContextFrom a b;
##
# Cut a string with a separator and produces a list of strings which were
# separated by this separator. e.g.,
# `splitString "." "foo.bar.baz"' returns ["foo" "bar" "baz"].
# From nixpkgs.
splitString = _sep: _s:
let
sep = addContextFrom _s _sep;
s = addContextFrom _sep _s;
sepLen = stringLength sep;
sLen = stringLength s;
lastSearch = sLen - sepLen;
startWithSep = startAt:
substring startAt sepLen s == sep;
recurse = index: startAt:
let cutUntil = i: [(substring startAt (i - startAt) s)]; in
if index < lastSearch then
if startWithSep index then
let restartAt = index + sepLen; in
cutUntil index ++ recurse restartAt restartAt
else
recurse (index + 1) startAt
else
cutUntil sLen;
in
recurse 0 0;
##
# What I thought builtins.match would do.
matchPattern = pat: str:
concatLists (
map
( l:
let m = match pat l; in
if m == null then [] else m
)
(splitString "\n" str)
);
##
# Generate a set of local ("") and system (<>)
# preprocessor include directives from a file.
relativeIncludes = file:
let
matches = pattern: lines:
concatLists (filter (x: x != null) (map (match pattern) lines));
lines = splitString "\n" (readFile file);
in
{ local = matches ''.*#include\s*"([^>]*)".*'' lines;
system = matches ''.*#include\s*<([^>]*)>.*'' lines;
};
##
# Find a file in a set of directories.
findFile' = key: dirs:
if substring 0 1 key == "!" then builtins.trace "found a !key" key else
if dirs == [] then null else
let abs = (builtins.head dirs) +"/${key}"; in
if builtins.pathExists abs then abs
else findFile' key (builtins.tail dirs);
##
# Generate a set of relative to absolute include mappings from a file.
# This set includes a mapping from the orginal file basename to its
# absolute path.
#
# The genericClosure primative applies an operation to a list of sets that
# contain the attribute 'key'. This operation returns a similar list of sets,
# and genericClosure appends elements of that list that contain a key
# that does not already exist in the previous set. All sets returned by this
# operation contain a function to resolve the relative path at 'key' into an
# absolute one at 'abs', and a function to parse the absolute path at 'abs'
# into a list of relative includes at 'inc'. GenericClosure discards any set
# with a relative path at 'key' that it has already been seen, and thus due
# to lazy evaulation, no relative path is resolved or parsed twice.
#
# A ! is prepended to the files of the initial set, to differentiate them from
# files with unsolved locations and to satisfy the requirement that strings
# not directly reference store paths in findFile'
includesOfFiles = files: searchPath:
let
concat = sets:
if sets == [] then {} else
let x = head sets; in
(if x.abs == null || substring 0 1 x.key == "!" then {} else { "${x.key}" = x.abs; }) // concat (tail sets);
in
concat (genericClosure {
# Can the startSet really be filled with elements sharing a key?
startSet = map (abs: { key = "!${abs}"; inherit abs; inc = includesOf abs; }) files;
operator =
{ key, abs, inc }: if abs == null then [] else let abs' = abs; in
(map
(key: rec { inherit key; abs = (findFile' key searchPath); inc = includesOf abs; })
inc.system)
++
(map
(key: rec { inherit key; abs = (findFile' key (if typeOf abs' == "path" then searchPath ++ [ (dirOf abs') ] else searchPath)); inc = relativeIncludes abs; })
inc.local);
});
##
# Load expressions from a directory path and apply func.
loadExpressions = func: path:
let
dirSet = builtins.readDir path;
default =
if builtins.hasAttr "default.nix" dirSet
then func (import (path + "/default.nix"))
else {};
in
default // (builtins.listToAttrs (builtins.filter (x: x != {}) (map
(name:
let
type = builtins.getAttr name dirSet;
more = loadExpressions func (path + "/${name}");
in
if type == "directory"
then { inherit name; value = more; }
else
if
(type == "regular" || type == "symlink") &&
(hasSuffix ".nix" name)
then
{ name = dropSuffix ".nix" name;
value = func (import (path+"/${name}"));
}
else { }
)
(builtins.attrNames dirSet)
)));
}

View File

@ -0,0 +1,10 @@
export PATH=
for i in $initialPath; do
if [ "$i" = / ]; then i=; fi
PATH=$PATH${PATH:+:}$i/bin
done
mkdir $out
sed -e "s^@initialPath@^$initialPath^g" \
< $setup > $out/setup

View File

@ -0,0 +1,2 @@
source $preparePort/setup
genericBuild

View File

@ -0,0 +1,39 @@
{ nixpkgs }:
let
shell = nixpkgs.bash + "/bin/sh";
initialPath =
[ nixpkgs.coreutils
nixpkgs.findutils
nixpkgs.diffutils
nixpkgs.gawk
nixpkgs.gnugrep
nixpkgs.gnused
nixpkgs.gnutar
nixpkgs.patch
nixpkgs.gzip
nixpkgs.bzip2
nixpkgs.xz
];
in
{ name
, outputs ? [ "out" ]
, preferLocalBuild ? true
, ... } @ attrs:
derivation (attrs // {
inherit name outputs initialPath;
preparePort = derivation {
name = "prepare-port";
system = builtins.currentSystem;
builder = shell;
args = [ "-e" ./builder.sh ];
setup = ./setup.sh;
inherit initialPath;
};
system = builtins.currentSystem;
builder = attrs.realBuilder or shell;
args = attrs.args or [ "-e" (attrs.builder or ./default-builder.sh) ];
})

1221
tool/prepare-port/setup.sh Normal file

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit a7c2ad872dd1f58377d667a37bc85893fab7bdf4
Subproject commit c1cf7c9ad6d43a35b1f28f5f7ebe1472bf293585