Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Add the dependency analyser with the go toolchain to kraft (V3) #22

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,9 @@ properclean:
$(Q)$(RM) -Rfv $(DISTDIR)/*
endif


include $(KRAFTDIR)/contrib/Makefile
include $(KRAFTDIR)/package/docker/Makefile


.PHONY:
no-help:
@echo "No help for target: $(strip $(subst help,,$(MAKECMDGOALS)))"
9 changes: 9 additions & 0 deletions contrib/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CONTRIBDIR ?= $(KRAFTDIR)/contrib
GOTOOLS ?= $(CONTRIBDIR)/gotools
SRCS ?= $(GOTOOLS)/srcs
.DEFAULT_TARGET: all
all: gotools

.PHONY: gotools
gotools:
include $(SRCS)/Makefile
6 changes: 6 additions & 0 deletions contrib/gotools/configfiles/nginx.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
nginx -h
nginx -v
nginx -V
nginx -t
nginx -T
nginx -Tq
69 changes: 69 additions & 0 deletions contrib/gotools/srcs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# Authors: Gaulthier Gain <[email protected]>
#
# Copyright (c) 2020, Université de Liège., ULiege. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

# Program arguments
BINARY_NAME ?= gotools
BINARY_UNIX ?= $(BINARY_NAME)_unix
CONTAINER_NAME ?= unikraft/gotools:latest

## Gotools
DOCKER ?= docker
TARGET ?= binary
GO ?= go
GOBUILD ?= $(GO) build
GOCLEAN ?= $(GO) clean
GOGET ?= $(GO) get

# Targets
all: build
container:
$(DOCKER) build \
-t $(CONTAINER_NAME) \
-f Dockerfile \
--target=$(TARGET) \
.
build: deps
$(GOBUILD) -o $(BINARY_NAME) -v
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_UNIX)
run:
$(GOBUILD) -o $(BINARY_NAME) -v
./$(BINARY_NAME)
deps:
$(GOGET) github.com/fatih/color
$(GOGET) github.com/akamensky/argparse
$(GOGET) github.com/awalterschulze/gographviz
$(GOGET) github.com/sergi/go-diff/...
# Cross compilation
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v
66 changes: 66 additions & 0 deletions contrib/gotools/srcs/buildtool/args.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Authors: Gaulthier Gain <[email protected]>
//
// Copyright (c) 2020, Université de Liège., ULiege. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

package buildtool

import (
"os"
u "tools/srcs/common"

"github.com/akamensky/argparse"
)

const (
programArg = "program"
unikraftArg = "unikraft"
sourcesArg = "sources"
makefileArg = "makefile"
)

// ParseArguments parses arguments of the application.
//
// It returns an error if any, otherwise it returns nil.
func parseLocalArguments(p *argparse.Parser, args *u.Arguments) error {

args.InitArgParse(p, args, u.STRING, "p", programArg,
&argparse.Options{Required: true, Help: "Program name"})

args.InitArgParse(p, args, u.STRING, "u", unikraftArg,
&argparse.Options{Required: false, Help: "Unikraft Path"})
args.InitArgParse(p, args, u.STRING, "s", sourcesArg,
&argparse.Options{Required: true, Help: "App Sources " +
"Folder"})
args.InitArgParse(p, args, u.STRING, "m", makefileArg,
&argparse.Options{Required: false, Help: "Add additional properties " +
"for Makefile"})

return u.ParserWrapper(p, os.Args)
}
Loading