Skip to content

Commit f225fbe

Browse files
committed
Fix: Linking issue after 0de2a77
As the build flags are included at the place its required, linking also must occur at that place. This also makes sense after all why would one compile in one place and link in another. The root CMakeLists.txt now just includes `src/kernel/CMakeLists.txt` with the former now fully builds the Kernel and drivers. Inclusion of targets into the global 'build-all' target also happens where the target is defined not at the root CMakeLists.txt which seems to me how it should have been (Dependency goes from parent to child CMakeLists but not the other way). Also includes: * After decoupling of application build & kernel flags, all references of kernel definitions in applib headers & applications were removed or defined separately at the application level.
1 parent f86d2ed commit f225fbe

File tree

6 files changed

+55
-37
lines changed

6 files changed

+55
-37
lines changed

CMakeLists.txt

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -101,43 +101,20 @@ if(CMAKE_CROSSCOMPILING)
101101
set(MOS_DISKIMAGE_PATH ${MOS_DISKIMAGE_DIR}/mos.flp)
102102

103103
#---------------------------------------------------------------------------
104+
# Components which want to build by default should add themselves to this global target.
104105
add_custom_target(build-all ALL)
105-
add_dependencies(build-all kernel.flt boot1.flt boot0.flt)
106-
if (MOS_GRAPHICS_ENABLED)
107-
add_dependencies(build-all gui0.flt)
108-
else()
109-
add_dependencies(build-all proc1.flt mpdemo.flt)
110-
endif()
111106

112107
#---------------------------------------------------------------------------
113-
# Build & link kernel and process binaries
108+
# Build & link bootloader, kernel and application library
114109
#---------------------------------------------------------------------------
115110
add_subdirectory(src/bootloader/${ARCH})
116111
add_subdirectory(src/kernel)
117-
add_subdirectory(src/kernel/${ARCH})
118-
add_subdirectory(src/apps)
119112
add_subdirectory(src/apps/applib)
120-
add_subdirectory(src/kernel/drivers/${ARCH}/${MARCH})
121-
122-
set(KERNEL_RESOURCE_FILES)
123-
if (MOS_GRAPHICS_ENABLED)
124-
list (APPEND KERNEL_RESOURCE_FILES ${CMAKE_SOURCE_DIR}/docs/images/mos.rbm)
125-
endif()
126113

127-
link(
128-
FLATTEN
129-
NAME kernel.flt
130-
DEPENDS
131-
common
132-
kernel
133-
kernel_entry
134-
kernel_X86
135-
kernel_drivers
136-
RESOURCES ${KERNEL_RESOURCE_FILES}
137-
FLAGS ${MOS_LINKER_OPTIONS}
138-
LINKER_FILE ${MOS_KERNEL_LINKER_SCRIPT_FILE}
139-
LINK_LIBRARIES gcc
140-
)
114+
#---------------------------------------------------------------------------
115+
# Build & link applications
116+
#---------------------------------------------------------------------------
117+
add_subdirectory(src/apps)
141118

142119
#---------------------------------------------------------------------------
143120
# Create new floppy image and the copy flat binary files

include/applib/graphics.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77
#pragma once
88

9-
#ifndef GRAPHICS_MODE_ENABLED
10-
#error "Gui demo only works in graphics mode"
11-
#endif
12-
139
#include <types.h>
1410
#ifdef KERNEL
1511
#include <applib/osif.h>

src/apps/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ compile_lib(
4848
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/gui0.c
4949
FLAGS ${MOS_USER_GCC_FLAGS}
5050
DEFINITIONS ${MOS_USER_GCC_DEFINITIONS}
51+
GRAPHICS_BPP=${MOS_GRAPHICS_BPP}
5152
INCLUDE_DIRECTORIES ${MOS_USER_GCC_INCLUDE_DIRS}
5253
)
5354

@@ -59,3 +60,12 @@ link(
5960
LINKER_FILE ${MOS_USER_LINKER_SCRIPT_FILE}
6061
LINK_LIBRARIES app
6162
)
63+
64+
#---------------------------------------------------------------------------
65+
# Add to the global 'build-all' target
66+
#---------------------------------------------------------------------------
67+
if (MOS_GRAPHICS_ENABLED)
68+
add_dependencies(build-all gui0.flt)
69+
else()
70+
add_dependencies(build-all proc1.flt mpdemo.flt)
71+
endif()

src/apps/gui0.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
#include <app.h>
44
#include <graphics.h>
55

6-
#ifndef GRAPHICS_MODE_ENABLED
7-
#error "Gui demo only works in graphics mode"
8-
#endif
9-
106
void thread0();
117
void thread1();
128

src/bootloader/x86/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ assemble_and_copy_bin(
1919
${CMAKE_CURRENT_SOURCE_DIR}/boot1
2020
${MOS_KERNEL_ASM_INCLUDE_DIRS}
2121
)
22+
23+
#---------------------------------------------------------------------------
24+
# Add to the global 'build-all' target
25+
#---------------------------------------------------------------------------
26+
add_dependencies(build-all boot0.flt boot1.flt)

src/kernel/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,37 @@ compile_lib(
3434
DEFINITIONS ${MOS_KERNEL_GCC_DEFINITIONS}
3535
INCLUDE_DIRECTORIES ${MOS_KERNEL_GCC_INCLUDE_DIRS}
3636
)
37+
38+
#---------------------------------------------------------------------------
39+
# Build Arch dependent kernel & drivers
40+
#---------------------------------------------------------------------------
41+
add_subdirectory(${ARCH})
42+
add_subdirectory(drivers/${ARCH}/${MARCH})
43+
44+
set(KERNEL_RESOURCE_FILES)
45+
46+
#---------------------------------------------------------------------------
47+
# Link the kernel
48+
#---------------------------------------------------------------------------
49+
if (MOS_GRAPHICS_ENABLED)
50+
list (APPEND KERNEL_RESOURCE_FILES ${PROJECT_SOURCE_DIR}/docs/images/mos.rbm)
51+
endif()
52+
53+
link(
54+
FLATTEN
55+
NAME kernel.flt
56+
DEPENDS
57+
kernel
58+
kernel_entry
59+
kernel_X86
60+
kernel_drivers
61+
RESOURCES ${KERNEL_RESOURCE_FILES}
62+
FLAGS ${MOS_LINKER_OPTIONS}
63+
LINKER_FILE ${MOS_KERNEL_LINKER_SCRIPT_FILE}
64+
LINK_LIBRARIES gcc
65+
)
66+
67+
#---------------------------------------------------------------------------
68+
# Add to the global 'build-all' target
69+
#---------------------------------------------------------------------------
70+
add_dependencies(build-all kernel.flt)

0 commit comments

Comments
 (0)