Skip to content

Commit

Permalink
refactor(rake): env vars, conditionnal logs
Browse files Browse the repository at this point in the history
  • Loading branch information
berdal84 committed Nov 23, 2024
1 parent afac97a commit a428293
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
8 changes: 3 additions & 5 deletions rake/common.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

C_COMPILER = "clang"
CXX_COMPILER = "clang++"
require_relative 'environment'

def new_project(name, type)

Expand Down Expand Up @@ -135,7 +133,7 @@ def declare_project_tasks(project)

desc "Copy in #{INSTALL_DIR} the files to distribute the software"
task :pack do
copy_build_to_install_dir(project)
_pack(project)
end

desc "Compile #{project[:type]}"
Expand Down Expand Up @@ -190,7 +188,7 @@ def copy_assets_to_build_dir( project )
system commands or raise "Unable to copy assets"
end

def copy_build_to_install_dir( project )
def _pack( project )
commands = [
"mkdir -p #{INSTALL_DIR}",
"cp -r #{BUILD_DIR}/#{project[:asset_folder_path]} #{BUILD_DIR}/#{project[:name]} #{INSTALL_DIR}",
Expand Down
25 changes: 15 additions & 10 deletions rake/environment.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
require "rbconfig"

VERBOSE = false
C_COMPILER = "clang"
CXX_COMPILER = "clang++"
COMPILER_FOUND = system "#{C_COMPILER} --version" || false
BUILD_OS = RbConfig::CONFIG['build_os']
HOST_OS = RbConfig::CONFIG['host_os']
TARGET_OS = RbConfig::CONFIG['target_os']
Expand All @@ -16,17 +19,19 @@
BUILD_OS_MACOS = BUILD_OS.include?("darwin")
BUILD_OS_WINDOWS = BUILD_OS.include?("windows") || BUILD_OS.include?("mingw32")

system "echo Ruby version: && ruby -v"
puts "BUILD_OS_LINUX: #{BUILD_OS_LINUX}"
puts "BUILD_OS_MACOS: #{BUILD_OS_MACOS}"
puts "BUILD_OS_WINDOWS: #{BUILD_OS_WINDOWS}"
CLANG_FOUND = system "clang --version"
puts "CLANG_FOUND: #{CLANG_FOUND}"
puts "BUILD_TYPE_RELEASE: #{BUILD_TYPE_RELEASE}"
puts "BUILD_TYPE_DEBUG: #{BUILD_TYPE_DEBUG}"
if VERBOSE
system "echo Ruby version: && ruby -v"
puts "BUILD_OS_LINUX: #{BUILD_OS_LINUX}"
puts "BUILD_OS_MACOS: #{BUILD_OS_MACOS}"
puts "BUILD_OS_WINDOWS: #{BUILD_OS_WINDOWS}"

puts "COMPILER_FOUND: #{COMPILER_FOUND}"
puts "BUILD_TYPE_RELEASE: #{BUILD_TYPE_RELEASE}"
puts "BUILD_TYPE_DEBUG: #{BUILD_TYPE_DEBUG}"
end

if not CLANG_FOUND
raise "clang compiler is required, please install an retry."
if not COMPILER_FOUND
raise "Unable to find #{C_COMPILER}, this compiler is required, please install an retry."
elsif (not BUILD_OS_LINUX) and (not BUILD_OS_MACOS) and (not BUILD_OS_WINDOWS)
raise "Unable to determine the operating system"
end

0 comments on commit a428293

Please sign in to comment.