diff --git a/CONFIG.toml b/CONFIG.toml index ed583d4c..3c0117ba 100644 --- a/CONFIG.toml +++ b/CONFIG.toml @@ -94,9 +94,9 @@ PROJECT_SOURCE_URL = "https://github.com/ChewKeanHo/AutomataCI" ###################### -# GO TECHNOLOGY # +# NIM TECHNOLOGY # ###################### -# PROJECT_GO +# PROJECT_NIM # This is a control variable used for enabling Go technology and also defining # its source codes directory relative to PROJECT_PATH_ROOT. Depending on the # offered service (e.g. GitHub Actions), setting this variable with value shall @@ -104,13 +104,13 @@ PROJECT_SOURCE_URL = "https://github.com/ChewKeanHo/AutomataCI" # # To enable it: simply supply the path (e.g. default is 'srcGO'). # To disable it: simply supply an empty path (e.g. default is ''). -PROJECT_GO = '' +PROJECT_NIM = 'srcNIM' -# PROJECT_PATH_GO_ENGINE +# PROJECT_PATH_NIM_ENGINE # This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for # setting up localized environment. -PROJECT_PATH_GO_ENGINE = "go-engine" +PROJECT_PATH_NIM_ENGINE = "nim-engine" @@ -126,7 +126,29 @@ PROJECT_PATH_GO_ENGINE = "go-engine" # # To enable it: simply supply the path (e.g. default is 'srcC'). # To disable it: simply supply an empty path (e.g. default is ''). -PROJECT_C = 'srcC' +PROJECT_C = '' + + + + +###################### +# GO TECHNOLOGY # +###################### +# PROJECT_GO +# This is a control variable used for enabling Go technology and also defining +# its source codes directory relative to PROJECT_PATH_ROOT. Depending on the +# offered service (e.g. GitHub Actions), setting this variable with value shall +# notify the CI provider to setup Go development environment automatically. +# +# To enable it: simply supply the path (e.g. default is 'srcGO'). +# To disable it: simply supply an empty path (e.g. default is ''). +PROJECT_GO = '' + + +# PROJECT_PATH_GO_ENGINE +# This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for +# setting up localized environment. +PROJECT_PATH_GO_ENGINE = "go-engine" diff --git a/README.md b/README.md index 92506172..bf95918e 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Some good business reasons why using AutomataCI: ### Supported Technologies -* Nim Programming Language (*Coming Soon*) +* [Nim Programming Language](https://nim-lang.org/) * [Go Programming Language](https://go.dev/) * C Programming Language 1. [i386 & amd64 GCC Compilers](https://gcc.gnu.org/) diff --git a/automataCI/_package-sourcing_unix-any.sh b/automataCI/_package-sourcing_unix-any.sh index 06844ef4..539ba5b7 100644 --- a/automataCI/_package-sourcing_unix-any.sh +++ b/automataCI/_package-sourcing_unix-any.sh @@ -92,3 +92,21 @@ if [ ! -z "$PROJECT_C" ]; then fi fi fi + + + + +# source from Nim and overrides existing +if [ ! -z "$PROJECT_NIM" ]; then + __recipe="${PROJECT_PATH_ROOT}/${PROJECT_NIM}/${PROJECT_PATH_CI}" + __recipe="${__recipe}/package_unix-any.sh" + FS::is_file "$__recipe" + if [ $? -eq 0 ]; then + OS::print_status info "sourcing Nim content assembling functions: ${__recipe}\n" + . "$__recipe" + if [ $? -ne 0 ]; then + OS::print_status error "Sourcing failed\n" + return 1 + fi + fi +fi diff --git a/automataCI/_package-sourcing_windows-any.ps1 b/automataCI/_package-sourcing_windows-any.ps1 index 3cefb37b..80799430 100644 --- a/automataCI/_package-sourcing_windows-any.ps1 +++ b/automataCI/_package-sourcing_windows-any.ps1 @@ -90,3 +90,21 @@ if (-not [string]::IsNullOrEmpty(${env:PROJECT_C})) { } } } + + + + +# source from Nim and overrides existing +if (-not [string]::IsNullOrEmpty(${env:PROJECT_NIM})) { + $__recipe = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}\${env:PROJECT_PATH_CI}" + $__recipe = "${__recipe}\package_windows-any.ps1" + $__process = FS-Is-File "${__recipe}" + if ($__process -eq 0) { + OS-Print-Status info "sourcing Nim content assembling functions: ${__recipe}" + $__process = . "${__recipe}" + if ($__process -ne 0) { + OS-Print-Status error "Source failed." + return + } + } +} diff --git a/automataCI/ci.ps1 b/automataCI/ci.ps1 index 49b22e5e..035f7b14 100755 --- a/automataCI/ci.ps1 +++ b/automataCI/ci.ps1 @@ -136,6 +136,14 @@ if (Test-Path -Path "${env:PROJECT_PATH_ROOT}\SECRETS.toml" -PathType leaf) { +# update critical environment variables +$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") ` + + ";" ` + + [System.Environment]::GetEnvironmentVariable("Path","User") + + + + # execute command switch ($args[0]) { { $_ -in 'env', 'Env', 'ENV' } { diff --git a/automataCI/ci.sh b/automataCI/ci.sh index 2d6f2734..d3e67c3d 100755 --- a/automataCI/ci.sh +++ b/automataCI/ci.sh @@ -170,6 +170,24 @@ fi +# update environment variables +case "$PROJECT_OS" in +linux) + __location="/home/linuxbrew/.linuxbrew/bin/brew" + ;; +darwin) + __location="/usr/local/bin/brew" + ;; +*) + ;; +esac +if [ -f "$__location" ]; then + eval "$("${__location}" shellenv)" +fi + + + + # execute command case "$1" in env|Env|ENV) diff --git a/automataCI/common_unix-any.sh b/automataCI/common_unix-any.sh index 7cabb0e7..61e3894d 100644 --- a/automataCI/common_unix-any.sh +++ b/automataCI/common_unix-any.sh @@ -92,6 +92,24 @@ fi +# execute NIM if set +if [ ! -z "$PROJECT_NIM" ]; then + __recipe="$(STRINGS::to_lowercase "$PROJECT_CI_JOB")_unix-any.sh" + __recipe="${PROJECT_PATH_ROOT}/${PROJECT_NIM}/${PROJECT_PATH_CI}/${__recipe}" + FS::is_file "$__recipe" + if [ $? -eq 0 ]; then + OS::print_status info "NIM tech detected. Parsing job recipe: ${__recipe}\n" + . "$__recipe" + if [ $? -ne 0 ]; then + OS::print_status error "Parse failed.\n" + return 1 + fi + fi +fi + + + + # execute baseline as last __recipe="$(STRINGS::to_lowercase "$PROJECT_CI_JOB")_unix-any.sh" __recipe="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/${__recipe}" diff --git a/automataCI/common_windows-any.ps1 b/automataCI/common_windows-any.ps1 index 27805d62..059ddd31 100644 --- a/automataCI/common_windows-any.ps1 +++ b/automataCI/common_windows-any.ps1 @@ -90,6 +90,24 @@ if (-not [string]::IsNullOrEmpty(${env:PROJECT_C})) { +# execute NIM if set +if (-not [string]::IsNullOrEmpty(${env:PROJECT_NIM})) { + $__recipe = STRINGS-To-Lowercase "${env:PROJECT_CI_JOB}_windows-any.ps1" + $__recipe = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}\${env:PROJECT_PATH_CI}\${__recipe}" + $__process = FS-Is-File "${__recipe}" + if ($__process -eq 0) { + OS-Print-Status info "NIM tech detected. Parsing job recipe: ${__recipe}" + $__process = . $__recipe + if ($__process -ne 0) { + OS-Print-Status error "Parse failed." + return 1 + } + } +} + + + + # execute baseline as last $__recipe = STRINGS-To-Lowercase "${env:PROJECT_CI_JOB}_windows-any.ps1" $__recipe = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\${__recipe}" diff --git a/automataCI/docs/AutomataCI-Engineering-Specification.odt b/automataCI/docs/AutomataCI-Engineering-Specification.odt index 9707d078..8a754251 100644 Binary files a/automataCI/docs/AutomataCI-Engineering-Specification.odt and b/automataCI/docs/AutomataCI-Engineering-Specification.odt differ diff --git a/automataCI/docs/AutomataCI-Engineering-Specification.pdf b/automataCI/docs/AutomataCI-Engineering-Specification.pdf index 6bd9867a..06f5e212 100644 Binary files a/automataCI/docs/AutomataCI-Engineering-Specification.pdf and b/automataCI/docs/AutomataCI-Engineering-Specification.pdf differ diff --git a/automataCI/env_unix-any.sh b/automataCI/env_unix-any.sh index 45b8f53f..5d8c0341 100644 --- a/automataCI/env_unix-any.sh +++ b/automataCI/env_unix-any.sh @@ -79,7 +79,7 @@ if [ ! -z "$PROJECT_GO" ]; then fi -if [ ! -z "$PROJECT_C" ]; then +if [ ! -z "$PROJECT_C" ] || [ ! -z "$PROJECT_NIM" ]; then OS::print_status info "Installing c...\n" INSTALLER::setup_c "$PROJECT_OS" "$PROJECT_ARCH" if [ $? -ne 0 ]; then @@ -89,6 +89,16 @@ if [ ! -z "$PROJECT_C" ]; then fi +if [ ! -z "$PROJECT_NIM" ]; then + OS::print_status info "Installing nim...\n" + INSTALLER::setup_nim "$PROJECT_OS" "$PROJECT_ARCH" + if [ $? -ne 0 ]; then + OS::print_status error "install failed.\n" + return 1 + fi +fi + + # report status diff --git a/automataCI/env_windows-any.ps1 b/automataCI/env_windows-any.ps1 index 4565de45..d574131c 100644 --- a/automataCI/env_windows-any.ps1 +++ b/automataCI/env_windows-any.ps1 @@ -62,6 +62,7 @@ if (-not ([string]::IsNullOrEmpty(${env:PROJECT_PYTHON}))) { OS-Print-Status info "Installing python..." $__process = INSTALLER-Setup-Python if ($__process -ne 0) { + OS-Print-Status error "install failed." return 1 } } @@ -71,15 +72,28 @@ if (-not ([string]::IsNullOrEmpty(${env:PROJECT_GO}))) { OS-Print-Status info "Installing go..." $__process = INSTALLER-Setup-Go if ($__process -ne 0) { + OS-Print-Status error "install failed." return 1 } } -if (-not ([string]::IsNullOrEmpty(${env:PROJECT_C}))) { +if (-not ([string]::IsNullOrEmpty(${env:PROJECT_C})) -or + -not ([string]::IsNullOrEmpty(${env:PROJECT_NIM}))) { OS-Print-Status info "Installing c..." $__process = INSTALLER-Setup-C if ($__process -ne 0) { + OS-Print-Status error "install failed." + return 1 + } +} + + +if (-not ([string]::IsNullOrEmpty(${env:PROJECT_NIM}))) { + OS-Print-Status info "Installing nim..." + $__process = INSTALLER-Setup-Nim + if ($__process -ne 0) { + OS-Print-Status error "install failed." return 1 } } diff --git a/automataCI/compiler-c_unix-any.sh b/automataCI/operators_unix-any.sh similarity index 73% rename from automataCI/compiler-c_unix-any.sh rename to automataCI/operators_unix-any.sh index 621f1735..64a8abbf 100644 --- a/automataCI/compiler-c_unix-any.sh +++ b/automataCI/operators_unix-any.sh @@ -25,17 +25,14 @@ fi . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/strings.sh" . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/sync.sh" . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/compilers/c.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/compilers/nim.sh" BUILD::__exec_compile_source_code() { # execute - __line="$@" - __line="${__line#*-c }" - __line="${__line%%.c*}" - - OS::print_status info "compiling ${__line}.c\n" + OS::print_status info "executing ${@}\n" $@ if [ $? -ne 0 ]; then OS::print_status error "build failed.\n\n" @@ -129,7 +126,7 @@ BUILD::__validate_source_files() { # create command for parallel execution - if [ ! "${__path%.c*}" = "$__path" ]; then # it's a .c source file + if [ ! "${__path%.c*}" = "$__path" ]; then OS::print_status info "registering .c file...\n" printf -- "%b -o %b -c %b %b\n" \ "$_target_compiler" \ @@ -149,12 +146,32 @@ ${_target_directory}/${__path%.c*}.o OS::print_status error "register failed.\n\n" return 1 fi - elif [ ! "${__path%.o*}" = "$__path" ]; then # it's a .o compiled file + elif [ ! "${__path%.nim*}" = "$__path" ]; then + OS::print_status info "registering .nim file...\n" + printf -- "%b %b --out:%b %b\n" \ + "$_target_compiler" \ + "$_target_args" \ + "${_target_directory}/${__path%.nim*}" \ + "${PROJECT_PATH_ROOT}/${_target_source}/${__path}" \ + >> "$_parallel_control" + if [ $? -ne 0 ]; then + OS::print_status error "register failed.\n\n" + return 1 + fi + + FS::append_file "$_linker_control" "\ +${_target_directory}/${__path%.nim*} +" + if [ $? -ne 0 ]; then + OS::print_status error "register failed.\n\n" + return 1 + fi + elif [ ! "${__path%.o*}" = "$__path" ]; then OS::print_status info "registering .o file...\n" __target_path="${_target_directory}/${__path}" FS::make_housing_directory "$__target_path" FS::copy_file \ - "${PROJECT_PATH_ROOT}/${_target_source}/$__path" \ + "${PROJECT_PATH_ROOT}/${_target_source}/${__path}" \ "${__target_path%/*}" if [ $? -ne 0 ]; then OS::print_status error "register failed.\n\n" @@ -168,7 +185,7 @@ ${_target_directory}/${__path} OS::print_status error "register failed.\n\n" return 1 fi - else # it's an unsupported file + else OS::print_status error "unsupported file: ${__path}\n\n" return 1 fi @@ -236,10 +253,24 @@ BUILD::_exec_build() { _target_arch="$(STRINGS::to_lowercase "$_target_arch")" _target_directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}" case "$(STRINGS::to_lowercase "$_target_type")" in - c_binary) + nim-binary) + _target_source="$PROJECT_NIM" + _target_type="none" + _target_directory="${_target_directory}/nim-bin_${_target}" + _target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}/${_target}" + _target_compiler="nim" + ;; + nim-test) + _target_source="$PROJECT_NIM" + _target_type="none" + _target_directory="${_target_directory}/nim-test_${_target}" + _target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}/${_target}" + _target_compiler="nim" + ;; + c-binary) _target_source="$PROJECT_C" _target_type="bin" - _target_directory="${_target_directory}/cbin_${_target}" + _target_directory="${_target_directory}/c-bin_${_target}" case "$_target_arch" in wasm) _target="${_target}.wasm" @@ -249,19 +280,58 @@ BUILD::_exec_build() { ;; esac _target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}/${_target}" + _target_compiler="$(C::get_compiler \ + "$_target_os" \ + "$_target_arch" \ + "$PROJECT_OS" \ + "$PROJECT_ARCH" \ + "$_target_compiler" \ + )" + if [ $? -ne 0 ]; then + OS::print_status warning "No available compiler. Skipping...\n\n" + return 10 + else + OS::print_status info "selected ${_target_compiler} compiler...\n" + fi ;; - c_library) + c-library) _target_source="$PROJECT_C" _target_type="lib" _target="${PROJECT_SKU}-lib_${_target_os}-${_target_arch}" - _target_directory="${_target_directory}/clib_${_target}" + _target_directory="${_target_directory}/c-lib_${_target}" _target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}/${_target}.a" + _target_compiler="$(C::get_compiler \ + "$_target_os" \ + "$_target_arch" \ + "$PROJECT_OS" \ + "$PROJECT_ARCH" \ + "$_target_compiler" \ + )" + if [ $? -ne 0 ]; then + OS::print_status warning "No available compiler. Skipping...\n\n" + return 10 + else + OS::print_status info "selected ${_target_compiler} compiler...\n" + fi ;; - c_test) + c-test) _target_source="$PROJECT_C" _target_type="test-bin" - _target_directory="${_target_directory}/ctest_${_target}" + _target_directory="${_target_directory}/c-test_${_target}" _target="${_target_directory}" + _target_compiler="$(C::get_compiler \ + "$_target_os" \ + "$_target_arch" \ + "$PROJECT_OS" \ + "$PROJECT_ARCH" \ + "$_target_compiler" \ + )" + if [ $? -ne 0 ]; then + OS::print_status warning "No available compiler. Skipping...\n\n" + return 10 + else + OS::print_status info "selected ${_target_compiler} compiler...\n" + fi ;; *) OS::print_status error "validation failed.\n\n" @@ -271,19 +341,6 @@ BUILD::_exec_build() { _parallel_control="${_target_directory}/sync.txt" _linker_control="${_target_directory}/o-list.txt" _parallel_total=0 - _target_compiler="$(C::get_compiler \ - "$_target_os" \ - "$_target_arch" \ - "$PROJECT_OS" \ - "$PROJECT_ARCH" \ - "$_target_compiler" \ - )" - if [ $? -ne 0 ]; then - OS::print_status warning "No available compiler. Skipping...\n\n" - return 10 - else - OS::print_status info "selected ${_target_compiler} compiler...\n" - fi OS::print_status info "validating config file (${_target_config##*/}) existence...\n" @@ -327,7 +384,7 @@ BUILD::_exec_build() { # link all objects BUILD::_exec_link \ "$_target_type" \ - "${_target}" \ + "$_target" \ "$_target_directory" \ "$_linker_control" \ "$_target_compiler" @@ -362,11 +419,14 @@ BUILD::_exec_link() { # link all objects case "$_target_type" in + none) + OS::print_status info "linking object file into executable...\n" + ;; test-bin) OS::print_status info "linking object file into executable...\n" old_IFS="$IFS" while IFS="" read -r __line || [ -n "$__line" ]; do - _target="${__line%.o*}" + _target="${__line%.*}" FS::remove_silently "$_target" if [ $? -ne 0 ]; then OS::print_status error "link failed.\n\n" @@ -474,19 +534,43 @@ BUILD::test() { # prepare test environment _target="${PROJECT_SKU}_${_target_os}-${_target_arch}" - _target_directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/ctest_${_target}" - _target_build_list="${_target_directory}/build-list.txt" + _target_directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}" # scan for all test source codes OS::print_status info "setup test workspace...\n" - FS::remake_directory "$_target_directory" case "$1" in + "$PROJECT_NIM") + OS::print_status info "scanning all nim test codes...\n" + _target_code="nim-test" + _target_directory="${_target_directory}/${_target_code}_${_target}" + _target_build_list="${_target_directory}/build-list.txt" + + FS::remake_directory "$_target_directory" + + __old_IFS="$IFS" + find "${PROJECT_PATH_ROOT}/${PROJECT_NIM}" -name '*_test.nim' -print0 \ + | while IFS="" read -r __line || [ -n "$__line" ]; do + __line="${__line#*${PROJECT_PATH_ROOT}/${PROJECT_NIM}/}" + + OS::print_status info "registering ${__line}\n" + FS::append_file \ + "$_target_build_list" \ + "${_target_os}-${_target_arch} ${__line}\n" + done + IFS="$__old_IFS" && unset __old_IFS + ;; "$PROJECT_C") OS::print_status info "scanning all C test codes...\n" + _target_code="c-test" + _target_directory="${_target_directory}/${_target_code}_${_target}" + _target_build_list="${_target_directory}/build-list.txt" + + FS::remake_directory "$_target_directory" + __old_IFS="$IFS" - find "${PROJECT_PATH_ROOT}/${PROJECT_C}" -name '*_test.c' -print0 | - while IFS="" read -r __line || [ -n "$__line" ]; do + find "${PROJECT_PATH_ROOT}/${PROJECT_C}" -name '*_test.c' -print0 \ + | while IFS="" read -r __line || [ -n "$__line" ]; do __line="${__line#*${PROJECT_PATH_ROOT}/${PROJECT_C}/}" OS::print_status info "registering ${__line}\n" @@ -503,8 +587,15 @@ BUILD::test() { esac + # check if no test is available, get out early. + if [ ! -f "$_target_build_list" ]; then + OS::print_status success "\n\n" + return 0 + fi + + # build all test artifacts - BUILD::_exec_build "c_test" "$2" "$3" "$_target_build_list" "$4" "$5" + BUILD::_exec_build "$_target_code" "$2" "$3" "$_target_build_list" "$4" "$5" case $? in 0) ;; @@ -519,7 +610,8 @@ BUILD::test() { # execute all test artifacts _target_config="${PROJECT_SKU}_${PROJECT_OS}-${PROJECT_ARCH}" - _target_config="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/ctest_${_target_config}" + _target_config="${_target_code}_${_target_config}" + _target_config="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/${_target_config}" _target_config="${_target_config}/o-list.txt" OS::print_status info "checking test execution workspace...\n" @@ -531,7 +623,7 @@ BUILD::test() { EXIT_CODE=0 __old_IFS="$IFS" while IFS="" read -r __line || [ -n "$__line" ]; do - __line="${__line%.o*}" + __line="${__line%.*}" OS::print_status info "testing ${__line}\n" $__line diff --git a/automataCI/compiler-c_windows-any.ps1 b/automataCI/operators_windows-any.ps1 similarity index 75% rename from automataCI/compiler-c_windows-any.ps1 rename to automataCI/operators_windows-any.ps1 index bccfe4fa..3f42920f 100644 --- a/automataCI/compiler-c_windows-any.ps1 +++ b/automataCI/operators_windows-any.ps1 @@ -24,16 +24,14 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\strings.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\sync.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\c.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\nim.ps1" function BUILD-__Exec-Compile-Source-Code { # execute - $__line = $args -Join " " - $__line = $__line -replace '.*(D:\\.*\.c).*', '$1' - - OS-Print-Status info "compiling ${__line}" + OS-Print-Status info "executing ${args}" $__process = Invoke-Expression "$args" if ($LASTEXITCODE -ne 0) { OS-Print-Status error "build failed.`n" @@ -54,6 +52,7 @@ function BUILD-__Init-Sync { . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\strings.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\sync.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\c.ps1" + . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\nim.ps1" } @@ -157,6 +156,26 @@ function BUILD-__Validate-Source-Files { $__process = FS-Append-File "${_linker_control}" @" ${_target_directory}\$($__path -replace '.c.*', '.o') +"@ + if ($__process -ne 0) { + OS-Print-Status error "register failed.`n" + return + } + } elseif ($__path -match "\.nim$") { + OS-Print-Status info "registering .nim file..." + $__str = "{0} {1} --out:{2} {3}" -f ` + "${_target_compiler}", ` + "${_target_args}", ` + "${_target_directory}\$($__path -replace '.nim.*', '')", ` + "${env:PROJECT_PATH_ROOT}\${_target_source}\${__path}" + $__process = FS-Append-File "${_parallel_control}" "${__str}" + if ($__process -ne 0) { + OS-Print-Status error "register failed.`n" + return 1 + } + + $__process = FS-Append-File "${_linker_control}" @" +${_target_directory}\$($__path -replace '.nim.*', '') "@ if ($__process -ne 0) { OS-Print-Status error "register failed.`n" @@ -175,7 +194,7 @@ ${_target_directory}\$($__path -replace '.c.*', '.o') } $__process = FS-Append-File "${_linker_control}" @" -${_target_directory}\$($__path -replace '.c.*', '.o') +${_target_directory}\${__path} "@ if ($__process -ne 0) { OS-Print-Status error "register failed.`n" @@ -247,10 +266,22 @@ function BUILD-_Exec-Build { $_target_directory = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}" $_target_type = STRINGS-To-Lowercase "${_target_type}" switch ($_target_type) { - c_binary { + nim-binary { + $_target_source = "${env:PROJECT_NIM}" + $_target_type = "none" + $_target_directory = "${_target_directory}\nim-bin_${_target}" + $_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}\${_target}" + $_target_compiler = "nim" + } nim-test { + $_target_source = "${env:PROJECT_NIM}" + $_target_type = "none" + $_target_directory = "${_target_directory}\nim-test_${_target}" + $_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}\${_target}" + $_target_compiler = "nim" + } c-binary { $_target_source = "${env:PROJECT_C}" $_target_type = "bin" - $_target_directory = "${_target_directory}\cbin_${_target}" + $_target_directory = "${_target_directory}\c-bin_${_target}" switch ($_target_arch) { wasm { $_target = "${_target}.wasm" @@ -258,17 +289,53 @@ function BUILD-_Exec-Build { $_target = "${_target}.exe" }} $_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}\${_target}" - } c_library { + $_target_compiler = C-Get-Compiler ` + "${_target_os}" ` + "${_target_arch}" ` + "${env:PROJECT_OS}" ` + "${env:PROJECT_ARCH}" ` + "${_target_compiler}" + if ([string]::IsNullOrEmpty($_target_compiler)) { + OS-Print-Status warning "No available compiler. Skipping...`n" + return 10 + } else { + OS-Print-Status info "selected ${_target_compiler} compiler..." + } + } c-library { $_target_source = "${env:PROJECT_C}" $_target_type = "lib" $_target = "${env:PROJECT_SKU}-lib_${_target_os}-${_target_arch}" - $_target_directory = "${_target_directory}\clib_${_target}" + $_target_directory = "${_target_directory}\c-lib_${_target}" $_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}\${_target}.dll" - } c_test { + $_target_compiler = C-Get-Compiler ` + "${_target_os}" ` + "${_target_arch}" ` + "${env:PROJECT_OS}" ` + "${env:PROJECT_ARCH}" ` + "${_target_compiler}" + if ([string]::IsNullOrEmpty($_target_compiler)) { + OS-Print-Status warning "No available compiler. Skipping...`n" + return 10 + } else { + OS-Print-Status info "selected ${_target_compiler} compiler..." + } + } c-test { $_target_source = "${env:PROJECT_C}" $_target_type = "test-bin" - $_target_directory = "${_target_directory}\ctest_${_target}" + $_target_directory = "${_target_directory}\c-test_${_target}" $_target = "${_target_directory}" + $_target_compiler = C-Get-Compiler ` + "${_target_os}" ` + "${_target_arch}" ` + "${env:PROJECT_OS}" ` + "${env:PROJECT_ARCH}" ` + "${_target_compiler}" + if ([string]::IsNullOrEmpty($_target_compiler)) { + OS-Print-Status warning "No available compiler. Skipping...`n" + return 10 + } else { + OS-Print-Status info "selected ${_target_compiler} compiler..." + } } default { OS-Print-Status error "validation failed.`n" return 1 @@ -276,18 +343,6 @@ function BUILD-_Exec-Build { $_parallel_control = "${_target_directory}\sync.txt" $_linker_control = "${_target_directory}\o-list.txt" $_parallel_total = 0 - $_target_compiler = C-Get-Compiler ` - "${_target_os}" ` - "${_target_arch}" ` - "${env:PROJECT_OS}" ` - "${env:PROJECT_ARCH}" ` - "${_target_compiler}" - if ([string]::IsNullOrEmpty($_target_compiler)) { - OS-Print-Status warning "No available compiler. Skipping...`n" - return 10 - } else { - OS-Print-Status info "selected ${_target_compiler} compiler..." - } OS-Print-Status info ` @@ -369,7 +424,9 @@ function BUILD-_Exec-Link { # link all objects switch ($_target_type) { - test-bin { + none { + OS-Print-Status info "linking object file into executable..." + } test-bin { OS-Print-Status info "linking object file into executable..." foreach ($__line in (Get-Content -Path "${_linker_control}")) { $_target = $__line -replace '\.o$', '.exe' @@ -401,8 +458,6 @@ function BUILD-_Exec-Link { return 1 } - - # convert pathing to be GCC friendly $__directory = Split-Path -Parent -Path "${_linker_control}" $__file = Split-Path -Leaf -Path "${_linker_control}" $_linker_control = "${__directory}\~${__file}" @@ -491,26 +546,49 @@ function BUILD-Test { # prepare test environment $_target = "${env:PROJECT_SKU}_${_target_os}-${_target_arch}" - $_target_directory = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\ctest_${_target}" - $_target_build_list = "${_target_directory}\build-list.txt" + $_target_directory = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}" # scan for all test source codes OS-Print-Status info "setup test workspace..." $null = FS-Remake-Directory "${_target_directory}" switch ($_target_type) { - "${env:PROJECT_C}" { + "${env:PROJECT_NIM}" { + OS-Print-Status info "scanning all nim test codes..." + $_target_code = "nim-test" + $_target_directory = "${_target_directory}\${_target_code}_${_target}" + $_target_build_list = "${_target_directory}\build-list.txt" + + $null = FS-Remake-Directory "${_target_directory}" + + foreach ($__line in (Get-ChildItem ` + -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}" ` + -Recurse ` + -Filter "*_test.nim").FullName) { + $__line = $__line.Replace("${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}\", "") + + OS-Print-Status info "registering ${__line}" + $null = FS-Append-File ` + "${_target_build_list}" ` + "${_target_os}-${_target_arch} ${__line}" + } + } "${env:PROJECT_C}" { OS-Print-Status info "scanning all C test codes..." + $_target_code = "c-test" + $_target_directory = "${_target_directory}\${_target_code}_${_target}" + $_target_build_list = "${_target_directory}\build-list.txt" + + $null = FS-Remake-Directory "${_target_directory}" + foreach ($__line in (Get-ChildItem ` -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}" ` -Recurse ` -Filter "*_test.c").FullName) { - $__line = $__line.TrimStart("${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}\") - + $__line = $__line.Replace("${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}\", "") OS-Print-Status info "registering ${__line}" - FS-Append-File "${_target_build_list}" @" -${_target_os}-${_target_arch} ${__line} -"@ + $null = FS-Append-File ` + "${_target_build_list}" ` + "${_target_os}-${_target_arch} ${__line}" } } Default { @@ -519,9 +597,16 @@ ${_target_os}-${_target_arch} ${__line} }} + # check if no test is available, get out early + if (-not (Test-Path -Path "${_target_build_list}")) { + OS-Print-Status success "`n" + return 0 + } + + # build all test artifacts $__process = BUILD-_Exec-Build ` - "c_test" ` + "${_target_code}" ` "${_target_os}" ` "${_target_arch}" ` "${_target_build_list}" ` @@ -536,7 +621,8 @@ ${_target_os}-${_target_arch} ${__line} # execute all test artifacts $_target_config = "${env:PROJECT_SKU}_${env:PROJECT_OS}-${env:PROJECT_ARCH}" - $_target_config = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\ctest_${_target_config}" + $_target_config = "${_target_code}_${_target_config}" + $_target_config = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\${_target_config}" $_target_config = "${_target_config}\o-list.txt" OS-Print-Status info "checking test execution workspace..." @@ -551,7 +637,7 @@ ${_target_os}-${_target_arch} ${__line} OS-Print-Status info "testing ${__line}" try { - $__process = Invoke-Expression "${__line}" + $null = Write-Host "$(Invoke-Expression "${__line}")" if ($LASTEXITCODE -ne 0) { $EXIT_CODE = 1 } diff --git a/automataCI/services/compilers/c.ps1 b/automataCI/services/compilers/c.ps1 index 008b5293..bf6aed56 100644 --- a/automataCI/services/compilers/c.ps1 +++ b/automataCI/services/compilers/c.ps1 @@ -190,23 +190,23 @@ function C-Get-Compiler-By-Arch { }} } mips { $__compiler = "mips-linux-gnu-gcc" - } mipsle { + } { $_ -in "mipsle", "mipsel" } { $__compiler = "mipsel-linux-gnu-gcc" } mips64 { $__compiler = "mips64-linux-gnuabi64-gcc" - } {$_ -in "mips64le", "mips64el" } { + } { $_ -in "mips64le", "mips64el" } { $__compiler = "mips64el-linux-gnuabi64-gcc" } mipsisa32r6 { $__compiler = "mipsisa32r6-linux-gnu-gcc" - } {$_ -in "mips64r6", "mipsisa64r6" } { + } { $_ -in "mips64r6", "mipsisa64r6" } { $__compiler = "mipsisa64r6-linux-gnuabi64-gcc" - } mipsisa32r6el { + } { $_ -in "mips32r6le", "mipsisa32r6le", "mipsisa32r6el" } { $__compiler = "mipsisa32r6el-linux-gnu-gcc" - } {$_ -in "mips64r6el", "mipsisa64r6el" } { + } { $_ -in "mips64r6le", "mips64r6el", "mipsisa64r6el" } { $__compiler = "mipsisa64r6el-linux-gnuabi64-gcc" } powerpc { $__compiler = "powerpc-linux-gnu-gcc" - } ppc64el { + } { $_ -in "ppc64le", "ppc64el" } { $__compiler = "powerpc64le-linux-gnu-gcc" } riscv64 { $__compiler = "riscv64-elf-gcc" diff --git a/automataCI/services/compilers/c.sh b/automataCI/services/compilers/c.sh index 72c70c84..9239614f 100644 --- a/automataCI/services/compilers/c.sh +++ b/automataCI/services/compilers/c.sh @@ -216,22 +216,22 @@ C::get_compiler_by_arch() { mips64le|mips64el) __compiler="mips64el-linux-gnuabi64-gcc" ;; - mipsisa32r6) + mips32r6|mipsisa32r6) __compiler="mipsisa32r6-linux-gnu-gcc" ;; mips64r6|mipsisa64r6) __compiler="mipsisa64r6-linux-gnuabi64-gcc" ;; - mipsisa32r6el) + mips32r6le|mipsisa32r6le|mipsisa32r6el) __compiler="mipsisa32r6el-linux-gnu-gcc" ;; - mips64r6el|mipsisa64r6el) + mips64r6le|mipsisa64r6le|mipsisa64r6el) __compiler="mipsisa64r6el-linux-gnuabi64-gcc" ;; powerpc) __compiler="powerpc-linux-gnu-gcc" ;; - ppc64el) + ppc64le|ppc64el) __compiler="powerpc64le-linux-gnu-gcc" ;; riscv64) diff --git a/automataCI/services/compilers/go.ps1 b/automataCI/services/compilers/go.ps1 index 988b2bdd..0123e540 100644 --- a/automataCI/services/compilers/go.ps1 +++ b/automataCI/services/compilers/go.ps1 @@ -132,6 +132,9 @@ function deactivate { } # activate +`$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") `` + + ";" `` + + [System.Environment]::GetEnvironmentVariable("Path","User") `${env:GOPATH} = "$(Split-Path -Path ${__location})" `${env:GOBIN} = "$(Split-Path -Path ${__location})\bin" `${env:GOCACHE} = "$(Split-Path -Path ${__location})\cache" @@ -150,8 +153,8 @@ function global:prompt { # testing the activation - $null = . "${__location}" - if ($LASTEXITCODE -ne 0) { + $__process = GO-Activate-Local-Environment + if ($__process -ne 0) { return 1 } diff --git a/automataCI/services/compilers/go.sh b/automataCI/services/compilers/go.sh index 1da84364..5cc7cd99 100644 --- a/automataCI/services/compilers/go.sh +++ b/automataCI/services/compilers/go.sh @@ -112,6 +112,14 @@ GO::setup_local_environment() { __label="($PROJECT_PATH_GO_ENGINE)" __location="$(GO::get_activator_path)" + if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then + __brew="eval \$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + elif [ -f "/usr/local/bin/brew" ]; then + __brew="eval \$(/usr/local/bin/brew shellenv)" + else + __brew="" + fi + FS::make_housing_directory "$__location" FS::make_directory "${__location%/*}/bin" FS::make_directory "${__location%/*}/cache" @@ -134,6 +142,7 @@ deactivate() { } # activate +${__brew} export GOPATH='${__location%/*}' export GOBIN='${__location%/*}/bin' export GOCACHE='${__location%/*}/cache' diff --git a/automataCI/services/compilers/installer.ps1 b/automataCI/services/compilers/installer.ps1 index d4a03533..13f8cd5d 100644 --- a/automataCI/services/compilers/installer.ps1 +++ b/automataCI/services/compilers/installer.ps1 @@ -110,6 +110,11 @@ function INSTALLER-Setup-C { #} + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") ` + + ";" ` + + [System.Environment]::GetEnvironmentVariable("Path","User") + + # report status return 0 } @@ -164,6 +169,9 @@ function INSTALLER-Setup-Go { if ($__process -ne 0) { return 1 } + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") ` + + ";" ` + + [System.Environment]::GetEnvironmentVariable("Path","User") # report status @@ -242,6 +250,41 @@ function INSTALLER-Setup-Index-Repo { +function INSTALLER-Setup-Nim { + # validate input + $__process = OS-Is-Command-Available "choco" + if ($__process -ne 0) { + return 1 + } + + $__process = OS-Is-Command-Available "nim" + if ($__process -eq 0) { + return 0 + } + + + # execute + $__process = OS-Exec "choco" "install nim -y" + if ($__process -ne 0) { + return 1 + } + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") ` + + ";" ` + + [System.Environment]::GetEnvironmentVariable("Path","User") + + + # report status + $__process = OS-Is-Command-Available "nim" + if ($__process -eq 0) { + return 0 + } + + return 1 +} + + + + function INSTALLER-Setup-Python { # validate input $__process = OS-Is-Command-Available "choco" diff --git a/automataCI/services/compilers/installer.sh b/automataCI/services/compilers/installer.sh index a383659f..7de0d5e4 100644 --- a/automataCI/services/compilers/installer.sh +++ b/automataCI/services/compilers/installer.sh @@ -280,6 +280,34 @@ INSTALLER::setup_index_repo() { +INSTALLER::setup_nim() { + # validate input + OS::is_command_available "brew" + if [ $? -ne 0 ]; then + return 1 + fi + + OS::is_command_available "nim" + if [ $? -eq 0 ]; then + return 0 + fi + + + # execute + brew install nim + + + # report status + if [ $? -eq 0 ]; then + return 0 + fi + + return 1 +} + + + + INSTALLER::setup_python() { # validate input OS::is_command_available "brew" diff --git a/automataCI/services/compilers/nim.ps1 b/automataCI/services/compilers/nim.ps1 new file mode 100644 index 00000000..44597d6d --- /dev/null +++ b/automataCI/services/compilers/nim.ps1 @@ -0,0 +1,212 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\strings.ps1" + + + + +function NIM-Activate-Local-Environment { + # validate input + $__process = NIM-Is-Available + if ($__process -ne 0) { + return 1 + } + + $__process = NIM-Is-Localized + if ($__process -eq 0) { + return 0 + } + + + # execute + $__location = "$(NIM-Get-Activator-Path)" + if (-not (Test-Path "${__location}")) { + return 1 + } + + . $__location + $__process = NIM-Is-Localized + if ($__process -eq 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function NIM-Check-Package { + param( + [string]$__directory + ) + + + # execute + $__current_path = Get-Location + $null = Set-Location "${__directory}" + $__process = OS-Exec "nimble" "check" + $null = Set-Location "${__current_path}" + $null = Remove-Variable __current_path + if ($__process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NIM-Get-Activator-Path { + return "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}" ` + + "\${env:PROJECT_PATH_NIM_ENGINE}\Activate.ps1" +} + + + + +function NIM-Is-Available { + # execute + $__program = Get-Command nim -ErrorAction SilentlyContinue + if (-not $__program) { + return 1 + } + + $__program = Get-Command nimble -ErrorAction SilentlyContinue + if (-not $__program) { + return 1 + } + + $__program = Get-Command gcc -ErrorAction SilentlyContinue + if ($__program) { + return 0 + } + + $__program = Get-Command x86_64-w64-mingw32-gcc -ErrorAction SilentlyContinue + if ($__program) { + return 0 + } + + + # report status + return 1 +} + + + + +function NIM-Is-Localized { + # execute + if (-not [string]::IsNullOrEmpty($env:PROJECT_NIM_LOCALIZED)) { + return 0 + } + + + # report status + return 1 +} + + + + +function NIM-Setup-Local-Environment { + # validate input + if ([string]::IsNullOrEmpty($env:PROJECT_PATH_ROOT)) { + return 1 + } + + if ([string]::IsNullOrEmpty($env:PROJECT_PATH_TOOLS)) { + return 1 + } + + if ([string]::IsNullOrEmpty($env:PROJECT_PATH_NIM_ENGINE)) { + return 1 + } + + + # execute + $__process = NIM-Is-Available + if ($__process -ne 0) { + return 1 + } + + $__process = NIM-Is-Localized + if ($__process -eq 0) { + return 0 + } + + + ## it's a clean repo. Start setting up localized environment... + $__label = "($env:PROJECT_PATH_NIM_ENGINE)" + $__location = "$(NIM-Get-Activator-Path)" + + $null = FS-Make-Housing-Directory "${__location}" + $null = FS-Write-File "${__location}" @" +if (-not (Get-Command "nim" -ErrorAction SilentlyContinue)) { + Write-Error "[ ERROR ] missing nim compiler." + return +} + +if (-not (Get-Command "nimble" -ErrorAction SilentlyContinue)) { + Write-Error "[ ERROR ] missing nimble package manager." + return +} + +function deactivate { + if ([string]::IsNullOrEmpty(`$env:old_NIMBLE_DIR)) { + `${env:NIMBLE_DIR} = `$null + `${env:old_NIMBLE_DIR} = `$null + } else { + `${env:NIMBLE_DIR} = "`${env:old_NIMBLE_DIR}" + `${env:old_NIMBLE_DIR} = `$null + } + `${env:PROJECT_NIM_LOCALIZED} = `$null + Copy-Item -Path Function:_OLD_PROMPT -Destination Function:prompt + Remove-Item -Path Function:_OLD_PROMPT +} + +# activate +`$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") `` + + ";" `` + + [System.Environment]::GetEnvironmentVariable("Path","User") +`${env:old_NIMBLE_DIR} = "`${NIMBLE_DIR}" +`${env:NIMBLE_DIR} = "$(Split-Path -Parent -Path "${__location}")" +`${env:PROJECT_NIM_LOCALIZED} = "${__location}" +Copy-Item -Path function:prompt -Destination function:_OLD_PROMPT +function global:prompt { + Write-Host -NoNewline -ForegroundColor Green "(${__label}) " + _OLD_VIRTUAL_PROMPT +} +"@ + + if (-not (Test-Path "${__location}")) { + return 1 + } + + + # testing the activation + $__process = NIM-Activate-Local-Environment + if ($__process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/nim.sh b/automataCI/services/compilers/nim.sh new file mode 100644 index 00000000..c51cf654 --- /dev/null +++ b/automataCI/services/compilers/nim.sh @@ -0,0 +1,210 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/strings.sh" + + + + +NIM::activate_local_environment() { + # validate input + NIM::is_available + if [ $? -ne 0 ] ; then + return 1 + fi + + NIM::is_localized + if [ $? -eq 0 ] ; then + return 0 + fi + + + # execute + __location="$(NIM::get_activator_path)" + if [ ! -f "$__location" ]; then + return 1 + fi + + . "$__location" + NIM::is_localized + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +NIM::check_package() { + #__directory="$1" + + + # execute + __current_path="$PWD" && cd "$1" + nimble check + __exit=$? + cd "$__current_path" && unset __current_path + if [ $__exit -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NIM::get_activator_path() { + # execute + __location="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_NIM_ENGINE}" + __location="${__location}/activate.sh" + printf -- "%b" "$__location" + + + # report status + return 0 +} + + + + +NIM::is_available() { + # execute + if [ -z "$(type -t nim)" ]; then + return 1 + fi + + if [ -z "$(type -t nimble)" ]; then + return 1 + fi + + if [ -z "$(type -t gcc)" ] && [ -z "$(type -t clang)" ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NIM::is_localized() { + # execute + if [ ! -z "$PROJECT_NIM_LOCALIZED" ] ; then + return 0 + fi + + + # report status + return 1 +} + + + + +NIM::setup_local_environment() { + # validate input + if [ -z "$PROJECT_PATH_ROOT" ]; then + return 1 + fi + + if [ -z "$PROJECT_PATH_TOOLS" ]; then + return 1 + fi + + if [ -z "$PROJECT_PATH_NIM_ENGINE" ]; then + return 1 + fi + + + # execute + NIM::is_available + if [ $? -ne 0 ] ; then + return 1 + fi + + NIM::is_localized + if [ $? -eq 0 ] ; then + return 0 + fi + + + ## it's a clean repo. Start setting up localized environment... + __label="($PROJECT_PATH_NIM_ENGINE)" + __location="$(NIM::get_activator_path)" + + if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then + __brew="eval \$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + elif [ -f "/usr/local/bin/brew" ]; then + __brew="eval \$(/usr/local/bin/brew shellenv)" + else + __brew="" + fi + + FS::make_housing_directory "$__location" + FS::write_file "${__location}" "\ +#!/bin/sh +if [ -z \"\$(type -t 'nim')\" ]; then + 1>&2 printf -- '[ ERROR ] missing nim compiler.\\\\n' + return 1 +fi + +if [ -z \"\$(type -t 'nimble')\" ]; then + 1>&2 printf -- '[ ERROR ] missing nimble package manager.\\\\n' + return 1 +fi + +deactivate() { + if [ -z \"\$old_NIMBLE_DIR\" ]; then + unset old_NIMBLE_DIR NIMBLE_DIR + else + NIMBLE_DIR=\"\$old_NIMBLE_DIR\" + unset old_NIMBLE_DIR + fi + export PS1=\"\${PS1##*${__label} }\" + unset PROJECT_NIM_LOCALIZED + return 0 +} + +# activate +${__brew} +export old_NIMBLE_DIR=\"\$NIMBLE_DIR\" +export NIMBLE_DIR=\"${__location%/*}\" +export PROJECT_NIM_LOCALIZED='${__location}' +export PS1=\"${__label} \${PS1}\" +return 0 +" + if [ ! -f "${__location}" ]; then + return 1 + fi + + + # testing the activation + . "${__location}" + if [ $? -ne 0 ] ; then + return 1 + fi + + + # report status + return 0 +} diff --git a/src/changelog/data/latest b/src/changelog/data/latest new file mode 100644 index 00000000..e69de29b diff --git a/src/changelog/deb/latest b/src/changelog/deb/latest new file mode 100644 index 00000000..411cf8e8 --- /dev/null +++ b/src/changelog/deb/latest @@ -0,0 +1,4 @@ +automataci (1.7.0) stable; urgency=low + + +-- Your Legal Full Name Here Sun, 15 Oct 2023 07:59:13 +0800 diff --git a/srcC/.ci/build_unix-any.sh b/srcC/.ci/build_unix-any.sh index 27a2d199..533eca31 100644 --- a/srcC/.ci/build_unix-any.sh +++ b/srcC/.ci/build_unix-any.sh @@ -22,7 +22,7 @@ fi . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh" -. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/compiler-c_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/operator_unix-any.sh" diff --git a/srcC/.ci/build_windows-any.ps1 b/srcC/.ci/build_windows-any.ps1 index e8e26a02..a23a1105 100644 --- a/srcC/.ci/build_windows-any.ps1 +++ b/srcC/.ci/build_windows-any.ps1 @@ -21,7 +21,7 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" -. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\compiler-c_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\operator_windows-any.ps1" diff --git a/srcC/.ci/materialize_unix-any.sh b/srcC/.ci/materialize_unix-any.sh index 7a7eac5b..a98bdc35 100644 --- a/srcC/.ci/materialize_unix-any.sh +++ b/srcC/.ci/materialize_unix-any.sh @@ -22,7 +22,7 @@ fi . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh" -. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/compiler-c_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/operator_unix-any.sh" diff --git a/srcC/.ci/materialize_windows-any.ps1 b/srcC/.ci/materialize_windows-any.ps1 index f329a370..af13115e 100644 --- a/srcC/.ci/materialize_windows-any.ps1 +++ b/srcC/.ci/materialize_windows-any.ps1 @@ -21,7 +21,7 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" -. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\compiler-c_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\operator_windows-any.ps1" diff --git a/srcC/.ci/test_unix-any.sh b/srcC/.ci/test_unix-any.sh index e20be673..85aaf810 100644 --- a/srcC/.ci/test_unix-any.sh +++ b/srcC/.ci/test_unix-any.sh @@ -22,7 +22,7 @@ fi . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh" -. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/compiler-c_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/operator_unix-any.sh" diff --git a/srcC/.ci/test_windows-any.ps1 b/srcC/.ci/test_windows-any.ps1 index 94152955..9278a2ff 100644 --- a/srcC/.ci/test_windows-any.ps1 +++ b/srcC/.ci/test_windows-any.ps1 @@ -21,7 +21,7 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" -. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\compiler-c_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\operator_windows-any.ps1" diff --git a/srcNIM/.ci/_package-archive_unix-any.sh b/srcNIM/.ci/_package-archive_unix-any.sh new file mode 100644 index 00000000..e22643ab --- /dev/null +++ b/srcNIM/.ci/_package-archive_unix-any.sh @@ -0,0 +1,110 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh" + + + + +PACKAGE::assemble_archive_content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # package based on target's nature + if [ $(FS::is_target_a_source "$_target") -eq 0 ]; then + _target="${PROJECT_PATH_ROOT}/${PROJECT_NIM}/${PROJECT_SKU}pkg" + OS::print_status info "copying ${_target} to ${_directory}\n" + FS::copy_all "$_target" "$_directory" + if [ $? -ne 0 ]; then + return 1 + fi + elif [ $(FS::is_target_a_library "$_target") -eq 0 ]; then + OS::print_status info "copying ${_target} to ${_directory}\n" + FS::copy_file "$_target" "${_directory}/lib${PROJECT_SKU}.a" + if [ $? -ne 0 ]; then + return 1 + fi + elif [ $(FS::is_target_a_wasm_js "$_target") -eq 0 ]; then + return 10 # handled by wasm instead + elif [ $(FS::is_target_a_wasm "$_target") -eq 0 ]; then + OS::print_status info "copying ${_target} to ${_directory}\n" + FS::copy_file "$_target" "$_directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::is_file "${_target%.wasm*}.js" + if [ $? -eq 0 ]; then + OS::print_status info "copying ${_target%.wasm*}.js to ${_directory}\n" + FS::copy_file "${_target%.wasm*}.js" "$_directory" + if [ $? -ne 0 ]; then + return 1 + fi + fi + elif [ $(FS::is_target_a_chocolatey "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_homebrew "$_target") -eq 0 ]; then + return 10 # not applicable + else + case "$_target_os" in + windows) + _dest="${_directory}/${PROJECT_SKU}.exe" + ;; + *) + _dest="${_directory}/${PROJECT_SKU}" + ;; + esac + + OS::print_status info "copying ${_target} to ${_dest}\n" + FS::copy_file "$_target" "$_dest" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + + # copy user guide + _target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RESOURCES}/docs/USER-GUIDES-EN.pdf" + OS::print_status info "copying ${_target} to ${_directory}\n" + FS::copy_file "$_target" "${_directory}/." + if [ $? -ne 0 ]; then + return 1 + fi + + + # copy license file + _target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RESOURCES}/licenses/LICENSE-EN.pdf" + OS::print_status info "copying ${_target} to ${_directory}\n" + FS::copy_file "$_target" "${_directory}/." + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/srcNIM/.ci/_package-archive_windows-any.ps1 b/srcNIM/.ci/_package-archive_windows-any.ps1 new file mode 100644 index 00000000..5746422d --- /dev/null +++ b/srcNIM/.ci/_package-archive_windows-any.ps1 @@ -0,0 +1,112 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" + + + + +function PACKAGE-Assemble-Archive-Content { + param( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # copy main program + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + $_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}\${env:PROJECT_SKU}pkg" + OS-Print-Status info "copying ${_target} to ${_directory}" + $__process = FS-Copy-All "${_target}" "${_directory}" + if ($__process -ne 0) { + return 1 + } + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + OS-Print-Status info "copying ${_target} to ${_directory}..." + $__process = FS-Copy-File "${_target}" "${_directory}/lib${env:PROJECT_SKU}.a" + if ($__process -ne 0) { + return 1 + } + } elseif ($(FS-Is-Target-A-WASM-JS "${_target}") -eq 0) { + return 10 # handled by wasm instead + } elseif ($(FS-Is-Target-A-WASM "${_target}") -eq 0) { + OS-Print-Status info "copying ${_target} to ${_directory}" + $__process = Fs-Copy-File "${_target}" "${_directory}" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Is-File "$($_target -replace '\.wasm.*$', '.js')" + if ($__process -eq 0) { + OS-Print-Status info ` + "copying $($_target -replace '\.wasm.*$', '.js') to ${_directory}" + $__process = Fs-Copy-File ` + "$($_target -replace '\.wasm.*$', '.js')" ` + "${_directory}" + if ($__process -ne 0) { + return 1 + } + } + } elseif ($(FS-Is-Target-A-Chocolatey "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Homebrew "${_target}") -eq 0) { + return 10 # not applicable + } else { + switch (${_target_os}) { + "windows" { + $_dest = "${_directory}\${env:PROJECT_SKU}.exe" + } Default { + $_dest = "${_directory}\${env:PROJECT_SKU}" + }} + + OS-Print-Status info "copying ${_target} to ${_dest}" + $__process = FS-Copy-File "${_target}" "${_dest}" + if ($__process -ne 0) { + return 1 + } + } + + + # copy user guide + $_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RESOURCES}\docs\USER-GUIDES-EN.pdf" + OS-Print-Status info "copying ${_target} to ${_directory}" + $__process = FS-Copy-File "${_target}" "${_directory}" + if ($__process -ne 0) { + return 1 + } + + + # copy license file + $_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RESOURCES}\licenses\LICENSE-EN.pdf" + OS-Print-Status info "copying ${_target} to ${_directory}" + $__process = FS-Copy-File "${_target}" "${_directory}" + if ($__process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/srcNIM/.ci/_package-chocolatey_unix-any.sh b/srcNIM/.ci/_package-chocolatey_unix-any.sh new file mode 100644 index 00000000..71d2829c --- /dev/null +++ b/srcNIM/.ci/_package-chocolatey_unix-any.sh @@ -0,0 +1,222 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh" + + + + +PACKAGE::assemble_chocolatey_content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate project + if [ $(FS::is_target_a_source "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_library "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_wasm_js "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_wasm "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_chocolatey "$_target") -eq 0 ]; then + : # accepted + elif [ $(FS::is_target_a_homebrew "$_target") -eq 0 ]; then + return 10 # not applicable + else + return 10 # not applicable + fi + + + # assemble the package + FS::make_directory "${_directory}/Data/${PROJECT_PATH_SOURCE}" + FS::copy_all \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/" \ + "${_directory}/Data/${PROJECT_PATH_SOURCE}" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::copy_all "${PROJECT_PATH_ROOT}/${PROJECT_NIM}" "${_directory}/Data" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::copy_all "${PROJECT_PATH_ROOT}/automataCI" "${_directory}/Data" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::copy_file "${PROJECT_PATH_ROOT}/CONFIG.toml" "${_directory}/Data" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::copy_file "${PROJECT_PATH_ROOT}/ci.cmd" "${_directory}/Data" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::copy_file \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/icon-128x128.png" \ + "${_directory}/icon.png" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::copy_file \ + "${PROJECT_PATH_ROOT}/README.md" \ + "${_directory}/README.md" + if [ $? -ne 0 ]; then + return 1 + fi + + + # REQUIRED: chocolatey required tools\ directory + FS::make_directory "${_directory}/tools" + if [ $? -ne 0 ]; then + return 1 + fi + + + # OPTIONAL: chocolatey tools\chocolateyBeforeModify.ps1 + OS::print_status info "scripting tools/chocolateyBeforeModify.ps1...\n" + FS::write_file "${_directory}/tools/chocolateyBeforeModify.ps1" "\ +# REQUIRED - BEGIN EXECUTION +Write-Host \"Performing pre-configurations...\" +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # REQUIRED: chocolatey tools\chocolateyinstall.ps1 + OS::print_status info "scripting tools/chocolateyinstall.ps1...\n" + FS::write_file "${_directory}/tools/chocolateyinstall.ps1" "\ +# REQUIRED - PREPARING INSTALLATION +\$tools_dir = \"\$(Split-Path -Parent -Path \$MyInvocation.MyCommand.Definition)\" +\$data_dir = \"\$(Split-Path -Parent -Path \$tools_dir)\\\\Data\" +\$root_dir = \"\$(Split-Path -Parent -Path \$root_dir)\" +\$current_dir = (Get-Location).Path + + + + +# REQUIRED - BEGIN EXECUTION +# Materialize the binary +Write-Host \"Building ${PROJECT_SKU} (${PROJECT_VERSION})...\" +Set-Location \"\$data_dir\" +.\\\\ci.cmd setup +if (\$LASTEXITCODE -ne 0) { + Set-Location \"\$current_dir\" + Set-PowerShellExitCode 1 + return +} + +.\\\\ci.cmd prepare +if (\$LASTEXITCODE -ne 0) { + Set-Location \"\$current_dir\" + Set-PowerShellExitCode 1 + return +} + +.\\\\ci.cmd materialize +if (\$LASTEXITCODE -ne 0) { + Set-Location \"\$current_dir\" + Set-PowerShellExitCode 1 + return +} + +if (-not (Test-Path \"\${data_dir}\\\\bin\\\\${PROJECT_SKU}.exe\")) { + Set-Location \"\$current_dir\" + Write-Host \"Compile Failed. Missing executable.\" + Set-PowerShellExitCode 1 + return +} + + +# Install +Write-Host \"assembling workspace for installation...\" +Move-Item -Path \"\${data_dir}\\\\bin\" -Destination \"\${root_dir}\" +Move-Item -Path \"\${data_dir}\\\\lib\" -Destination \"\${root_dir}\" +Set-Location \"\$current_dir\" +Remove-Item \$data_dir -Force -Recurse -ErrorAction SilentlyContinue +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # REQUIRED: chocolatey tools\chocolateyuninstall.ps1 + OS::print_status info "scripting tools/chocolateyuninstall.ps1...\n" + FS::write_file "${_directory}/tools/chocolateyuninstall.ps1" "\ +# REQUIRED - PREPARING UNINSTALLATION +Write-Host \"Uninstalling ${PROJECT_SKU} (${PROJECT_VERSION})...\" +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # REQUIRED: chocolatey xml.nuspec file + OS::print_status info "scripting ${PROJECT_SKU}.nuspec...\n" + FS::write_file "${_directory}/${PROJECT_SKU}.nuspec" "\ + + + + ${PROJECT_SKU} + ${PROJECT_NAME} + ${PROJECT_VERSION} + ${PROJECT_CONTACT_NAME} + ${PROJECT_CONTACT_NAME} + ${PROJECT_CONTACT_WEBSITE} + ${PROJECT_LICENSE} + ${PROJECT_PITCH} + README.md + icon.png + + + + + + + + + + + + + +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/srcNIM/.ci/_package-chocolatey_windows-any.ps1 b/srcNIM/.ci/_package-chocolatey_windows-any.ps1 new file mode 100644 index 00000000..7a675482 --- /dev/null +++ b/srcNIM/.ci/_package-chocolatey_windows-any.ps1 @@ -0,0 +1,233 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + exit 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" + + + + +function PACKAGE-Assemble-CHOCOLATEY-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate project + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-WASM-JS "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-WASM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Chocolatey "${_target}") -eq 0) { + # accepted + } elseif ($(FS-Is-Target-A-Homebrew "${_target}") -eq 0) { + return 10 # not applicable + } else { + return 10 # not applicable + } + + + # assemble the package + $null = FS-Make-Directory "${_directory}\Data\${env:PROJECT_PATH_SOURCE}" + $null = FS-Make-Directory "${_directory}\Data\${env:PROJECT_NIM}" + $null = FS-Make-Directory "${_directory}\Data\automataCI" + + $__process = FS-Copy-All ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" ` + "${_directory}\Data\${env:PROJECT_PATH_SOURCE}" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Copy-All ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}" ` + "${_directory}\Data\${env:PROJECT_NIM}" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Copy-All ` + "${env:PROJECT_PATH_ROOT}\automataCI" ` + "${_directory}\Data\automataCI" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Copy-File ` + "${env:PROJECT_PATH_ROOT}\CONFIG.toml" ` + "${_directory}\Data" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Copy-File ` + "${env:PROJECT_PATH_ROOT}\ci.cmd" ` + "${_directory}\Data" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Copy-File ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\icons\icon-128x128.png" ` + "${_directory}\icon.png" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Copy-File ` + "${env:PROJECT_PATH_ROOT}\README.md" ` + "${_directory}\README.md" + if ($__process -ne 0) { + return 1 + } + + + # REQUIRED: chocolatey required tools\ directory + $__process = FS-Make-Directory "${_directory}\tools" + if ($__process -ne 0) { + return 1 + } + + + # OPTIONAL: chocolatey tools\chocolateyBeforeModify.ps1 + OS-Print-Status info "scripting tools\chocolateyBeforeModify.ps1..." + $__process = FS-Write-File "${_directory}\tools\chocolateyBeforeModify.ps1" @" +# REQUIRED - BEGIN EXECUTION +Write-Host "Performing pre-configurations..." +"@ + if ($__process -ne 0) { + return 1 + } + + + # REQUIRED: chocolatey tools\chocolateyinstall.ps1 + OS-Print-Status info "scripting tools\chocolateyinstall.ps1..." + $__process = FS-Write-File "${_directory}\tools\chocolateyinstall.ps1" @" +# REQUIRED - PREPARING INSTALLATION +`$tools_dir = "`$(Split-Path -Parent -Path `$MyInvocation.MyCommand.Definition)" +`$data_dir = "`$(Split-Path -Parent -Path `$tools_dir)\Data" +`$root_dir = "`$(Split-Path -Parent -Path `$tools_dir)" +`$current_dir = (Get-Location).Path + + + + +# REQUIRED - BEGIN EXECUTION +# Materialize the binary +Write-Host "Building ${env:PROJECT_SKU} (${env:PROJECT_VERSION})..." +Set-Location "`$data_dir" +.\ci.cmd setup +if (`$LASTEXITCODE -ne 0) { + Set-Location "`$current_dir" + Set-PowerShellExitCode 1 + return +} + +.\ci.cmd prepare +if (`$LASTEXITCODE -ne 0) { + Set-Location "`$current_dir" + Set-PowerShellExitCode 1 + return +} + +.\ci.cmd materialize +if (`$LASTEXITCODE -ne 0) { + Set-Location "`$current_dir" + Set-PowerShellExitCode 1 + return +} + +if (-not (Test-Path "`${data_dir}\bin\${env:PROJECT_SKU}.exe")) { + Set-Location "`$current_dir" + Write-Host "Compile Failed. Missing executable." + Set-PowerShellExitCode 1 + return +} + + +Write-Host "assembling workspace for installation..." +Move-Item -Path "`${data_dir}\bin" -Destination "`${root_dir}" +Move-Item -Path "`${data_dir}\lib" -Destination "`${root_dir}" +Set-Location "`$current_dir" +Remove-Item `$data_dir -Force -Recurse -ErrorAction SilentlyContinue +"@ + if ($__process -ne 0) { + return 1 + } + + + # REQUIRED: chocolatey tools\chocolateyuninstall.ps1 + OS-Print-Status info "scripting tools\chocolateyuninstall.ps1..." + $__process = FS-Write-File "${_directory}\tools\chocolateyuninstall.ps1" @" +# REQUIRED - PREPARING UNINSTALLATION +Write-Host "Uninstalling ${env:PROJECT_SKU} (${env:PROJECT_VERSION})..." +"@ + if ($__process -ne 0) { + return 1 + } + + + # REQUIRED: chocolatey xml.nuspec file + OS-Print-Status info "scripting ${env:PROJECT_SKU}.nuspec..." + $__process = FS-Write-File "${_directory}\${env:PROJECT_SKU}.nuspec" @" + + + + ${env:PROJECT_SKU} + ${env:PROJECT_NAME} + ${env:PROJECT_VERSION} + ${env:PROJECT_CONTACT_NAME} + ${env:PROJECT_CONTACT_NAME} + ${env:PROJECT_CONTACT_WEBSITE} + ${env:PROJECT_LICENSE} + ${env:PROJECT_PITCH} + README.md + icon.png + + + + + + + + + + + + + +"@ + if ($__process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/srcNIM/.ci/_package-docker_unix-any.sh b/srcNIM/.ci/_package-docker_unix-any.sh new file mode 100644 index 00000000..84880e16 --- /dev/null +++ b/srcNIM/.ci/_package-docker_unix-any.sh @@ -0,0 +1,122 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh" + + + + +PACKAGE::assemble_docker_content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate project + case "$_target_arch" in + avr|js) + return 10 # not applicable + ;; + *) + ;; + esac + + if [ $(FS::is_target_a_source "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_library "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_wasm_js "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_wasm "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_chocolatey "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_homebrew "$_target") -eq 0 ]; then + return 10 # not applicable + fi + + OS::print_status info "Running C specific content assembling function...\n" + + + # assemble the package + FS::copy_file "$_target" "${_directory}/${PROJECT_SKU}" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::touch_file "${_directory}/.blank" + if [ $? -ne 0 ]; then + return 1 + fi + + + # generate the Dockerfile + FS::write_file "${_directory}/Dockerfile" "\ +# Defining baseline image +FROM --platform=${_target_os}/${_target_arch} scratch +LABEL org.opencontainers.image.title=\"${PROJECT_NAME}\" +LABEL org.opencontainers.image.description=\"${PROJECT_PITCH}\" +LABEL org.opencontainers.image.authors=\"${PROJECT_CONTACT_NAME} <${PROJECT_CONTACT_EMAIL}>\" +LABEL org.opencontainers.image.version=\"${PROJECT_VERSION}\" +LABEL org.opencontainers.image.revision=\"${PROJECT_CADENCE}\" +LABEL org.opencontainers.image.licenses=\"${PROJECT_LICENSE}\" +" + + if [ ! -z "$PROJECT_CONTACT_WEBSITE" ]; then + FS::append_file "${_directory}/Dockerfile" "\ +LABEL org.opencontainers.image.url=\"${PROJECT_CONTACT_WEBSITE}\" +" + fi + + if [ ! -z "$PROJECT_SOURCE_URL" ]; then + FS::append_file "${_directory}/Dockerfile" "\ +LABEL org.opencontainers.image.source=\"${PROJECT_SOURCE_URL}\" +" + fi + + FS::append_file "${_directory}/Dockerfile" "\ +# Defining environment variables +ENV ARCH ${_target_arch} +ENV OS ${_target_os} +ENV PORT 80 + +# Assemble the file structure +COPY .blank /tmp/.tmpfile +ADD ${PROJECT_SKU} /app/bin/${PROJECT_SKU} + +# Set network port exposures +EXPOSE 80 + +# Set entry point +ENTRYPOINT [\"/app/bin/${PROJECT_SKU}\"] +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/srcNIM/.ci/_package-docker_windows-any.ps1 b/srcNIM/.ci/_package-docker_windows-any.ps1 new file mode 100644 index 00000000..3d105744 --- /dev/null +++ b/srcNIM/.ci/_package-docker_windows-any.ps1 @@ -0,0 +1,122 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + exit 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" + + + + +function PACKAGE-Assemble-DOCKER-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate project + switch ($_target_arch) { + { $_ -in "avr", "js" } { + return 10 # not applicable + } default { + # accepted + }} + + if ($(FS-Is-Target-A-Source "${_target}") -ne 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -ne 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-WASM-JS "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-WASM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Chocolatey "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Homebrew "${_target}") -eq 0) { + return 10 # not applicable + } + + OS-Print-Status info "Running Go specific content assembling function..." + + + # assemble the package + $__process = FS-Copy-File "${_target}" "${_directory}\${env:PROJECT_SKU}" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Touch-File "${_directory}\.blank" + if ($__process -ne 0) { + return 1 + } + + + # generate the Dockerfile + $__process = FS-Write-File "${_directory}\Dockerfile" @" +# Defining baseline image +FROM --platform=${_target_os}/${_target_arch} scratch +LABEL org.opencontainers.image.title=`"${env:PROJECT_NAME}`" +LABEL org.opencontainers.image.description=`"${env:PROJECT_PITCH}`" +LABEL org.opencontainers.image.authors=`"${env:PROJECT_CONTACT_NAME} <${env:PROJECT_CONTACT_EMAIL}>`" +LABEL org.opencontainers.image.version=`"${env:PROJECT_VERSION}`" +LABEL org.opencontainers.image.revision=`"${env:PROJECT_CADENCE}`" +LABEL org.opencontainers.image.licenses=`"${env:PROJECT_LICENSE}`" +"@ + + if (-not ([string]::IsNullOrEmpty(${env:PROJECT_CONTACT_WEBSITE}))) { + $__process = FS-Append-File "${_directory}\Dockerfile" @" +LABEL org.opencontainers.image.url=`"${env:PROJECT_CONTACT_WEBSITE}`" +"@ + } + + if (-not ([string]::IsNullOrEmpty(${env:PROJECT_SOURCE_URL}))) { + $__process = FS-Append-File "${_directory}\Dockerfile" @" +LABEL org.opencontainers.image.source=`"${env:PROJECT_SOURCE_URL}`" +"@ + } + + $__process = FS-Append-File "${_directory}\Dockerfile" @" +# Defining environment variables +ENV ARCH ${_target_arch} +ENV OS ${_target_os} +ENV PORT 80 + +# Assemble the file structure +COPY .blank /tmp/.tmpfile +ADD ${env:PROJECT_SKU} /app/bin/${env:PROJECT_SKU} + +# Set network port exposures +EXPOSE 80 + +# Set entry point +ENTRYPOINT ["/app/bin/${env:PROJECT_SKU}"] +"@ + if ($__process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/srcNIM/.ci/_package-homebrew_unix-any.sh b/srcNIM/.ci/_package-homebrew_unix-any.sh new file mode 100644 index 00000000..e7f7195d --- /dev/null +++ b/srcNIM/.ci/_package-homebrew_unix-any.sh @@ -0,0 +1,127 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/strings.sh" + + + + +PACKAGE::assemble_homebrew_content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate project + if [ $(FS::is_target_a_source "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_library "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_wasm_js "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_wasm "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_chocolatey "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS::is_target_a_homebrew "$_target") -eq 0 ]; then + : # accepted + else + return 10 # not applicable + fi + + + # assemble the package + FS::make_directory "${_directory}/Data/${PROJECT_PATH_SOURCE}" + FS::copy_all "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/" \ + "${_directory}/Data/${PROJECT_PATH_SOURCE}" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::copy_all "${PROJECT_PATH_ROOT}/${PROJECT_NIM}" "${_directory}/Data" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::copy_all "${PROJECT_PATH_ROOT}/automataCI" "${_directory}/Data" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::copy_file "${PROJECT_PATH_ROOT}/CONFIG.toml" "${_directory}/Data" + if [ $? -ne 0 ]; then + return 1 + fi + + FS::copy_file "${PROJECT_PATH_ROOT}/ci.cmd" "${_directory}/Data" + if [ $? -ne 0 ]; then + return 1 + fi + + + # script formula.rb + OS::print_status info "scripting formula.rb...\n" + FS::write_file "${_directory}/formula.rb" "\ +class ${PROJECT_SKU_TITLECASE} < Formula + desc \"${PROJECT_PITCH}\" + homepage \"${PROJECT_CONTACT_WEBSITE}\" + license \"${PROJECT_LICENSE}\" + url \"${PROJECT_HOMEBREW_SOURCE_URL}/${PROJECT_VERSION}/{{ TARGET_PACKAGE }}\" + sha256 \"{{ TARGET_SHASUM }}\" + + on_linux do + depends_on \"gcc\" => [:build, :test] + end + + on_macos do + depends_on \"clang\" => [:build, :test] + end + + def install + system \"./ci.cmd setup\" + system \"./ci.cmd prepare\" + system \"./ci.cmd materialize\" + chmod 0755, \"bin/${PROJECT_SKU}\" + bin.install \"bin/${PROJECT_SKU}\" + libexec.install Dir[\"lib/*\"] + end + + test do + system \"./ci.cmd setup\" + system \"./ci.cmd prepare\" + system \"./ci.cmd materialize\" + assert_predicate ./bin/${PROJECT_SKU}, :exist? + end +end +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/srcNIM/.ci/_package-homebrew_windows-any.ps1 b/srcNIM/.ci/_package-homebrew_windows-any.ps1 new file mode 100644 index 00000000..fee588a7 --- /dev/null +++ b/srcNIM/.ci/_package-homebrew_windows-any.ps1 @@ -0,0 +1,128 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + exit 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\strings.ps1" + + + + +function PACKAGE-Assemble-HOMEBREW-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate project + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-WASM-JS "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-WASM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Chocolatey "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Homebrew "${_target}") -eq 0) { + # accepted + } else { + return 10 # not applicable + } + + + # assemble the package + $null = FS-Make-Directory "${_directory}\Data\${env:PROJECT_PATH_SOURCE}" + $__process = FS-Copy-All "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" ` + "${_directory}\Data\${env:PROJECT_PATH_SOURCE}" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Copy-All "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}" "${_directory}" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Copy-All "${env:PROJECT_PATH_ROOT}\automataCI" "${_directory}" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Copy-File "${env:PROJECT_PATH_ROOT}\CONFIG.toml" "${_directory}" + if ($__process -ne 0) { + return 1 + } + + $__process = FS-Copy-File "${env:PROJECT_PATH_ROOT}\ci.cmd" "${_directory}" + if ($__process -ne 0) { + return 1 + } + + + # script formula.rb + OS-Print-Status info "scripting formula.rb..." + $__process = FS-Write-File "${_directory}\formula.rb" @" +class ${env:PROJECT_SKU_TITLECASE} < Formula + desc \"${env:PROJECT_PITCH}\" + homepage \"${env:PROJECT_CONTACT_WEBSITE}\" + license \"${env:PROJECT_LICENSE}\" + url \"${env:PROJECT_HOMEBREW_SOURCE_URL}/${env:PROJECT_VERSION}/{{ TARGET_PACKAGE }}\" + sha256 \"{{ TARGET_SHASUM }}\" + + on_linux do + depends_on \"gcc\" => [:build, :test] + end + + on_macos do + depends_on \"clang\" => [:build, :test] + end + + def install + system \"./ci.cmd setup\" + system \"./ci.cmd prepare\" + system \"./ci.cmd materialize\" + chmod 0755, \"bin/${env:PROJECT_SKU}\" + bin.install \"bin/${env:PROJECT_SKU}\" + libexec.install Dir[\"lib/*\"] + end + + test do + system \"./ci.cmd setup\" + system \"./ci.cmd prepare\" + system \"./ci.cmd materialize\" + assert_predicate ./bin/${env:PROJECT_SKU}, :exist? + end +end +"@ + if ($__process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/srcNIM/.ci/build_unix-any.sh b/srcNIM/.ci/build_unix-any.sh new file mode 100644 index 00000000..46cc297e --- /dev/null +++ b/srcNIM/.ci/build_unix-any.sh @@ -0,0 +1,629 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/compilers/nim.sh" + + + + +# safety check control surfaces +OS::print_status info "checking nim availability...\n" +NIM::is_available +if [ $? -ne 0 ]; then + OS::print_status error "missing nim compiler.\n" + return 1 +fi + + +OS::print_status info "activating local environment...\n" +NIM::activate_local_environment +if [ $? -ne 0 ]; then + OS::print_status error "activation failed.\n" + return 1 +fi + + +OS::print_status info "prepare nim workspace...\n" +__build="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}" +__source="${PROJECT_PATH_ROOT}/${PROJECT_NIM}" +__main="${__source}/${PROJECT_SKU}.nim" + +SETTINGS_CC="\ +compileToC \ +--passC:-Wall --passL:-Wall \ +--passC:-Wextra --passL:-Wextra \ +--passC:-std=gnu89 --passL:-std=gnu89 \ +--passC:-pedantic --passL:-pedantic \ +--passC:-Wstrict-prototypes --passL:-Wstrict-prototypes \ +--passC:-Wold-style-definition --passL:-Wold-style-definition \ +--passC:-Wundef --passL:-Wundef \ +--passC:-Wno-trigraphs --passL:-Wno-trigraphs \ +--passC:-fno-strict-aliasing --passL:-fno-strict-aliasing \ +--passC:-fno-common --passL:-fno-common \ +--passC:-fshort-wchar --passL:-fshort-wchar \ +--passC:-fstack-protector-all --passL:-fstack-protector-all \ +--passC:-Werror-implicit-function-declaration --passL:-Werror-implicit-function-declaration \ +--passC:-Wno-format-security --passL:-Wno-format-security \ +--passC:-Os --passL:-Os \ +--passC:-g0 --passL:-g0 \ +--passC:-flto --passL:-flto \ +" +SETTINGS_NIM="\ +--mm:orc \ +--define:release \ +--opt:size \ +--colors:on \ +--styleCheck:off \ +--showAllMismatches:on \ +--tlsEmulation:on \ +--implicitStatic:on \ +--trmacros:on \ +--panics:on \ +" + +FS::make_directory "$__build" + + + + +# checking nim package health +OS::print_status info "checking nim package health...\n" +NIM::check_package "$__source" +if [ $? -ne 0 ]; then + OS::print_status error "check failed.\n" + return 1 +fi + + + + +# building linux-amd64 +__compiler="x86_64-linux-gnu-gcc" +OS::print_status info "compiling linux-amd64 with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ] && [ ! "$PROJECT_OS" = "darwin" ]; then + __target="${PROJECT_SKU}_linux-amd64" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --amd64.linux.gcc.exe:"$__compiler" \ + --amd64.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:amd64 \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-arm64 +__compiler="aarch64-linux-gnu-gcc" +OS::print_status info "compiling linux-arm64 with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ] && [ ! "$PROJECT_OS" = "darwin" ]; then + __target="${PROJECT_SKU}_linux-arm64" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --arm64.linux.gcc.exe:"$__compiler" \ + --arm64.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:arm64 \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building darwin-amd64 +__compiler="clang" +OS::print_status info "compiling darwin-amd64 with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ] && [ "$PROJECT_OS" = "darwin" ]; then + __target="${PROJECT_SKU}_darwin-amd64" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:clang \ + --amd64.MacOS.clang.exe="$__compiler" \ + --amd64.MacOS.clang.linkerexe="$__compiler" \ + --passC:-fPIC \ + --cpu:amd64 \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building darwin-arm64 +__compiler="clang" +OS::print_status info "compiling darwin-arm64 with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ] && [ "$PROJECT_OS" = "darwin" ]; then + __target="${PROJECT_SKU}_darwin-arm64" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:clang \ + --arm64.MacOS.clang.exe="$__compiler" \ + --arm64.MacOS.clang.linkerexe="$__compiler" \ + --passC:-fPIC \ + --cpu:arm64 \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building windows-amd64 +__compiler="x86_64-w64-mingw32-gcc" +OS::print_status info "compiling windows-amd64 with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_windows-amd64" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --amd64.windows.gcc.exe:"$__compiler" \ + --amd64.windows.gcc.linkerexe:"$__compiler" \ + --os:windows \ + --cpu:amd64 \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building windows-arm64 +__compiler="x86_64-w64-mingw32-gcc" +OS::print_status info "compiling windows-arm64 with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_windows-arm64" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --arm64.windows.gcc.exe:"$__compiler" \ + --arm64.windows.gcc.linkerexe:"$__compiler" \ + --os:windows \ + --cpu:arm64 \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-armel +__compiler="arm-linux-gnueabi-gcc" +OS::print_status info "compiling linux-armel with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_linux-armel" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --arm.linux.gcc.exe:"$__compiler" \ + --arm.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:arm \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-armhf +__compiler="arm-linux-gnueabihf-gcc" +OS::print_status info "compiling linux-armhf with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_linux-armhf" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --arm.linux.gcc.exe:"$__compiler" \ + --arm.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:arm \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-mips +__compiler="mips-linux-gnu-gcc" +OS::print_status info "compiling linux-mips with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_linux-mips" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --mips.linux.gcc.exe:"$__compiler" \ + --mips.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:mips \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-mipsle +__compiler="mipsel-linux-gnu-gcc" +OS::print_status info "compiling linux-mipsle with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_linux-mipsle" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --mipsel.linux.gcc.exe:"$__compiler" \ + --mipsel.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:mipsel \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-mips64 +__compiler="mips64-linux-gnuabi64-gcc" +OS::print_status info "compiling linux-mips64 with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_linux-mips64" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --mips64.linux.gcc.exe:"$__compiler" \ + --mips64.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:mips64 \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-mips64le +__compiler="mips64el-linux-gnuabi64-gcc" +OS::print_status info "compiling linux-mips64le with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_linux-mips64le" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --mips64el.linux.gcc.exe:"$__compiler" \ + --mips64el.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:mips64el \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-mips64r6 +__compiler="mipsisa64r6-linux-gnuabi64-gcc" +OS::print_status info "compiling linux-mips64r6 with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_linux-mips64r6" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --mips64.linux.gcc.exe:"$__compiler" \ + --mips64.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:mips64 \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-mips64r6le +__compiler="mipsisa64r6el-linux-gnuabi64-gcc" +OS::print_status info "compiling linux-mips64r6le with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_linux-mips64r6le" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --mips64el.linux.gcc.exe:"$__compiler" \ + --mips64el.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:mips64el \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-powerpc +__compiler="powerpc-linux-gnu-gcc" +OS::print_status info "compiling linux-powerpc with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_linux-powerpc" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --powerpc.linux.gcc.exe:"$__compiler" \ + --powerpc.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:powerpc \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-ppc64le +__compiler="powerpc64le-linux-gnu-gcc" +OS::print_status info "compiling linux-ppc64le with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_linux-ppc64le" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:gcc \ + --passC:-static --passL:-static \ + --passC:-s --passL:-s \ + --powerpc64el.linux.gcc.exe:"$__compiler" \ + --powerpc64el.linux.gcc.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:powerpc64el \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building linux-riscv64 +__compiler="clang" +OS::print_status info "compiling linux-riscv64 with ${__compiler}...\n" +OS::is_command_available "$__compiler" +if [ $? -eq 0 ]; then + __target="${PROJECT_SKU}_linux-riscv64" + nim ${SETTINGS_CC} ${SETTINGS_NIM} \ + --cc:clang \ + --riscv64.clang.exe:"$__compiler" \ + --riscv64.clang.linkerexe:"$__compiler" \ + --os:linux \ + --cpu:riscv64 \ + --out:"${__build}/${__target}" \ + "$__main" + if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 + fi +else + OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +fi + + + + +# building js-wasm +#__compiler="emcc" +#OS::print_status info "compiling js-wasm with ${__compiler}...\n" +#OS::is_command_available "$__compiler" +#if [ $? -eq 0 ]; then +# __target="${PROJECT_SKU}_js-wasm.wasm" +# nim ${SETTINGS_CC} ${SETTINGS_NIM} \ +# --cc:clang \ +# --passC:-static --passL:-static \ +# --passC:-s --passL:-s \ +# --clang.exe:"$__compiler" \ +# --clang.linkerexe:"$__compiler" \ +# --os:linux \ +# --out:"${__build}/${__target}" \ +# "$__main" +# if [ $? -ne 0 ]; then +# OS::print_status error "build failed.\n" +# return 1 +# fi +#else +# OS::print_status warning "compilation skipped. Cross-compile is unavailable.\n" +#fi + + + + +# building js-js +OS::print_status info "compiling js-js...\n" +__target="${PROJECT_SKU}_js-js.js" +nim js ${SETTINGS_NIM} --out:"${__build}/${__target}" "$__main" +if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 +fi + + + + +# placeholding source code flag +__file="${PROJECT_SKU}-src_any-any" +OS::print_status info "building output file: ${__file}\n" +touch "${__build}/${__file}" +if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 +fi + + + + +# placeholding homebrew flag +__file="${PROJECT_SKU}-homebrew_any-any" +OS::print_status info "building output file: ${__file}\n" +touch "${__build}/${__file}" +if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 +fi + + + + +# placeholding chocolatey flag +__file="${PROJECT_SKU}-chocolatey_any-any" +OS::print_status info "building output file: ${__file}\n" +touch "${__build}/${__file}" +if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 +fi + + + + +# report status +return 0 diff --git a/srcNIM/.ci/build_windows-any.ps1 b/srcNIM/.ci/build_windows-any.ps1 new file mode 100644 index 00000000..25428500 --- /dev/null +++ b/srcNIM/.ci/build_windows-any.ps1 @@ -0,0 +1,590 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\nim.ps1" + + + + +# safety checking control surfaces +OS-Print-Status info "checking nim availability..." +$__process = NIM-Is-Available +if ($__process -ne 0) { + OS-Print-Status error "missing nim compiler." + return 1 +} + + +OS-Print-Status info "activating local environment..." +$__process = NIM-Activate-Local-Environment +if ($__process -ne 0) { + OS-Print-Status error "activation failed." + return 1 +} + + +OS-Print-Status info "prepare nim workspace..." +$__build = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}" +$__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}" +$__main = "${__source}\${env:PROJECT_SKU}.nim" + +$SETTINGS_CC = ` + "compileToC " ` + + "--passC:-Wall --passL:-Wall " ` + + "--passC:-Wextra --passL:-Wextra " ` + + "--passC:-std=gnu89 --passL:-std=gnu89 " ` + + "--passC:-pedantic --passL:-pedantic " ` + + "--passC:-Wstrict-prototypes --passL:-Wstrict-prototypes " ` + + "--passC:-Wold-style-definition --passL:-Wold-style-definition " ` + + "--passC:-Wundef --passL:-Wundef " ` + + "--passC:-Wno-trigraphs --passL:-Wno-trigraphs " ` + + "--passC:-fno-strict-aliasing --passL:-fno-strict-aliasing " ` + + "--passC:-fno-common --passL:-fno-common " ` + + "--passC:-fshort-wchar --passL:-fshort-wchar " ` + + "--passC:-fstack-protector-all --passL:-fstack-protector-all " ` + + "--passC:-Werror-implicit-function-declaration --passL:-Werror-implicit-function-declaration " ` + + "--passC:-Wno-format-security --passL:-Wno-format-security " ` + + "--passC:-Os --passL:-Os " ` + + "--passC:-g0 --passL:-g0 " ` + + "--passC:-flto --passL:-flto " + +$SETTINGS_NIM = "--mm:orc " ` + + "--define:release " ` + + "--opt:size " ` + + "--colors:on " ` + + "--styleCheck:off " ` + + "--showAllMismatches:on " ` + + "--tlsEmulation:on " ` + + "--implicitStatic:on " ` + + "--trmacros:on " ` + + "--panics:on " + +$null = FS-Make-Directory "${__build}" + + + + +# checking nim package health +OS-Print-Status info "checking nim package health..." +$__process = NIM-Check-Package "${__source}" +if ($__process -ne 0) { + OS-Print-Status error "check failed." + return 1 +} + + + + +# building linux-amd64 +$__compiler = "x86_64-linux-gnu-gcc" +OS-Print-Status info "compiling linux-amd64 with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if (($__process -eq 0) -and (-not ("${env:PROJECT_OS}" -eq "darwin"))) { + $__target = "${env:PROJECT_SKU}_linux-amd64" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--amd64.linux.gcc.exe:`"${__compiler}`" " ` + + "--amd64.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:amd64 " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-arm64 +$__compiler = "aarch64-linux-gnu-gcc" +OS-Print-Status info "compiling linux-arm64 with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if (($__process -eq 0) -and (-not ("${env:PROJECT_OS}" -eq "darwin"))) { + $__target = "${env:PROJECT_SKU}_linux-arm64" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--arm64.linux.gcc.exe:`"${__compiler}`" " ` + + "--arm64.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:arm64 " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building windows-amd64 +$__compiler = "x86_64-w64-mingw32-gcc" +OS-Print-Status info "compiling windows-amd64 with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_windows-amd64" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--amd64.windows.gcc.exe:`"${__compiler}`" " ` + + "--amd64.windows.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:windows " ` + + "--cpu:amd64 " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building windows-arm64 +$__compiler = "x86_64-w64-mingw32-gcc" +OS-Print-Status info "compiling windows-arm64 with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_windows-arm64" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--arm64.windows.gcc.exe:`"${__compiler}`" " ` + + "--arm64.windows.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:windows " ` + + "--cpu:arm64 " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-armel +$__compiler = "arm-linux-gnueabi-gcc" +OS-Print-Status info "compiling linux-armel with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_linux-armel" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--arm.linux.gcc.exe:`"${__compiler}`" " ` + + "--arm.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:arm " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-armhf +$__compiler = "arm-linux-gnueabihf-gcc" +OS-Print-Status info "compiling linux-armhf with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_linux-armhf" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--arm.linux.gcc.exe:`"${__compiler}`" " ` + + "--arm.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:arm " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-mips +$__compiler = "mips-linux-gnu-gcc" +OS-Print-Status info "compiling linux-mips with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_linux-mips" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--mips.linux.gcc.exe:`"${__compiler}`" " ` + + "--mips.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:mips " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-mipsle +$__compiler = "mipsel-linux-gnu-gcc" +OS-Print-Status info "compiling linux-mipsle with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_linux-mipsle" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--mipsel.linux.gcc.exe:`"${__compiler}`" " ` + + "--mipsel.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:mipsel " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-mips64 +$__compiler = "mips64-linux-gnu-gcc" +OS-Print-Status info "compiling linux-mips64 with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_linux-mips64" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--mips64.linux.gcc.exe:`"${__compiler}`" " ` + + "--mips64.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:mips64 " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-mips64le +$__compiler = "mips64el-linux-gnu-gcc" +OS-Print-Status info "compiling linux-mips64le with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_linux-mips64le" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--mips64el.linux.gcc.exe:`"${__compiler}`" " ` + + "--mips64el.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:mips64el " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-mips64r6 +$__compiler = "mipsisa64r6-linux-gnu-gcc" +OS-Print-Status info "compiling linux-mips64r6 with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_linux-mips64r6" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--mips64.linux.gcc.exe:`"${__compiler}`" " ` + + "--mips64.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:mips64 " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-mips64r6le +$__compiler = "mipsisa64r6el-linux-gnuabi64-gcc" +OS-Print-Status info "compiling linux-mips64r6le with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_linux-mips64r6le" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--mips64el.linux.gcc.exe:`"${__compiler}`" " ` + + "--mips64el.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:mips64el " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-powerpc +$__compiler = "powerpc-linux-gnu-gcc" +OS-Print-Status info "compiling linux-powerpc with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_linux-powerpc" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--powerpc.linux.gcc.exe:`"${__compiler}`" " ` + + "--powerpc.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:powerpc " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-ppc64le +$__compiler = "powerpc64le-linux-gnu-gcc" +OS-Print-Status info "compiling linux-ppc64le with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_linux-ppc64le" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--powerpc64el.linux.gcc.exe:`"${__compiler}`" " ` + + "--powerpc64el.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:powerpc64el " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building linux-riscv64 +$__compiler = "'disabled'" +OS-Print-Status info "compiling linux-riscv64 with ${__compiler}..." +$__process = OS-Is-Command-Available "${__compiler}" +if ($__process -eq 0) { + $__target = "${env:PROJECT_SKU}_linux-riscv64" + $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` + + "--cc:clang " ` + + "--riscv64.linux.gcc.exe:`"${__compiler}`" " ` + + "--riscv64.linux.gcc.linkerexe:`"${__compiler}`" " ` + + "--os:linux " ` + + "--cpu:riscv64 " ` + + "--out:`"${__build}\${__target}`" " ` + + "${__main}" + $__process = OS-Exec "nim" "${__arguments}" + if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 + } +} else { + OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +} + + + + +# building js-wasm +#$__compiler = "emcc" +#OS-Print-Status info "compiling js-wasm with ${__compiler}..." +#$__process = OS-Is-Command-Available "${__compiler}" +#if ($__process -eq 0) { +# $__target = "${env:PROJECT_SKU}_js-wasm.wasm" +# $__arguments = "${SETTINGS_CC} ${SETTINGS_NIM} " ` +# + "--cc:clang " ` +# + "--clang.exe:`"${__compiler}`" " ` +# + "--clang.linkerexe:`"${__compiler}`" " ` +# + "--os:linux " ` +# + "--out:`"${__build}\${__target}`" " ` +# + "${__main}" +# $__process = OS-Exec "nim" "${__arguments}" +# if ($__process -ne 0) { +# OS-Print-Status error "build failed." +# return 1 +# } +#} else { +# OS-Print-Status warning "compilation skipped. Cross-compile is unavailable." +#} + + + + +# building js-js +OS-Print-Status info "compiling js-js..." +$__target = "${env:PORJECT_SKU}_js-js.js" +$__process = OS-Exec "nim" "js ${SETTINGS_NIM} --out:`"${__build}\${__target}`" `"${__main}`"" +if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 +} + + + + +# placeholding source code flag +$__file = "${env:PROJECT_SKU}-src_any-any" +OS-Print-Status info "building output file: ${__file}" +$__process = FS-Touch-File "${__build}\${__file}" +if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 +} + + + + +# placeholding homebrew flag +$__file = "${env:PROJECT_SKU}-homebrew_any-any" +OS-Print-Status info "building output file: ${__file}" +$__process = FS-Touch-File "${__build}\${__file}" +if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 +} + + + + +# placeholding chocolatey flag +$__file = "${env:PROJECT_SKU}-chocolatey_any-any" +OS-Print-Status info "building output file: ${__file}" +$__process = FS-Touch-File "${__build}\${__file}" +if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 +} + + + + +# report status +return 0 diff --git a/srcNIM/.ci/materialize_unix-any.sh b/srcNIM/.ci/materialize_unix-any.sh new file mode 100644 index 00000000..51ed23f8 --- /dev/null +++ b/srcNIM/.ci/materialize_unix-any.sh @@ -0,0 +1,151 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/compilers/nim.sh" + + + + +# safety check control surfaces +OS::print_status info "checking nim availability...\n" +NIM::is_available +if [ $? -ne 0 ]; then + OS::print_status error "missing nim compiler.\n" + return 1 +fi + + +OS::print_status info "activating local environment...\n" +NIM::activate_local_environment +if [ $? -ne 0 ]; then + OS::print_status error "activation failed.\n" + return 1 +fi + + +OS::print_status info "prepare nim workspace...\n" +__target="${PROJECT_SKU}_${PROJECT_OS}-${PROJECT_ARCH}" +__workspace="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}" +__source="${PROJECT_PATH_ROOT}/${PROJECT_NIM}" +__main="${__source}/${PROJECT_SKU}.nim" + +SETTINGS_CC="\ +compileToC \ +--passC:-Wall --passL:-Wall \ +--passC:-Wextra --passL:-Wextra \ +--passC:-std=gnu89 --passL:-std=gnu89 \ +--passC:-pedantic --passL:-pedantic \ +--passC:-Wstrict-prototypes --passL:-Wstrict-prototypes \ +--passC:-Wold-style-definition --passL:-Wold-style-definition \ +--passC:-Wundef --passL:-Wundef \ +--passC:-Wno-trigraphs --passL:-Wno-trigraphs \ +--passC:-fno-strict-aliasing --passL:-fno-strict-aliasing \ +--passC:-fno-common --passL:-fno-common \ +--passC:-fshort-wchar --passL:-fshort-wchar \ +--passC:-fstack-protector-all --passL:-fstack-protector-all \ +--passC:-Werror-implicit-function-declaration --passL:-Werror-implicit-function-declaration \ +--passC:-Wno-format-security --passL:-Wno-format-security \ +--passC:-Os --passL:-Os \ +--passC:-g0 --passL:-g0 \ +--passC:-flto --passL:-flto \ +--passC:-s --passL:-s \ +" +SETTINGS_NIM="\ +--mm:orc \ +--define:release \ +--opt:size \ +--colors:on \ +--styleCheck:off \ +--showAllMismatches:on \ +--tlsEmulation:on \ +--implicitStatic:on \ +--trmacros:on \ +--panics:on \ +" + +case "$PROJECT_OS" in +darwin) + __arguments="\ +${SETTINGS_CC} \ +${SETTINGS_NIM} \ +--cc:clang \ +--passC:-fPIC \ +--cpu:${PROJECT_ARCH} \ +--out:${__workspace}/${__target} \ +$__main\ +" + ;; +*) + __arguments="\ +${SETTINGS_CC} \ +${SETTINGS_NIM} \ +--cc:gcc \ +--passC:-static --passL:-static \ +--os:${PROJECT_OS} \ +--cpu:${PROJECT_ARCH} \ +--out:${__workspace}/${__target} \ +$__main\ +" + ;; +esac +FS::make_directory "$__workspace" + + + + +# execute +OS::print_status info "checking nim package health...\n" +NIM::check_package "$__source" +if [ $? -ne 0 ]; then + OS::print_status error "check failed.\n" +fi + + +OS::print_status info "building nim application...\n" +nim $__arguments +if [ $? -ne 0 ]; then + OS::print_status error "build failed.\n" + return 1 +fi + + + + +# exporting executable +__source="${__workspace}/${__target}" +__dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BIN}/${PROJECT_SKU}" +OS::print_status info "exporting ${__source} to ${__dest}\n" +FS::make_housing_directory "$__dest" +FS::remove_silently "$__dest" +FS::move "$__source" "$__dest" +if [ $? -ne 0 ]; then + OS::print_status error "export failed.\n" + return 1 +fi + + + + +# report status +return 0 diff --git a/srcNIM/.ci/materialize_windows-any.ps1 b/srcNIM/.ci/materialize_windows-any.ps1 new file mode 100644 index 00000000..96d4dcae --- /dev/null +++ b/srcNIM/.ci/materialize_windows-any.ps1 @@ -0,0 +1,131 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\nim.ps1" + + + + +# safety checking control surfaces +OS-Print-Status info "checking nim availability..." +$__process = NIM-Is-Available +if ($__process -ne 0) { + OS-Print-Status error "missing nim compiler." + return 1 +} + + +OS-Print-Status info "activating local environment..." +$__process = NIM-Activate-Local-Environment +if ($__process -ne 0) { + OS-Print-Status error "activation failed." + return 1 +} + + +OS-Print-Status info "prepare nim workspace..." +$__target = "${env:PROJECT_SKU}_${env:PROJECT_OS}-${env:PROJECT_ARCH}" +$__workspace = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}" +$__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}" +$__main = "${__source}\${env:PROJECT_SKU}.nim" + +$SETTINGS_CC = ` + "compileToC " ` + + "--passC:-Wall --passL:-Wall " ` + + "--passC:-Wextra --passL:-Wextra " ` + + "--passC:-std=gnu89 --passL:-std=gnu89 " ` + + "--passC:-pedantic --passL:-pedantic " ` + + "--passC:-Wstrict-prototypes --passL:-Wstrict-prototypes " ` + + "--passC:-Wold-style-definition --passL:-Wold-style-definition " ` + + "--passC:-Wundef --passL:-Wundef " ` + + "--passC:-Wno-trigraphs --passL:-Wno-trigraphs " ` + + "--passC:-fno-strict-aliasing --passL:-fno-strict-aliasing " ` + + "--passC:-fno-common --passL:-fno-common " ` + + "--passC:-fshort-wchar --passL:-fshort-wchar " ` + + "--passC:-fstack-protector-all --passL:-fstack-protector-all " ` + + "--passC:-Werror-implicit-function-declaration --passL:-Werror-implicit-function-declaration " ` + + "--passC:-Wno-format-security --passL:-Wno-format-security " ` + + "--passC:-Os --passL:-Os " ` + + "--passC:-g0 --passL:-g0 " ` + + "--passC:-flto --passL:-flto " +$SETTINGS_NIM = ` + "--mm:orc " ` + + "--define:release " ` + + "--opt:size " ` + + "--colors:on " ` + + "--styleCheck:off " ` + + "--showAllMismatches:on " ` + + "--tlsEmulation:on " ` + + "--implicitStatic:on " ` + + "--trmacros:on " ` + + "--panics:on " + + + + +# execute +$null = FS-Make-Directory "${__workspace}" + + +OS-Print-Status info "checking nim package health..." +$__process = NIM-Check-Package "${__source}" +if ($__process -ne 0) { + OS-Print-Status error "check failed." + return 1 +} + + +OS-Print-Status info "building nim application..." +$__arguments = "${SETTINGS_CC} " ` + + "${SETTINGS_NIM} " ` + + "--passC:-static --passL:-static " ` + + "--passC:-s --passL:-s " ` + + "--os:${env:PROJECT_OS} " ` + + "--cpu:${env:PROJECT_ARCH} " ` + + "--out:${__workspace}\${__target} " +$__process = OS-Exec "nim" "${__arguments} ${__main}" +if ($__process -ne 0) { + OS-Print-Status error "build failed." + return 1 +} + + + + +# exporting executable +$__source = "${__workspace}\${__target}.exe" +$__dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BIN}\${env:PROJECT_SKU}.exe" +OS-Print-Status info "exporting ${__source} to ${__dest}" +$null = FS-Make-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BIN}" +$null = FS-Remove-Silently "${__dest}" +$__process = FS-Move "${__source}" "${__dest}" +if ($__process -ne 0) { + OS-Print-Status error "export failed." + return 1 +} + + + + +# report status +return 0 diff --git a/srcNIM/.ci/package_unix-any.sh b/srcNIM/.ci/package_unix-any.sh new file mode 100644 index 00000000..f5068048 --- /dev/null +++ b/srcNIM/.ci/package_unix-any.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# (0) initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_NIM}/${PROJECT_PATH_CI}/_package-archive_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_NIM}/${PROJECT_PATH_CI}/_package-chocolatey_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_NIM}/${PROJECT_PATH_CI}/_package-docker_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_NIM}/${PROJECT_PATH_CI}/_package-homebrew_unix-any.sh" + + + + +# report status +return 0 diff --git a/srcNIM/.ci/package_windows-any.ps1 b/srcNIM/.ci/package_windows-any.ps1 new file mode 100644 index 00000000..0132647e --- /dev/null +++ b/srcNIM/.ci/package_windows-any.ps1 @@ -0,0 +1,31 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}\${env:PROJECT_PATH_CI}\_package-archive_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}\${env:PROJECT_PATH_CI}\_package-chocolatey_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}\${env:PROJECT_PATH_CI}\_package-docker_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}\${env:PROJECT_PATH_CI}\_package-homebrew_windows-any.ps1" + + + + +# report status +return 0 diff --git a/srcNIM/.ci/prepare_unix-any.sh b/srcNIM/.ci/prepare_unix-any.sh new file mode 100644 index 00000000..db445114 --- /dev/null +++ b/srcNIM/.ci/prepare_unix-any.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/compilers/nim.sh" + + + + +# safety checking control surfaces +OS::print_status info "checking nim availability...\n" +NIM::is_available +if [ $? -ne 0 ]; then + OS::print_status error "missing nim compiler.\n" + return 1 +fi + + +OS::print_status info "activating local environment...\n" +NIM::activate_local_environment +if [ $? -ne 0 ]; then + OS::print_status error "activation failed.\n" + return 1 +fi + + + + +# execute +OS::print_status info "refreshing nimble repo list...\n" +__current_path="$PWD" && cd "${PROJECT_PATH_ROOT}/${PROJECT_NIM}" +nimble refresh +if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + OS::print_status error "refresh failed.\n" + return 1 +fi +cd "$__current_path" && unset __current_path + + + + +# report status +return 0 diff --git a/srcNIM/.ci/prepare_windows-any.ps1 b/srcNIM/.ci/prepare_windows-any.ps1 new file mode 100644 index 00000000..a95c971f --- /dev/null +++ b/srcNIM/.ci/prepare_windows-any.ps1 @@ -0,0 +1,65 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\nim.ps1" + + + + +# safety checking control surfaces +OS-Print-Status info "checking nim availability..." +$__process = NIM-Is-Available +if ($__process -ne 0) { + OS-Print-Status error "missing nim compiler." + return 1 +} + + +OS-Print-Status info "activating local environment..." +$__process = NIM-Activate-Local-Environment +if ($__process -ne 0) { + OS-Print-Status error "activation failed." + return 1 +} + + + + +# execute +OS-Print-Status info "refreshing nimble repo list..." +$__current_path = Get-Location +$null = Set-Location "${env:PROJECT_PATH_ROOT}/${env:PROJECT_NIM}" +$__process = OS-Exec "nimble" "refresh" +if ($__process -ne 0) { + $null = Set-Location "${__current_path}" + $null = Remove-Variable -Name __current_path + OS-Print-Status error "refresh failed." + return 1 +} +$null = Set-Location "${__current_path}" +$null = Remove-Variable -Name __current_path + + + + +# return status +return 0 diff --git a/srcNIM/.ci/setup_unix-any.sh b/srcNIM/.ci/setup_unix-any.sh new file mode 100644 index 00000000..6e798128 --- /dev/null +++ b/srcNIM/.ci/setup_unix-any.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/compilers/nim.sh" + + + + +# safety checking control surfaces +OS::print_status info "checking nim availability...\n" +NIM::is_available +if [ $? -ne 0 ]; then + OS::print_status error "missing nim compiler.\n" + return 1 +fi + + + + +# execute +OS::print_status info "setup localized environment...\n" +NIM::setup_local_environment +if [ $? -ne 0 ]; then + OS::print_status error "setup failed.\n" + return 1 +fi + + + + +# report status +return 0 diff --git a/srcNIM/.ci/setup_windows-any.ps1 b/srcNIM/.ci/setup_windows-any.ps1 new file mode 100644 index 00000000..a4ba21e2 --- /dev/null +++ b/srcNIM/.ci/setup_windows-any.ps1 @@ -0,0 +1,51 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\nim.ps1" + + + + +# safety checking control surfaces +OS-Print-Status info "checking nim availability..." +$__process = NIM-Is-Available +if ($__process -ne 0) { + OS-Print-Status error "missing nim compiler." + return 1 +} + + + + +# execute +OS-Print-Status info "setup localized environment..." +$__process = NIM-Setup-Local-Environment +if ($__process -ne 0) { + OS-Print-Status error "setup failed." + return 1 +} + + + + +# report status +return 0 diff --git a/srcNIM/.ci/start_unix-any.sh b/srcNIM/.ci/start_unix-any.sh new file mode 100644 index 00000000..b2af1678 --- /dev/null +++ b/srcNIM/.ci/start_unix-any.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/compilers/nim.sh" + + + + +# safety checking control surfaces +OS::print_status info "checking nim availability...\n" +NIM::is_available +if [ $? -ne 0 ]; then + OS::print_status error "missing nim compiler.\n" + return 1 +fi + + +OS::print_status info "activating localized environment...\n" +NIM::activate_local_environment +if [ $? -ne 0 ]; then + OS::print_status error "activation failed.\n" + return 1 +fi + + + + +# execute +OS::print_status info "\n" +OS::print_status note "IMPORTANT NOTICE\n" +OS::print_status note "please perform the following command at your terminal manually:\n" +OS::print_status note " $ . ${PROJECT_NIM_LOCALIZED}\n" +OS::print_status info "\n" + + + + +# report status +return 0 diff --git a/srcNIM/.ci/start_windows-any.ps1 b/srcNIM/.ci/start_windows-any.ps1 new file mode 100644 index 00000000..67580628 --- /dev/null +++ b/srcNIM/.ci/start_windows-any.ps1 @@ -0,0 +1,58 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\nim.ps1" + + + + +# safety checking control surfaces +OS-Print-Status info "checking nim availability..." +$__process = NIM-Is-Available +if ($__process -ne 0) { + OS-Print-Status error "missing nim intepreter." + return 1 +} + + +OS-Print-Status info "activating localized environment..." +$__process = NIM-Activate-Local-Environment +if ($__process -ne 0) { + OS-Print-Status error "activation failed." + return 1 +} + + + + +# execute +OS-Print-Status info "" +OS-Print-Status note "IMPORTANT NOTE - PowerShell ONLY" +OS-Print-Status note "please perform the following command at your terminal manually:" +OS-Print-Status note " $ . ${env:PROJECT_NIM_LOCALIZED}" +OS-Print-Status info "" + + + + +# report status +return 0 diff --git a/srcNIM/.ci/stop_unix-any.sh b/srcNIM/.ci/stop_unix-any.sh new file mode 100644 index 00000000..80fdd2ef --- /dev/null +++ b/srcNIM/.ci/stop_unix-any.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" + + + + +# execute +OS::print_status info "\n" +OS::print_status note "IMPORTANT NOTICE\n" +OS::print_status note "please perform the following command at your terminal manually:\n" +OS::print_status note " $ deactivate\n" +OS::print_status info "\n" + + + + +# report status +return 0 diff --git a/srcNIM/.ci/stop_windows-any.ps1 b/srcNIM/.ci/stop_windows-any.ps1 new file mode 100644 index 00000000..fbabba4c --- /dev/null +++ b/srcNIM/.ci/stop_windows-any.ps1 @@ -0,0 +1,38 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + exit 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" + + + + +# execute +OS-Print-Status info "" +OS-Print-Status note "IMPORTANT NOTE" +OS-Print-Status note "please perform the following command at your terminal manually:" +OS-Print-Status note " $ deactivate" +OS-Print-Status info "" + + + + +# report status +return 0 diff --git a/srcNIM/.ci/test_unix-any.sh b/srcNIM/.ci/test_unix-any.sh new file mode 100644 index 00000000..18730113 --- /dev/null +++ b/srcNIM/.ci/test_unix-any.sh @@ -0,0 +1,139 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +fi + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/compilers/nim.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/operators_unix-any.sh" + + + + +# safety checking control surfaces +OS::print_status info "checking nim availability...\n" +NIM::is_available +if [ $? -ne 0 ]; then + OS::print_status error "missing nim compiler.\n" + return 1 +fi + + +OS::print_status info "activating local environment...\n" +NIM::activate_local_environment +if [ $? -ne 0 ]; then + OS::print_status error "activation failed.\n" + return 1 +fi + + +OS::print_status info "checking BUILD::test function availability...\n" +OS::is_command_available "BUILD::test" +if [ $? -ne 0 ]; then + OS::print_status error "check failed.\n" + return 1 +fi + + +OS::print_status info "prepare nim workspace...\n" +__source="${PROJECT_PATH_ROOT}/${PROJECT_NIM}" +__main="${__source}/${PROJECT_SKU}.nim" + +SETTINGS_CC="\ +compileToC \ +--passC:-Wall --passL:-Wall \ +--passC:-Wextra --passL:-Wextra \ +--passC:-std=gnu89 --passL:-std=gnu89 \ +--passC:-pedantic --passL:-pedantic \ +--passC:-Wstrict-prototypes --passL:-Wstrict-prototypes \ +--passC:-Wold-style-definition --passL:-Wold-style-definition \ +--passC:-Wundef --passL:-Wundef \ +--passC:-Wno-trigraphs --passL:-Wno-trigraphs \ +--passC:-fno-strict-aliasing --passL:-fno-strict-aliasing \ +--passC:-fno-common --passL:-fno-common \ +--passC:-fshort-wchar --passL:-fshort-wchar \ +--passC:-fstack-protector-all --passL:-fstack-protector-all \ +--passC:-Werror-implicit-function-declaration --passL:-Werror-implicit-function-declaration \ +--passC:-Wno-format-security --passL:-Wno-format-security \ +--passC:-Os --passL:-Os \ +--passC:-g0 --passL:-g0 \ +--passC:-flto --passL:-flto \ +" +SETTINGS_NIM="\ +--mm:orc \ +--define:release \ +--opt:size \ +--colors:on \ +--styleCheck:off \ +--showAllMismatches:on \ +--tlsEmulation:on \ +--implicitStatic:on \ +--trmacros:on \ +--panics:on \ +" + +case "$PROJECT_OS" in +darwin) + __arguments="\ +${SETTINGS_CC} \ +${SETTINGS_NIM} \ +--cc:clang \ +--passC:-fPIC \ +--cpu:${PROJECT_ARCH} \ +" + ;; +*) + __arguments="\ +${SETTINGS_CC} \ +${SETTINGS_NIM} \ +--cc:gcc \ +--passC:-static --passL:-static \ +--os:${PROJECT_OS} \ +--cpu:${PROJECT_ARCH} \ +" + ;; +esac + + + + +# checking nim package health +OS::print_status info "checking nim package health...\n" +NIM::check_package "$__source" +if [ $? -ne 0 ]; then + OS::print_status error "check failed.\n" + return 1 +fi + + + + +# execute +BUILD::test "$PROJECT_NIM" "$PROJECT_OS" "$PROJECT_ARCH" "$__arguments" "nim" +if [ $? -ne 0 -a $? -ne 10 ]; then + EXIT_CODE=1 +fi + + + + +# return status +return $EXIT_CODE diff --git a/srcNIM/.ci/test_windows-any.ps1 b/srcNIM/.ci/test_windows-any.ps1 new file mode 100644 index 00000000..5a6507ba --- /dev/null +++ b/srcNIM/.ci/test_windows-any.ps1 @@ -0,0 +1,124 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n" + return 1 +} + +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\nim.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\operators_windows-any.ps1" + + + + +# safety checking control surfaces +OS-Print-Status info "checking nim availability..." +$__process = NIM-Is-Available +if ($__process -ne 0) { + OS-Print-Status error "missing nim compiler." + return 1 +} + + +OS-Print-Status info "activating local environment..." +$__process = NIM-Activate-Local-Environment +if ($__process -ne 0) { + OS-Print-Status error "activation failed." + return 1 +} + + +OS-Print-Status info "checking BUILD-Test function availability..." +$__process = OS-Is-Command-Available "Build-Test" +if ($__process -ne 0) { + OS-Print-Status error "check failed." + return 1 +} + + +OS-Print-Status info "prepare nim workspace..." +$__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}" +$__main = "${__source}\${env:PROJECT_SKU}.nim" + +$SETTINGS_CC = "compileToC " ` + + "--passC:-Wall --passL:-Wall " ` + + "--passC:-Wextra --passL:-Wextra " ` + + "--passC:-std=gnu89 --passL:-std=gnu89 " ` + + "--passC:-pedantic --passL:-pedantic " ` + + "--passC:-Wstrict-prototypes --passL:-Wstrict-prototypes " ` + + "--passC:-Wold-style-definition --passL:-Wold-style-definition " ` + + "--passC:-Wundef --passL:-Wundef " ` + + "--passC:-Wno-trigraphs --passL:-Wno-trigraphs " ` + + "--passC:-fno-strict-aliasing --passL:-fno-strict-aliasing " ` + + "--passC:-fno-common --passL:-fno-common " ` + + "--passC:-fshort-wchar --passL:-fshort-wchar " ` + + "--passC:-fstack-protector-all --passL:-fstack-protector-all " ` + + "--passC:-Werror-implicit-function-declaration --passL:-Werror-implicit-function-declaration " ` + + "--passC:-Wno-format-security --passL:-Wno-format-security " ` + + "--passC:-Os --passL:-Os " ` + + "--passC:-g0 --passL:-g0 " ` + + "--passC:-flto --passL:-flto" + +$SETTINGS_NIM = "--mm:orc " ` + + "--define:release " ` + + "--opt:size " ` + + "--colors:on " ` + + "--styleCheck:off " ` + + "--showAllMismatches:on " ` + + "--tlsEmulation:on " ` + + "--implicitStatic:on " ` + + "--trmacros:on " ` + + "--panics:on " + +$__arguments = "${SETTINGS_CC} " ` + + "${SETTINGS_NIM} " ` + + "--cc:gcc " ` + + "--passC:-static --passL:-static " ` + + "--cpu:${env:PROJECT_ARCH} " + + + + +# checking nim package health +OS-Print-Status info "checking nim package health..." +$__process = NIM-Check-Package "${__source}" +if ($__process -ne 0) { + OS-Print-Status error "check failed." + return 1 +} + + + + +# execute +$__process = BUILD-Test ` + "${env:PROJECT_NIM}" ` + "${env:PROJECT_OS}" ` + "${env:PROJECT_ARCH}" ` + "${__arguments}" ` + "nim" +if (($__process -ne 0) -and ($__process -ne 10)) { + return 1 +} + + + + +# report status +return 0 diff --git a/srcNIM/automataCI.txt b/srcNIM/automataCI.txt new file mode 100644 index 00000000..b328239a --- /dev/null +++ b/srcNIM/automataCI.txt @@ -0,0 +1,12 @@ +# AUTOMATACI SOURCE CODES LIST +# +# Step to do: +# (1) List all the executable source codes for compilation in the following +# patterns: +# [OS]-[ARCH] relative/path/to/code.[TYPE] +# Example: +# any-any main.nim +# linux-amd64 fx1_linux-amd64.nim +# darwin-arm64 fx2_linux-amd64.nim +# +any-any automataci.nim diff --git a/srcNIM/automataci.nim b/srcNIM/automataci.nim new file mode 100644 index 00000000..a6ba660b --- /dev/null +++ b/srcNIM/automataci.nim @@ -0,0 +1,12 @@ +# [ COPYRIGHT CLAUSE HERE ] +import automatacipkg/Sample/Greeter +import automatacipkg/Sample/Entity +import automatacipkg/Sample/Location + + + + +# main +proc main = + echo "Hello " & Greeter.Process(Entity.Name, Location.Name) +main() diff --git a/srcNIM/automataci.nimble b/srcNIM/automataci.nimble new file mode 100644 index 00000000..c289d031 --- /dev/null +++ b/srcNIM/automataci.nimble @@ -0,0 +1,13 @@ +# Package AutomataCI +############ +# METADATA # +############ +version = "1.7.0" +author = "Your Legal Full Name Here" +description = "Solid Foundation for Kickstarting Your Software Development" +license = "Apache-2.0" + +installExt = @["nim"] +bin = @["automataci"] + +srcDir = "." diff --git a/srcNIM/automatacipkg/Sample/Entity.nim b/srcNIM/automatacipkg/Sample/Entity.nim new file mode 100644 index 00000000..1ee3d795 --- /dev/null +++ b/srcNIM/automatacipkg/Sample/Entity.nim @@ -0,0 +1,2 @@ +# [ COPYRIGHT CLASE HERE ] +var NAME* = "Jane" diff --git a/srcNIM/automatacipkg/Sample/Greeter.nim b/srcNIM/automatacipkg/Sample/Greeter.nim new file mode 100644 index 00000000..87f0165c --- /dev/null +++ b/srcNIM/automatacipkg/Sample/Greeter.nim @@ -0,0 +1,16 @@ +# [ COPYRIGHT CLASE HERE ] + + + + +proc Process*(name, location: string): string = + ## Process it to generate a sample response based on a given name and + ## location. + if name == "" and location == "": + return "" + elif name == "": + return "stranger from " & location & "!" + elif location == "": + return name & "!" + else: + return name & " form " & location & "!" diff --git a/srcNIM/automatacipkg/Sample/Greeter_test.nim b/srcNIM/automatacipkg/Sample/Greeter_test.nim new file mode 100644 index 00000000..4fd71238 --- /dev/null +++ b/srcNIM/automatacipkg/Sample/Greeter_test.nim @@ -0,0 +1,81 @@ +# [ COPYRIGHT CLAUSE HERE ] +import Greeter + + +# define test libraries +type + Scenario = object + ID: uint64 + Name: string + Description: string + + + + +# define test algorithm +proc test_process_api(s: var Scenario, name: string, location: string): int = + var str: string = "" + + # test + str = Greeter.Process(name, location) + + # log output + echo "TEST CASE" + echo "=========" + echo "Test Scenario ID" + echo " ", s.ID + echo "Test Scenario Name" + echo " ", s.Name + echo "Test Scenario Description" + echo " ", s.Description + echo "Input Name" + echo " ", name + echo "Input Location" + echo " ", location + echo "Got Output:" + echo " ", str + echo "" + + # assert + echo "Asserting conditions..." + if str != "": + if name == "" and location == "": + echo "[ FAILED ] Expecting string but got empty instead.\n\n\n" + return 1 + else: + if name != "" or location != "": + echo "[ FAILED ] Expecting empty string but got result instead.\n\n\n" + return 1 + + # report status + echo "[ PASSED ]\n\n\n" + return 0 + + + + +# execute main test +proc main = + var s = Scenario(ID: 0, Name: "Test Process(...) API") + + s.Description = "Test Process() is able to work with proper name and location." + if test_process_api(s, "Alpha", "Rivendell") != 0: + return + s.ID += 1 + + s.Description = "Test Process() is able to work with proper name and empty location." + if test_process_api(s, "Alpha", "") != 0: + return + s.ID += 1 + + s.Description = "Test Process() is able to work with empty name and proper location." + if test_process_api(s, "Alpha", "") != 0: + return + s.ID += 1 + + s.Description = "Test Process() is able to work with empty name and empty location." + if test_process_api(s, "Alpha", "") != 0: + return + s.ID += 1 + +main() diff --git a/srcNIM/automatacipkg/Sample/Location.nim b/srcNIM/automatacipkg/Sample/Location.nim new file mode 100644 index 00000000..c3720d29 --- /dev/null +++ b/srcNIM/automatacipkg/Sample/Location.nim @@ -0,0 +1,2 @@ +# [ COPYRIGHT CLASE HERE ] +const Name* = "Sample" diff --git a/srcPYTHON/Libs/Sample/Entity.py b/srcPYTHON/Libs/Sample/Entity.py index 07b1722e..5312fd70 100644 --- a/srcPYTHON/Libs/Sample/Entity.py +++ b/srcPYTHON/Libs/Sample/Entity.py @@ -1,2 +1,2 @@ -# [ COPYRIGHT CLASE HERE] +# [ COPYRIGHT CLASE HERE ] NAME = 'Jane' diff --git a/srcPYTHON/Libs/Sample/Location.py b/srcPYTHON/Libs/Sample/Location.py index a53fe324..d9ef5d97 100644 --- a/srcPYTHON/Libs/Sample/Location.py +++ b/srcPYTHON/Libs/Sample/Location.py @@ -1,2 +1,2 @@ -# [ COPYRIGHT CLASE HERE] +# [ COPYRIGHT CLASE HERE ] NAME = 'Sample' diff --git a/srcPYTHON/Libs/Sample/Strings.py b/srcPYTHON/Libs/Sample/Strings.py index 37258cbe..2ce92656 100644 --- a/srcPYTHON/Libs/Sample/Strings.py +++ b/srcPYTHON/Libs/Sample/Strings.py @@ -1,4 +1,4 @@ -# [ COPYRIGHT CLASE HERE] +# [ COPYRIGHT CLASE HERE ] def Process(name: str, location: str) -> str: """ Generate a printable statement for a name and a location.