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

Support for namespace #6001

Merged
merged 44 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e81a234
add namespace basic test
waruqi Dec 21, 2024
904e941
add namespace stub
waruqi Dec 21, 2024
32db8fc
add nested namespace tests
waruqi Dec 22, 2024
3e07f68
update namespace string
waruqi Dec 22, 2024
4b35267
add test.lua
waruqi Dec 22, 2024
36a07b4
add root tests
waruqi Jan 6, 2025
d4cbbbb
add root tests
waruqi Jan 6, 2025
7d3cfca
fix namespace end
waruqi Jan 6, 2025
d630e9c
fix namespace scope
waruqi Jan 6, 2025
7447e95
fix root namespace values order
waruqi Jan 6, 2025
4fe6254
add includes test
waruqi Jan 6, 2025
1aa63e9
fix target path for namespace
waruqi Jan 6, 2025
1ce4271
improve progress info
waruqi Jan 6, 2025
f6904d7
add namespace info to build object
waruqi Jan 6, 2025
ae8a596
support for inner namespace access
waruqi Jan 6, 2025
61812aa
support for namespace options
waruqi Jan 6, 2025
508341c
improve option test
waruqi Jan 6, 2025
55dc4ce
add namespace for rule
waruqi Jan 6, 2025
e66776b
fix cli
waruqi Jan 6, 2025
bdc9a4c
add namespace for task
waruqi Jan 6, 2025
27b2539
Update task.lua
waruqi Jan 6, 2025
c184146
add namespace for toolchain
waruqi Jan 7, 2025
e5ea7bc
add package for namespace
waruqi Jan 7, 2025
9021afe
support namespace for xpack
waruqi Jan 7, 2025
bd6ded5
fix package with 3rd namespace
waruqi Jan 7, 2025
545c055
merge root scope for namespace
waruqi Jan 7, 2025
76fd3ab
improve project.get
waruqi Jan 7, 2025
154345c
improve comments
waruqi Jan 7, 2025
14fff0b
get namespaces in project
waruqi Jan 7, 2025
4ad0083
fix package error
waruqi Jan 7, 2025
7dec01b
get packages with namespace
waruqi Jan 8, 2025
6ef0f9b
improve package name
waruqi Jan 8, 2025
cd44af7
update test
waruqi Jan 8, 2025
34a6d0e
fix display name
waruqi Jan 8, 2025
26921bb
use tbox namespace
waruqi Jan 8, 2025
53f1507
add has_config test
waruqi Jan 8, 2025
6721129
improve has_config test
waruqi Jan 8, 2025
a74774a
improve has_config
waruqi Jan 8, 2025
ed685ec
add namespace to sandbox
waruqi Jan 8, 2025
9491877
remove config.has
waruqi Jan 8, 2025
279b1f0
improve to get config
waruqi Jan 8, 2025
7a4c72e
improve is_config
waruqi Jan 8, 2025
9c0f92f
improve has_package
waruqi Jan 8, 2025
6317ffd
fix config
waruqi Jan 8, 2025
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
7 changes: 6 additions & 1 deletion core/src/xmake/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ target("xmake")
set_kind("static")

-- add deps
add_deps("sv", "lz4", "tbox")
add_deps("sv", "lz4")
if false then--namespace then
add_deps("tbox::tbox")
else
add_deps("tbox")
end
if is_config("runtime", "luajit") then
add_deps("luajit")
else
Expand Down
9 changes: 8 additions & 1 deletion core/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,14 @@ if is_plat("windows") then
end

-- add projects
includes("src/sv", "src/lz4", "src/tbox", "src/xmake", "src/cli")
includes("src/sv", "src/lz4", "src/xmake", "src/cli")
if false then --namespace then
namespace("tbox", function ()
includes("src/tbox")
end)
else
includes("src/tbox")
end
if has_config("lua_cjson") then
includes("src/lua-cjson")
end
Expand Down
8 changes: 8 additions & 0 deletions tests/apis/namespace/basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Xmake cache
.xmake/
build/

# MacOS Cache
.DS_Store


5 changes: 5 additions & 0 deletions tests/apis/namespace/basic/src/bar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "bar.h"

int sub(int a, int b) {
return a - b;
}
9 changes: 9 additions & 0 deletions tests/apis/namespace/basic/src/bar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef __cplusplus
extern "C" {
#endif

int sub(int a, int b);

#ifdef __cplusplus
}
#endif
5 changes: 5 additions & 0 deletions tests/apis/namespace/basic/src/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "foo.h"

int add(int a, int b) {
return a + b;
}
9 changes: 9 additions & 0 deletions tests/apis/namespace/basic/src/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef __cplusplus
extern "C" {
#endif

int add(int a, int b);

#ifdef __cplusplus
}
#endif
9 changes: 9 additions & 0 deletions tests/apis/namespace/basic/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "foo.h"
#include "bar.h"
#include <iostream>

int main(int argc, char** argv) {
std::cout << "add(1, 2) = " << add(1, 2) << std::endl;
std::cout << "sub(2, 1) = " << sub(2, 1) << std::endl;
return 0;
}
3 changes: 3 additions & 0 deletions tests/apis/namespace/basic/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function main()
os.exec("xmake -vD")
end
19 changes: 19 additions & 0 deletions tests/apis/namespace/basic/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
add_rules("mode.debug", "mode.release")

namespace("ns1", function ()
target("foo")
set_kind("static")
add_files("src/foo.cpp")
end)

namespace("ns2")
target("bar")
set_kind("static")
add_files("src/bar.cpp")
namespace_end()

target("test")
set_kind("binary")
add_deps("ns1::foo", "ns2::bar")
add_files("src/main.cpp")

8 changes: 8 additions & 0 deletions tests/apis/namespace/includes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Xmake cache
.xmake/
build/

# MacOS Cache
.DS_Store


5 changes: 5 additions & 0 deletions tests/apis/namespace/includes/src/bar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "bar.h"

int sub(int a, int b) {
return a - b;
}
9 changes: 9 additions & 0 deletions tests/apis/namespace/includes/src/bar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef __cplusplus
extern "C" {
#endif

int sub(int a, int b);

#ifdef __cplusplus
}
#endif
5 changes: 5 additions & 0 deletions tests/apis/namespace/includes/src/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "foo.h"

int add(int a, int b) {
return a + b;
}
9 changes: 9 additions & 0 deletions tests/apis/namespace/includes/src/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef __cplusplus
extern "C" {
#endif

int add(int a, int b);

#ifdef __cplusplus
}
#endif
9 changes: 9 additions & 0 deletions tests/apis/namespace/includes/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "foo.h"
#include "bar.h"
#include <iostream>

int main(int argc, char** argv) {
std::cout << "add(1, 2) = " << add(1, 2) << std::endl;
std::cout << "sub(2, 1) = " << sub(2, 1) << std::endl;
return 0;
}
8 changes: 8 additions & 0 deletions tests/apis/namespace/includes/src/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace("ns2", function ()
add_defines("NS2_ROOT")
target("bar")
set_kind("static")
add_files("bar.cpp")
add_defines("BAR")
end)

3 changes: 3 additions & 0 deletions tests/apis/namespace/includes/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function main()
os.exec("xmake -vD")
end
20 changes: 20 additions & 0 deletions tests/apis/namespace/includes/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
add_rules("mode.debug", "mode.release")

add_defines("ROOT")

namespace("ns1", function ()
add_defines("NS1_ROOT")
target("foo")
set_kind("static")
add_files("src/foo.cpp")
add_defines("FOO")

includes("src")
end)

target("test")
set_kind("binary")
add_deps("ns1::foo", "ns1::ns2::bar")
add_files("src/main.cpp")
add_defines("TEST")

8 changes: 8 additions & 0 deletions tests/apis/namespace/inner/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Xmake cache
.xmake/
build/

# MacOS Cache
.DS_Store


5 changes: 5 additions & 0 deletions tests/apis/namespace/inner/src/bar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "bar.h"

int sub(int a, int b) {
return a - b;
}
9 changes: 9 additions & 0 deletions tests/apis/namespace/inner/src/bar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef __cplusplus
extern "C" {
#endif

int sub(int a, int b);

#ifdef __cplusplus
}
#endif
5 changes: 5 additions & 0 deletions tests/apis/namespace/inner/src/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "foo.h"

int add(int a, int b) {
return a + b;
}
9 changes: 9 additions & 0 deletions tests/apis/namespace/inner/src/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef __cplusplus
extern "C" {
#endif

int add(int a, int b);

#ifdef __cplusplus
}
#endif
9 changes: 9 additions & 0 deletions tests/apis/namespace/inner/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "foo.h"
#include "bar.h"
#include <iostream>

int main(int argc, char** argv) {
std::cout << "add(1, 2) = " << add(1, 2) << std::endl;
std::cout << "sub(2, 1) = " << sub(2, 1) << std::endl;
return 0;
}
3 changes: 3 additions & 0 deletions tests/apis/namespace/inner/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function main()
os.exec("xmake -vD")
end
19 changes: 19 additions & 0 deletions tests/apis/namespace/inner/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
add_rules("mode.debug", "mode.release")

namespace("ns1", function ()
target("foo")
set_kind("static")
add_files("src/foo.cpp")

namespace("ns2", function()
target("bar")
set_kind("static")
add_files("src/bar.cpp")
end)

target("test")
set_kind("binary")
add_deps("foo", "ns2::bar")
add_files("src/main.cpp")
end)

8 changes: 8 additions & 0 deletions tests/apis/namespace/nested/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Xmake cache
.xmake/
build/

# MacOS Cache
.DS_Store


5 changes: 5 additions & 0 deletions tests/apis/namespace/nested/src/bar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "bar.h"

int sub(int a, int b) {
return a - b;
}
9 changes: 9 additions & 0 deletions tests/apis/namespace/nested/src/bar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef __cplusplus
extern "C" {
#endif

int sub(int a, int b);

#ifdef __cplusplus
}
#endif
5 changes: 5 additions & 0 deletions tests/apis/namespace/nested/src/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "foo.h"

int add(int a, int b) {
return a + b;
}
9 changes: 9 additions & 0 deletions tests/apis/namespace/nested/src/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef __cplusplus
extern "C" {
#endif

int add(int a, int b);

#ifdef __cplusplus
}
#endif
9 changes: 9 additions & 0 deletions tests/apis/namespace/nested/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "foo.h"
#include "bar.h"
#include <iostream>

int main(int argc, char** argv) {
std::cout << "add(1, 2) = " << add(1, 2) << std::endl;
std::cout << "sub(2, 1) = " << sub(2, 1) << std::endl;
return 0;
}
3 changes: 3 additions & 0 deletions tests/apis/namespace/nested/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function main()
os.exec("xmake -vD")
end
19 changes: 19 additions & 0 deletions tests/apis/namespace/nested/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
add_rules("mode.debug", "mode.release")

namespace("ns1", function ()
target("foo")
set_kind("static")
add_files("src/foo.cpp")

namespace("ns2")
target("bar")
set_kind("static")
add_files("src/bar.cpp")
namespace_end()
end)

target("test")
set_kind("binary")
add_deps("ns1::foo", "ns1::ns2::bar")
add_files("src/main.cpp")

8 changes: 8 additions & 0 deletions tests/apis/namespace/option/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Xmake cache
.xmake/
build/

# MacOS Cache
.DS_Store


5 changes: 5 additions & 0 deletions tests/apis/namespace/option/src/bar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "bar.h"

int sub(int a, int b) {
return a - b;
}
9 changes: 9 additions & 0 deletions tests/apis/namespace/option/src/bar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef __cplusplus
extern "C" {
#endif

int sub(int a, int b);

#ifdef __cplusplus
}
#endif
5 changes: 5 additions & 0 deletions tests/apis/namespace/option/src/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "foo.h"

int add(int a, int b) {
return a + b;
}
9 changes: 9 additions & 0 deletions tests/apis/namespace/option/src/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef __cplusplus
extern "C" {
#endif

int add(int a, int b);

#ifdef __cplusplus
}
#endif
9 changes: 9 additions & 0 deletions tests/apis/namespace/option/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "foo.h"
#include "bar.h"
#include <iostream>

int main(int argc, char** argv) {
std::cout << "add(1, 2) = " << add(1, 2) << std::endl;
std::cout << "sub(2, 1) = " << sub(2, 1) << std::endl;
return 0;
}
3 changes: 3 additions & 0 deletions tests/apis/namespace/option/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function main()
os.exec("xmake -vD")
end
Loading
Loading