Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00960b6b8f | ||
|
|
a3f08704e6 |
+65
-39
@@ -5,48 +5,53 @@ HIDE = > /dev/zero
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
TIMESTAMP = $(shell date +"%T")
|
TIMESTAMP = $(shell date +"%T")
|
||||||
cmd_copy = cp -a $(1) $(2)
|
copy_files = cp $(1) $(2)
|
||||||
cmd_link = ln -sfr $(1) $(2)
|
copy_dir = cp -r $(1) $(2)
|
||||||
cmd_remove = rm -rf $(1)
|
remove_file = rm -rf $(1)
|
||||||
cmd_mkdir = mkdir -p $(1)
|
remove_dir = rm -rf $(1)
|
||||||
cmd_cat = cat $(1) 2>/dev/null
|
mk_dir = mkdir -p $(1)
|
||||||
cmd_print_lines = echo $(1) | tr ' ' '\n'
|
read_file = cat $(1) 2>/dev/null
|
||||||
|
print_lines = echo $(1) | tr ' ' '\n'
|
||||||
color_green = \033[32m$(1)\033[0m
|
green = \\e[32m$(1)\\e[39m
|
||||||
log = @printf "$(call color_green,[$(TIMESTAMP)]) %s\n" "$(1)"
|
print = printf "$(call green,[$(TIMESTAMP)]) $(1)\n"
|
||||||
show_build_type = $(call log,Building for $(call green,$(1)))
|
make_dir_link = ln -sfr $(1) $(2)
|
||||||
|
make_link = ln -sfr $(1) $(2)
|
||||||
check-var = $(if $(strip $($(1))),,$(error [ERROR] Missing required variable: $(1)))
|
|
||||||
check_command = $(shell which $(1) > /dev/null 2>&1 && echo y || echo n)
|
check_command = $(shell which $(1) > /dev/null 2>&1 && echo y || echo n)
|
||||||
|
print_build_type = $(call print,Building for $(call green,$(1)))
|
||||||
|
|
||||||
$(call check-var,PROJECT)
|
ifeq ('y', '$(strip $(LINK_SRCS))')
|
||||||
$(call check-var,PLATFORM)
|
update_files = $(call make_link,$(1),$(2))
|
||||||
$(call check-var,BUILD_DIR)
|
update_dir = $(call make_dir_link,$(1),$(2))
|
||||||
$(call check-var,CONFIG_FILE)
|
ACTION = Linking
|
||||||
$(call check-var,LINK_SRCS)
|
else
|
||||||
|
update_files = $(call copy_files,$(1),$(dir $(2)))
|
||||||
|
update_dir = $(call copy_dir,$(1),$(2))
|
||||||
|
ACTION = Copying
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef PROJECT
|
||||||
|
@$(error "PROJECT variable needs to be set")
|
||||||
|
endif
|
||||||
|
ifndef PLATFORM
|
||||||
|
@$(error "PLATFORM variable needs to be set")
|
||||||
|
endif
|
||||||
|
ifndef BUILD_DIR
|
||||||
|
@$(error "BUILD_DIR variable needs to be set")
|
||||||
|
endif
|
||||||
|
ifndef CONFIG_FILE
|
||||||
|
@$(error "CONFIG_FILE variable needs to be set")
|
||||||
|
endif
|
||||||
ifndef SCRIPT_DIR
|
ifndef SCRIPT_DIR
|
||||||
CURRENT_FILE := $(lastword $(MAKEFILE_LIST))
|
CURRENT_FILE := $(lastword $(MAKEFILE_LIST))
|
||||||
CURRENT_DIR := $(patsubst %/,%,$(dir $(CURRENT_FILE)))
|
CURRENT_DIR := $(patsubst %/,%,$(dir $(CURRENT_FILE)))
|
||||||
SCRIPT_DIR := $(CURRENT_DIR)
|
SCRIPT_DIR := $(CURRENT_DIR)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(strip $(LINK_SRCS)),y)
|
|
||||||
update_files = $(call cmd_link,$(1),$(2))
|
|
||||||
update_dir = $(call cmd_link,$(1),$(2))
|
|
||||||
ACTION = Linking
|
|
||||||
else
|
|
||||||
update_files = $(call cmd_copy,$(1),$(dir $(2)))
|
|
||||||
update_dir = $(call cmd_copy,$(1),$(2))
|
|
||||||
ACTION = Copying
|
|
||||||
endif
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# COMMON INITIALIZATION
|
# COMMON INITIALIZATION
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
PLATFORM_TOOLS = $(SCRIPT_DIR)/platform/$(PLATFORM)
|
PLATFORM_TOOLS = $(SCRIPT_DIR)/platform/$(PLATFORM)
|
||||||
BUILD_LOCK = $(BUILD_DIR)/.build.lock
|
BUILD_LOCK = $(BUILD_DIR)/.project.lock
|
||||||
PROJECT_LOCK = $(BUILD_DIR)/.project.lock
|
|
||||||
|
|
||||||
ifeq ('xilinx', '$(PLATFORM)')
|
ifeq ('xilinx', '$(PLATFORM)')
|
||||||
include $(PLATFORM_TOOLS)/xilinx.mk
|
include $(PLATFORM_TOOLS)/xilinx.mk
|
||||||
@@ -57,28 +62,49 @@ endif
|
|||||||
# Generic Goals
|
# Generic Goals
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
PHONY := clean reset project build sdkopen
|
.DEFAULT_GOAL := all
|
||||||
.DEFAULT_GOAL := project
|
PHONY += all
|
||||||
|
ifneq ($(wildcard $(BUILD_LOCK)),)
|
||||||
|
all:
|
||||||
|
@$(call print_build_type,$(PLATFORM))
|
||||||
|
$(MAKE) --no-print-directory build
|
||||||
|
@$(call print,Done ($(notdir $(BUILD_DIR))))
|
||||||
|
else
|
||||||
|
all:
|
||||||
|
@$(call print_build_type,$(PLATFORM))
|
||||||
|
$(MAKE) --no-print-directory project
|
||||||
|
$(MAKE) --no-print-directory build
|
||||||
|
@$(call print,Done ($(notdir $(BUILD_DIR))))
|
||||||
|
endif
|
||||||
|
|
||||||
# Create project using corresponding SDK
|
|
||||||
project: $(PLATFORM)_project
|
project: $(PLATFORM)_project
|
||||||
|
@echo "$(TIMESTAMP): Build lock." > $(BUILD_LOCK)
|
||||||
|
|
||||||
# Build project using corresponding compiler
|
standalone:
|
||||||
build: project $(PLATFORM)_sdkbuild
|
$(MAKE) --no-print-directory project LINK_SRCS=n
|
||||||
|
|
||||||
|
# Build project using generic compiler
|
||||||
|
build: $(PLATFORM)_sdkbuild
|
||||||
|
|
||||||
# Open the project using the corresponding SDK
|
# Open the project using the corresponding SDK
|
||||||
sdkopen: project $(PLATFORM)_sdkopen
|
sdkopen: $(PLATFORM)_sdkopen
|
||||||
|
|
||||||
# Remove build artefacts
|
# Remove build artefacts
|
||||||
|
PHONY += clean
|
||||||
ifneq ($(wildcard $(BUILD_LOCK)),)
|
ifneq ($(wildcard $(BUILD_LOCK)),)
|
||||||
clean: $(PLATFORM)_sdkclean
|
clean:
|
||||||
|
@$(call print,Cleaning sdk build uploaded to board)
|
||||||
|
$(MAKE) --no-print-directory $(PLATFORM)_sdkclean
|
||||||
else
|
else
|
||||||
clean: reset
|
clean:
|
||||||
|
@$(call print,No project found, cleaning dummy files)
|
||||||
|
$(MAKE) --no-print-directory reset
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Remove the whole build directory
|
# Remove the whole build directory
|
||||||
|
PHONY += reset
|
||||||
reset: $(PLATFORM)_reset
|
reset: $(PLATFORM)_reset
|
||||||
@$(call log,[Delete] $(BUILD_DIR))
|
@$(call print,[Delete] $(BUILD_DIR))
|
||||||
@$(call cmd_remove,$(BUILD_DIR))
|
@$(call remove_dir,$(BUILD_DIR))
|
||||||
|
|
||||||
.PHONY: $(PHONY)
|
.PHONY: $(PHONY)
|
||||||
|
|||||||
+39
-69
@@ -90,46 +90,6 @@ proc _configure_bsp {bsp_name bsp_config platform_name is_vitis} {
|
|||||||
return $bsp_name
|
return $bsp_name
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper procedure to recursively create hard links for files in a directory
|
|
||||||
proc _link_or_copy_dir {source_dir target_dir link_mode} {
|
|
||||||
# Create target directory if it doesn't exist
|
|
||||||
if {![file exists $target_dir]} {
|
|
||||||
file mkdir $target_dir
|
|
||||||
_info "Created directory: $target_dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Process each file and subdirectory in the source directory
|
|
||||||
foreach item [glob -nocomplain -directory $source_dir *] {
|
|
||||||
set item_name [file tail $item]
|
|
||||||
set target_item [file join $target_dir $item_name]
|
|
||||||
|
|
||||||
# Remove existing file or directory
|
|
||||||
if {[file exists $target_item]} {
|
|
||||||
file delete -force $target_item
|
|
||||||
_warn "Deleted existing item: $target_item"
|
|
||||||
}
|
|
||||||
|
|
||||||
if {[file isfile $item]} {
|
|
||||||
# Handle file - create hard link or copy
|
|
||||||
if {$link_mode eq "y"} {
|
|
||||||
if {[catch {
|
|
||||||
file link -hard $target_item $item
|
|
||||||
} err]} {
|
|
||||||
error "Failed to create hard link: $err"
|
|
||||||
} else {
|
|
||||||
_info "Created hard link: $target_item -> $item"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
file copy $item $target_item
|
|
||||||
_info "Copied file: $item to $target_item"
|
|
||||||
}
|
|
||||||
} elseif {[file isdirectory $item]} {
|
|
||||||
# Handle subdirectory recursively
|
|
||||||
_link_or_copy_dir $item $target_item $link_mode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Helper procedure to handle source files: link or copy based on LINK_SRCS
|
# Helper procedure to handle source files: link or copy based on LINK_SRCS
|
||||||
proc _handle_sources {app_name sources} {
|
proc _handle_sources {app_name sources} {
|
||||||
# Check environment variable LINK_SRCS
|
# Check environment variable LINK_SRCS
|
||||||
@@ -144,41 +104,52 @@ proc _handle_sources {app_name sources} {
|
|||||||
if {[llength $expanded_sources] == 0} {
|
if {[llength $expanded_sources] == 0} {
|
||||||
_error "Source file not found" "No file or directory matches $source_file"
|
_error "Source file not found" "No file or directory matches $source_file"
|
||||||
}
|
}
|
||||||
|
# Hanle each expanded source
|
||||||
# Handle each expanded source
|
|
||||||
foreach eval_source $expanded_sources {
|
foreach eval_source $expanded_sources {
|
||||||
set relative_source [string range $eval_source [expr [string length $::root] + 1] end]
|
set relative_source [string range $eval_source [expr [string length $::root] + 1] end]
|
||||||
set target_path [file join $::ws $app_name $relative_source]
|
set target_path [file join $::ws $app_name $relative_source]
|
||||||
|
|
||||||
if {[file isfile $eval_source]} {
|
# Ensure the target directory exists
|
||||||
# For files, ensure the parent directory exists
|
set target_dir [file dirname $target_path]
|
||||||
set target_dir [file dirname $target_path]
|
if {![file exists $target_dir]} {
|
||||||
if {![file exists $target_dir]} {
|
file mkdir $target_dir
|
||||||
file mkdir $target_dir
|
_info "Created directory: $target_dir"
|
||||||
_info "Created directory: $target_dir"
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# Delete existing file if it exists
|
# Delete existing symbolic link or file if it exists
|
||||||
if {[file exists $target_path]} {
|
if {[file exists $target_path]} {
|
||||||
file delete -force $target_path
|
file delete -force $target_path
|
||||||
_warn "Deleted existing file: $target_path"
|
_warn "Deleted existing link or file: $target_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle file based on LINK_SRCS
|
# Handle source based on the value of LINK_SRCS
|
||||||
if {$link_srcs eq "y"} {
|
switch $link_srcs {
|
||||||
if {[catch {
|
"y" {
|
||||||
file link -hard $target_path $eval_source
|
# Create symbolic link
|
||||||
} err]} {
|
# -- Symbolic link for file dose not support on NTFS
|
||||||
error "Failed to create hard link: $err"
|
if {$::tcl_platform(platform) eq "windows" && [file isfile $eval_source]} {
|
||||||
|
if {[catch {
|
||||||
|
file link -hard $target_path $eval_source
|
||||||
|
} err]} {
|
||||||
|
error "Failed to create file hard link: $err"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if {[catch {
|
||||||
|
file link -symbolic $target_path $eval_source
|
||||||
|
} err]} {
|
||||||
|
error "Failed to create symbolic link: $err"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_info "Created hard link: $target_path -> $eval_source"
|
_info "Created symbolic link: $target_path -> $eval_source"
|
||||||
} else {
|
}
|
||||||
file copy $eval_source $target_path
|
"n" {
|
||||||
_info "Copied file: $eval_source to $target_path"
|
# Copy the source file
|
||||||
|
file copy $eval_source $target_path
|
||||||
|
_info "Copied source file: $eval_source to $target_path"
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
_error "Unknown value for LINK_SRCS: ${link_srcs}."
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
# For directories, use the helper function
|
|
||||||
_link_or_copy_dir $eval_source $target_path $link_srcs
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -261,8 +232,7 @@ proc _update_app_build_config {app_name build_type build_config is_vitis} {
|
|||||||
"linker-misc" -
|
"linker-misc" -
|
||||||
"linker-script" {
|
"linker-script" {
|
||||||
if {$value ne ""} {
|
if {$value ne ""} {
|
||||||
set value_list [list $value]
|
eval $cmd $app_name -set $param $value
|
||||||
eval $cmd $app_name -set $param $value_list
|
|
||||||
_info "Set $param: $value for $app_name."
|
_info "Set $param: $value for $app_name."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-24
@@ -1,21 +1,14 @@
|
|||||||
$(call check-var,XILINX_VITIS_CLASSIC)
|
#------------------------------------------------------------------------------
|
||||||
$(call check-var,PLATFORM_TOOLS)
|
# ENVIRONMENT VARIABLES
|
||||||
$(call check-var,CONFIG_FILE)
|
#------------------------------------------------------------------------------
|
||||||
$(call check-var,BUILD_DIR)
|
|
||||||
$(call check-var,PROJECT_LOCK)
|
|
||||||
$(call check-var,BUILD_LOCK)
|
|
||||||
$(call check-var,LINK_SRCS)
|
|
||||||
|
|
||||||
define tcl_util
|
define tcl_util
|
||||||
xsct -nodisp $(PLATFORM_TOOLS)/util.tcl \
|
xsct -nodisp $(PLATFORM_TOOLS)/util.tcl \
|
||||||
$(1) \
|
$(1) \
|
||||||
$(CONFIG_FILE) $(BUILD_DIR)
|
$(CONFIG_FILE) $(BUILD_DIR)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
PHONY += xilinx_reset xilinx_project xilinx_sdkclean xilinx_sdkbuild
|
|
||||||
|
|
||||||
xilinx_sdkopen:
|
xilinx_sdkopen:
|
||||||
@$(call log,Launching IDE...)
|
@$(call print,Launching IDE...)
|
||||||
@if [ "$(call check_command,vitis)" = "y" ]; then \
|
@if [ "$(call check_command,vitis)" = "y" ]; then \
|
||||||
if [ "$(XILINX_VITIS_CLASSIC)" = "y" ]; then \
|
if [ "$(XILINX_VITIS_CLASSIC)" = "y" ]; then \
|
||||||
vitis -classic -workspace=$(BUILD_DIR); \
|
vitis -classic -workspace=$(BUILD_DIR); \
|
||||||
@@ -28,22 +21,20 @@ xilinx_sdkopen:
|
|||||||
echo "No IDE found!" && exit 1; \
|
echo "No IDE found!" && exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PHONY += xilinx_sdkbuild
|
||||||
xilinx_sdkbuild:
|
xilinx_sdkbuild:
|
||||||
@$(call log,[Build] SDK projects in $(BUILD_DIR))
|
@$(call print,[Build] SDK projects in $(BUILD_DIR))
|
||||||
$(call tcl_util, build) $(HIDE)
|
$(call tcl_util, build) $(HIDE)
|
||||||
@echo "$(TIMESTAMP): Build lock." > $(BUILD_LOCK)
|
|
||||||
|
|
||||||
|
PHONY += xilinx_sdkclean
|
||||||
xilinx_sdkclean:
|
xilinx_sdkclean:
|
||||||
@$(call log,[Delete] SDK artefacts from $(BUILD_DIR))
|
@$(call print,[Delete] SDK artefacts from $(BUILD_DIR))
|
||||||
$(call tcl_util, clean_project) $(HIDE)
|
$(call tcl_util, clean_project) $(HIDE)
|
||||||
|
|
||||||
$(PROJECT_LOCK):
|
xilinx_project:
|
||||||
@$(call log,Creating and configuring the IDE project)
|
@$(call print,Creating and configuring the IDE project)
|
||||||
@$(call cmd_mkdir,$(BUILD_DIR))
|
$(call mk_dir,$(BUILD_DIR))
|
||||||
$(call tcl_util, create_project) $(HIDE)
|
$(call tcl_util, create_project) $(HIDE)
|
||||||
@echo "$(TIMESTAMP): Project lock." > $@
|
|
||||||
|
|
||||||
xilinx_project: $(PROJECT_LOCK)
|
|
||||||
|
|
||||||
xilinx_reset:
|
xilinx_reset:
|
||||||
$(call cmd_remove,.Xil) $(HIDE)
|
$(call remove_dir,.Xil) $(HIDE)
|
||||||
Reference in New Issue
Block a user