Skip to content

Commit

Permalink
improve templates
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Dec 1, 2022
1 parent 90613a3 commit 0914303
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 92 deletions.
5 changes: 5 additions & 0 deletions xmake/templates/c++/shared/project/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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ extern "C" {
# define __export
#endif

/*! calculate add(a, b)
*
* @param a the first argument
* @param b the second argument
*
* @return the result
*/
__export int add(int a, int b);
__export int add(int a, int b);

#ifdef __cplusplus
}
Expand Down
6 changes: 0 additions & 6 deletions xmake/templates/c++/shared/project/src/interface.cpp

This file was deleted.

5 changes: 2 additions & 3 deletions xmake/templates/c++/shared/project/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include "interface.h"
#include "foo.h"
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
int main(int argc, char** argv) {
cout << "add(1, 2) = " << add(1, 2) << endl;
return 0;
}
8 changes: 4 additions & 4 deletions xmake/templates/c++/shared/project/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
add_rules("mode.debug", "mode.release")

target("${TARGETNAME}")
target("foo")
set_kind("shared")
add_files("src/interface.cpp")
add_files("src/foo.cpp")

target("${TARGETNAME}_demo")
target("${TARGETNAME}")
set_kind("binary")
add_deps("${TARGETNAME}")
add_deps("foo")
add_files("src/main.cpp")

${FAQ}
5 changes: 5 additions & 0 deletions xmake/templates/c++/static/project/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 xmake/templates/c++/static/project/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
6 changes: 0 additions & 6 deletions xmake/templates/c++/static/project/src/interface.cpp

This file was deleted.

16 changes: 0 additions & 16 deletions xmake/templates/c++/static/project/src/interface.h

This file was deleted.

5 changes: 2 additions & 3 deletions xmake/templates/c++/static/project/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include "interface.h"
#include "foo.h"
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
int main(int argc, char** argv) {
cout << "add(1, 2) = " << add(1, 2) << endl;
return 0;
}
8 changes: 4 additions & 4 deletions xmake/templates/c++/static/project/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
add_rules("mode.debug", "mode.release")

target("${TARGETNAME}")
target("foo")
set_kind("static")
add_files("src/interface.cpp")
add_files("src/foo.cpp")

target("${TARGETNAME}_demo")
target("${TARGETNAME}")
set_kind("binary")
add_deps("${TARGETNAME}")
add_deps("foo")
add_files("src/main.cpp")

${FAQ}
5 changes: 5 additions & 0 deletions xmake/templates/c/shared/project/src/foo.c
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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
# define __export
#endif

/*! calculate add(a, b)
*
* @param a the first argument
* @param b the second argument
*
* @return the result
*/
__export int add(int a, int b);
__export int add(int a, int b);


6 changes: 0 additions & 6 deletions xmake/templates/c/shared/project/src/interface.c

This file was deleted.

5 changes: 2 additions & 3 deletions xmake/templates/c/shared/project/src/main.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "interface.h"
#include "foo.h"
#include <stdio.h>

int main(int argc, char** argv)
{
int main(int argc, char** argv) {
printf("add(1, 2) = %d\n", add(1, 2));
return 0;
}
8 changes: 4 additions & 4 deletions xmake/templates/c/shared/project/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
add_rules("mode.debug", "mode.release")

target("${TARGETNAME}")
target("foo")
set_kind("shared")
add_files("src/interface.c")
add_files("src/foo.c")

target("${TARGETNAME}_demo")
target("${TARGETNAME}")
set_kind("binary")
add_deps("${TARGETNAME}")
add_deps("foo")
add_files("src/main.c")

${FAQ}
5 changes: 5 additions & 0 deletions xmake/templates/c/static/project/src/foo.c
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;
}
1 change: 1 addition & 0 deletions xmake/templates/c/static/project/src/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int add(int a, int b);
6 changes: 0 additions & 6 deletions xmake/templates/c/static/project/src/interface.c

This file was deleted.

8 changes: 0 additions & 8 deletions xmake/templates/c/static/project/src/interface.h

This file was deleted.

5 changes: 2 additions & 3 deletions xmake/templates/c/static/project/src/main.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "interface.h"
#include "foo.h"
#include <stdio.h>

int main(int argc, char** argv)
{
int main(int argc, char** argv) {
printf("add(1, 2) = %d\n", add(1, 2));
return 0;
}
8 changes: 4 additions & 4 deletions xmake/templates/c/static/project/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
add_rules("mode.debug", "mode.release")

target("${TARGETNAME}")
target("foo")
set_kind("static")
add_files("src/interface.c")
add_files("src/foo.c")

target("${TARGETNAME}_demo")
target("${TARGETNAME}")
set_kind("binary")
add_deps("${TARGETNAME}")
add_deps("foo")
add_files("src/main.c")

${FAQ}

0 comments on commit 0914303

Please sign in to comment.