Skip to content

Commit ed6f93b

Browse files
committed
cmakelists for c agent & jansson
1 parent e2da977 commit ed6f93b

File tree

377 files changed

+25198
-10
lines changed

Some content is hidden

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

377 files changed

+25198
-10
lines changed

c-jvm-agent-lib/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
# Project Agent
22

33
## Run release
4+
5+
```
46
java -jar app.jar
57
68
java -agentpath:CodEvoAgent -jar app.jar
79
810
java -agentpath:CodEvoAgent -DcodevoSources=../java/java_test/ -DcodevoVerbose=3 -jar app.jar
11+
```
912

1013
## Building setup
1114

1215
Useful setup commands to be able to build
1316

17+
```
1418
curl
1519
brew link curl --force
1620
@@ -26,3 +30,4 @@ http://www.xmlsoft.org/downloads.html xml2-config --libs
2630
2731
brew install libxml2
2832
brew install gpg
33+
```\

c-jvm-agent-lib/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ rm ./release/*.dll
2424
rm ./release/*.log
2525
rm ./release/*.dylib
2626
cp ./java/output/app.jar ./release/app.jar
27-
cp ./c/agent/output/agent.dll ./release/CodEvoAgent.dll
28-
cp ./c/agent/output/agent.dylib ./release/libCodEvoAgent.dylib
27+
cp ./c/agent/build/libagent.dylib.dll ./release/CodEvoAgent.dll
28+
cp ./c/agent/build/libagent.dylib.dylib ./release/libCodEvoAgent.dylib
2929

3030
echo "Released!"
3131
sleep 2

c-jvm-agent-lib/c/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# agent
2+
3+
4+
```
5+
brew install libxml2
6+
```

c-jvm-agent-lib/c/agent/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/**
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(agent)
3+
4+
# Define sources
5+
file(GLOB SOURCES "code/*.cpp")
6+
7+
# Set output directory
8+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/output")
9+
10+
# Add jansson library as a subdirectory
11+
add_subdirectory("jansson" "${CMAKE_BINARY_DIR}/jansson_build")
12+
13+
# Find required packages
14+
find_package(PkgConfig REQUIRED)
15+
pkg_check_modules(LIBXML2 REQUIRED libxml-2.0)
16+
find_package(OpenSSL REQUIRED)
17+
find_package(CURL REQUIRED)
18+
19+
# Include directories
20+
include_directories(
21+
${LIBXML2_INCLUDE_DIRS}
22+
${OPENSSL_INCLUDE_DIR}
23+
${CURL_INCLUDE_DIR}
24+
${JANSSON_INCLUDE_DIRS}
25+
"jdk1.8.0_91.jdk/Contents/Home/include"
26+
"jdk1.8.0_91.jdk/Contents/Home/include/darwin"
27+
"."
28+
)
29+
30+
# Link directories
31+
link_directories(${LIBXML2_LIBRARY_DIRS} ${CURL_LIBRARY_DIRS})
32+
33+
# Set platform-specific flags and output names
34+
if(WIN32)
35+
set(LIB_NAME "agent.dll")
36+
add_compile_options(-DWIN32)
37+
add_library(${LIB_NAME} SHARED ${SOURCES})
38+
target_link_libraries(${LIB_NAME} ${LIBXML2_LIBRARIES} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} jansson)
39+
elseif(APPLE)
40+
set(LIB_NAME "agent.dylib")
41+
add_compile_options(-DAPPLE)
42+
add_library(${LIB_NAME} SHARED ${SOURCES})
43+
target_link_libraries(${LIB_NAME} ${LIBXML2_LIBRARIES} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} jansson)
44+
endif()
45+
46+
# Clean up object files
47+
add_custom_target(clean-objects
48+
COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/*.o
49+
COMMENT "Cleaning up object files"
50+
)

c-jvm-agent-lib/c/agent/build.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
cd ./output/
1+
mkdir build
22

3-
#win32 vs darwin
4-
g++ -c -I "/usr/local/opt/libxml2/include/libxml2/" -I "/usr/local/opt/openssl/include" -I "." -I "../jdk1.8.0_91.jdk/Contents/Home/include" -I "../jdk1.8.0_91.jdk/Contents/Home/include/darwin" ../code/*.cpp
3+
cd build
54

6-
g++ -lssl -lxml2 -lcrypto -lcurl -ljansson -o agent.dll *.o
7-
g++ -lssl -lxml2 -lcrypto -dynamiclib -ljansson -lcurl -o agent.dylib *.o
5+
cmake ..
86

9-
rm *.o
7+
make

c-jvm-agent-lib/c/agent/code/server_communication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <string.h>
44
#include "common_data_structures.h"
55
#include "xml_utils.h"
6-
#include <jansson.h>
6+
#include "jansson.h"
77

88
extern char * API_KEY;
99
extern pid_t PID;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
BasedOnStyle: LLVM
2+
AlignConsecutiveMacros: true
3+
ColumnLimit: 90
4+
IndentCaseLabels: true
5+
IndentWidth: 4
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
*~
2+
*.o
3+
*.a
4+
.libs
5+
.deps
6+
Makefile
7+
Makefile.in
8+
aclocal.m4
9+
autom4te.cache
10+
config.guess
11+
config.h
12+
config.h.in
13+
config.log
14+
config.status
15+
config.sub
16+
configure
17+
depcomp
18+
install-sh
19+
libtool
20+
ltmain.sh
21+
missing
22+
compile
23+
test-driver
24+
*.lo
25+
*.la
26+
stamp-h1
27+
*.pyc
28+
*.pc
29+
/src/jansson_config.h
30+
/jansson_private_config.h.in
31+
/jansson_private_config.h
32+
/build
33+
*.exe
34+
.idea
35+
cmake-build-debug/
36+
*.log
37+
*.trs
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
LOCAL_PATH:= $(call my-dir)
2+
include $(CLEAR_VARS)
3+
4+
LOCAL_ARM_MODE := arm
5+
6+
LOCAL_SRC_FILES := \
7+
src/dump.c \
8+
src/error.c \
9+
src/hashtable.c \
10+
src/hashtable_seed.c \
11+
src/load.c \
12+
src/memory.c \
13+
src/pack_unpack.c \
14+
src/strbuffer.c \
15+
src/strconv.c \
16+
src/utf.c \
17+
src/value.c
18+
19+
LOCAL_C_INCLUDES += \
20+
$(LOCAL_PATH) \
21+
$(LOCAL_PATH)/android \
22+
$(LOCAL_PATH)/src
23+
24+
LOCAL_MODULE_TAGS := optional
25+
LOCAL_SHARED_LIBRARIES := libc
26+
LOCAL_CFLAGS += -O3 -DHAVE_STDINT_H=1
27+
28+
LOCAL_MODULE:= libjansson
29+
30+
include $(BUILD_SHARED_LIBRARY)

0 commit comments

Comments
 (0)