Skip to content

Commit

Permalink
intial commit
Browse files Browse the repository at this point in the history
First commit to public git.

Signed-off-by: Thomas Ingleby <[email protected]>
  • Loading branch information
tingleby committed Feb 27, 2020
0 parents commit de9f50b
Show file tree
Hide file tree
Showing 37 changed files with 2,987 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/bin/
/build/
/config.*
!config.toml.dist
/docker-compose.override.yml
/var/
/vendor/
cover.out

# IDE integration
/.vscode/*
!/.vscode/launch.json
!/.vscode/tasks.json
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"env": {},
"args": [""]
}
]
}
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause "New" or "Revised" License

Copyright (c) 2019 Intel Corporation
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

- 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.

- 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.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# oneapi-cli tool

`oneapi-cli` is a tool to help you get started with Intel<sup>®</sup> oneAPI

## Where to find Intel oneAPI.

This tool does not provide any of the tools that may be required to compile/run the samples `oneapi-cli` can extract for you.

Please visit https://software.intel.com/en-us/oneapi for details.

## Development Install

Fetch using
```bash
go get github.com/intel/oneapi-cli
```
Alternativly see the tags/releases for a binary build for your OS.

## Building
Go 1.13 should be used to build the CLI/TUI app.

```bash
git clone https://github.com/intel/oneapi-cli.git
cd oneapi-cli
go build
./oneapi-cli
```

There is also a `build.sh` which will embed version information within the build.
8 changes: 8 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

version=$(git describe --long --dirty --abbrev=10 --tags)
lf="-X github.com/intel/oneapi-cli/cmd.version=${version}"

GOOS=linux GOARCH=amd64 go build -ldflags "$lf" -o linux/bin/oneapi-cli
GOOS=windows GOARCH=amd64 go build -ldflags "$lf" -o win/bin/oneapi-cli.exe
GOOS=darwin GOARCH=amd64 go build -ldflags "$lf" -o osx/bin/oneapi-cli
57 changes: 57 additions & 0 deletions cmd/check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2019 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
/*
usage:
oneapi-cli check --deps="mkl,tbb"
TODO: --html flag
https://software.intel.com/en-us/oneapi
*/

package cmd

import (
"fmt"
"os"

"github.com/intel/oneapi-cli/pkg/deps"
"github.com/spf13/cobra"
)

var depsParam []string
var root string

// checkCmd represents the check command
var checkCmd = &cobra.Command{
Use: "check",
Short: "check dependencies",
Hidden: true,
Long: `check dependencies, returns an error/retrieve-it- message if dependencies are absent`,
Run: func(cmd *cobra.Command, args []string) {

if root == "" {
//Find the oneAPI root
var err error
root, err = deps.GetOneAPIRoot()
if err != nil {
fmt.Println(err) //Failed to find the Env, may be unset.
os.Exit(-1)
}
}

//Check the deps at the found root.
msg, errCode := deps.CheckDeps(depsParam, root)
if errCode != 0 {
fmt.Println(msg)
os.Exit(errCode)
}
},
}

func init() {
rootCmd.AddCommand(checkCmd)
checkCmd.Flags().StringSliceVarP(&depsParam, "deps", "", nil, "comma seperated dependency array")
checkCmd.Flags().StringVar(&root, "oneapi-root", "", "(optional) path to oneAPI root, default attempts to use environment varible ONEAPI_ROOT")
}
26 changes: 26 additions & 0 deletions cmd/clean.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2019 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
"os"
"path/filepath"

"github.com/intel/oneapi-cli/pkg/aggregator"
"github.com/spf13/cobra"
)

// cleanCmd represents the clean command
var cleanCmd = &cobra.Command{
Use: "clean",
Short: "Clean Sample Cache",
Long: `Removes local Sample Cache`,
Run: func(cmd *cobra.Command, args []string) {
os.RemoveAll(filepath.Join(baseFilePath, aggregator.AggregatorLocalAPILevel))
},
}

func init() {
rootCmd.AddCommand(cleanCmd)
}
54 changes: 54 additions & 0 deletions cmd/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2019 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
"fmt"
"os"
"path/filepath"

"github.com/intel/oneapi-cli/pkg/aggregator"
"github.com/intel/oneapi-cli/pkg/extractor"
"github.com/spf13/cobra"
)

// listCmd represents the list command
var createCmd = &cobra.Command{
Use: "create",
Short: "Create Sample",
Hidden: true,
Long: `Creates the sample based on the passed in path
i.e. oneapi-cli create my/long/path/from/index/json /tmp/mynewproject`,
Run: func(cmd *cobra.Command, args []string) {

//Arg 0 being sample
//arg 1 being where to create teh sample. Complete path

if len(args) != 2 || args[0] == "" || args[1] == "" {
fmt.Println("Please pass both a sample and where you want it extracted to")
os.Exit(1)
}

lang := "cpp" //temp
tarPath := filepath.Join(baseFilePath, aggregator.AggregatorLocalAPILevel, lang, args[0], lang+".tar.gz")

_, err := os.Stat(tarPath)
if os.IsNotExist(err) {
fmt.Println("Sample does not exist in cache, that should not have happened.")
os.Exit(2)
}

err = extractor.ExtractTarGz(tarPath, args[1])
if err != nil {
fmt.Println(err)
os.Exit(3)
}

},
}

func init() {
rootCmd.AddCommand(createCmd)
}
59 changes: 59 additions & 0 deletions cmd/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2019 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
"encoding/json"
"fmt"
"os"

"github.com/spf13/cobra"
)

func prettyPrint(i interface{}) string {
s, _ := json.MarshalIndent(i, "", "\t")
return string(s)
}

var language string
var outputJSON bool

// listCmd represents the list command
var listCmd = &cobra.Command{
Use: "list",
Short: "List Samples",
Hidden: true,
Long: `Lists the available samples. Checks online if newer sample index
is available`,
Run: func(cmd *cobra.Command, args []string) {

if language == "" {
for _, l := range getAggregator().GetLanguages() {
fmt.Printf("%s\n", l)
}
os.Exit(1)
}

if getAggregator().Samples[language] == nil {
fmt.Printf("Invalid language provided, available languages: %v\n", getAggregator().GetLanguages())
os.Exit(1)
}

if outputJSON {
fmt.Printf("%s\n", prettyPrint(getAggregator().Samples[language]))
return
}

for _, s := range getAggregator().Samples[language] {
fmt.Printf("%s:\n\t%s\n", s.Fields.Name, s.Fields.Description)
}

},
}

func init() {
rootCmd.AddCommand(listCmd)
listCmd.Flags().StringVarP(&language, "output", "o", "", "specific language samples you want to list")
listCmd.Flags().BoolVarP(&outputJSON, "json", "j", false, "output as JSON")
}
Loading

0 comments on commit de9f50b

Please sign in to comment.