Alex079 / vscode-avr-helper

Helper extension to simplify code compilation and flashing for AVR chips
MIT License
12 stars 1 forks source link

An error in the command syntax. #26

Closed Djentmat closed 2 years ago

Djentmat commented 2 years ago

Hi! I have a simple code in test.c:

#include <avr/io.h>

int main(void)
{
    DDRB = 1 << PB5;
    return 0;
}

When I try to make avr.targets.mk with avr-gcc-12.1.0-x64-windows I get some troubles. There is console output:

An error in the command syntax. make: *** [c:\Users\djentmat\Downloads\_avr_test\.vscode\avr.targets.mk:50: .vscode/avr.build/output.elf] Error 1

50th string is @mkdir -p $(@D)

So I don't know how to resolve this error.

avr.targets.mk:

-include .vscode/avr.properties.mk

ifeq ($(AVR.source.compiler),$(notdir $(AVR.source.compiler)))
A.compiler.dir :=
else
A.compiler.dir := $(dir $(AVR.source.compiler))
endif
A.libraries := $(addprefix -I,$(wildcard $(AVR.source.libraries:=/.) $(AVR.source.libraries:=/*/.) $(AVR.source.libraries:=/*/*/.)))
A.output.dir := .vscode/avr.build
A.elf := $(A.output.dir)/output.elf
A.list := $(A.output.dir)/output.lst

E.compiler := $(AVR.source.compiler) -DF_CPU=$(AVR.device.frequency) -mmcu=$(AVR.device.type) -pipe $(A.libraries)
E.get.dep := $(E.compiler) -MM
E.compile := $(E.compiler) -std=c++14 -g -Os -Wall -Wextra -pedantic -c -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto
E.link := $(E.compiler) -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -lm
E.make.list := $(A.compiler.dir)avr-objdump --disassemble --source --line-numbers --demangle
E.get.size := $(A.compiler.dir)avr-size -A

F.dep.base = $(basename $1 $(filter %.h %.hpp,$(shell $(E.get.dep) $1)))
F.dep.1lvl = $(sort $(wildcard $(addsuffix .c,$(call F.dep.base,$1)) $(addsuffix .cc,$(call F.dep.base,$1)) $(addsuffix .cpp,$(call F.dep.base,$1)) $(addsuffix .c++,$(call F.dep.base,$1)) $(addsuffix .C,$(call F.dep.base,$1))))
F.dep = $(if $(filter-out $1,$(call F.dep.1lvl,$1)),$(call F.dep,$(call F.dep.1lvl,$1)),$1)

A.src := $(call F.dep,$(sort $(wildcard *.c) $(wildcard */*.c) $(wildcard */*/*.c) $(sort $(wildcard *.cc) $(wildcard */*.cc) $(wildcard */*/*.cc) $(wildcard *.cpp) $(wildcard */*.cpp) $(wildcard */*/*.cpp) $(wildcard *.c++) $(wildcard */*.c++) $(wildcard */*/*.c++) $(wildcard *.C) $(wildcard */*.C) $(wildcard */*/*.C))))
A.obj := $(addprefix $(A.output.dir)/obj/,$(addsuffix .o,$(A.src)))

.PHONY : clean build scan

build : $(A.list)
    @$(E.get.size) $(A.elf)

clean :
    @$(RM) -r $(A.output.dir)

scan :
    $(info Found source files)
    $(info )
    $(foreach s,$(A.src),$(info $(realpath $(s))))
    $(info )

-include $(A.obj:.o=.d)

$(A.list) : $(A.elf)
    @mkdir -p $(@D)
    $(info ===== Making $@)
    @$(E.make.list) $^ > $@
    $(info )

$(A.elf) : $(A.obj)
    @mkdir -p $(@D)
    $(info ===== Making $@)
    @$(E.link) $^ -o $@
    $(info )

$(A.output.dir)/obj/%.c.o : %.c
    @mkdir -p $(@D)
    $(info ===== Making $@)
    @$(E.compile) $< -o $@
    $(info )

$(A.output.dir)/obj/%.cc.o : %.cc
    @mkdir -p $(@D)
    $(info ===== Making $@)
    @$(E.compile) $< -o $@
    $(info )

$(A.output.dir)/obj/%.cpp.o : %.cpp
    @mkdir -p $(@D)
    $(info ===== Making $@)
    @$(E.compile) $< -o $@
    $(info )

$(A.output.dir)/obj/%.c++.o : %.c++
    @mkdir -p $(@D)
    $(info ===== Making $@)
    @$(E.compile) $< -o $@
    $(info )

$(A.output.dir)/obj/%.C.o : %.C
    @mkdir -p $(@D)
    $(info ===== Making $@)
    @$(E.compile) $< -o $@
    $(info )
Alex079 commented 2 years ago

Hi!

I decided to move away from using make. Version 2 is underway. https://github.com/Alex079/vscode-avr-helper/blob/master/CHANGELOG.md

Regards

Alex079 commented 2 years ago

released v2