Как добавить исходные файлы в пакет PN-sr c в yocto - PullRequest
0 голосов
/ 07 апреля 2020

Я написал базовый c рецепт для простого C приложения

DESCRIPTION = "Simple helloworld C application"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://userprog.c \
       file://function.c \
       file://ReadMe.txt"

S = "${WORKDIR}"

do_compile() {
    ${CC} userprog.c function.c ${LDFLAGS} -o userprog
}

do_install() {
    install -d ${D}${bindir}
    install -m 0755 userprog ${D}${bindir}
    install -d ${D}${docdir}
    install -m 0644 ReadMe.txt ${D}${docdir}
}

Команда дерева в папке с разделением пакетов

tree packages-split/
packages-split/
├── myhello
│   └── usr
│       └── bin
│           └── userprog
├── myhello-dbg
│   └── usr
│       └── bin
├── myhello-dev
├── myhello-doc
│   └── usr
│       └── share
│           └── doc
│               └── ReadMe.txt
├── myhello-locale
├── myhello.shlibdeps
├── myhello-src
└── myhello-staticdev

Итак, ReadMe.txt автоматически копируется в пакет myhello-do c. Какие изменения я должен сделать, чтобы мои исходные файлы были скопированы в пакет 'myhello-sr c'

Когда я изменил свой рецепт на использование Makefile, он автоматически добавился в пакет sr c

DESCRIPTION = "Simple helloworld C application"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://userprog.c \
        file://Makefile"

S = "${WORKDIR}"

EXTRA_OEMAKE = "'DESTDIR=${D}/usr/bin' V=1"

do_install() {
    oe_runmake install
}

Makefile:

# compiler flags:
#  -g    adds debugging information to the executable file
#  -Wall turns on most, but not all, compiler warnings
CFLAGS  = -g -Wall -DUSE_SYSCALL

# the name to use for both the target source file, and the output file:
TARGET = userprog

all: $(TARGET)

$(TARGET): $(TARGET).c
    ${CC} $(CFLAGS) -o $(TARGET)  $(TARGET).c $(LDFLAGS)

install:
    install -d $(DESTDIR)
    install -m 0755 $(TARGET) $(DESTDIR)

clean:
    rm  -f $(TARGET)

uninstall:
    rm $(DESTDIR)$(TARGET)

package-split:

packages-split/
├── myhello4
│   └── usr
│       └── bin
│           └── userprog
├── myhello4-dbg
│   └── usr
│       └── bin
├── myhello4-dev
├── myhello4-doc
├── myhello4-locale
├── myhello4.shlibdeps
├── myhello4-src
│   └── usr
│       └── src
│           └── debug
│               └── myhello4
│                   └── 0.1-r0
│                       └── userprog.c
└── myhello4-staticdev

В чем разница между первым подходом и вторым и как userprog. c файл был добавлен во второй подход

1 Ответ

0 голосов
/ 14 апреля 2020
    DESCRIPTION = "Simple helloworld C application"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://userprog.c \
       file://function.c \
       file://ReadMe.txt"

S = "${WORKDIR}"

do_compile() {
    ${CC} userprog.c function.c ${LDFLAGS} -o userprog
}

do_install() {
    install -d ${D}${bindir}
    install -m 0755 userprog ${D}${bindir}
    install -d ${D}${docdir}
    install -m 0644 ReadMe.txt ${D}${docdir}
    install -d ${D}/src
    cp -rf ${S}/*.c ${D}/src/
}

PACKAGES = "${PN} ${PN}-src ${PN}-doc"
FILES_${PN} = "
 ${bindir}/*
"
FILES_${PN}-src = "
 /src/*
"
FILES_${PN}-doc = "
${docdir}/*
"
...