[Add] Build.sh

This commit is contained in:
gaoyang3513
2023-10-30 22:26:28 +08:00
parent 5fb4b5d4a2
commit 2ab4495bf9
3 changed files with 48 additions and 32 deletions

View File

@ -14,12 +14,10 @@ INSTALL_DIR ?= $(LOCAL_DIR)/__install
# Variables
#*******************************************************************************
# target
TARGET ?= demo_rf
TARGET ?= demo_hello
PRODUCT ?= T673
PLATFORM_F1 := T340 T343 T673 T641A
PLATFORM_AI := T641 T680
PLATFORM_A2 := T681
PRODUCT ?= LBC2
PLATFORM_RK3568 := LBC2
#*******************************************************************************
# Functions
@ -32,45 +30,23 @@ sources = $(subst $(LOCAL_DIR)/,,$(shell find $(SOURCE_DIR) -name "
#$(info sources=$(sources))
filter_out_files :=
filter_out_dirs := src/core
filter_out_dirs :=
sources_out := $(foreach dir,$(filter_out_dirs),$(shell find $(dir) -name "*.c"))
#$(info sources_out=$(sources_out))
sources := $(filter-out $(sources_out),$(sources))
sources := $(foreach file,$(sources),$(if $(filter $(subst $(LOCAL_DIR)/,,$(strip $(patsubst %/,%,$(sort $(dir $(file)))))),$(filter_out_dirs)),,$(file)))
objects = $(addprefix $(OUTPUT_DIR)/,$(patsubst %.c,%.o,$(sources)))
#$(info sources=$(sources))
#$(info objects=$(objects))
$(info objects=$(objects))
#*******************************************************************************
# Compile configure
#*******************************************************************************
ARCH := arm
ifneq ($(filter $(PRODUCT),$(PLATFORM_A2)),)
PLATFORM := A2
KERNEL_CONFIG := rockchip_defconfig
CROSS_COMPILE := aarch64-linux-android-
else ifneq ($(filter $(PRODUCT),$(PLATFORM_A2S)),)
PLATFORM := A2S
KERNEL_CONFIG := rockchip_defconfig rk356x_evb.config android-11.config
KERNEL_OPTION := BOOT_IMG=$(OUTPUT_DIR)/boot.img TS3672.img
ifneq ($(filter $(PRODUCT),$(PLATFORM_RK3568)),)
ARCH := arm64
CROSS_COMPILE := $(HOME)/Workspaces/03-Toolschain/A2S_gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
else ifneq ($(filter $(PRODUCT),$(PLATFORM_F1)),)
PLATFORM := F1
KERNEL_CONFIG := bsp_f1x_defconfig
CROSS_COMPILE := arm-ca9-linux-gnueabihf-
LIBS_F1 := pthread
else ifneq ($(filter $(PRODUCT),$(PLATFORM_F3)),)
PLATFORM := F3
KERNEL_CONFIG := bsp_f3_defconfig
CROSS_COMPILE := arm-ca9-linux-uclibcgnueabihf-
else ifneq ($(filter $(PRODUCT),$(PLATFORM_AI)),)
PLATFORM := AI
CROSS_COMPILE := arm-ca53-linux-gnueabihf-
else
PLATFORM := H10
CROSS_COMPILE := arm-hisiv500-linux-
#CROSS_COMPILE := $(HOME)/Workspaces/Toolchains/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
CROSS_COMPILE := $(HOME)/Workspaces/Toolchains/aarch64/aarch64-linux-android-4.9/
endif
CC := $(CROSS_COMPILE)gcc

32
build.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
LOCAL_DIR=`pwd`
#----------------------------------
OUTPUT_DIR=${LOCAL_DIR}/output
INSTALL_DIR=${LOCAL_DIR}/install
NDK=${HOME}/Workspaces/ndk/android-ndk-r21e
# Only choose one of these, depending on your build machine...
#export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/darwin-x86_64
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
# Only choose one of these, depending on your device...
export TARGET=aarch64-linux-android
#export TARGET=armv7a-linux-androideabi
#export TARGET=i686-linux-android
#export TARGET=x86_64-linux-android
# Set this to your minSdkVersion.
export API=30
# Configure and build.
export AR=$TOOLCHAIN/bin/llvm-ar
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export AS=$CC
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
export LD=$TOOLCHAIN/bin/ld
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
export STRIP=$TOOLCHAIN/bin/llvm-strip
make

8
src/main.c Normal file
View File

@ -0,0 +1,8 @@
#include <stdio.h>
int main(void)
{
printf("Hello, Lubancat2\n");
return 0;
}