diff --git a/ISM/CommandLine.cr b/ISM/CommandLine.cr index 872ee3b..8b0fbb2 100644 --- a/ISM/CommandLine.cr +++ b/ISM/CommandLine.cr @@ -2101,11 +2101,14 @@ module ISM showTaskCompilationTitleMessage generateTasksFile(tasks) - buildTasksFile + + if Ism.settings.binaryTaskMode + buildTasksFile + end showCalculationDoneMessage - runTasksFile(logEnabled: true, softwareList: neededSoftwares) + runTasksFile(asBinary: Ism.settings.binaryTaskMode, logEnabled: true, softwareList: neededSoftwares) rescue error printSystemCallErrorNotification(error) @@ -2115,7 +2118,7 @@ module ISM def buildTasksFile processResult = IO::Memory.new - Process.run("CRYSTAL_WORKERS=#{Ism.settings.systemMakeOptions[2..-1]} crystal build --release --progress #{ISM::Default::Filename::Task}.cr -o #{@settings.rootPath}#{ISM::Default::Path::RuntimeDataDirectory}#{ISM::Default::Filename::Task} -f json", + Process.run("CRYSTAL_WORKERS=#{Ism.settings.systemMakeOptions[2..-1]} crystal build --release #{ISM::Default::Filename::Task}.cr -o #{@settings.rootPath}#{ISM::Default::Path::RuntimeDataDirectory}#{ISM::Default::Filename::Task} -f json", error: processResult, shell: true, chdir: "#{@settings.rootPath}#{ISM::Default::Path::RuntimeDataDirectory}") do |process| @@ -2141,13 +2144,15 @@ module ISM exitProgram end - def runTasksFile(logEnabled = false, softwareList = Array(ISM::SoftwareInformation).new) + def runTasksFile(asBinary = true, logEnabled = false, softwareList = Array(ISM::SoftwareInformation).new) + + command = (asBinary ? "./#{ISM::Default::Filename::Task}" : "crystal #{ISM::Default::Filename::Task}.cr") logIOMemory = IO::Memory.new logWriter = logEnabled ? IO::MultiWriter.new(STDOUT,logIOMemory) : Process::Redirect::Inherit - process = Process.run( "./#{ISM::Default::Filename::Task}", + process = Process.run( command: command, output: logWriter, error: logWriter, shell: true, diff --git a/ISM/CommandLineSettings.cr b/ISM/CommandLineSettings.cr index 1cfc4c6..7b82f92 100644 --- a/ISM/CommandLineSettings.cr +++ b/ISM/CommandLineSettings.cr @@ -6,6 +6,7 @@ module ISM #Generic parameters property secureMode : Bool + property binaryTaskMode : Bool property installByChroot : Bool property rootPath : String property defaultMirror : String @@ -60,6 +61,7 @@ module ISM def initialize( #Generic parameters @secureMode = ISM::Default::CommandLineSettings::SecureMode, + @binaryTaskMode = ISM::Default::CommandLineSettings::BinaryTaskMode, @installByChroot = ISM::Default::CommandLineSettings::InstallByChroot, @rootPath = ISM::Default::CommandLineSettings::RootPath, @defaultMirror = ISM::Default::CommandLineSettings::DefaultMirror, @@ -148,6 +150,7 @@ module ISM #Generic parameters secureMode : Bool, + binaryTaskMode : Bool, installByChroot : Bool, rootPath : String, defaultMirror : String, @@ -208,6 +211,7 @@ module ISM settings = {#Generic parameters "secureMode" => secureMode, + "binaryTaskMode" => binaryTaskMode, "installByChroot" => installByChroot, "rootPath" => rootPath, "defaultMirror" => defaultMirror, @@ -275,6 +279,7 @@ module ISM @rootPath+ISM::Default::CommandLineSettings::SettingsFilePath, #Generic parameters ISM::Default::CommandLineSettings::SecureMode, + ISM::Default::CommandLineSettings::BinaryTaskMode, ISM::Default::CommandLineSettings::InstallByChroot, ISM::Default::CommandLineSettings::RootPath, @defaultMirror, @@ -338,6 +343,7 @@ module ISM #Generic parameters @secureMode, + @binaryTaskMode, @installByChroot, @rootPath, @defaultMirror, @@ -701,6 +707,14 @@ module ISM Ism.exitProgram end + def setBinaryTaskMode(@binaryTaskMode) + writeSystemConfiguration + + rescue error + Ism.printSystemCallErrorNotification(error) + Ism.exitProgram + end + def setInstallByChroot(@installByChroot) writeSystemConfiguration diff --git a/ISM/Default/CommandLineSettings.cr b/ISM/Default/CommandLineSettings.cr index c1ab039..9b9d0d5 100644 --- a/ISM/Default/CommandLineSettings.cr +++ b/ISM/Default/CommandLineSettings.cr @@ -13,6 +13,7 @@ module ISM #Generic parameters SecureMode = true + BinaryTaskMode = true InstallByChroot = false RootPath = "/" DefaultMirror = "Uk" diff --git a/ISM/Default/Option/Settings/DisableBinaryTaskMode/DisableBinaryTaskMode.cr b/ISM/Default/Option/Settings/DisableBinaryTaskMode/DisableBinaryTaskMode.cr new file mode 100644 index 0000000..a9511fc --- /dev/null +++ b/ISM/Default/Option/Settings/DisableBinaryTaskMode/DisableBinaryTaskMode.cr @@ -0,0 +1,20 @@ +module ISM + + module Default + + module Option + + module SettingsDisableBinaryTaskMode + + ShortText = "-dbtm" + LongText = "disablebinarytaskmode" + Description = "Disable compilation for ism tasks. Task will be interpreted and will start directly, but speed process will be slower." + SetText = "Disable binary task mode" + + end + + end + + end + +end diff --git a/ISM/Default/Option/Settings/EnableBinaryTaskMode/EnableBinaryTaskMode.cr b/ISM/Default/Option/Settings/EnableBinaryTaskMode/EnableBinaryTaskMode.cr new file mode 100644 index 0000000..ef26d94 --- /dev/null +++ b/ISM/Default/Option/Settings/EnableBinaryTaskMode/EnableBinaryTaskMode.cr @@ -0,0 +1,20 @@ +module ISM + + module Default + + module Option + + module SettingsEnableBinaryTaskMode + + ShortText = "-ebtm" + LongText = "enablebinarytaskmode" + Description = "Enable compilation for ism tasks. Improve highly task speed, at cost of compilation time." + SetText = "Enable binary task mode" + + end + + end + + end + +end diff --git a/ISM/Default/Option/Settings/Settings.cr b/ISM/Default/Option/Settings/Settings.cr index d4744f8..62f887b 100644 --- a/ISM/Default/Option/Settings/Settings.cr +++ b/ISM/Default/Option/Settings/Settings.cr @@ -13,6 +13,8 @@ module ISM #Global options ISM::Option::SettingsEnableSecureMode.new, ISM::Option::SettingsDisableSecureMode.new, + ISM::Option::SettingsEnableBinaryTaskMode.new, + ISM::Option::SettingsDisableBinaryTaskMode.new, ISM::Option::SettingsEnableInstallByChroot.new, ISM::Option::SettingsDisableInstallByChroot.new, ISM::Option::SettingsSetRootPath.new, diff --git a/ISM/Option/Settings/DisableBinaryTaskMode/DisableBinaryTaskMode.cr b/ISM/Option/Settings/DisableBinaryTaskMode/DisableBinaryTaskMode.cr new file mode 100644 index 0000000..2a505e9 --- /dev/null +++ b/ISM/Option/Settings/DisableBinaryTaskMode/DisableBinaryTaskMode.cr @@ -0,0 +1,28 @@ +module ISM + + module Option + + class SettingsDisableBinaryTaskMode < ISM::CommandLineOption + + def initialize + super( ISM::Default::Option::SettingsDisableBinaryTaskMode::ShortText, + ISM::Default::Option::SettingsDisableBinaryTaskMode::LongText, + ISM::Default::Option::SettingsDisableBinaryTaskMode::Description) + end + + def start + if ARGV.size == 2 + if !Ism.ranAsSuperUser + Ism.printNeedSuperUserAccessNotification + else + Ism.settings.setBinaryTaskMode(false) + Ism.printProcessNotification(ISM::Default::Option::SettingsDisableBinaryTaskMode::SetText) + end + end + end + + end + + end + +end diff --git a/ISM/Option/Settings/EnableBinaryTaskMode/EnableBinaryTaskMode.cr b/ISM/Option/Settings/EnableBinaryTaskMode/EnableBinaryTaskMode.cr new file mode 100644 index 0000000..2894807 --- /dev/null +++ b/ISM/Option/Settings/EnableBinaryTaskMode/EnableBinaryTaskMode.cr @@ -0,0 +1,28 @@ +module ISM + + module Option + + class SettingsEnableBinaryTaskMode < ISM::CommandLineOption + + def initialize + super( ISM::Default::Option::SettingsEnableBinaryTaskMode::ShortText, + ISM::Default::Option::SettingsEnableBinaryTaskMode::LongText, + ISM::Default::Option::SettingsEnableBinaryTaskMode::Description) + end + + def start + if ARGV.size == 2 + if !Ism.ranAsSuperUser + Ism.printNeedSuperUserAccessNotification + else + Ism.settings.setBinaryTaskMode(true) + Ism.printProcessNotification(ISM::Default::Option::SettingsEnableBinaryTaskMode::SetText) + end + end + end + + end + + end + +end diff --git a/RequiredLibraries.cr b/RequiredLibraries.cr index b6bb9a9..da4649b 100644 --- a/RequiredLibraries.cr +++ b/RequiredLibraries.cr @@ -50,6 +50,8 @@ require "./ISM/Default/Option/Settings/Settings" require "./ISM/Default/Option/Settings/Show/Show" require "./ISM/Default/Option/Settings/EnableSecureMode/EnableSecureMode" require "./ISM/Default/Option/Settings/DisableSecureMode/DisableSecureMode" +require "./ISM/Default/Option/Settings/EnableBinaryTaskMode/EnableBinaryTaskMode" +require "./ISM/Default/Option/Settings/DisableBinaryTaskMode/DisableBinaryTaskMode" require "./ISM/Default/Option/Settings/EnableInstallByChroot/EnableInstallByChroot" require "./ISM/Default/Option/Settings/DisableInstallByChroot/DisableInstallByChroot" require "./ISM/Default/Option/Settings/SetRootPath/SetRootPath" @@ -121,6 +123,8 @@ require "./ISM/Option/Settings/Settings" require "./ISM/Option/Settings/Show/Show" require "./ISM/Option/Settings/EnableSecureMode/EnableSecureMode" require "./ISM/Option/Settings/DisableSecureMode/DisableSecureMode" +require "./ISM/Option/Settings/EnableBinaryTaskMode/EnableBinaryTaskMode" +require "./ISM/Option/Settings/DisableBinaryTaskMode/DisableBinaryTaskMode" require "./ISM/Option/Settings/EnableInstallByChroot/EnableInstallByChroot" require "./ISM/Option/Settings/DisableInstallByChroot/DisableInstallByChroot" require "./ISM/Option/Settings/SetRootPath/SetRootPath"