From 947eeb5c394a6a8c18d3cdd1407e1bedaf645c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Felipe=20Barco=20Santa?= Date: Tue, 22 Nov 2022 09:59:55 -0500 Subject: [PATCH 1/7] Added support fot csharp and hello world example --- .github/workflows/main.yml | 7 +++++++ WORKSPACE | 20 ++++++++++++++++++++ csharp/BUILD | 11 +++++++++++ csharp/Main.cs | 11 +++++++++++ 4 files changed, 49 insertions(+) create mode 100644 csharp/BUILD create mode 100644 csharp/Main.cs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 00c64e53..5f01ff3a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,3 +51,10 @@ jobs: run: | bazel build //typescript/... bazel test //typescript/... + + - name: Building //csharp directory + run: | + bazel build \ + --host_platform @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.407 \ + --platforms @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.407 \ + //csharp/... diff --git a/WORKSPACE b/WORKSPACE index 03305a90..0ba8c7b5 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -203,3 +203,23 @@ nodejs_register_toolchains( load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +git_repository( + name = "io_bazel_rules_dotnet", + remote = "https://github.com/bazelbuild/rules_dotnet", + branch = "master", +) + +load("@io_bazel_rules_dotnet//dotnet:deps.bzl", "dotnet_repositories") + +dotnet_repositories() + +load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "dotnet_register_toolchains", "dotnet_repositories_nugets") + +dotnet_register_toolchains() + +dotnet_repositories_nugets() + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") diff --git a/csharp/BUILD b/csharp/BUILD new file mode 100644 index 00000000..1a43aedd --- /dev/null +++ b/csharp/BUILD @@ -0,0 +1,11 @@ +load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "csharp_binary") + +csharp_binary( + name = "csharp.exe", + srcs = [ + "Main.cs", + ], + deps = [ + "@core_sdk_stdlib//:libraryset", + ], +) diff --git a/csharp/Main.cs b/csharp/Main.cs new file mode 100644 index 00000000..e581983e --- /dev/null +++ b/csharp/Main.cs @@ -0,0 +1,11 @@ +using System; + +namespace HelloWorld +{ + class Hello { + static void Main(string[] args) + { + System.Console.WriteLine("Hello World!"); + } + } +} From ff1e23c923c2becbca8106c753f28e0516c932e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Felipe=20Barco=20Santa?= Date: Tue, 22 Nov 2022 15:09:01 -0500 Subject: [PATCH 2/7] Added conditional for runner.os --- .github/workflows/main.yml | 11 ++++++++++- WORKSPACE | 2 -- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5f01ff3a..beab254d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,9 +52,18 @@ jobs: bazel build //typescript/... bazel test //typescript/... - - name: Building //csharp directory + - name: Building //csharp directory (Linux) + if: runner.os == 'Linux' run: | bazel build \ --host_platform @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.407 \ --platforms @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.407 \ //csharp/... + + - name: Building //csharp directory (macOS) + if: runner.os == 'macOS' + run: | + bazel build \ + --host_platform @io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.407 \ + --platforms @io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.407 \ + //csharp/... diff --git a/WORKSPACE b/WORKSPACE index 0ba8c7b5..33f44e84 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -221,5 +221,3 @@ load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "dotnet_register_toolchains", "d dotnet_register_toolchains() dotnet_repositories_nugets() - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") From b915e4be7914054d150f8c05d9c6e42a66fbb8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Felipe=20Barco=20Santa?= Date: Tue, 22 Nov 2022 18:03:55 -0500 Subject: [PATCH 3/7] rules dotnet using commit and applied buildifier --- WORKSPACE | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 33f44e84..c13a8100 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -207,9 +207,9 @@ bazel_skylib_workspace() load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") git_repository( - name = "io_bazel_rules_dotnet", - remote = "https://github.com/bazelbuild/rules_dotnet", - branch = "master", + name = "io_bazel_rules_dotnet", + commit = "0b7ae93fa81b7327a655118da0581db5ebbe0b8d", + remote = "https://github.com/bazelbuild/rules_dotnet", ) load("@io_bazel_rules_dotnet//dotnet:deps.bzl", "dotnet_repositories") From 2b41c4f4cc7edf69d0fb5ff0d9a52c2d56de1b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Felipe=20Barco=20Santa?= Date: Wed, 23 Nov 2022 15:24:23 -0500 Subject: [PATCH 4/7] Changed git_repository by http_archive --- .github/workflows/main.yml | 8 ++++---- WORKSPACE | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index beab254d..e7fdb1fa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,14 +56,14 @@ jobs: if: runner.os == 'Linux' run: | bazel build \ - --host_platform @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.407 \ - --platforms @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.407 \ + --host_platform @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.100 \ + --platforms @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.100 \ //csharp/... - name: Building //csharp directory (macOS) if: runner.os == 'macOS' run: | bazel build \ - --host_platform @io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.407 \ - --platforms @io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.407 \ + --host_platform @io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.100 \ + --platforms @io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.100 \ //csharp/... diff --git a/WORKSPACE b/WORKSPACE index c13a8100..016fb9b0 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -204,12 +204,11 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") - -git_repository( +http_archive( name = "io_bazel_rules_dotnet", - commit = "0b7ae93fa81b7327a655118da0581db5ebbe0b8d", - remote = "https://github.com/bazelbuild/rules_dotnet", + sha256 = "400416de5d5d321fa7ca9e46110373cd39db7ed84ef3a61e1150c5813cb1c99e", + strip_prefix = "rules_dotnet-0.0.7", + urls = ["https://github.com/bazelbuild/rules_dotnet/archive/refs/tags/0.0.7.zip"], ) load("@io_bazel_rules_dotnet//dotnet:deps.bzl", "dotnet_repositories") From 251367dc73f574c606cbd64cb5a81b872b56a03c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Felipe=20Barco=20Santa?= Date: Wed, 23 Nov 2022 15:33:25 -0500 Subject: [PATCH 5/7] Added linux and macos configs for csharp runs --- .bazelrc | 6 ++++++ .github/workflows/main.yml | 12 ++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.bazelrc b/.bazelrc index 82be45bc..3dac9090 100644 --- a/.bazelrc +++ b/.bazelrc @@ -6,6 +6,7 @@ build:engflow_common --experimental_inmemory_dotd_files build:engflow_common --experimental_inmemory_jdeps_files build:engflow_common --incompatible_strict_action_env=true build:engflow_common --remote_timeout=3600 +build:engflow_common --enable_platform_specific_config build:engflow_common --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 build:engflow_common --crosstool_top=//remote_config/cc:toolchain @@ -17,6 +18,11 @@ build:engflow_common --platforms=//remote_config/config:platform build:engflow_common --java_runtime_version=remotejdk_11 build:engflow_common --java_language_version=11 +build:macos --host_platform @io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.100 +build:macos --platforms @io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.100 +build:linux --host_platform @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.100 +build:linux --platforms @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.100 + build:without_bytes --experimental_remote_download_outputs=minimal # Options for a private EngFlow cluster. diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e7fdb1fa..ce2d18be 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,16 +54,8 @@ jobs: - name: Building //csharp directory (Linux) if: runner.os == 'Linux' - run: | - bazel build \ - --host_platform @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.100 \ - --platforms @io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.100 \ - //csharp/... + run: bazel build //csharp/... --config=linux - name: Building //csharp directory (macOS) if: runner.os == 'macOS' - run: | - bazel build \ - --host_platform @io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.100 \ - --platforms @io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.100 \ - //csharp/... + run: bazel build //csharp/... --config=macos From 3e7cf978633cee51e3acf825b6d781f9a423a492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Felipe=20Barco=20Santa?= Date: Wed, 23 Nov 2022 17:40:50 -0500 Subject: [PATCH 6/7] Update .bazelrc Co-authored-by: Jay Conrod --- .bazelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index 3dac9090..0fb7c616 100644 --- a/.bazelrc +++ b/.bazelrc @@ -6,7 +6,7 @@ build:engflow_common --experimental_inmemory_dotd_files build:engflow_common --experimental_inmemory_jdeps_files build:engflow_common --incompatible_strict_action_env=true build:engflow_common --remote_timeout=3600 -build:engflow_common --enable_platform_specific_config +build --enable_platform_specific_config build:engflow_common --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 build:engflow_common --crosstool_top=//remote_config/cc:toolchain From 95a70bd504b7d6283d9fc2a8d93194d011e98cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Felipe=20Barco=20Santa?= Date: Wed, 23 Nov 2022 17:53:56 -0500 Subject: [PATCH 7/7] No need for two steps when building csharp --- .bazelrc | 2 +- .github/workflows/main.yml | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.bazelrc b/.bazelrc index 0fb7c616..558b781e 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,3 +1,4 @@ +build --enable_platform_specific_config # Options common for all EngFlow remote configurations. build:engflow_common --jobs=8 build:engflow_common --define=EXECUTOR=remote @@ -6,7 +7,6 @@ build:engflow_common --experimental_inmemory_dotd_files build:engflow_common --experimental_inmemory_jdeps_files build:engflow_common --incompatible_strict_action_env=true build:engflow_common --remote_timeout=3600 -build --enable_platform_specific_config build:engflow_common --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 build:engflow_common --crosstool_top=//remote_config/cc:toolchain diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ce2d18be..119ff14e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,10 +52,5 @@ jobs: bazel build //typescript/... bazel test //typescript/... - - name: Building //csharp directory (Linux) - if: runner.os == 'Linux' - run: bazel build //csharp/... --config=linux - - - name: Building //csharp directory (macOS) - if: runner.os == 'macOS' - run: bazel build //csharp/... --config=macos + - name: Building //csharp directory + run: bazel build //csharp/...