diff --git a/reactos/lib/directory.xml b/reactos/lib/directory.xml index 83f82969501..c61a46c03c7 100644 --- a/reactos/lib/directory.xml +++ b/reactos/lib/directory.xml @@ -1,3 +1,6 @@ + + + diff --git a/reactos/lib/kernel32/kernel32.xml b/reactos/lib/kernel32/kernel32.xml new file mode 100644 index 00000000000..4e9b6a1cbf1 --- /dev/null +++ b/reactos/lib/kernel32/kernel32.xml @@ -0,0 +1,107 @@ + + + . + include + + + pseh + rosrtl + ntdll + + break.c + debugger.c + output.c + + + except.c + + + backup.c + bintype.c + cnotify.c + copy.c + create.c + curdir.c + delete.c + deviceio.c + dir.c + dosdev.c + file.c + find.c + hardlink.c + iocompl.c + lfile.c + lock.c + mailslot.c + move.c + npipe.c + pipe.c + rw.c + tape.c + volume.c + + + global.c + heap.c + isbad.c + local.c + procmem.c + resnotify.c + section.c + virtual.c + + + atom.c + chartype.c + comm.c + computername.c + console.c + dllmain.c + env.c + error.c + errormsg.c + handle.c + lang.c + lcformat.c + ldr.c + lzexpand_main.c + muldiv.c + nls.c + perfcnt.c + profile.c + res.c + stubs.c + sysinfo.c + time.c + timerqueue.c + toolhelp.c + + + cmdline.c + create.c + job.c + proc.c + session.c + + + lstring.c + + + critical.c + event.c + intrlck.c + mutex.c + sem.c + timer.c + wait.c + + + + fiber.S + + fiber.c + fls.c + thread.c + tls.c + + diff --git a/reactos/lib/kernel32/makefile b/reactos/lib/kernel32/makefile index 422caf1041c..4ffc491517b 100644 --- a/reactos/lib/kernel32/makefile +++ b/reactos/lib/kernel32/makefile @@ -17,7 +17,7 @@ TARGET_LFLAGS = -nostartfiles -nostdlib TARGET_RCFLAGS += -DWINVER=0x0500 -TARGET_SDKLIBS = pseh.a rosrtl.a ntdll.a kernel32.a +TARGET_SDKLIBS = pseh.a rosrtl.a ntdll.a TARGET_GCCLIBS = gcc diff --git a/reactos/lib/kernel32/mem/heap.c b/reactos/lib/kernel32/mem/heap.c index 9fb0afd9321..b239e4d79f7 100644 --- a/reactos/lib/kernel32/mem/heap.c +++ b/reactos/lib/kernel32/mem/heap.c @@ -32,6 +32,17 @@ #define NDEBUG #include "../include/debug.h" +PVOID WINAPI HeapAlloc(HANDLE hHeap, DWORD dwFlags, DWORD dwBytes) +{ + return RtlAllocateHeap(hHeap, dwFlags, dwBytes); +} + +BOOL WINAPI HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) +{ + return RtlFreeHeap(hHeap, dwFlags, lpMem); +} + + /********************************************************************* * HeapCreate -- KERNEL32 * *********************************************************************/ diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 6395f4fdd42..b526cee763f 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -59,6 +59,33 @@ MingwBackend::GenerateHeader () fprintf ( fMakefile, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" ); } +string +MingwBackend::GenerateProjectCFLAGS () +{ + string clags; + for ( size_t i = 0; i < ProjectNode.includes.size (); i++ ) + { + Include& include = *ProjectNode.includes[i]; + if (clags.length () > 0) + clags += " "; + clags += "-I" + include.directory; + } + + for ( size_t i = 0; i < ProjectNode.defines.size (); i++ ) + { + Define& define = *ProjectNode.defines[i]; + if ( clags.length () > 0 ) + clags += " "; + clags += "-D" + define.name; + if ( define.value.size() > 0 ) + { + clags += "="; + clags += define.value; + } + } + return clags; +} + void MingwBackend::GenerateGlobalVariables () { @@ -70,6 +97,7 @@ MingwBackend::GenerateGlobalVariables () fprintf ( fMakefile, "ld = ld\n" ); fprintf ( fMakefile, "ar = ar\n" ); fprintf ( fMakefile, "dlltool = dlltool\n" ); + fprintf ( fMakefile, "PROJECT_CFLAGS = %s\n", GenerateProjectCFLAGS ().c_str () ); fprintf ( fMakefile, "\n" ); } @@ -82,7 +110,7 @@ MingwBackend::GenerateAllTarget () Module& module = *ProjectNode.modules[i]; fprintf ( fMakefile, " %s", - FixupTargetFilename( module.GetPath () ).c_str () ); + FixupTargetFilename ( module.GetPath () ).c_str () ); } fprintf ( fMakefile, "\n\t\n\n" ); } diff --git a/reactos/tools/rbuild/backend/mingw/mingw.h b/reactos/tools/rbuild/backend/mingw/mingw.h index e79e529b02f..f23d84c4c08 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.h +++ b/reactos/tools/rbuild/backend/mingw/mingw.h @@ -14,6 +14,7 @@ private: void CreateMakefile (); void CloseMakefile (); void GenerateHeader (); + std::string GenerateProjectCFLAGS (); void GenerateGlobalVariables (); void GenerateAllTarget (); FILE* fMakefile; diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index af98501b3aa..e807ce0fbbc 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -395,6 +395,11 @@ MingwModuleHandler::GenerateMacros ( "endif\n\n" ); } } + + fprintf ( + fMakefile, + "%s_CFLAGS += $(PROJECT_CFLAGS)\n\n", + module.name.c_str () ); } string @@ -939,3 +944,64 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& modul target.c_str ()); } } + + +static MingwWin32DLLModuleHandler win32dll_handler; + +MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler () + : MingwModuleHandler ( Win32DLL ) +{ +} + +void +MingwWin32DLLModuleHandler::Process ( const Module& module ) +{ + GeneratePreconditionDependencies ( module ); + GenerateWin32DLLModuleTarget ( module ); + GenerateInvocations ( module ); +} + +void +MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module ) +{ + static string ros_junk ( "$(ROS_TEMPORARY)" ); + string target ( FixupTargetFilename ( module.GetPath () ) ); + string workingDirectory = GetWorkingDirectory ( ); + string archiveFilename = GetModuleArchiveFilename ( module ); + string importLibraryDependencies = GetImportLibraryDependencies ( module ); + + if (module.importLibrary != NULL) + { + fprintf ( fMakefile, "%s:\n", + module.GetDependencyPath ().c_str () ); + + fprintf ( fMakefile, + "\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n", + module.GetTargetName ().c_str (), + FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (), + FixupTargetFilename ( module.GetDependencyPath () ).c_str () ); + } + + if (module.files.size () > 0) + { + fprintf ( fMakefile, "%s: %s %s\n", + target.c_str (), + archiveFilename.c_str (), + importLibraryDependencies.c_str () ); + + fprintf ( fMakefile, + "\t${gcc} -Wl,--subsystem,console -Wl,--entry,_DllMain@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll -o %s %s %s\n", + target.c_str (), + archiveFilename.c_str (), + importLibraryDependencies.c_str () ); + + GenerateMacrosAndTargetsTarget ( module ); + } + else + { + fprintf ( fMakefile, "%s:\n\n", + target.c_str ()); + fprintf ( fMakefile, ".PHONY: %s\n\n", + target.c_str ()); + } +} diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index 8570eb079e9..582ce0a9d42 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -147,4 +147,14 @@ private: void GenerateNativeDLLModuleTarget ( const Module& module ); }; + +class MingwWin32DLLModuleHandler : public MingwModuleHandler +{ +public: + MingwWin32DLLModuleHandler (); + virtual void Process ( const Module& module ); +private: + void GenerateWin32DLLModuleTarget ( const Module& module ); +}; + #endif /* MINGW_MODULEHANDLER_H */ diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 125531f09c3..1732a49509e 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -197,6 +197,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute ) return KernelModeDLL; if ( attribute.value == "nativedll" ) return NativeDLL; + if ( attribute.value == "win32dll" ) + return Win32DLL; throw InvalidAttributeValueException ( location, attribute.name, attribute.value ); @@ -214,12 +216,18 @@ Module::GetDefaultModuleExtension () const case Kernel: return ".exe"; case KernelModeDLL: - return ".dll"; case NativeDLL: + case Win32DLL: return ".dll"; } - throw InvalidOperationException (__FILE__, - __LINE__); + throw InvalidOperationException ( __FILE__, + __LINE__ ); +} + +bool +Module::HasImportLibrary () const +{ + return importLibrary != NULL; } string @@ -231,23 +239,16 @@ Module::GetTargetName () const string Module::GetDependencyPath () const { - switch ( type ) + if ( HasImportLibrary () ) { - case KernelModeDLL: return ssprintf ( "dk%snkm%slib%slib%s.a", SSEP, SSEP, SSEP, name.c_str () ); - case NativeDLL: - return ssprintf ( "dk%sw32%slib%slib%s.a", - SSEP, - SSEP, - SSEP, - name.c_str () ); - default: - return GetPath(); } + else + return GetPath(); } string diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index cde527be227..f10993be685 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -67,7 +67,8 @@ enum ModuleType StaticLibrary, Kernel, KernelModeDLL, - NativeDLL + NativeDLL, + Win32DLL }; @@ -95,6 +96,7 @@ public: ~Module (); ModuleType GetModuleType ( const std::string& location, const XMLAttribute& attribute ); + bool HasImportLibrary () const; std::string GetTargetName () const; std::string GetDependencyPath () const; std::string GetBasePath() const;