-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a5771a
commit d02d51e
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |