How to generate a "make installation" action using gyp?

I am using gyp to create makefiles for my project. Makefiles work by making working binaries pop up in the "out" directory, that's all dandy.

However, I would like my makefiles to have some “standard” actions / goals, namely “install”, “delete”, and “clean”.

I have added the “set” target to the .gyp files, but I have doubts if this is the right way to do this, especially since there seems to be no way to exclude the “set” target from “everything” in make using gyp.

I am also wondering if there is a tool for creating. / configure files for gyp, or if they should be written by the developer and only run gyp with some necessary parameters.

What is the correct way to add these targets ("install" ...) to make files created by gyp? Is it possible to do this in such a way that, as soon as they are indicated, these actions will work with other build systems? (ninja, etc.)

+4
source share
1 answer

, , make gyp , make "install", "clean" .., Makefile, gyp.

, gyp , ./configure

:

+ build
    |- Makefile (generated by gyp)
|- Makefile (written by hand)
|- configure (written by hand)
|- build.gyp (written by hand)

./:

#!/bin/bash

PREFIX=/usr/local
BUILDTYPE=Release


for i in "$@"
do
        case $i in
            -p=*|--prefix=*)
            PREFIX="${i#*=}"

            ;;
        esac
        case $i in
            -b=*|--buildtype=*)
            BUILDTYPE="${i#*=}"

            ;;
        esac
done
gyp -D prefix="$PREFIX" -D configuration="$BUILDTYPE" --depth=. --generator-output=./build -f make

echo -e "prefix=$PREFIX\n" > ./config.mk

Makefile:

include config.mk

prefix ?= /usr/local

builddir=build/out
abs_builddir := $(abspath $(builddir))

all: config.mk
    $(MAKE) -C "./build" builddir="$(abs_builddir)"

binaries=$(prefix)/bin/foo $(prefix)/bin/bar

$(binaries): $(prefix)/bin/%: $(builddir)/%
    cp $< $@

install: $(binaries) $(directories)

# $(directories), uninstall, clean, .PHONY, etc.

build.gyp:

{
    'variables': {
    },
    'target_defaults': {
        // (...)
    },
    'targets': [
        {
            'target_name': 'foo',
            'type': 'executable',
            'defines': [],
            'include_dirs':[ 
                'src/headers'
            ],
            'sources': [ 
                'src/foo.c'
            ],
            'libraries': [
                '-lcrypto'
            ]
        },
        // (...)
    ]
}

, , :

./configure --prefix="/home/me/local_builds"
make
make install
0

All Articles