-
Notifications
You must be signed in to change notification settings - Fork 265
feat: add MSBuild rule to build MSBuild projects. #1443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jsun-splunk
wants to merge
1
commit into
bazel-contrib:main
Choose a base branch
from
jsun-splunk:jsun-msbuild
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| load("@rules_cc//cc:defs.bzl", "cc_test") | ||
| load("@rules_foreign_cc//foreign_cc:defs.bzl", "msbuild") | ||
|
|
||
| msbuild( | ||
| name = "mylib", | ||
| lib_source = "//msbuild_simple/code:srcs", | ||
| out_lib_dir = "", | ||
| out_static_libs = ["mylib.lib"], | ||
| sln_file = "mysolution.sln", | ||
| target_compatible_with = ["@platforms//os:windows"], | ||
|
jsun-splunk marked this conversation as resolved.
|
||
| targets = ["Build"], | ||
| ) | ||
|
|
||
| cc_test( | ||
| name = "mylib_test", | ||
| srcs = ["test_mylib.cpp"], | ||
| target_compatible_with = ["@platforms//os:windows"], | ||
| deps = [":mylib"], | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| filegroup( | ||
| name = "srcs", | ||
| srcs = [ | ||
| "mylib.cpp", | ||
| "mylib.h", | ||
| "mylib.vcxproj", | ||
| "mysolution.sln", | ||
| ], | ||
| visibility = ["//msbuild_simple:__subpackages__"], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #include "mylib.h" | ||
|
|
||
| std::string hello_mylib(void) { return "Hello from MyLib!"; } | ||
|
|
||
| int add_numbers(int a, int b) { return a + b; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #ifndef MYLIB_H_ | ||
| #define MYLIB_H_ (1) | ||
|
|
||
| #include <string> | ||
|
|
||
| std::string hello_mylib(void); | ||
| int add_numbers(int a, int b); | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project DefaultTargets="Build" ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <ItemGroup Label="ProjectConfigurations"> | ||
| <ProjectConfiguration Include="Debug|Win32"> | ||
| <Configuration>Debug</Configuration> | ||
| <Platform>Win32</Platform> | ||
| </ProjectConfiguration> | ||
| <ProjectConfiguration Include="Release|Win32"> | ||
| <Configuration>Release</Configuration> | ||
| <Platform>Win32</Platform> | ||
| </ProjectConfiguration> | ||
| <ProjectConfiguration Include="Debug|x64"> | ||
| <Configuration>Debug</Configuration> | ||
| <Platform>x64</Platform> | ||
| </ProjectConfiguration> | ||
| <ProjectConfiguration Include="Release|x64"> | ||
| <Configuration>Release</Configuration> | ||
| <Platform>x64</Platform> | ||
| </ProjectConfiguration> | ||
| </ItemGroup> | ||
| <PropertyGroup Label="Globals"> | ||
| <VCProjectVersion>17.0</VCProjectVersion> | ||
| <ProjectGuid>{B2C3D4E5-F6A7-8901-BCDE-F01234567890}</ProjectGuid> | ||
| <Keyword>Win32Proj</Keyword> | ||
| <RootNamespace>mylib</RootNamespace> | ||
| <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
| <ConfigurationType>StaticLibrary</ConfigurationType> | ||
| <UseDebugLibraries>true</UseDebugLibraries> | ||
| <PlatformToolset>v143</PlatformToolset> | ||
| <CharacterSet>Unicode</CharacterSet> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
| <ConfigurationType>StaticLibrary</ConfigurationType> | ||
| <UseDebugLibraries>false</UseDebugLibraries> | ||
| <PlatformToolset>v143</PlatformToolset> | ||
| <WholeProgramOptimization>true</WholeProgramOptimization> | ||
| <CharacterSet>Unicode</CharacterSet> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
| <ConfigurationType>StaticLibrary</ConfigurationType> | ||
| <UseDebugLibraries>true</UseDebugLibraries> | ||
| <PlatformToolset>v143</PlatformToolset> | ||
| <CharacterSet>Unicode</CharacterSet> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
| <ConfigurationType>StaticLibrary</ConfigurationType> | ||
| <UseDebugLibraries>false</UseDebugLibraries> | ||
| <PlatformToolset>v143</PlatformToolset> | ||
| <WholeProgramOptimization>true</WholeProgramOptimization> | ||
| <CharacterSet>Unicode</CharacterSet> | ||
| </PropertyGroup> | ||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
| <ImportGroup Label="ExtensionSettings"> | ||
| </ImportGroup> | ||
| <ImportGroup Label="Shared"> | ||
| </ImportGroup> | ||
| <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| </ImportGroup> | ||
| <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| </ImportGroup> | ||
| <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| </ImportGroup> | ||
| <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| </ImportGroup> | ||
| <PropertyGroup Label="UserMacros" /> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
| <IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir> | ||
| <TargetName>mylib</TargetName> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
| <IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir> | ||
| <TargetName>mylib</TargetName> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| <IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir> | ||
| <TargetName>mylib</TargetName> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
| <IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir> | ||
| <TargetName>mylib</TargetName> | ||
| </PropertyGroup> | ||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
| <ClCompile> | ||
| <WarningLevel>Level3</WarningLevel> | ||
| <SDLCheck>true</SDLCheck> | ||
| <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| <ConformanceMode>true</ConformanceMode> | ||
| <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
| </ClCompile> | ||
| <Lib> | ||
| <AdditionalDependencies></AdditionalDependencies> | ||
| </Lib> | ||
| </ItemDefinitionGroup> | ||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
| <ClCompile> | ||
| <WarningLevel>Level3</WarningLevel> | ||
| <FunctionLevelLinking>true</FunctionLevelLinking> | ||
| <IntrinsicFunctions>true</IntrinsicFunctions> | ||
| <SDLCheck>true</SDLCheck> | ||
| <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| <ConformanceMode>true</ConformanceMode> | ||
| <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
| </ClCompile> | ||
| <Lib> | ||
| <AdditionalDependencies></AdditionalDependencies> | ||
| </Lib> | ||
| </ItemDefinitionGroup> | ||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| <ClCompile> | ||
| <WarningLevel>Level3</WarningLevel> | ||
| <SDLCheck>true</SDLCheck> | ||
| <PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| <ConformanceMode>true</ConformanceMode> | ||
| <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
| </ClCompile> | ||
| <Lib> | ||
| <AdditionalDependencies></AdditionalDependencies> | ||
| </Lib> | ||
| </ItemDefinitionGroup> | ||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
| <ClCompile> | ||
| <WarningLevel>Level3</WarningLevel> | ||
| <FunctionLevelLinking>true</FunctionLevelLinking> | ||
| <IntrinsicFunctions>true</IntrinsicFunctions> | ||
| <SDLCheck>true</SDLCheck> | ||
| <PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| <ConformanceMode>true</ConformanceMode> | ||
| <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
| </ClCompile> | ||
| <Lib> | ||
| <AdditionalDependencies></AdditionalDependencies> | ||
| </Lib> | ||
| </ItemDefinitionGroup> | ||
| <ItemGroup> | ||
| <ClInclude Include="mylib.h" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ClCompile Include="mylib.cpp" /> | ||
| </ItemGroup> | ||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
| <ImportGroup Label="ExtensionTargets"> | ||
| </ImportGroup> | ||
| <Target Name="CopyHeaders" AfterTargets="Build"> | ||
| <MakeDir Directories="$(OutDir)include" /> | ||
| <Copy SourceFiles="mylib.h" DestinationFolder="$(OutDir)include" /> | ||
| </Target> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.0.31903.59 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mylib", "mylib.vcxproj", "{B2C3D4E5-F6A7-8901-BCDE-F01234567890}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|x64 = Debug|x64 | ||
| Debug|Win32 = Debug|Win32 | ||
| Release|x64 = Release|x64 | ||
| Release|Win32 = Release|Win32 | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {B2C3D4E5-F6A7-8901-BCDE-F01234567890}.Debug|x64.ActiveCfg = Debug|x64 | ||
| {B2C3D4E5-F6A7-8901-BCDE-F01234567890}.Debug|x64.Build.0 = Debug|x64 | ||
| {B2C3D4E5-F6A7-8901-BCDE-F01234567890}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
| {B2C3D4E5-F6A7-8901-BCDE-F01234567890}.Debug|Win32.Build.0 = Debug|Win32 | ||
| {B2C3D4E5-F6A7-8901-BCDE-F01234567890}.Release|x64.ActiveCfg = Release|x64 | ||
| {B2C3D4E5-F6A7-8901-BCDE-F01234567890}.Release|x64.Build.0 = Release|x64 | ||
| {B2C3D4E5-F6A7-8901-BCDE-F01234567890}.Release|Win32.ActiveCfg = Release|Win32 | ||
| {B2C3D4E5-F6A7-8901-BCDE-F01234567890}.Release|Win32.Build.0 = Release|Win32 | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {B5C6D7E8-F9A0-1234-5678-90ABCDEF0123} <!-- Another unique GUID --> | ||
| EndGlobalSection | ||
| EndGlobal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #include <iostream> | ||
| #include <stdexcept> | ||
| #include <string> | ||
|
|
||
| #include "mylib.h" | ||
|
|
||
| int main(int argc, char* argv[]) { | ||
| // Test the hello_mylib function | ||
| std::string result = hello_mylib(); | ||
| if (result != "Hello from MyLib!") { | ||
| throw std::runtime_error("Wrong result from hello_mylib: " + result); | ||
| } | ||
|
|
||
| // Test the add_numbers function | ||
| int math_result = add_numbers(5, 3); | ||
| if (math_result != 8) { | ||
| throw std::runtime_error("Wrong math_result from add_numbers: " + | ||
| std::to_string(math_result)); | ||
| } | ||
|
|
||
| std::cout << "Everything's fine!"; | ||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.