提交 fbae0112 编写于 作者: C Caoruihong

chore: use the patched linux kernel to generate uapi headers

the //kernel/linux-4.19 kernel is not the final codes used to
generate linux kernel image, it is patched before compile.
so we should use the patched kernel source to generate uapi
header files.
Signed-off-by: NCaoruihong <crh.cao@huawei.com>
Change-Id: Id229522e2d10a4960ca010a2742bf2ca4cc9264c
上级 3e0ee082
......@@ -39,29 +39,34 @@ if (ohos_kernel_type == "liteos_a") {
assert(targets != "", "Unsupported ohos_kernel_type: $ohos_kernel_type")
sysroot_path = rebase_path(ohos_current_sysroot)
build_deps = []
if (!defined(board_configed_sysroot) || board_configed_sysroot == "") {
group("empty") {
}
build_ext_component("build_sysroot") {
# deps to this group to mark the target as prebuilts and/or avoid cycle dependencies
group("mark_as_prebuilts") {
}
build_ext_component("build_sysroot") {
deps = [ ":mark_as_prebuilts" ]
if (!defined(board_configed_sysroot) || board_configed_sysroot == "") {
exec_path = rebase_path(target_out_dir)
makefile = rebase_path("Makefile", exec_path)
arch_cflags = string_join(" ", target_arch_cflags)
command = "make TOPDIR=$ohos_root_path SYSROOTDIR=$sysroot_path TARGETS=$targets -f $makefile"
command += " ARCH=$arch TARGET=$target_triple ARCH_CFLAGS=\"$arch_cflags\""
command += " BUILD_DEBUG=false BUILD_ALL_MULTILIB=false CLANG=\"$ohos_current_cc_command\""
# copy standard libraries libc.so and libc++.so to lib out dir
libcpp = "\$($ohos_current_cxx_command --target=$target_triple --sysroot=$sysroot_path $arch_cflags -print-file-name=libc++.so)"
libc = "\$($ohos_current_cc_command --target=$target_triple --sysroot=$sysroot_path $arch_cflags -print-file-name=libc.so)"
lib_out_dir = rebase_path(root_out_dir)+"/libs/"
command += " && mkdir -p $lib_out_dir && sh -c \"cp -f $libcpp $libc $lib_out_dir\""
deps = [ ":empty" ] # we made deps non-empty on purpose
if (ohos_kernel_type == "linux") {
deps += [ "//kernel/linux/patches:linux_kernel" ]
command += " LINUXDIR="+rebase_path("$root_out_dir/kernel/linux-4.19")
command += " PREBUILTLINUXHDRDIR="+rebase_path("//kernel/linux/patches/linux-4.19/prebuilts/usr/include")
}
} else {
command = "echo $board_configed_sysroot"
}
build_deps += [ ":build_sysroot" ]
# copy standard libraries libc.so and libc++.so to lib out dir
libcpp = "\$($ohos_current_cxx_command --target=$target_triple --sysroot=$sysroot_path $arch_cflags -print-file-name=libc++.so)"
libc = "\$($ohos_current_cc_command --target=$target_triple --sysroot=$sysroot_path $arch_cflags -print-file-name=libc.so)"
lib_out_dir = rebase_path("$root_out_dir/libs/")
command += " && mkdir -p $lib_out_dir && sh -c \"cp -f $libcpp $libc $lib_out_dir\""
}
config("sysroot_flags") {
......@@ -72,7 +77,5 @@ config("sysroot_flags") {
group("build") {
all_dependent_configs = [ ":sysroot_flags" ]
if (build_deps != []) {
deps = build_deps
}
deps = [ ":build_sysroot" ]
}
......@@ -103,12 +103,6 @@ linux_header_install_for_liteos_a_user: musl_copy_for_liteos_a_user
$(HIDE) install -p -m 644 -D $@/include/linux/capability.h $</include/linux/capability.h
$(HIDE) echo "$$LINUX_TYPES_H" > $</include/linux/types.h
linux_header_install_for_linux_user: musl_copy_for_linux_user
$(HIDE) make -sj headers_install ARCH=$(ARCH) INSTALL_HDR_PATH=$(shell pwd)/$@ -C $(LINUXDIR)
$(HIDE) find $@ \( -name .install -o -name ..install.cmd \) -delete
$(HIDE) find $@ -type d -empty -delete
$(HIDE) cp -rfp $@/* $</
musl_patch_for_liteos_a_user: nuttx_header_install_for_liteos_a_user
musl_patch_for_liteos_a_user: linux_header_install_for_liteos_a_user
musl_patch_for_liteos_a_user: optimized_routines_install_for_liteos_a_user
......@@ -119,18 +113,6 @@ musl_patch_for_liteos_a_user_debug: musl_patch_for_liteos_a_user
musl_patch_for_liteos_a_user_debug: musl_copy_for_liteos_a_user
$(HIDE) cp -rfp $(MUSLDIR)/porting/liteos_a/user_debug/* $</
musl_patch_for_linux_user: linux_header_install_for_linux_user
musl_patch_for_linux_user: musl_copy_for_linux_user
$(HIDE) cp -rfp $(MUSLDIR)/porting/linux/user/* $</
musl_install_for_linux_user: TARGET = $(ARCH)-linux-ohosmusl
musl_install_for_linux_user: musl_patch_for_linux_user
$(HIDE) cd musl_copy_for_linux_user && mkdir -p $(MUSLBUILDDIR) && cd $(MUSLBUILDDIR) && \
../configure --prefix=/usr --target=$(TARGET) --includedir=/usr/include/$(TARGET) --libdir=/usr/$(MULTILIB) \
CC="$(CC)" CROSS_COMPILE="$(CROSS_COMPILE)" CFLAGS="$(CFLAGS)" >/dev/null && \
sed 's, -m 644 , -m 444 ,g' Makefile | make -f- -sj install-headers install-libs DESTDIR=$(SYSROOTDIR)
$(HIDE) cp -rfp linux_header_install_for_linux_user/include/* $(SYSROOTDIR)/usr/include/$(TARGET)
ifeq ($(BUILD_DEBUG),true)
musl_install_for_liteos_a_user: CFLAGS += -funwind-tables -fasynchronous-unwind-tables -rdynamic -I $(shell $(CC) -print-file-name=)include
musl_install_for_liteos_a_user: LDFLAGS = -L $(dir $(shell $(CC) -print-libgcc-file-name)) -lunwind -L lib -ldl
......@@ -142,7 +124,26 @@ musl_install_for_liteos_a_user: musl_patch_for_liteos_a_user
../configure --prefix=/usr --target=$(TARGET) --includedir=/usr/include/$(TARGET) --libdir=/usr/$(MULTILIB) \
$(if $(LDFLAGS),LDFLAGS="$(LDFLAGS)",) \
CC="$(CC)" CROSS_COMPILE="$(CROSS_COMPILE)" CFLAGS="$(CFLAGS)" >/dev/null && \
sed 's, -m 644 , -m 444 ,g' Makefile | make -f- -sj install-headers install-libs DESTDIR=$(SYSROOTDIR)
make -sj install-headers install-libs DESTDIR=$(SYSROOTDIR)
ifeq ($(wildcard $(PREBUILTLINUXHDRDIR)),)
PREBUILTLINUXHDRDIR = $(shell pwd)/linux_header_install_for_linux_user/include
linux_header_install_for_linux_user:
$(HIDE) make -sj headers_install ARCH=$(ARCH) INSTALL_HDR_PATH=$(shell pwd)/$@ -C $(LINUXDIR)
musl_patch_for_linux_user: linux_header_install_for_linux_user
endif
musl_patch_for_linux_user: musl_copy_for_linux_user
$(HIDE) cp -rfp $(MUSLDIR)/porting/linux/user/* $</
musl_install_for_linux_user: CFLAGS += -I $(PREBUILTLINUXHDRDIR)
musl_install_for_linux_user: TARGET = $(ARCH)-linux-ohosmusl
musl_install_for_linux_user: musl_patch_for_linux_user
$(HIDE) cd musl_copy_for_linux_user && mkdir -p $(MUSLBUILDDIR) && cd $(MUSLBUILDDIR) && \
../configure --prefix=/usr --target=$(TARGET) --includedir=/usr/include/$(TARGET) --libdir=/usr/$(MULTILIB) \
CC="$(CC)" CROSS_COMPILE="$(CROSS_COMPILE)" CFLAGS="$(CFLAGS)" >/dev/null && \
make -sj install-headers install-libs DESTDIR=$(SYSROOTDIR)
$(HIDE) cp -rfp $(PREBUILTLINUXHDRDIR)/* $(SYSROOTDIR)/usr/include/$(TARGET)
ifeq ($(ARCH),arm)
ifeq ($(BUILD_ALL_MULTILIB),true)
......@@ -159,13 +160,14 @@ ifneq ($$(ARCH_CFLAGS),$$($(2)))
all: $$(if $$(filter linux_user,$$(TARGETS)),musl_install_for_linux_user$(1),)
all: $$(if $$(filter liteos_a_user,$$(TARGETS)),musl_install_for_liteos_a_user$(1),)
musl_install_for_linux_user$(1): CFLAGS += -I $$(PREBUILTLINUXHDRDIR)
musl_install_for_linux_user$(1): TARGET = $$(ARCH)-linux-ohosmusl
musl_install_for_linux_user$(1): override ARCH_CFLAGS = $$($(2))
musl_install_for_linux_user$(1): musl_install_for_linux_user
$$(HIDE) cd musl_copy_for_linux_user && mkdir -p $$(MUSLBUILDDIR) && cd $$(MUSLBUILDDIR) && \
../configure --prefix=/usr --target=$$(TARGET) --libdir=/usr/$$(MULTILIB) \
CC="$$(CC)" CROSS_COMPILE="$$(CROSS_COMPILE)" CFLAGS="$$(CFLAGS)" >/dev/null && \
sed 's, -m 644 , -m 444 ,g' Makefile | make -f- -sj install-libs DESTDIR=$$(SYSROOTDIR)
make -sj install-libs DESTDIR=$$(SYSROOTDIR)
ifeq ($$(BUILD_DEBUG),true)
musl_install_for_liteos_a_user$(1): CFLAGS += -funwind-tables -fasynchronous-unwind-tables -rdynamic -I $$(shell $$(CC) -print-file-name=)include
......@@ -178,7 +180,7 @@ musl_install_for_liteos_a_user$(1): musl_install_for_liteos_a_user
../configure --prefix=/usr --target=$$(TARGET) --libdir=/usr/$$(MULTILIB) \
$$(if $$(LDFLAGS),LDFLAGS="$$(LDFLAGS)",) \
CC="$$(CC)" CROSS_COMPILE="$$(CROSS_COMPILE)" CFLAGS="$$(CFLAGS)" >/dev/null && \
sed 's, -m 644 , -m 444 ,g' Makefile | make -f- -sj install-libs DESTDIR=$$(SYSROOTDIR)
make -sj install-libs DESTDIR=$$(SYSROOTDIR)
endif
endef
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册