Skip to content

Commit

Permalink
Merge pull request #93 from sayansil/mobile-compatible
Browse files Browse the repository at this point in the history
Mobile compatible
  • Loading branch information
sayansil authored Aug 6, 2023
2 parents 8318171 + 0ceb247 commit b62dd4e
Show file tree
Hide file tree
Showing 105 changed files with 4,589 additions and 1,134 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
build_type: [dbg, rel]
include:
- compiler: gcc
dependencies: 'ninja-build xorg-dev libglu1-mesa-dev'
dependencies: 'ninja-build'
- compiler: clang
dependencies: 'ninja-build xorg-dev libglu1-mesa-dev clang-14'
dependencies: 'ninja-build clang-14'
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
Expand Down Expand Up @@ -173,11 +173,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ilammy/msvc-dev-cmd@v1.10.0
- uses: actions/cache/restore@v3
id: cache_load_content
with:
path: simulation/build/.fetchcontent_cache
key: fetchcontent-win-${{ github.event.pull_request.head.sha }}
- uses: actions/cache/restore@v3
id: cache_load_build
with:
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
build_type: [dbg, rel]
include:
- compiler: gcc
dependencies: 'ninja-build xorg-dev libglu1-mesa-dev'
dependencies: 'ninja-build'
- compiler: clang
dependencies: 'ninja-build xorg-dev libglu1-mesa-dev clang-12'
dependencies: 'ninja-build clang-12'
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -178,11 +178,6 @@ jobs:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- uses: ilammy/msvc-dev-cmd@v1.10.0
- uses: actions/cache/restore@v3
id: cache_load_content
with:
path: simulation/build/.fetchcontent_cache
key: fetchcontent-win-${{ github.event.pull_request.head.sha }}
- uses: actions/cache/restore@v3
id: cache_load_build
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ ecosystem-*
tags
**/output/**
**/.DS_Store
checks.json
checks.json
**/.fetchcontent_cache/
33 changes: 27 additions & 6 deletions simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ if(${ENABLE_CLANG_TIDY})
set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "-checks=-*,${CLANG_TIDY_CHECKS}-*")
endif()

if (NOT MSVC)
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output)
if(result)
message("IPO support enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
else()
message(WARNING "IPO is not supported: ${output}")
endif()
endif()

find_program(CCACHE_PROGRAM ccache)

if(CCACHE_PROGRAM)
Expand All @@ -38,7 +49,7 @@ if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}")
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_POSITION_INDEPENDENT_CODE 1)

set(FETCHCONTENT_QUIET FALSE)
Expand Down Expand Up @@ -104,15 +115,25 @@ FetchContent_Declare(
FetchContent_Populate(whereami)
include_directories(${whereami_SOURCE_DIR}/src)

FetchContent_Declare(
rangev3
GIT_REPOSITORY "https://github.com/ericniebler/range-v3"
GIT_TAG 0.12.0
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(rangev3)
include_directories(${rangev3_SOURCE_DIR}/include)

add_subdirectory(src)
add_subdirectory(schema)

include_directories(schema/cpp)
add_subdirectory(RandomTests)
# add_subdirectory(setup)
add_subdirectory(run)
#add_subdirectory(python)
#add_subdirectory(WebApp)

if(NOT ANDROID)
add_subdirectory(RandomTests)
# TODO: xorg and mesa dependency is currently broken on Ubuntu servers. Fix dependencies in workflows and then enable this
#add_subdirectory(run)
endif()

include(CTest)
add_subdirectory(tests)
53 changes: 53 additions & 0 deletions simulation/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@
"rhs": "Darwin"
}
},
{
"name": "conf-android-common",
"description": "Android settings for NDK toolchain",
"hidden": true,
"inherits": "conf-common",
"cacheVariables": {
"CMAKE_ANDROID_NDK": "$env{NDK}",
"CMAKE_TOOLCHAIN_FILE": "$env{NDK}/build/cmake/android.toolchain.cmake",
"ANDROID_PLATFORM": "android-19",
"ANDROID_STL": "c++_shared",
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "win-msvc-dbg",
"displayName": "msvc Debug (Developer Mode)",
Expand Down Expand Up @@ -207,6 +220,34 @@
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "and-arm64v8a",
"displayName": "Android arm64-v8a",
"description": "Target android with architecture arm64-v8a",
"inherits": "conf-android-common",
"cacheVariables": {
"ANDROID_ABI": "arm64-v8a"
}
},
{
"name": "and-armeabiv7a",
"displayName": "Android armeabi-v7a",
"description": "Target android with architecture armeabi-v7a",
"inherits": "conf-android-common",
"cacheVariables": {
"ANDROID_ABI": "armeabi-v7a"
}
},
{
"name": "and-armeabiv7a-neon",
"displayName": "Android armeabi-v7a with neon",
"description": "Target android with architecture armeabi-v7a with Neon",
"inherits": "conf-android-common",
"cacheVariables": {
"ANDROID_ABI": "armeabi-v7a",
"ANDROID_ARM_NEON": "ON"
}
}
],
"buildPresets":[
Expand Down Expand Up @@ -257,6 +298,18 @@
{
"name": "osx-gcc-dbg",
"configurePreset": "osx-gcc-dbg"
},
{
"name": "and-arm64v8a",
"configurePreset": "and-arm64v8a"
},
{
"name": "and-armeabiv7a",
"configurePreset": "and-armeabiv7a"
},
{
"name": "and-armeabiv7a-neon",
"configurePreset": "and-armeabiv7a-neon"
}
],
"testPresets": [
Expand Down
8 changes: 3 additions & 5 deletions simulation/RandomTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ endfunction()

add_code(reportgen_test)
add_code(sanity_test)
# add_code(unit_tests)
# add_code(test1)
add_code(test1)
add_code(test2)
# add_code(test3)
# add_code(client)
# add_code(server)
add_code(test3)
add_code(test4)

add_c_code(test1)
5 changes: 3 additions & 2 deletions simulation/RandomTests/reportgen_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ int main() {
std::vector<std::vector<FBuffer>> rows;
const size_t simulation_years = 250;

auto root_path = setup::setup();
std::filesystem::path ecosystem_root = helper::get_ecosystem_root();
setup::setup(ecosystem_root);

const size_t initial_organism_count = 500;

Expand All @@ -21,7 +22,7 @@ int main() {
{{"kind", "deer"}, {"kingdom", "0"}, {"age", "20"}});
}

God allah(root_path, true);
God allah(ecosystem_root, true);
allah.cleanSlate();
allah.createWorld(organisms);
for (size_t i = 0; i < simulation_years; i++) {
Expand Down
3 changes: 2 additions & 1 deletion simulation/RandomTests/sanity_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#include <vector>

int main() {
setup::setup();
std::filesystem::path ecosystem_root = helper::get_ecosystem_root();
setup::setup(ecosystem_root);

const size_t initial_organism_count = 500;
const size_t simulation_years = 10;
Expand Down
35 changes: 29 additions & 6 deletions simulation/RandomTests/test1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,35 @@
#include <ecosystem_wrapper.hpp>

int main() {
create_god(0);
void *session = session_init();
create_god(session, 1, get_ecosystem_root(session));
clean_slate(session);

set_initial_organisms(0, "deer", 10, 10);
set_initial_organisms(0, "deer", 20, 100);
set_initial_organisms(0, "deer", 30, 50);
set_initial_organisms(session, 0, "deer", 10, 10);
set_initial_organisms(session, 0, "deer", 20, 100);
set_initial_organisms(session, 0, "deer", 30, 50);
set_initial_organisms(session, 1, "bamboo", 30, 50);

create_world();
run_simulation(100);
create_world(session);

for (size_t i = 0; i < 5; i++) {
happy_new_year(session);
add_current_world_record(session);
}

struct FloatData fData =
get_plot_values(session, "deer", "weight_on_speed");
for (size_t i = 0; i < fData.length; i++) {
printf("%f\n", fData.data[i]);
}

fData = get_plot_values(session, "bamboo", "population");
for (size_t i = 0; i < fData.length; i++) {
printf("%f\n", fData.data[i]);
}

printf("%s\n", get_plot_attributes(session));

free_god(session);
free_session(session);
}
Loading

0 comments on commit b62dd4e

Please sign in to comment.