Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
francescobianco committed Sep 14, 2023
1 parent de2b831 commit b26d93f
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 56 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ test-docs:

test-sysinfo:
@bash tests/bare/sysinfo-test.sh

test-install-help:
@bash tests/bare/help/install-test.sh
31 changes: 19 additions & 12 deletions bin/mush
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
## BP010: Release metadata
## @build_date: 2023-09-13T15:52:53Z
## @build_date: 2023-09-14T15:51:59Z
set -e
extern() {
extern=$1
Expand Down Expand Up @@ -700,15 +700,18 @@ run_init() {
}

parser_definition_install() {
setup REST help:usage abbr:true -- "Compile the current package" ''
setup REST help:usage abbr:true -- "Install a Mush binary. Default location is \$HOME/.mush/bin" ''

msg -- 'USAGE:' " ${2##*/} build [OPTIONS] [SUBCOMMAND]" ''
msg -- 'USAGE:' " ${2##*/} install [OPTIONS] [package]..." ''

msg -- 'OPTIONS:'
flag FLAG_C -c --flag-c
param MODULE_NAME -n --name
param BUILD_TARGET -t --target
disp :usage -h --help
msg -- 'OPTIONS:'
flag VERBOSE -v --verbose counter:true init:=0 -- "Use verbose output (-vv or -vvv to increase level)"
flag QUIET -q --quiet -- "Do not print cargo log messages"
flag BUILD_RELEASE -r --release -- "Build artifacts in release mode, with optimizations"

param PACKAGE_PATH --path -- "Filesystem path to local package to install"
param BUILD_TARGET -t --target -- "Build for the specific target"
disp :usage -h --help -- "Print help information"
}

run_install() {
Expand All @@ -719,6 +722,8 @@ run_install() {
#echo "MODULE_NAME: $MODULE_NAME"
#echo "BUILD_TARGET: $BUILD_TARGET"



exec_manifest_lookup

MUSH_TARGET_DIR=target/dist
Expand Down Expand Up @@ -1081,12 +1086,14 @@ exec_build_release() {
echo "## BP005: Execute the entrypoint" >> "${build_file}"
echo "main \"\$@\"" >> "${build_file}"

## Generate binary file
mkdir -p bin/
chmod +x "${build_file}"
## Generate binary on target
cp "${build_file}" "${final_file}"
chmod +x "${final_file}"

## Generate binary on root
mkdir -p bin/
cp "${final_file}" "${bin_file}"
chmod +x "${bin_file}"
}

exec_init() {
Expand Down Expand Up @@ -1122,7 +1129,7 @@ exec_install() {
local bin_name=$MUSH_PACKAGE_NAME
local pwd=$PWD

local bin_file=/usr/local/bin/${bin_name}
local bin_file=$HOME/.mush/bin/${bin_name}
local final_file=target/dist/${bin_name}

local cp=cp
Expand Down
19 changes: 12 additions & 7 deletions src/commands/install.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@

parser_definition_install() {
setup REST help:usage abbr:true -- "Compile the current package" ''
setup REST help:usage abbr:true -- "Install a Mush binary. Default location is \$HOME/.mush/bin" ''

msg -- 'USAGE:' " ${2##*/} build [OPTIONS] [SUBCOMMAND]" ''
msg -- 'USAGE:' " ${2##*/} install [OPTIONS] [package]..." ''

msg -- 'OPTIONS:'
flag FLAG_C -c --flag-c
param MODULE_NAME -n --name
param BUILD_TARGET -t --target
disp :usage -h --help
msg -- 'OPTIONS:'
flag VERBOSE -v --verbose counter:true init:=0 -- "Use verbose output (-vv or -vvv to increase level)"
flag QUIET -q --quiet -- "Do not print cargo log messages"
flag BUILD_RELEASE -r --release -- "Build artifacts in release mode, with optimizations"

param PACKAGE_PATH --path -- "Filesystem path to local package to install"
param BUILD_TARGET -t --target -- "Build for the specific target"
disp :usage -h --help -- "Print help information"
}

run_install() {
Expand All @@ -19,6 +22,8 @@ run_install() {
#echo "MODULE_NAME: $MODULE_NAME"
#echo "BUILD_TARGET: $BUILD_TARGET"



exec_manifest_lookup

MUSH_TARGET_DIR=target/dist
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exec_install() {
local bin_name=$MUSH_PACKAGE_NAME
local pwd=$PWD

local bin_file=/usr/local/bin/${bin_name}
local bin_file=$HOME/.mush/bin/${bin_name}
local final_file=target/dist/${bin_name}

local cp=cp
Expand Down
31 changes: 19 additions & 12 deletions target/dist/mush
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
## BP010: Release metadata
## @build_date: 2023-09-13T15:52:53Z
## @build_date: 2023-09-14T15:51:59Z
set -e
extern() {
extern=$1
Expand Down Expand Up @@ -700,15 +700,18 @@ run_init() {
}

parser_definition_install() {
setup REST help:usage abbr:true -- "Compile the current package" ''
setup REST help:usage abbr:true -- "Install a Mush binary. Default location is \$HOME/.mush/bin" ''

msg -- 'USAGE:' " ${2##*/} build [OPTIONS] [SUBCOMMAND]" ''
msg -- 'USAGE:' " ${2##*/} install [OPTIONS] [package]..." ''

msg -- 'OPTIONS:'
flag FLAG_C -c --flag-c
param MODULE_NAME -n --name
param BUILD_TARGET -t --target
disp :usage -h --help
msg -- 'OPTIONS:'
flag VERBOSE -v --verbose counter:true init:=0 -- "Use verbose output (-vv or -vvv to increase level)"
flag QUIET -q --quiet -- "Do not print cargo log messages"
flag BUILD_RELEASE -r --release -- "Build artifacts in release mode, with optimizations"

param PACKAGE_PATH --path -- "Filesystem path to local package to install"
param BUILD_TARGET -t --target -- "Build for the specific target"
disp :usage -h --help -- "Print help information"
}

run_install() {
Expand All @@ -719,6 +722,8 @@ run_install() {
#echo "MODULE_NAME: $MODULE_NAME"
#echo "BUILD_TARGET: $BUILD_TARGET"



exec_manifest_lookup

MUSH_TARGET_DIR=target/dist
Expand Down Expand Up @@ -1081,12 +1086,14 @@ exec_build_release() {
echo "## BP005: Execute the entrypoint" >> "${build_file}"
echo "main \"\$@\"" >> "${build_file}"

## Generate binary file
mkdir -p bin/
chmod +x "${build_file}"
## Generate binary on target
cp "${build_file}" "${final_file}"
chmod +x "${final_file}"

## Generate binary on root
mkdir -p bin/
cp "${final_file}" "${bin_file}"
chmod +x "${bin_file}"
}

exec_init() {
Expand Down Expand Up @@ -1122,7 +1129,7 @@ exec_install() {
local bin_name=$MUSH_PACKAGE_NAME
local pwd=$PWD

local bin_file=/usr/local/bin/${bin_name}
local bin_file=$HOME/.mush/bin/${bin_name}
local final_file=target/dist/${bin_name}

local cp=cp
Expand Down
31 changes: 19 additions & 12 deletions target/dist/mush.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
## BP010: Release metadata
## @build_date: 2023-09-13T15:52:53Z
## @build_date: 2023-09-14T15:51:59Z
set -e
extern() {
extern=$1
Expand Down Expand Up @@ -700,15 +700,18 @@ run_init() {
}

parser_definition_install() {
setup REST help:usage abbr:true -- "Compile the current package" ''
setup REST help:usage abbr:true -- "Install a Mush binary. Default location is \$HOME/.mush/bin" ''

msg -- 'USAGE:' " ${2##*/} build [OPTIONS] [SUBCOMMAND]" ''
msg -- 'USAGE:' " ${2##*/} install [OPTIONS] [package]..." ''

msg -- 'OPTIONS:'
flag FLAG_C -c --flag-c
param MODULE_NAME -n --name
param BUILD_TARGET -t --target
disp :usage -h --help
msg -- 'OPTIONS:'
flag VERBOSE -v --verbose counter:true init:=0 -- "Use verbose output (-vv or -vvv to increase level)"
flag QUIET -q --quiet -- "Do not print cargo log messages"
flag BUILD_RELEASE -r --release -- "Build artifacts in release mode, with optimizations"

param PACKAGE_PATH --path -- "Filesystem path to local package to install"
param BUILD_TARGET -t --target -- "Build for the specific target"
disp :usage -h --help -- "Print help information"
}

run_install() {
Expand All @@ -719,6 +722,8 @@ run_install() {
#echo "MODULE_NAME: $MODULE_NAME"
#echo "BUILD_TARGET: $BUILD_TARGET"



exec_manifest_lookup

MUSH_TARGET_DIR=target/dist
Expand Down Expand Up @@ -1081,12 +1086,14 @@ exec_build_release() {
echo "## BP005: Execute the entrypoint" >> "${build_file}"
echo "main \"\$@\"" >> "${build_file}"

## Generate binary file
mkdir -p bin/
chmod +x "${build_file}"
## Generate binary on target
cp "${build_file}" "${final_file}"
chmod +x "${final_file}"

## Generate binary on root
mkdir -p bin/
cp "${final_file}" "${bin_file}"
chmod +x "${bin_file}"
}

exec_init() {
Expand Down Expand Up @@ -1122,7 +1129,7 @@ exec_install() {
local bin_name=$MUSH_PACKAGE_NAME
local pwd=$PWD

local bin_file=/usr/local/bin/${bin_name}
local bin_file=$HOME/.mush/bin/${bin_name}
local final_file=target/dist/${bin_name}

local cp=cp
Expand Down
31 changes: 19 additions & 12 deletions target/dist/mush.tmp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
## BP010: Release metadata
## @build_date: 2023-09-13T15:52:53Z
## @build_date: 2023-09-14T15:51:59Z
set -e
extern() {
extern=$1
Expand Down Expand Up @@ -700,15 +700,18 @@ run_init() {
}

parser_definition_install() {
setup REST help:usage abbr:true -- "Compile the current package" ''
setup REST help:usage abbr:true -- "Install a Mush binary. Default location is \$HOME/.mush/bin" ''

msg -- 'USAGE:' " ${2##*/} build [OPTIONS] [SUBCOMMAND]" ''
msg -- 'USAGE:' " ${2##*/} install [OPTIONS] [package]..." ''

msg -- 'OPTIONS:'
flag FLAG_C -c --flag-c
param MODULE_NAME -n --name
param BUILD_TARGET -t --target
disp :usage -h --help
msg -- 'OPTIONS:'
flag VERBOSE -v --verbose counter:true init:=0 -- "Use verbose output (-vv or -vvv to increase level)"
flag QUIET -q --quiet -- "Do not print cargo log messages"
flag BUILD_RELEASE -r --release -- "Build artifacts in release mode, with optimizations"

param PACKAGE_PATH --path -- "Filesystem path to local package to install"
param BUILD_TARGET -t --target -- "Build for the specific target"
disp :usage -h --help -- "Print help information"
}

run_install() {
Expand All @@ -719,6 +722,8 @@ run_install() {
#echo "MODULE_NAME: $MODULE_NAME"
#echo "BUILD_TARGET: $BUILD_TARGET"



exec_manifest_lookup

MUSH_TARGET_DIR=target/dist
Expand Down Expand Up @@ -1081,12 +1086,14 @@ exec_build_release() {
echo "## BP005: Execute the entrypoint" >> "${build_file}"
echo "main \"\$@\"" >> "${build_file}"

## Generate binary file
mkdir -p bin/
chmod +x "${build_file}"
## Generate binary on target
cp "${build_file}" "${final_file}"
chmod +x "${final_file}"

## Generate binary on root
mkdir -p bin/
cp "${final_file}" "${bin_file}"
chmod +x "${bin_file}"
}

exec_init() {
Expand Down Expand Up @@ -1122,7 +1129,7 @@ exec_install() {
local bin_name=$MUSH_PACKAGE_NAME
local pwd=$PWD

local bin_file=/usr/local/bin/${bin_name}
local bin_file=$HOME/.mush/bin/${bin_name}
local final_file=target/dist/${bin_name}

local cp=cp
Expand Down
8 changes: 8 additions & 0 deletions tests/bare/help/install-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e

echo "==> Build: mush"
cp target/dist/mush target/dist/mush.sh
bash target/dist/mush.sh -vv build

target/dist/mush install --help

0 comments on commit b26d93f

Please sign in to comment.