Skip to content

Commit c1fcb45

Browse files
committed
Move out some code to primitive libraries.
1 parent f4300e3 commit c1fcb45

58 files changed

Lines changed: 283 additions & 2659 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cppan.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@ local_settings:
22
#storage_dir: .cppan_storage
33

44
dependencies:
5-
pvt.cppan.demo.boost.filesystem: 1
6-
pvt.cppan.demo.boost.log: 1
75
pvt.cppan.demo.boost.optional: 1
86
pvt.cppan.demo.boost.program_options: 1
97
pvt.cppan.demo.boost.property_tree: 1
108
pvt.cppan.demo.boost.variant: 1
11-
pvt.cppan.demo.badger.curl.libcurl: 7
12-
pvt.cppan.demo.libarchive.libarchive: 3
13-
pvt.cppan.demo.openssl.crypto: 1
149
pvt.cppan.demo.jbeder.yaml_cpp: master
1510
pvt.cppan.demo.sqlite3: 3
16-
pvt.cppan.demo.coruus.keccak_tiny_unrolled: singlefile
1711
pvt.cppan.demo.yhirose.cpp_linenoise: master
1812

1913
pvt.egorpugin.primitives.string: master
2014
pvt.egorpugin.primitives.filesystem: master
2115
pvt.egorpugin.primitives.context: master
16+
pvt.egorpugin.primitives.date_time: master
17+
pvt.egorpugin.primitives.executor: master
18+
pvt.egorpugin.primitives.hash: master
19+
pvt.egorpugin.primitives.http: master
20+
pvt.egorpugin.primitives.lock: master
21+
pvt.egorpugin.primitives.log: master
22+
pvt.egorpugin.primitives.pack: master
2223

2324
root_project: pvt.cppan.client
2425

@@ -29,7 +30,6 @@ projects:
2930

3031
files:
3132
- src/common/.*
32-
- src/context/.*
3333
- src/printers/.*
3434
- dep/process/.*
3535
- src/comments/.*
@@ -45,7 +45,6 @@ projects:
4545
public:
4646
- src
4747
- src/common
48-
- src/context
4948
- dep/process
5049

5150
dependencies:

src/CMakeLists.txt

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@ include_directories(${PROJECT_SOURCE_DIR}/dep/process)
1717
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
1818
include_directories(${CMAKE_CURRENT_BINARY_DIR})
1919

20-
########################################
21-
# context
22-
########################################
23-
24-
set(context_src
25-
context/context.cpp
26-
context/context.h
27-
)
28-
add_library(context ${context_src})
29-
target_include_directories(context INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/context)
30-
3120
########################################
3221
# inserter
3322
########################################
@@ -39,6 +28,23 @@ add_executable(inserter ${inserter_src})
3928
set_property(TARGET inserter PROPERTY FOLDER gen)
4029
target_link_libraries(inserter pvt.cppan.demo.boost.filesystem)
4130

31+
########################################
32+
# support
33+
########################################
34+
35+
file(GLOB common_src "support/*")
36+
set(common_src ${common_src})
37+
add_library(support ${common_src})
38+
add_dependencies(support inserts_gen gen_stamp)
39+
target_include_directories(support PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/support)
40+
41+
target_link_libraries(support
42+
pvt.egorpugin.primitives.hash
43+
pvt.egorpugin.primitives.http
44+
pvt.egorpugin.primitives.log
45+
pvt.egorpugin.primitives.lock
46+
)
47+
4248
########################################
4349
# common
4450
########################################
@@ -88,18 +94,19 @@ target_include_directories(common
8894
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/common
8995
)
9096
target_link_libraries(common
91-
context
97+
support
9298
bazel_parser
9399
extract_comments
94100
)
95101

96102
target_link_libraries(common
97-
pvt.cppan.demo.boost.log
98-
pvt.cppan.demo.badger.curl.libcurl
99-
pvt.cppan.demo.libarchive.libarchive
100103
pvt.cppan.demo.jbeder.yaml_cpp
101104
pvt.cppan.demo.sqlite3
102-
pvt.cppan.demo.coruus.keccak_tiny_unrolled
105+
106+
pvt.egorpugin.primitives.context
107+
pvt.egorpugin.primitives.pack
108+
pvt.egorpugin.primitives.date_time
109+
pvt.egorpugin.primitives.executor
103110
)
104111

105112
################################################################################

src/client/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ target_link_libraries(client common
1313
pvt.cppan.demo.boost.program_options
1414
pvt.cppan.demo.yhirose.cpp_linenoise
1515
)
16+
add_custom_command(TARGET client POST_BUILD
17+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:client> $<TARGET_FILE_DIR:client>/cppanx${CMAKE_EXECUTABLE_SUFFIX}
18+
)
1619

1720
set_target_properties(client PROPERTIES OUTPUT_NAME cppan)
1821
if (WIN32)

src/client/build.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include <iostream>
3131

32-
#include "logger.h"
32+
#include <primitives/log.h>
3333
DECLARE_STATIC_LOGGER(logger, "build");
3434

3535
int build_packages(const String &name, const std::set<Package> &pkgs, const path &settings_fn, const String &config);

src/client/fix_imports.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
#include "fix_imports.h"
1818

1919
#include <config.h>
20-
#include <context.h>
2120
#include <project_path.h>
2221

2322
#include <printers/cmake.h>
2423

2524
#include <boost/algorithm/string.hpp>
25+
#include <primitives/context.h>
2626

2727
#include <deque>
2828
#include <iostream>

src/client/init.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ auto read_versions(const String &pkg)
8181

8282
bool y_n_branch(const String &s, const void_f &yf = void_f(), const void_f &nf = void_f())
8383
{
84-
std::cout << s << " (y/n) [n]: ";
84+
std::cout << s << " (yes/no) [no]: ";
8585
String t;
8686
readline(t);
8787
bool y = is_y(t);
@@ -96,6 +96,7 @@ void command_init(const Strings &args)
9696
{
9797
bool script = false;
9898
bool build_project = true;
99+
bool header_only = false;
99100
String project_type = "e";
100101
String idir;
101102
Project p;
@@ -116,6 +117,8 @@ void command_init(const Strings &args)
116117
{
117118
p.type = ProjectType::Library;
118119

120+
y_n_branch("Header only?", [&] { header_only = true; });
121+
119122
std::cout << "Enter include directory name [" << idir << "]: ";
120123
readline(idir);
121124
}
@@ -169,10 +172,12 @@ void command_init(const Strings &args)
169172
idir = p.name;
170173
project_type = args[i++];
171174

172-
if (project_type[0] == 'l')
175+
if (project_type[0] == 'l' || project_type[0] == 'h')
173176
{
174177
p.type = ProjectType::Library;
175178
idir = args[i++];
179+
if (project_type[0] == 'h')
180+
header_only = true;
176181
}
177182

178183
for (; i < (int)args.size(); i++)
@@ -262,7 +267,8 @@ void command_init(const Strings &args)
262267
{
263268
fs::create_directories(root / p.name / "include" / idir);
264269
write_file(root / p.name / "include" / idir / (p.name + ".h"), "//#include <something>\n\n");
265-
write_file(root / p.name / "src" / (p.name + ".cpp"), "#include <" + idir + "/" + p.name + ".h>\n\n");
270+
if (header_only)
271+
write_file(root / p.name / "src" / (p.name + ".cpp"), "#include <" + idir + "/" + p.name + ".h>\n\n");
266272
}
267273
else
268274
{

src/client/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,21 @@
2626
#include <filesystem.h>
2727
#include <hash.h>
2828
#include <http.h>
29-
#include <logger.h>
30-
#include <pack.h>
3129
#include <printers/cmake.h>
3230
#include <program.h>
3331
#include <settings.h>
3432
#include <shell_link.h>
3533
#include <verifier.h>
3634

3735
#include <boost/algorithm/string.hpp>
36+
#include <primitives/pack.h>
3837

3938
#include <iostream>
4039
#include <thread>
4140

41+
#include <primitives/log.h>
42+
DECLARE_STATIC_LOGGER(logger, "main");
43+
4244
enum class ApiResult
4345
{
4446
Handled,

src/common/api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "project.h"
2121
#include "settings.h"
2222

23-
#include "logger.h"
23+
#include <primitives/log.h>
2424
DECLARE_STATIC_LOGGER(logger, "api");
2525

2626
ptree api_call(const Remote &r, const String &api, ptree request)

src/common/checks.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
#include "checks.h"
1818
#include "checks_detail.h"
1919

20-
#include "context.h"
2120
#include "hash.h"
2221
#include "printers/printer.h"
2322

2423
#include <boost/algorithm/string.hpp>
2524

2625
#include <memory>
2726

28-
#include "logger.h"
27+
#include <primitives/log.h>
2928
DECLARE_STATIC_LOGGER(logger, "checks");
3029

3130
const std::map<int, Check::Information> check_information{

src/common/checks_detail.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
#include "checks.h"
1818

19-
#include "context.h"
2019
#include "printers/printer.h"
2120

2221
#include <boost/algorithm/string.hpp>
22+
#include <primitives/context.h>
2323

2424
#include <memory>
2525

0 commit comments

Comments
 (0)