Skip to content

Commit

Permalink
Improve build variant support
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmry committed Jun 29, 2019
1 parent b6422c3 commit c1cf7c9
Show file tree
Hide file tree
Showing 23 changed files with 86 additions and 113 deletions.
27 changes: 3 additions & 24 deletions Tuprules.tup
@@ -1,3 +1,5 @@
.gitignore

GENODE_DIR = $(TUP_CWD)

export NIX_PATH
Expand All @@ -18,30 +20,6 @@ INCLUDES_LIBPORTS += -I$(GENODE_DIR)/repos/libports/include
LIB_DIR = $(GENODE_DIR)/lib
STUB_DIR = $(GENODE_DIR)/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 (@(TUP_ARCH),i386)
CC_MARCH = -march=i686 -m32
LD_MARCH = -melf_i386
endif

ifeq (@(TUP_ARCH),x86_64)
CC_MARCH = -m64 -mcmodel=large
LD_MARCH = -melf_x86_64
endif

BASE_DIR = $(GENODE_DIR)/repos/base
&BASE_DIR = repos/base
&BASE_INCLUDES = repos/base/headers.tup
Expand All @@ -61,6 +39,7 @@ export LD_DIR
export TOOLCHAIN_DIR
SED_PKGCONFIG_FLAGS += -e "s|@LD_DIR@|$LD_DIR|"
SED_PKGCONFIG_FLAGS += -e "s|@TOOLCHAIN_DIR@|$TOOLCHAIN_DIR|"
SED_FLAGS += -e "s|@version@|`git describe --always`|"

!sed_pkgconfig_file = |> ^ SED %B^ \
sed $(SED_PKGCONFIG_FLAGS) $(SED_FLAGS) < %f > %o \
Expand Down
2 changes: 1 addition & 1 deletion repos/base-nova/src/NOVA
Submodule NOVA updated from e56077 to ad0c2b
4 changes: 4 additions & 0 deletions repos/base-nova/src/core/Tupfile
@@ -1,3 +1,5 @@
ifeq (@(BUILD_NOVA),y)

include_rules
GEN_CORE_DIR = $(BASE_DIR)/src/core

Expand Down Expand Up @@ -47,3 +49,5 @@ CXXFLAGS_$(GEN_CORE_DIR)/version.cc += -DGENODE_VERSION=\"`git describe`\"

CORE_OBJ = core-nova.o
include $(BASE_DIR)/src/core/target.tup

endif
4 changes: 4 additions & 0 deletions repos/base-nova/src/lib/base/Tupfile
@@ -1,3 +1,5 @@
ifeq (@(BUILD_NOVA),y)

include_rules
INCLUDES += -I$(BASE_DIR)/src/include

Expand Down Expand Up @@ -38,3 +40,5 @@ SRC_CC += \
: foreach $(SRC_CC) |> !cxx |> {base-obj}

: {base-obj} |> !ar |> base-nova.lib.a

endif
4 changes: 4 additions & 0 deletions repos/base-nova/src/lib/ld/nova/Tupfile
@@ -1,3 +1,5 @@
ifeq (@(BUILD_NOVA),y)

TARGET_NAME = base-nova
include_rules
INCLUDES += -I$(BASE_DIR)/src/include
Expand Down Expand Up @@ -58,3 +60,5 @@ BASE_LIBS += \

: {bin} |> !collect_bin |>
include &(BIN_RULES)

endif
14 changes: 7 additions & 7 deletions repos/base/Tupfile
@@ -1,20 +1,16 @@
include_rules

SED_FLAGS += -e "s|@includedir@|`nix-store --add $(REP_DIR)/include`|"
SED_FLAGS += -e "s|@toolchainincludedir@|`$(CC) -print-file-name=include`|"
SED_FLAGS += -e "s|@lddir@|`nix-store --add $(REP_DIR)/src/ld`|"
SED_FLAGS += -e "s|@toolchainincludedir@|`$(CC) $(CC_MARCH) -print-file-name=include`|"
SED_FLAGS += -e "s|@libgcc@|`$(CC) $(CC_MARCH) -print-file-name=libgcc.a`|"

SED_FLAGS += -e "s|@cc@|$(CC)|"
SED_FLAGS += -e "s|@cxx@|$(CXX)|"
SED_FLAGS += -e "s|@ld@|$(LD)|"
SED_FLAGS += -e "s|@ar@|$(AR)|"
SED_FLAGS += -e "s|@ranlib@|$(RANLIB)|"

SED_FLAGS += -e "s|@version@|`git describe --always`|"

ifeq (@(TUP_ARCH),arm64)
SED_FLAGS += -e 's|@spec_includes@| -I${includedir}/spec/arm_64 -I${includedir}/spec/64bit|'
endif

ifeq (@(TUP_ARCH),i386)
SED_FLAGS += -e 's|@spec_includes@|-I${includedir}/spec/x86_32 -I${includedir}/spec/x86 -I${includedir}/spec/32bit|'
endif
Expand All @@ -23,4 +19,8 @@ ifeq (@(TUP_ARCH),x86_64)
SED_FLAGS += -e 's|@spec_includes@|-I${includedir}/spec/x86_64 -I${includedir}/spec/x86 -I${includedir}/spec/64bit|'
endif

ifeq (@(TUP_ARCH),arm_v8)
SED_FLAGS += -e 's|@spec_includes@| -I${includedir}/spec/arm_64 -I${includedir}/spec/64bit|'
endif

: foreach *.pc.in |> !sed_pkgconfig_file |>
6 changes: 1 addition & 5 deletions repos/base/genode-lib.pc.in
@@ -1,8 +1,4 @@
lddir=@LD_DIR@
toolchaindir=@TOOLCHAIN_DIR@

Name: genode-lib
Description: Flags for linking Genode libraries
Version: @version@
Requires: base
Libs: -shared --eh-frame-hdr -melf_x86_64 -gc-sections -z max-page-size=0x1000 -T ${lddir}/genode_rel.ld --entry=0x0 -l:ldso-startup.lib.a ${toolchaindir}/lib/gcc/x86_64-pc-elf/8.3.0/64/libgcc.a
Libs: -shared --eh-frame-hdr -gc-sections -z max-page-size=0x1000 -T@lddir@/genode_rel.ld --entry=0x0 -l:ldso-startup.lib.a @libgcc@
8 changes: 3 additions & 5 deletions repos/base/genode-prg.pc.in
@@ -1,9 +1,7 @@
lddir=@LD_DIR@
toolchaindir=@TOOLCHAIN_DIR@
ld=${toolchaindir}/bin/genode-x86-ld
lddir=@lddir@

Name: genode-prg
Description: Flags for dynamically-linked Genode programs
URL: https://genode.org/
Version: @SDK_VERSION@
Libs: -melf_x86_64 -gc-sections -z max-page-size=0x1000 --dynamic-list=${lddir}/genode_dyn.dl -nostdlib -Ttext=0x01000000 --dynamic-linker=ld.lib.so --eh-frame-hdr -rpath-link=. -T ${lddir}/genode_dyn.ld -l:ld.lib.so ${toolchaindir}/lib/gcc/x86_64-pc-elf/8.3.0/64/libgcc.a
Version: @version@
Libs: -gc-sections -z max-page-size=0x1000 --dynamic-list=${lddir}/genode_dyn.dl -nostdlib -Ttext=0x01000000 --dynamic-linker=ld.lib.so --eh-frame-hdr -rpath-link=. -T${lddir}/genode_dyn.ld -l:ld.lib.so @libgcc@
5 changes: 5 additions & 0 deletions repos/base/headers.tup
Expand Up @@ -10,4 +10,9 @@ INCLUDES += -I$(BASE_DIR)/include/spec/x86
INCLUDES += -I$(BASE_DIR)/include/spec/64bit
endif

ifeq (@(TUP_ARCH),arm_v8)
INCLUDES += -I$(BASE_DIR)/include/spec/arm_64
INCLUDES += -I$(BASE_DIR)/include/spec/64bit
endif

INCLUDES += -I$(BASE_DIR)/include
8 changes: 0 additions & 8 deletions repos/base/src/lib/base/Tupfile

This file was deleted.

6 changes: 6 additions & 0 deletions repos/base/src/lib/startup/Tupfile
Expand Up @@ -2,8 +2,14 @@ include_rules

: foreach *.cc |> !cxx |> {obj}

ifeq (@(TUP_ARCH),i386)
: foreach spec/x86_32/*.s |> !asm |> {obj}
endif
ifeq (@(TUP_ARCH),x86_64)
: foreach spec/x86_64/*.s |> !asm |> {obj}
endif
ifeq (@(TUP_ARCH),arm_v8)
: foreach spec/arm_64/*.s |> !asm |> {obj}
endif

: {obj} |> !ar |> startup.lib.a $(BASE_DIR)/<base-libs>
1 change: 0 additions & 1 deletion repos/gems/Tupfile
@@ -1,6 +1,5 @@
include_rules

SED_FLAGS += -e "s|@includedir@|`nix-store --add $(REP_DIR)/include`|"
SED_FLAGS += -e "s|@version@|`git describe --always`|"

: *.pc.in |> !sed_pkgconfig_file |>
1 change: 0 additions & 1 deletion repos/libports/Tupfile
@@ -1,4 +1,3 @@
include_rules
SED_FLAGS += -e "s|@includedir@|`nix-store --add include`|"
SED_FLAGS += -e "s|@version@|`git describe --always`|"
: *.pc.in |> !sed_pkgconfig_file |>
20 changes: 20 additions & 0 deletions repos/libports/ports/egl_api.nix
@@ -0,0 +1,20 @@
{ preparePort, fetchFromGitHub }:

preparePort {
name = "egl";
outputs = [ "include" ];

src = fetchFromGitHub {
name = "EGL";
owner = "KhronosGroup";
repo = "EGL-Registry";
rev = "d738c39fe25bab9f65bed2cb78c4db253bd473c4";
sha256 = "1bb2pgv516i1p8x3171yj3gqkxqxqwg7q42ak627md4x3irmqf2q";
};

installPhase = ''
mkdir -p $include
cp -r api/1.? api/EGL api/KHR $include
cp ${../include/EGL/eglplatform.h} $include/EGL/eglplatform.h
'';
}
4 changes: 4 additions & 0 deletions repos/libports/src/lib/egl_api/Tupfile
@@ -0,0 +1,4 @@
include_rules
SED_FLAGS += -e "s|@includedir@|`readlink result-include`|"
: |> nix-build $(REP_DIR)/ports -A egl_api |> result-include
: egl_api.pc.in | result-include |> !sed_pkgconfig_file |>
3 changes: 2 additions & 1 deletion repos/libports/src/lib/egl_api/egl_api.pc.in
@@ -1,5 +1,6 @@
includedir=@includedir@/egl_api
includedir=@includedir@

Name: EGL
Description: EGL API headers
Version: @version@
Cflags: -I${includedir}
50 changes: 0 additions & 50 deletions repos/libports/src/lib/libc/.gitignore

This file was deleted.

5 changes: 5 additions & 0 deletions repos/libports/src/lib/libc/Tupfile
Expand Up @@ -23,6 +23,11 @@ INCLUDES += -Ilibc-include/spec/x86
INCLUDES += -I./include/spec/x86_64
endif

ifeq (@(TUP_ARCH),arm_v8)
INCLUDES += -Ilibc-include/spec/arm_64
INCLUDES += -I./include/spec/arm_64
endif

INCLUDES += -Ilibc-include
INCLUDES += -I./

Expand Down
1 change: 0 additions & 1 deletion repos/os/Tupfile
@@ -1,6 +1,5 @@
include_rules

SED_FLAGS += -e "s|@includedir@|`nix-store --add $(REP_DIR)/include`|"
SED_FLAGS += -e "s|@version@|`git describe --always`|"

: *.pc.in |> !sed_pkgconfig_file |>
8 changes: 0 additions & 8 deletions repos/os/src/drivers/ahci/Tupfile

This file was deleted.

3 changes: 3 additions & 0 deletions repos/os/src/drivers/ahci/Tuprules.tup
@@ -0,0 +1,3 @@
LIBS = base
INCLUDES += -I$(TUP_CWD)
SRC_CC = $(TUP_CWD)/*.cc
14 changes: 14 additions & 0 deletions repos/os/src/drivers/ahci/spec/x86/Tupfile
@@ -0,0 +1,14 @@
ifeq (@(TUP_ARCH),i386)
ARCH = x86
endif
ifeq (@(TUP_ARCH),x86_64)
ARCH = x86
endif
ifeq ($(ARCH),x86)

include_rules

: foreach $(SRC_CC) *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> ahci_drv

endif
1 change: 0 additions & 1 deletion repos/os/src/lib/vfs/Tupfile
Expand Up @@ -5,7 +5,6 @@ include_rules

: $(REP_DIR)/lib/symbols/vfs |> !abi_stub |>

SED_FLAGS += -e "s|@version@|`git describe --always`|"
: vfs.pc.in |> !sed_pkgconfig_file |>

: foreach *.cc |> !cxx |> %B.o {lib-obj}
Expand Down

0 comments on commit c1cf7c9

Please sign in to comment.