Created separate CMakeLists.txt for euser and ekern to easily build them with different compiler definitions. Ekern now building as a DLL. anywhere
authorSlion
Wed, 06 Jan 2010 20:35:57 +0100
branchanywhere
changeset 24 18d195b75193
parent 23 9c130f173b89
child 25 57330c35d3d7
Created separate CMakeLists.txt for euser and ekern to easily build them with different compiler definitions. Ekern now building as a DLL.
kernel/eka/CMakeLists.txt
kernel/eka/euser/CMakeLists.txt
kernel/eka/kernel/CMakeLists.txt
kernel/eka/kernel/win32/cinit.cpp
kernel/eka/memmodel/emul/win32/mcodeseg.cpp
--- a/kernel/eka/CMakeLists.txt	Wed Jan 06 16:05:22 2010 +0100
+++ b/kernel/eka/CMakeLists.txt	Wed Jan 06 20:35:57 2010 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) 2009 Stéphane Lenclud.
+# Copyright (c) 2009-2010 Stéphane Lenclud.
 # All rights reserved.
 # This component and the accompanying materials are made available
 # under the terms of the License "Eclipse Public License v1.0"
@@ -13,126 +13,26 @@
 
 cmake_minimum_required(VERSION 2.6)
 
-#add_definitions(-DUNICODE)
-add_definitions(-D__VC32__)
-add_definitions(-D_UNICODE)
-add_definitions(-D__LEAVE_EQUALS_THROW__)
-add_definitions(-D__WINS__)
-#__CPU_X86 is declared by __WINS__ 
-#add_definitions(-D__CPU_X86)
-add_definitions(-D__DLL__)
-
-include_directories (./euser ./euser/unicode ./include)
-
-
-#Add the given source files to our source prepending the sourcepath
-macro(add_source)
-	foreach(mySource ${ARGV})
-		string(REGEX REPLACE "(^.+)" "${sourcepath}\\1" newsource ${mySource})
-		set(source ${source} ${newsource})
-	endforeach(mySource) 
-endmacro(add_source) 
-
-
-#Adding the sources from cbase
-set (sourcepath ./euser/cbase/)
-add_source(
-ub_act.cpp ub_array.cpp ub_bma.cpp ub_buf.cpp
-ub_circ.cpp ub_cln.cpp ub_cons.cpp ub_dtim.cpp
-ub_obj.cpp ub_svr.cpp ub_polsvr.cpp
-ub_tim.cpp ub_utl.cpp ub_tque.cpp
-)
-
-
-#Add euser sources
-set (sourcepath ./euser/)
-add_source(
-us_evnt.cpp locmapping.cpp us_exec.cpp us_func.cpp
-us_graph.cpp us_hand.cpp us_ksvr.cpp us_des.cpp
-us_lex16.cpp us_lex8.cpp us_loc.cpp us_mes.cpp
-us_parse.cpp us_power.cpp us_property.cpp us_que.cpp
-us_ref.cpp us_regn.cpp us_test.cpp us_time.cpp
-us_trp.cpp us_utl.cpp us_mqueue.cpp us_encode.cpp
-us_decode.cpp us_secure.cpp us_htab.cpp us_rwlock.cpp
-us_shbuf.cpp
-)
-
-
-#Adding the sources from common
-set (sourcepath ./common/)
-add_source(
-array.cpp des8.cpp des16.cpp alloc.cpp heap.cpp
-mem.cpp secure.cpp
-)
-
-#Adding the sources from common/win32
-set (sourcepath ./common/win32/)
-add_source(
-atomics.cpp
-)
-
-#Adding the sources from maths
-set (sourcepath ./euser/maths/)
-add_source(
-um_asin.cpp um_atan.cpp um_dtor.cpp um_exp.cpp
-um_frac.cpp um_int.cpp um_ln.cpp um_log.cpp
-um_mod.cpp um_pow.cpp um_pow10.cpp
-um_rand.cpp um_rtod.cpp um_sin.cpp um_spec.cpp
-um_sqrt.cpp um_tan.cpp um_utl.cpp
-)
-
-
-#Adding the sources from epoc/win32
-set (sourcepath ./euser/epoc/win32/)
-add_source(
-uc_i64.cpp uc_realx.cpp
-uc_trp.cpp uc_utl.cpp uc_exec.cpp
-uc_dll.cpp
-)
-
-#Adding the sources from epoc
-set (sourcepath ./euser/epoc/)
-add_source(
-up_lib.cpp up_utl.cpp
-)
-
-#Adding the sources from unicode
-set (sourcepath ./euser/unicode/)
-add_source(
-collate.cpp unicode.cpp unitable.cpp Compare.cpp
-)
-
-#define our library
-add_library (emulator SHARED ./euser/epoc/win32/emulator.cpp)
-target_link_libraries(emulator kernel32)
-
-add_library (euser SHARED ${source})
-target_link_libraries(euser emulator)
-
-add_library (estub ./euser/epoc/win32/uc_stub.cpp)
-
-#No need for emulator here
-#add_executable(epoc ./euser/epoc/win32/uc_epoc.cpp)
-#target_link_libraries(epoc estub euser)
-
-
-
-
-
-
-
-#define vs IDE folders
-source_group(Sources REGULAR_EXPRESSION ".+\\.cpp$")
-source_group(Includes REGULAR_EXPRESSION ".+\\.h$") 	
 
 #Generate the exec enum using CMAKE custom command
 #perl genexec.pl -i execs.txt -e ../include/exec_enum.h -u ../include/exec_user.h -k ../include/exec_kernel.h
-
 add_custom_command (
- 	TARGET euser
-   	PRE_BUILD
-   	COMMAND perl ./kernel/genexec.pl -i ./kernel/execs.txt -e ./include/exec_enum.h -u ./include/exec_user.h -k ./include/exec_kernel.h
-	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 	
+	OUTPUT ./include/exec_enum.h ./include/exec_user.h ./include/kernel/exec_kernel.h
+   	COMMAND perl ./kernel/genexec.pl -i ./kernel/execs.txt -e ./include/exec_enum.h -u ./include/exec_user.h -k ./include/kernel/exec_kernel.h
+	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}	
    	COMMENT "Generating exec headers..."
    	VERBATIM
  	)
+	
+#Tell cmake those file won't be available until build time
+set_source_files_properties(./include/exec_enum.h PROPERTIES GENERATED 1)
+set_source_files_properties(./include/exec_user.h PROPERTIES GENERATED 1)
+set_source_files_properties(./include/kernel/exec_kernel.h PROPERTIES GENERATED 1)
+
+#Custom target that will generate our exec headers 
+add_custom_target(genexec DEPENDS ./include/exec_enum.h ./include/exec_user.h ./include/kernel/exec_kernel.h)
+
+add_subdirectory(./euser ./euser/bin)
+add_subdirectory(./kernel ./kernel/bin)
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/eka/euser/CMakeLists.txt	Wed Jan 06 20:35:57 2010 +0100
@@ -0,0 +1,118 @@
+# Copyright (c) 2009 Stéphane Lenclud.
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Stéphane Lenclud.
+#
+
+project (euser)
+
+cmake_minimum_required(VERSION 2.6)
+
+#Add the given source files to our source prepending the sourcepath
+macro(add_source)
+	foreach(mySource ${ARGV})
+		string(REGEX REPLACE "(^.+)" "${sourcepath}\\1" newsource ${mySource})
+		set(source ${source} ${newsource})
+	endforeach(mySource) 
+endmacro(add_source) 
+
+#add_definitions(-DUNICODE)
+add_definitions(-D__VC32__)
+add_definitions(-D_UNICODE)
+add_definitions(-D__LEAVE_EQUALS_THROW__)
+add_definitions(-D__WINS__)
+#__CPU_X86 is declared by __WINS__ 
+#add_definitions(-D__CPU_X86)
+add_definitions(-D__DLL__)
+
+include_directories (../euser ../euser/unicode ../include 
+../include/nkern ../include/nkern/win32 ../include/kernel ../include/kernel/win32 ../include/memmodel/emul/win32 ../include/memmodel/emul)
+
+
+#Adding the sources from cbase
+set (sourcepath ../euser/cbase/)
+add_source(
+ub_act.cpp ub_array.cpp ub_bma.cpp ub_buf.cpp
+ub_circ.cpp ub_cln.cpp ub_cons.cpp ub_dtim.cpp
+ub_obj.cpp ub_svr.cpp ub_polsvr.cpp
+ub_tim.cpp ub_utl.cpp ub_tque.cpp
+)
+
+
+#Add euser sources
+set (sourcepath ../euser/)
+add_source(
+us_evnt.cpp locmapping.cpp us_exec.cpp us_func.cpp
+us_graph.cpp us_hand.cpp us_ksvr.cpp us_des.cpp
+us_lex16.cpp us_lex8.cpp us_loc.cpp us_mes.cpp
+us_parse.cpp us_power.cpp us_property.cpp us_que.cpp
+us_ref.cpp us_regn.cpp us_test.cpp us_time.cpp
+us_trp.cpp us_utl.cpp us_mqueue.cpp us_encode.cpp
+us_decode.cpp us_secure.cpp us_htab.cpp us_rwlock.cpp
+us_shbuf.cpp
+)
+
+
+#Adding the sources from common
+set (sourcepath ../common/)
+add_source(
+array.cpp des8.cpp des16.cpp alloc.cpp heap.cpp
+mem.cpp secure.cpp
+)
+
+#Adding the sources from common/win32
+set (sourcepath ../common/win32/)
+add_source(
+atomics.cpp
+)
+
+#Adding the sources from maths
+set (sourcepath ../euser/maths/)
+add_source(
+um_asin.cpp um_atan.cpp um_dtor.cpp um_exp.cpp
+um_frac.cpp um_int.cpp um_ln.cpp um_log.cpp
+um_mod.cpp um_pow.cpp um_pow10.cpp
+um_rand.cpp um_rtod.cpp um_sin.cpp um_spec.cpp
+um_sqrt.cpp um_tan.cpp um_utl.cpp
+)
+
+
+#Adding the sources from epoc/win32
+set (sourcepath ../euser/epoc/win32/)
+add_source(
+uc_i64.cpp uc_realx.cpp
+uc_trp.cpp uc_utl.cpp uc_exec.cpp
+uc_dll.cpp
+)
+
+#Adding the sources from epoc
+set (sourcepath ../euser/epoc/)
+add_source(
+up_lib.cpp up_utl.cpp
+)
+
+#Adding the sources from unicode
+set (sourcepath ../euser/unicode/)
+add_source(
+collate.cpp unicode.cpp unitable.cpp Compare.cpp
+)
+
+#define our library
+add_library (emulator SHARED ../euser/epoc/win32/emulator.cpp)
+target_link_libraries(emulator kernel32)
+
+add_library (euser SHARED ${source})
+add_dependencies(euser genexec emulator)
+
+add_library (estub ../euser/epoc/win32/uc_stub.cpp)
+
+#define vs IDE folders
+source_group(Sources REGULAR_EXPRESSION ".+\\.cpp$")
+source_group(Includes REGULAR_EXPRESSION ".+\\.h$") 	
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kernel/eka/kernel/CMakeLists.txt	Wed Jan 06 20:35:57 2010 +0100
@@ -0,0 +1,141 @@
+# Copyright (c) 2009 Stéphane Lenclud.
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Stéphane Lenclud.
+#
+
+project (kernel)
+
+cmake_minimum_required(VERSION 2.6)
+
+#Add the given source files to our source prepending the sourcepath
+macro(add_source)
+	foreach(mySource ${ARGV})
+		string(REGEX REPLACE "(^.+)" "${sourcepath}\\1" newsource ${mySource})
+		set(source ${source} ${newsource})
+	endforeach(mySource) 
+endmacro(add_source) 
+
+add_definitions(-DUNICODE)
+add_definitions(-D__VC32__)
+add_definitions(-D_UNICODE)
+add_definitions(-D__LEAVE_EQUALS_THROW__)
+add_definitions(-D__WINS__)
+add_definitions(-D__EXPORT_MEMCPY__)				
+add_definitions(-D__IN_KERNEL__)
+add_definitions(-D__KERNEL_MODE__)
+
+#__CPU_X86 is declared by __WINS__ 
+#add_definitions(-D__CPU_X86)
+#add_definitions(-D__DLL__)
+
+include_directories (../euser ../euser/unicode ../include 
+../include/nkern ../include/nkern/win32 ../include/kernel ../include/kernel/win32 ../include/memmodel/emul/win32 ../include/memmodel/emul)
+
+#Define source for ekern
+set (sourcepath ../nkern/)
+add_source(
+nkern.cpp nkerns.cpp sched.cpp dfcs.cpp nk_timer.cpp
+nk_old.cpp
+)
+
+set (sourcepath ../common/win32/)
+add_source(
+atomics.cpp
+)
+
+set (sourcepath ../nkern/win32/)
+add_source(
+vectors.cpp ncsched.cpp nctimer.cpp ncutilf.cpp ncutils.cpp
+ncthrd.cpp ncglob.cpp
+)
+
+set (sourcepath ../common/win32/)
+add_source(
+seh.cpp
+)
+
+set (sourcepath ../kernel/win32/)
+add_source(
+cboot.cpp
+cglobals.cpp cexec.cpp cinit.cpp
+ckernel.cpp csched.cpp
+cutils.cpp cache.cpp
+)
+#k_entry.cpp
+
+
+set (sourcepath ../kernel/)
+add_source(
+sglobals.cpp device.cpp eventq.cpp
+sexec.cpp sinit.cpp skernel.cpp
+scodeseg.cpp sipc.cpp notifier.cpp 
+object.cpp power.cpp server.cpp
+stimer.cpp sutils.cpp random.cpp
+sprocess.cpp sthread.cpp 
+smqueue.cpp
+sproperty.cpp
+ssharedio.cpp
+ssecure.cpp
+emi.cpp
+objectix.cpp
+sbtrace.cpp
+stest.cpp
+sshbuf.cpp smap.cpp
+)
+				
+set (sourcepath ../klib/)
+add_source(
+dbase.cpp kdes8.cpp
+kheap.cpp bma.cpp
+)
+
+#
+set (sourcepath ../common/)
+add_source(
+alloc.cpp array.cpp des8.cpp heap.cpp mem.cpp
+secure.cpp
+)
+
+set (sourcepath ../memmodel/emul/)
+add_source(
+pglobals.cpp
+nvram.cpp
+)
+
+#
+set (sourcepath ../memmodel/emul/win32/)
+add_source(
+zrom.cpp
+mchunk.cpp mglobals.cpp minit.cpp mkernel.cpp
+mcodeseg.cpp mprocess.cpp mutils.cpp mshbuf.cpp
+)
+
+#add_executable(ekern ${source})
+add_library(ekern SHARED ${source})
+add_dependencies(ekern genexec emulator)
+				
+#library					
+#include "../memmodel/memmodel.mmp"
+
+
+#macro					
+
+
+#No need for emulator here
+#add_executable(epoc ./euser/epoc/win32/uc_epoc.cpp)
+#target_link_libraries(epoc estub euser)
+
+
+
+
+#define vs IDE folders
+source_group(Sources REGULAR_EXPRESSION ".+\\.cpp$")
+source_group(Includes REGULAR_EXPRESSION ".+\\.h$") 	
+
+
--- a/kernel/eka/kernel/win32/cinit.cpp	Wed Jan 06 16:05:22 2010 +0100
+++ b/kernel/eka/kernel/win32/cinit.cpp	Wed Jan 06 20:35:57 2010 +0100
@@ -44,7 +44,9 @@
 	HMODULE h=(HMODULE)aHandle;
 	TVariantInitialise f=(TVariantInitialise)Emulator::GetProcAddress(h, (LPCSTR)1);
 	__KTRACE_OPT(KBOOT,Kern::Printf("Calling Initialise %08x",f));
-	Emul::TheAsic=(*f)(EmulRunExe);
+	//SL: Fixed our linkage error
+	//Emul::TheAsic=(*f)(EmulRunExe);
+	Emul::TheAsic=(*f)(EFalse);
 	__KTRACE_OPT(KBOOT,Kern::Printf("Initialise returned %08x",Emul::TheAsic));
 	if (!Emul::TheAsic)
 		return KErrGeneral;
--- a/kernel/eka/memmodel/emul/win32/mcodeseg.cpp	Wed Jan 06 16:05:22 2010 +0100
+++ b/kernel/eka/memmodel/emul/win32/mcodeseg.cpp	Wed Jan 06 20:35:57 2010 +0100
@@ -379,7 +379,7 @@
 				TInt	mainlen;
 				{
 				TUint16 mainBuf[MAX_PATH];
-				mainlen=Emulator::GetModuleFileName(reinterpret_cast<HMODULE>(pM->iModuleHandle),mainBuf);
+				mainlen=Emulator::GetModuleFileName(reinterpret_cast<HMODULE>(pM->iModuleHandle),(LPWSTR)mainBuf);
 				TruncToNarrow(mainBuf8, mainBuf, mainlen);
 				}
 				TPtrC mainp(mainBuf8,mainlen);
@@ -393,7 +393,7 @@
 				TInt	deplen;
 				{
 				TUint16 depBuf[MAX_PATH];
-				deplen=Emulator::GetModuleFileName(reinterpret_cast<HMODULE>(dep.iModuleHandle),depBuf);
+				deplen=Emulator::GetModuleFileName(reinterpret_cast<HMODULE>(dep.iModuleHandle),(LPWSTR)depBuf);
 				TruncToNarrow(depBuf8, depBuf, deplen);
 				}
 				TPtrC depp(depBuf8,deplen);
@@ -729,14 +729,14 @@
 		TUint16 fileNameW[KMaxFileName];
 		ExpandToWide(fileNameW, iFileName->Ptr(), iFileName->Length());
 		fileNameW[iFileName->Length()] = '\0';
-		iWinInstance = Emulator::LoadLibrary(fileNameW);
+		iWinInstance = Emulator::LoadLibrary((LPCWSTR)fileNameW);
 		__KTRACE_OPT(KDLL,Kern::Printf("W32CodeSeg : EKERN %08x", iWinInstance));
 		if (!iWinInstance)
 			return KErrGeneral;
 		if (aInfo.iTotalDataSize)
 			iMark|=EMarkData|EMarkDataPresent;
 		KernelCodeSeg=this;
-		KernelModuleHandle=Emulator::GetModuleHandle(fileNameW);
+		KernelModuleHandle=Emulator::GetModuleHandle((LPCWSTR)fileNameW);
 		return RegisterCodeSeg(KernelModuleHandle);
 		}
 	TWin32Filename w32fn(*iFileName);
@@ -880,7 +880,7 @@
 	if (!r)
 		return Emulator::LastError();
 	TUint8 name8[MAX_PATH+1];
-	TruncToNarrow(name8,name,-1);
+	TruncToNarrow(name8,(const TUint16*)name,-1);
 
 	TPtrC fpptr((const TText*)name8);
 	TInt slash=fpptr.LocateReverse('\\');