Skip to content
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

Improve msvc toolchain for package #5880

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/apis/add_deps/src/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <stdio.h>

int main(int argc, char** argv)
{
int main(int argc, char** argv) {
printf("hello world!\n");
return 0;
}
3 changes: 1 addition & 2 deletions tests/apis/check_xxx/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
int main(int argc, char** argv)
{
int main(int argc, char** argv) {
return 0;
}
3 changes: 1 addition & 2 deletions tests/apis/rules/src/main2.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <stdio.h>

extern int test(int a, int b);
int main(int argc, char** argv)
{
int main(int argc, char** argv) {
printf("1 + 1 = %d\n", test(1, 1));
return 0;
}
3 changes: 1 addition & 2 deletions tests/plugins/pack/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

using namespace std;

int main(int argc, char** argv)
{
int main(int argc, char** argv) {
cout << "hello world!" << endl;
return 0;
}
4 changes: 2 additions & 2 deletions tests/projects/c/asn1c/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ int main(int ac, char **av) {
exit(71); /* better, EX_OSERR */
}

/*
* Initialize the Rectangle members
/*
* Initialize the Rectangle members
*/

/* height */
Expand Down
3 changes: 1 addition & 2 deletions tests/projects/package/toolchain_llvm/src/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <stdio.h>

int main(int argc, char** argv)
{
int main(int argc, char** argv) {
printf("hello world!\n");
return 0;
}
3 changes: 1 addition & 2 deletions tests/projects/package/toolchain_llvm_mingw/src/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <stdio.h>

int main(int argc, char** argv)
{
int main(int argc, char** argv) {
printf("hello world!\n");
return 0;
}
6 changes: 6 additions & 0 deletions tests/projects/package/toolchain_msvc/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

int main(int argc, char** argv) {
printf("hello world!\n");
return 0;
}
8 changes: 8 additions & 0 deletions tests/projects/package/toolchain_msvc/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
add_rules("mode.debug", "mode.release")
add_requires("msvc")

target("test")
set_kind("binary")
add_files("src/*.c")
set_toolchains("@msvc")
--set_toolchains("clang-cl@msvc")
13 changes: 12 additions & 1 deletion xmake/toolchains/clang-cl/check.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ function _check_vc_build_tools(toolchain, sdkdir)
end
end

-- main entry
function main(toolchain)

-- only for windows or linux (msvc-wine)
Expand All @@ -154,6 +153,18 @@ function main(toolchain)
if sdkdir then
return _check_vc_build_tools(toolchain, sdkdir)
else
-- find it from packages
for _, package in ipairs(toolchain:packages()) do
local installdir = package:installdir()
if installdir and os.isdir(installdir) then
local result = _check_vc_build_tools(toolchain, installdir)
if result then
return result
end
end
end

-- find it from system
return _check_vstudio(toolchain)
end
end
Expand Down
13 changes: 12 additions & 1 deletion xmake/toolchains/msvc/check.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ function _check_vc_build_tools(toolchain, sdkdir)
end
end

-- main entry
function main(toolchain)

-- only for windows or linux (msvc-wine)
Expand All @@ -145,6 +144,18 @@ function main(toolchain)
if sdkdir then
return _check_vc_build_tools(toolchain, sdkdir)
else
-- find it from packages
for _, package in ipairs(toolchain:packages()) do
local installdir = package:installdir()
if installdir and os.isdir(installdir) then
local result = _check_vc_build_tools(toolchain, installdir)
if result then
return result
end
end
end

-- find it from system
return _check_vstudio(toolchain)
end
end
Expand Down
Loading