Skip to content

Commit

Permalink
i forgor this part >~<
Browse files Browse the repository at this point in the history
  • Loading branch information
cinnamonwolfy committed Aug 16, 2023
1 parent 8a5771a commit d02d51e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions pl-files/compile-modules/kernel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
require_relative 'common.rb'

def kernelBuild globalVars
Dir.chdir("#{globalVars["buildDir"]}/linux-#{globalVars["linux"]}")

moduleSupport = false
extraKernelFlags = ""
oldPath = ENV["PATH"]
ENV["PATH"] = "#{globalVars["tcprefix"]}/bin:#{ENV["PATH"]}"
if globalVars["toolchain"] == "llvm"
extraKernelFlags = "HOSTCC=cc HOSTLD=ld LLVM=#{globalVars["tcprefix"]}/bin"
end

if File.exist?(".config") == false
print "Please input default configuration: "
defconfig = gets.chomp
if defconfig == "" or defconfig == nil
defconfig = "defconfig"
end

system("make ARCH=#{globalVars["linux_arch"]} #{defconfig}")
print "Would you like to configure further? (N/y) "
yn = gets.chomp
if yn == "y" or yn == "yes" or yn == "Y"
system("make menuconfig")
end

matches = File.foreach(".config").grep("CONFIG_MODULES")
if matches != Array.new
moduleSupport = true
end
end

puts "Compiling kernel..."
system("make -j#{globalVars["threads"]} #{extraKernelFlags} CROSS_COMPILE=#{globalVars["triple"]}- ARCH=#{globalVars["linux_arch"]} -j#{globalVars["threads"]}")
puts "Installing kernel files..."

Dir.chdir("#{globalVars["buildDir"]}/linux-#{globalVars["linux"]}/arch/#{globalVars["linux_arch"]}/boot")
realPath = File.dirname(File.readlink(Dir.foreach(".").grep(/Image/).shift))
Dir.chdir(realPath)
FileUtils.copy(Dir.foreach(".").grep(/Image/), "#{globalVars["outputDir"]}")

if Dir.exist?("dts")
FileUtils.copy_entry("dts", "#{globalVars["outputDir"]}")
end

Dir.chdir("../../..")
if moduleSupport == true
system("make ARCH=#{globalVars["linux_arch"]} INSTALL_MOD_PATH=#{globalVars["outputDir"]}/rootfs modules_install")
end
ENV["PATH"] = oldPath

Dir.chdir("#{globalVars["baseDir"]}")
end

0 comments on commit d02d51e

Please sign in to comment.