336 lines
15 KiB
Plaintext
336 lines
15 KiB
Plaintext
|
<!--
|
||
|
##############################################################################
|
||
|
|
||
|
Microsoft Research Singularity
|
||
|
|
||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||
|
|
||
|
File: Targets\Distro.targets
|
||
|
|
||
|
Note:
|
||
|
|
||
|
This file handles building "Distro" projects. Distro projects are a collection
|
||
|
of applications, which are built and packaged into a complete, bootable OS image.
|
||
|
The OS image can be served to PXE clients by using bootd.exe, can be burned to
|
||
|
a CD-ROM (or Virtual PC can boot using the CD-ROM image), or can be copied to
|
||
|
a bootable FAT partition.
|
||
|
|
||
|
Distro projects are currently stored in the $(SINGULARITY_ROOT)\Distro directory.
|
||
|
|
||
|
Distro projects can set the following properties:
|
||
|
|
||
|
* DistroName - Specifies a name for the distribution, which allows the build
|
||
|
outputs to be isolated from other distributions. It is important that
|
||
|
distro projects have distinct names. This property is required.
|
||
|
|
||
|
|
||
|
Distro projects can declare the following items:
|
||
|
|
||
|
* Application - Specifies a reference to an application project that should be
|
||
|
included in this distribution. This must refer to a project that imports
|
||
|
App.targets, either directly or indirectly.
|
||
|
|
||
|
|
||
|
|
||
|
##############################################################################
|
||
|
-->
|
||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||
|
|
||
|
<PropertyGroup>
|
||
|
<DistroName Condition="'$(DistroName)'==''">$(MSBuildProjectName)</DistroName>
|
||
|
|
||
|
<PATH>$(SINGULARITY_PATH);$(SYSTEMROOT)\system32</PATH>
|
||
|
|
||
|
<DISTRO_OBJNAME>$(Configuration).$(Platform).$(COLLECTOR_APP).$(SCHEDULER).$(COLLECTOR_KERNEL)$(PAGING_FLAG)</DISTRO_OBJNAME>
|
||
|
<DISTRO_ROOT>$(SINGULARITY_OBJROOT)\Distros\$(DistroName).$(DISTRO_OBJNAME)</DISTRO_ROOT>
|
||
|
<DISTRO_ISO>$(DISTRO_ROOT).iso</DISTRO_ISO>
|
||
|
<DISTRO_ISO_LOG>$(DISTRO_ISO).log</DISTRO_ISO_LOG>
|
||
|
<DISTRO_ENV>$(SINGULARITY_ROOT)\buildcfg.cmd</DISTRO_ENV>
|
||
|
|
||
|
<DISTDIR>$(DISTRO_ROOT)</DISTDIR>
|
||
|
|
||
|
<DISTRO_SINGULARITY_DIR>$(DISTDIR)\Singularity</DISTRO_SINGULARITY_DIR>
|
||
|
<DISTRO_FILES_DIR>$(DISTDIR)\Singularity\Files</DISTRO_FILES_DIR>
|
||
|
<DISTRO_BINARIES_DIR>$(DISTDIR)\Singularity\Binaries</DISTRO_BINARIES_DIR>
|
||
|
<DISTRO_SCRIPT_DIR>$(DISTDIR)\Singularity\Scripts</DISTRO_SCRIPT_DIR>
|
||
|
|
||
|
<KERNEL_DUMP>kernel.dmp</KERNEL_DUMP>
|
||
|
<KERNEL_PDB>kernel.x86.pdb</KERNEL_PDB>
|
||
|
<SINGLDR_FILE>Singldr</SINGLDR_FILE>
|
||
|
<INIFILE_NAME>Singularity\Singboot.ini</INIFILE_NAME>
|
||
|
|
||
|
<NIB_FLAGS>/bartok:$(BARTOK) /machine:$(MACHINE)</NIB_FLAGS>
|
||
|
<NibFileList>$(DISTDIR)\NibFileList.txt</NibFileList>
|
||
|
|
||
|
<!-- #[TODO]: this ought to depend on $(PLATFORM) but doesn't right now. -->
|
||
|
<SYSDATA_NAME Condition="'$(SYSDATA_NAME)'==''">$(SINGULARITY_ROOT)\Distro\LegacyPCDistro.xml</SYSDATA_NAME>
|
||
|
|
||
|
<METADATA_NAME>metadata.xml</METADATA_NAME>
|
||
|
<FILE_LIST>$(DISTDIR)\files.txt</FILE_LIST>
|
||
|
|
||
|
</PropertyGroup>
|
||
|
|
||
|
<Target Name="Build"
|
||
|
DependsOnTargets="
|
||
|
BuildDistro;
|
||
|
BuildIso;
|
||
|
BuildEnv;
|
||
|
"/>
|
||
|
|
||
|
<Target Name="BuildDistro"
|
||
|
DependsOnTargets="
|
||
|
CheckProject;
|
||
|
ShowDebugInfo;
|
||
|
CreateDirs;
|
||
|
BuildBootSectors;
|
||
|
BuildBaseProjects;
|
||
|
ConvertKernelManifest;
|
||
|
BuildAppsNative;
|
||
|
CreateFileList;
|
||
|
RunDistroBuilder;
|
||
|
">
|
||
|
|
||
|
</Target>
|
||
|
|
||
|
<Target Name="ShowDebugInfo">
|
||
|
<Message Text="Distro name: $(DistroName)"/>
|
||
|
<Message Text="DISTRO_BINARIES_DIR: $(DISTRO_BINARIES_DIR)"/>
|
||
|
<Message Text="DISTRO_FILES_DIR: $(DISTRO_FILES_DIR)"/>
|
||
|
<Message Text="DISTRO_SCRIPT_DIR: $(DISTRO_SCRIPT_DIR)"/>
|
||
|
</Target>
|
||
|
|
||
|
<Target Name="CreateDirs">
|
||
|
<MakeDir Directories="
|
||
|
$(DISTDIR);
|
||
|
$(DISTRO_BINARIES_DIR);
|
||
|
$(DISTRO_FILES_DIR);
|
||
|
$(DISTRO_SCRIPT_DIR);
|
||
|
$(DISTRO_TEMP_DIR);
|
||
|
$(APPS_NATIVE_IMAGE_DIR);
|
||
|
"/>
|
||
|
</Target>
|
||
|
|
||
|
<Target Name="CheckProject">
|
||
|
<Error Condition="'$(DistroName)'==''" Text="The 'DistroName' property has not been set, and is required." />
|
||
|
<Warning Condition="'$(DistroSkipKernel)'=='true'" Text="You have chosen to skip compiling the kernel (by specifying DistroSkipKernel=true)."/>
|
||
|
<Warning Condition="'$(DistroSkipApps)'=='true'" Text="You have chosen to skip compiling all apps (by specifying DistroSkipApps=true)."/>
|
||
|
</Target>
|
||
|
|
||
|
<ItemGroup>
|
||
|
<BaseProject Condition="'$(DistroSkipKernel)'!='true'" Include="$(SINGULARITY_ROOT)\Kernel\Kernel.proj"/>
|
||
|
<BaseProject Condition="'$(DistroSkipApps)'!='true'" Include="$(SINGULARITY_ROOT)\Applications\Runtime\Corlib.Native.proj"/>
|
||
|
</ItemGroup>
|
||
|
|
||
|
<Target Name="BuildBaseProjects">
|
||
|
<MSBuild Projects="$(SINGULARITY_ROOT)\Interfaces\Interfaces.proj"/>
|
||
|
<MSBuild Projects="@(BaseProject)" Condition="'$(BuildInParallel)'!='true'"/>
|
||
|
<MSBuild Projects="@(BaseProject)" Condition="'$(BuildInParallel)'=='true'" BuildInParallel="true"/>
|
||
|
</Target>
|
||
|
|
||
|
<Target Name="BuildBootSectors" Condition="'$(DistroSkipKernel)'!='true'">
|
||
|
<MSBuild Projects="$(SINGULARITY_ROOT)\Boot\BootSectors\BootSectors.proj"/>
|
||
|
</Target>
|
||
|
|
||
|
<Target Name="BuildIso"
|
||
|
Condition="'$(SINGULARITY_BUILD_ISO)'!='false'"
|
||
|
DependsOnTargets="BuildDistro">
|
||
|
<Message Text="Building CD-ROM ISO image"/>
|
||
|
<MakeDir Condition="'$(DISTRO_ISO_DIR)'!=''" Directories="$(DISTRO_ISO_DIR)"/>
|
||
|
<Exec Command="$(BUILDDIR)\cdimage -j1 -lSingularity -b$(BOOTDIR)\Etfs_BS.bin $(DISTDIR) $(DISTRO_ISO) 1>$(DISTRO_ISO_LOG) 2>&1">
|
||
|
<Output TaskParameter="ExitCode" PropertyName="BuildIsoExitCode"/>
|
||
|
</Exec>
|
||
|
<Message Text="CD-ROM image: $(DISTRO_ISO)" Condition="'$(BuildIsoExitCode)'=='0'"/>
|
||
|
<Error Text="cdimage failed. Check $(DISTRO_ISO_LOG)" Condition="'$(BuildIsoExitCode)'!='0'"/>
|
||
|
<Exec Command="type $(DISTRO_ISO_LOG)" Condition="'$(BuildIsoExitCode)'!='0'"/>
|
||
|
<Delete Files="$(DISTRO_ISO_LOG)" Condition="'$(BuildIsoExitCode)'=='0'"/>
|
||
|
</Target>
|
||
|
|
||
|
<Target Name="BuildEnv"
|
||
|
Outputs="$(DISTRO_ENV)">
|
||
|
<WriteLinesToFile File="$(DISTRO_ENV)"
|
||
|
Overwrite="true"
|
||
|
Lines="
|
||
|
@rem Generated by $(Username) on $(ComputerName)
|
||
|
@rem at $(_time) on $(_date)
|
||
|
|
||
|
set _BOOTD_TFTP_DIR=$(DISTRO_ROOT)
|
||
|
set _BOOT_CD=$(DISTRO_ISO)
|
||
|
set _NT_DEBUGGER_EXTENSION_PATH=$(SINGULARITY_ROOT)\build
|
||
|
set _NT_SOURCE_PATH=srv*%3b$(SINGULARITY_ROOT)%3b$(SINGULARITY_ROOT)\Applications%3b$(SINGULARITY_ROOT)\Boot%3b$(SINGULARITY_ROOT)\drivers%3b$(SINGULARITY_ROOT)\interfaces%3b$(SINGULARITY_ROOT)\kernel%3b$(SINGULARITY_ROOT)\Libraries%3b$(SINGULARITY_ROOT)\Services
|
||
|
set _NT_SYMBOL_PATH=$(DISTRO_TEMP_DIR)%3b$(KERNEL_NATIVE_DIR)%3b
|
||
|
"
|
||
|
/>
|
||
|
<!--
|
||
|
It would be good to tell the user a relative path
|
||
|
here so they could cut-and-paste name in single pass. The RelativeDir
|
||
|
transform doesn't deal with directories up the tree though., ie output
|
||
|
could just be along the lines of ..\base.obj\SomeDistroName.cmd
|
||
|
-->
|
||
|
<Message Text="-------------------------------------------------------------------------------
|
||
|
Debugger and bootd environment file:
|
||
|
$(DISTRO_ENV)
|
||
|
-------------------------------------------------------------------------------
|
||
|
" Importance="High"/>
|
||
|
</Target>
|
||
|
|
||
|
<ItemGroup>
|
||
|
<ScriptFiles Include="Scripts\*"/>
|
||
|
<DataFiles Include="Files\*"/>
|
||
|
<BootSectors Include="$(BOOTDIR)\*.bin"/>
|
||
|
<Binaries Include="$(KERNEL_NATIVE_DIR)\$(KERNEL_DUMP)"/>
|
||
|
<Binaries Include="$(KERNEL_NATIVE_DIR)\testpe.x86"/>
|
||
|
<Binaries Include="$(KERNEL_NATIVE_DIR)\testpe.manifest"/>
|
||
|
</ItemGroup>
|
||
|
|
||
|
<ItemGroup Condition="'$(PAGING)'=='On'">
|
||
|
<Binaries Include="$(KERNEL_NATIVE_DIR)\syscalls.dll"/>
|
||
|
</ItemGroup>
|
||
|
|
||
|
<Target Name="CopyFiles"
|
||
|
DependsOnTargets="BuildAppsNative;BuildBaseProjects;CopyContentFiles">
|
||
|
<Copy SourceFiles="@(ScriptFiles)" DestinationFolder="$(DISTRO_SCRIPT_DIR)" SkipUnchangedFiles="true"/>
|
||
|
<Copy SourceFiles="@(DataFiles)" DestinationFolder="$(DISTRO_FILES_DIR)" SkipUnchangedFiles="true"/>
|
||
|
<Copy SourceFiles="@(Binaries)" DestinationFolder="$(DISTRO_BINARIES_DIR)" SkipUnchangedFiles="true"/>
|
||
|
<Copy SourceFiles="$(BOOTDIR)\$(SINGLDR_FILE)" DestinationFolder="$(DISTDIR)" SkipUnchangedFiles="true"/>
|
||
|
<Copy SourceFiles="@(BootSectors)" DestinationFolder="$(DISTDIR)" SkipUnchangedFiles="true"/>
|
||
|
</Target>
|
||
|
|
||
|
<!-- This always runs; there is no incremental build support here. -->
|
||
|
<Target Name="CreateFileList"
|
||
|
Outputs="$(FILE_LIST)"
|
||
|
DependsOnTargets="CopyFiles">
|
||
|
|
||
|
<!-- Create a list of files in the distribution. -->
|
||
|
<Message Text="Building Distro file list in $(DISTDIR)"/>
|
||
|
|
||
|
<!--
|
||
|
@rem NB Put kernel pdb alongside other pdbs. This makes kernel debug
|
||
|
@rem symbol location robust with respect to entire tree moves (as
|
||
|
@rem might happen with a build on a farm).
|
||
|
-->
|
||
|
<!-- <Copy SourceFiles="$(KERNDIR)\$(KERNEL_PDB)" DestinationFolder="$(DISTRO_TEMP_DIR)" SkipUnchangedFiles="true"/> -->
|
||
|
|
||
|
<Message Text="Creating file list - $(FILE_LIST)"/>
|
||
|
<Exec Command="dir /b /s /a-d $(DISTDIR) > $(FILE_LIST)"/>
|
||
|
</Target>
|
||
|
|
||
|
|
||
|
<!-- Create the system manifest and metadata file. -->
|
||
|
<Target Name="RunDistroBuilder"
|
||
|
DependsOnTargets="CreateDirs;CreateFileList">
|
||
|
<Message Text="Creating Distribution"/>
|
||
|
<Exec Command="$(BUILDDIR)\distrobuilder /out:$(DISTDIR)\Singularity\$(METADATA_NAME) /policy:$(SYSDATA_NAME) /dir:$(DISTDIR) /ini:$(DISTDIR)\$(INIFILE_NAME) /desc:$(FILE_LIST)"/>
|
||
|
</Target>
|
||
|
|
||
|
<!-- Convert all MSIL files into native images. -->
|
||
|
<Target Name="BuildAppsNative">
|
||
|
|
||
|
<Message Condition="'$(DistroSkipApps)'!='true'" Importance="high" Text="Building native images"/>
|
||
|
|
||
|
<!-- Remove duplicates from the Application set. -->
|
||
|
<RemoveDuplicates Inputs="@(Application)">
|
||
|
<Output ItemName="Application_no_dups" TaskParameter="Filtered"/>
|
||
|
</RemoveDuplicates>
|
||
|
|
||
|
<!--
|
||
|
Build all Application projects. If the invoking MSBuild instance supports parallel builds,
|
||
|
then build the applications in parallel. We need to duplicate the MSBuild task, because MSBuild 2.0
|
||
|
will reject the task if the BuildInParallel attribute is present, even if it is empty or "false".
|
||
|
-->
|
||
|
<MSBuild Projects="@(Application_no_dups)"
|
||
|
Condition="'$(DistroSkipApps)'!='true' and '$(BuildInParallel)'!='true'">
|
||
|
<Output ItemName="__app_build_outputs" TaskParameter="TargetOutputs"/>
|
||
|
</MSBuild>
|
||
|
<MSBuild Projects="@(Application_no_dups)"
|
||
|
Condition="'$(DistroSkipApps)'!='true' and '$(BuildInParallel)'=='true'"
|
||
|
BuildInParallel="true">
|
||
|
<Output ItemName="__app_build_outputs" TaskParameter="TargetOutputs"/>
|
||
|
</MSBuild>
|
||
|
|
||
|
<!--
|
||
|
If DistroSkipApps=true, then we still need to determine the names of the output assemblies.
|
||
|
We do this by "building" the app projects, but only building the GetOutputAssemblyPath target.
|
||
|
-->
|
||
|
<MSBuild Projects="@(Application_no_dups)"
|
||
|
Targets="GetOutputAssemblyPath"
|
||
|
Condition="'$(DistroSkipApps)'=='true'">
|
||
|
<Output ItemName="__app_build_outputs" TaskParameter="TargetOutputs"/>
|
||
|
</MSBuild>
|
||
|
|
||
|
<!-- Filter the build outputs from the Application item set, so that we only pick up executables. -->
|
||
|
<CreateItem Include="%(__app_build_outputs.identity)">
|
||
|
<Output ItemName="__app_exes" TaskParameter="Include" Condition="'%(__app_build_outputs.extension)' == '.exe'"/>
|
||
|
</CreateItem>
|
||
|
<Message Text="__app_exes: %(__app_exes.identity)"/>
|
||
|
|
||
|
<Warning Text="Found library in Application set: %(__app_build_outputs.identity)"
|
||
|
Condition="'%(__app_build_outputs.extension)'!='.exe' and '%(__app_build_outputs.extension)'!=''"/>
|
||
|
|
||
|
<!-- Create items that represent the app manifests. -->
|
||
|
<CreateItem Include="%(__app_exes.rootdir)%(__app_exes.directory)%(__app_exes.filename).manifest">
|
||
|
<Output ItemName="__app_manifests" TaskParameter="Include"/>
|
||
|
</CreateItem>
|
||
|
|
||
|
<Message Text="__app_manifests: %(__app_manifests.identity)"/>
|
||
|
|
||
|
<WriteLinesToFile File="$(NibFileList)"
|
||
|
Overwrite="true"
|
||
|
Lines="@(__app_manifests)"
|
||
|
Condition="'$(DistroSkipApps)'!='true'"/>
|
||
|
<Exec Condition="'$(DistroSkipApps)'!='true'"
|
||
|
Command="PATH $(SINGULARITY_PATH) & $(NIB) $(NIB_FLAGS) /cache:$(DISTRO_CACHE_DIR) /libcache:$(DISTRO_LIB_DIR) /native:$(APPS_NATIVE_IMAGE_DIR) /options:$(SINGULARITY_ROOT)\Options\$(Configuration).$(COLLECTOR_APP).$(Machine).options /temp:$(DISTRO_TEMP_DIR) $(NIBOPTS) /apps:$(NibFileList)"/>
|
||
|
|
||
|
<Copy SourceFiles="$(APPS_NATIVE_IMAGE_DIR)\%(__app_exes.filename).x86;$(APPS_NATIVE_IMAGE_DIR)\%(__app_exes.filename).manifest"
|
||
|
DestinationFolder="$(DISTRO_BINARIES_DIR)" SkipUnchangedFiles="true"/>
|
||
|
</Target>
|
||
|
|
||
|
|
||
|
<Target Name="ConvertKernelManifest"
|
||
|
Inputs="$(KERNEL_NATIVE_DIR)\kernel.manifest"
|
||
|
Outputs="$(DISTRO_BINARIES_DIR)\kernel.manifest"
|
||
|
DependsOnTargets="BuildBaseProjects">
|
||
|
<Exec Command="$(NIB) $(NIB_FLAGS) /cache:$(BUILD_ROOT) /libcache:$(BUILD_ROOT) /native:$(DISTRO_BINARIES_DIR) /temp:$(BUILD_ROOT) /manifest $(KERNEL_NATIVE_DIR)\kernel.manifest"/>
|
||
|
</Target>
|
||
|
|
||
|
<!--
|
||
|
This target copies content files from projects to the distro output.
|
||
|
If an app project is included in the 'Application' item set of a distro project,
|
||
|
and that app project declares one or more 'Content' items, then those items will
|
||
|
be copied to the distribution output tree. This allows apps to declare dependencies
|
||
|
on files, and have those files built as part of the distribution, similar to binplace.
|
||
|
-->
|
||
|
<Target Name="CopyContentFiles" Condition="'$(EnableContentFiles)'!='false'">
|
||
|
<MSBuild Projects="@(Application)" Targets="GetContentItems">
|
||
|
<Output ItemName="AppContent" TaskParameter="TargetOutputs"/>
|
||
|
</MSBuild>
|
||
|
|
||
|
<!-- <Message Text="AppContent: %(AppContent.identity) DistroPath=%(AppContent.DistroPath)"/> -->
|
||
|
|
||
|
<!-- Create directories for the content files, if any -->
|
||
|
<MakeDir Directories="$(DISTRO_SINGULARITY_DIR)\%(AppContent.DistroPath)"/>
|
||
|
|
||
|
<Copy SourceFiles="%(AppContent.identity)" DestinationFolder="$(DISTRO_FILES_DIR)\%(AppContent.DistroPath)" SkipUnchangedFiles="true"/>
|
||
|
|
||
|
</Target>
|
||
|
|
||
|
<ItemGroup>
|
||
|
<CleanDirs Include="$(BOOTDIR)"/>
|
||
|
<CleanDirs Include="$(DRIVDIR)"/>
|
||
|
<CleanDirs Include="$(LIBSDIR)"/>
|
||
|
<CleanDirs Include="$(APPSDIR)"/>
|
||
|
<CleanDirs Include="$(KERNEL_IL_DIR)"/>
|
||
|
<CleanDirs Include="$(KERNEL_NATIVE_DIR)"/>
|
||
|
<CleanDirs Include="$(ILLSDIR)"/>
|
||
|
<CleanDirs Include="$(APPRUNTIMEDIR)"/>
|
||
|
<CleanDirs Include="$(APPRUNTIMENATIVEDIR)"/>
|
||
|
<CleanDirs Include="$(DISTRO_LIB_DIR)"/>
|
||
|
<CleanDirs Include="$(DISTRO_TEMP_DIR)"/>
|
||
|
<CleanDirs Include="$(APPS_NATIVE_IMAGE_DIR)"/>
|
||
|
<CleanDirs Include="$(DISTRO_ROOT)"/>
|
||
|
</ItemGroup>
|
||
|
|
||
|
<Target Name="Clean">
|
||
|
<RemoveDir Directories="@(CleanDirs)" />
|
||
|
</Target>
|
||
|
</Project>
|