build.ck 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*++
  2. Copyright (c) 2012 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. Kernel
  9. Abstract:
  10. This is the core of the operating system.
  11. Author:
  12. Evan Green 26-Jul-2012
  13. Environment:
  14. Kernel
  15. --*/
  16. from menv import staticLibrary, copy, driver, createVersionHeader, mconfig;
  17. function build() {
  18. var arch = mconfig.arch;
  19. var archSources;
  20. var armSources;
  21. var baseSources;
  22. var binroot = mconfig.binroot;
  23. var bootArchLib;
  24. var bootArchSources;
  25. var entries;
  26. var kernel;
  27. var kernelConfig;
  28. var kernelLibs;
  29. var versionConfig;
  30. var versionFile;
  31. var versionMajor;
  32. var versionMinor;
  33. var versionRevision;
  34. baseSources = [
  35. "init.c"
  36. ];
  37. if ((arch == "armv7") || (arch == "armv6")) {
  38. armSources = [
  39. "armv7/commsup.S",
  40. "armv7/inttable.S",
  41. "armv7/prochw.c",
  42. "armv7/sstep.c",
  43. "armv7/trap.S",
  44. "armv7/vfp.c"
  45. ];
  46. bootArchSources = [":armv7/sstep.o"];
  47. if (arch == "armv7") {
  48. archSources = armSources + [
  49. "armv7/archsup.S",
  50. "armv7/archsupc.c"
  51. ];
  52. } else {
  53. archSources = armSources + [
  54. "armv6/archsup.S",
  55. "armv6/archsupc.c"
  56. ];
  57. }
  58. } else if (arch == "x86") {
  59. archSources = [
  60. "x86/archsup.S",
  61. "x86/archsupc.c",
  62. "x86/prochw.c",
  63. "x86/trap.S"
  64. ];
  65. }
  66. kernelLibs = [
  67. "kernel/acpi:acpi",
  68. "lib/crypto:crypto",
  69. "kernel/ob:ob",
  70. "lib/rtl/base:basertl",
  71. "lib/rtl/kmode:krtl",
  72. "lib/im:im",
  73. "lib/basevid:basevid",
  74. "lib/termlib:termlib",
  75. "kernel/kd:kd",
  76. "kernel/kd/kdusb:kdusb",
  77. "kernel/ps:ps",
  78. "kernel/ke:ke",
  79. "kernel/io:io",
  80. "kernel/hl:hl",
  81. "kernel/mm:mm",
  82. "kernel/sp:sp"
  83. ];
  84. kernelConfig = {
  85. "LDFLAGS": ["-Wl,--whole-archive"]
  86. };
  87. kernel = {
  88. "label": "kernel",
  89. "inputs": baseSources + archSources + kernelLibs,
  90. "implicit": [":kernel-version"],
  91. "entry": "KepStartSystem",
  92. "config": kernelConfig
  93. };
  94. bootArchLib = {
  95. "label": "archboot",
  96. "inputs": bootArchSources
  97. };
  98. entries = driver(kernel);
  99. if (bootArchSources) {
  100. entries += staticLibrary(bootArchLib);
  101. }
  102. //
  103. // Copy the config files.
  104. //
  105. entries += copy("config/dev2drv.set",
  106. binroot + "/dev2drv.set",
  107. "dev2drv.set",
  108. null,
  109. null);
  110. entries += copy("config/devmap.set",
  111. binroot + "/devmap.set",
  112. "devmap.set",
  113. null,
  114. null);
  115. entries += copy("config/init.set",
  116. binroot + "/init.set",
  117. "init.set",
  118. null,
  119. null);
  120. entries += copy("config/init.sh",
  121. binroot + "/init.sh",
  122. "init.sh",
  123. null,
  124. null);
  125. //
  126. // Create the version header.
  127. //
  128. versionMajor = "0";
  129. versionMinor = "4";
  130. versionRevision = "0";
  131. entries += createVersionHeader(versionMajor,
  132. versionMinor,
  133. versionRevision);
  134. //
  135. // Also create a version file in the binroot.
  136. //
  137. versionConfig = {
  138. "MAJOR": versionMajor,
  139. "MINOR": versionMinor,
  140. "REVISION": versionRevision,
  141. "FORM": "simple"
  142. };
  143. versionFile = {
  144. "type": "target",
  145. "label": "kernel-version",
  146. "output": binroot + "/kernel-version",
  147. "tool": "gen_version",
  148. "config": versionConfig
  149. };
  150. entries += [versionFile];
  151. return entries;
  152. }