diff --git a/ShangEn/CMakeLists.txt b/ShangEn/lab1/part1/CMakeLists.txt similarity index 100% rename from ShangEn/CMakeLists.txt rename to ShangEn/lab1/part1/CMakeLists.txt diff --git a/ShangEn/src/hello.cpp b/ShangEn/lab1/part1/src/hello.cpp similarity index 100% rename from ShangEn/src/hello.cpp rename to ShangEn/lab1/part1/src/hello.cpp diff --git a/ShangEn/lab1/part2/CMakeLists.txt b/ShangEn/lab1/part2/CMakeLists.txt new file mode 100644 index 0000000..5c4412a --- /dev/null +++ b/ShangEn/lab1/part2/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.22) + +project(hello_world LANGUAGES CXX) + +add_library(hello_world_lib SHARED src/part2.cpp) +target_include_directories(hello_world_lib PUBLIC include) + +add_executable(test src/main.cpp) +target_link_libraries(test PUBLIC hello_world_lib) \ No newline at end of file diff --git a/ShangEn/lab1/part2/CMakeLists.txt:Zone.Identifier b/ShangEn/lab1/part2/CMakeLists.txt:Zone.Identifier new file mode 100644 index 0000000..e69de29 diff --git a/ShangEn/lab1/part2/include/part2.hpp b/ShangEn/lab1/part2/include/part2.hpp new file mode 100644 index 0000000..83ce8d0 --- /dev/null +++ b/ShangEn/lab1/part2/include/part2.hpp @@ -0,0 +1,9 @@ +#pragma once +#include + +class MyLib +{ +public: + MyLib() = default; + void hello(); +}; \ No newline at end of file diff --git a/ShangEn/lab1/part2/include/part2.hpp:Zone.Identifier b/ShangEn/lab1/part2/include/part2.hpp:Zone.Identifier new file mode 100644 index 0000000..e69de29 diff --git a/ShangEn/lab1/part2/src/main.cpp b/ShangEn/lab1/part2/src/main.cpp new file mode 100644 index 0000000..ff56221 --- /dev/null +++ b/ShangEn/lab1/part2/src/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + MyLib test; + test.hello(); +} \ No newline at end of file diff --git a/ShangEn/lab1/part2/src/main.cpp:Zone.Identifier b/ShangEn/lab1/part2/src/main.cpp:Zone.Identifier new file mode 100644 index 0000000..e69de29 diff --git a/ShangEn/lab1/part2/src/part2.cpp b/ShangEn/lab1/part2/src/part2.cpp new file mode 100644 index 0000000..c8e8fdb --- /dev/null +++ b/ShangEn/lab1/part2/src/part2.cpp @@ -0,0 +1,7 @@ +#include +#include + +void MyLib::hello() +{ + std::cout << "Hello, World!!!" << std::endl; +} \ No newline at end of file diff --git a/ShangEn/lab1/part2/src/part2.cpp:Zone.Identifier b/ShangEn/lab1/part2/src/part2.cpp:Zone.Identifier new file mode 100644 index 0000000..e69de29 diff --git a/ShangEn/lab2/part1/CMakeLists.txt b/ShangEn/lab2/part1/CMakeLists.txt new file mode 100644 index 0000000..6eae2c5 --- /dev/null +++ b/ShangEn/lab2/part1/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.22) + +project(hello_world LANGUAGES CXX) + +add_library(hello_world_lib SHARED src/hellolib.cpp) +target_include_directories(hello_world_lib PUBLIC include) + +add_executable(test src/main.cpp) +target_link_libraries(test PUBLIC hello_world_lib) + +include(GNUInstallDirs) +install(TARGETS test DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS hello_world_lib DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install( + DIRECTORY include/ + DESTINATION ${CMAKE_INSTALL_PREFIX}/include + FILES_MATCHING PATTERN "*.h*" +) \ No newline at end of file diff --git a/ShangEn/lab2/part1/default.nix b/ShangEn/lab2/part1/default.nix new file mode 100644 index 0000000..dd5cc84 --- /dev/null +++ b/ShangEn/lab2/part1/default.nix @@ -0,0 +1,8 @@ +{ stdenv, cmake }: + +stdenv.mkDerivation rec { + pname = "easy_cmake"; + version = "0.1.0"; + src = ./.; + nativeBuildInputs = [ cmake ]; +} \ No newline at end of file diff --git a/ShangEn/lab2/part1/flake.lock b/ShangEn/lab2/part1/flake.lock new file mode 100644 index 0000000..48bb1fd --- /dev/null +++ b/ShangEn/lab2/part1/flake.lock @@ -0,0 +1,127 @@ +{ + "nodes": { + "easy_cmake": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1722065012, + "narHash": "sha256-t5sDKfmN9isLJASCrvSzVEhbYH2mMeBrByMWvbpClmc=", + "owner": "RCMast3r", + "repo": "easy_cmake", + "rev": "06cfd8aab9e0d0d636c45c6d6014e29ae8b669bd", + "type": "github" + }, + "original": { + "owner": "RCMast3r", + "repo": "easy_cmake", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1719994518, + "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1695825837, + "narHash": "sha256-4Ne11kNRnQsmSJCRSSNkFRSnHC4Y5gPDBIQGjjPfJiU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5cfafa12d57374f48bcc36fda3274ada276cf69e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1719876945, + "narHash": "sha256-Fm2rDDs86sHy0/1jxTOKB1118Q0O3Uc7EC0iXvXKpbI=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "easy_cmake": "easy_cmake", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/ShangEn/lab2/part1/flake.nix b/ShangEn/lab2/part1/flake.nix new file mode 100644 index 0000000..2d62581 --- /dev/null +++ b/ShangEn/lab2/part1/flake.nix @@ -0,0 +1,52 @@ +{ + description = "vectornav c++ library"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; + utils.url = "github:numtide/flake-utils"; + easy_cmake.url = "github:RCMast3r/easy_cmake"; + }; + outputs = { self, nixpkgs, utils, easy_cmake }: + let + vn_lib_overlay = final: prev: { + vn_lib = final.callPackage ./default.nix { }; + }; + my_overlays = [ easy_cmake.overlays.default vn_lib_overlay ]; + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ self.overlays.default ]; + }; + in + { + overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; + + packages.x86_64-linux = + rec { + vn_lib = pkgs.vn_lib; + py_vn_lib = pkgs.py_vn_lib; + default = vn_lib; + }; + + devShells.x86_64-linux.default = + pkgs.mkShell rec { + # Update the name to something that suites your project. + name = "nix-devshell"; + packages = with pkgs; [ + # Development Tools + cmake + vn_lib + ]; + + # Setting up the environment variables you need during + # development. + shellHook = + let + icon = "f121"; + in + '' + export PS1="$(echo -e '\u${icon}') {\[$(tput sgr0)\]\[\033[38;5;228m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]} (${name}) \\$ \[$(tput sgr0)\]" + ''; + }; + + }; +} diff --git a/ShangEn/lab2/part1/include/hellolib.hpp b/ShangEn/lab2/part1/include/hellolib.hpp new file mode 100644 index 0000000..83ce8d0 --- /dev/null +++ b/ShangEn/lab2/part1/include/hellolib.hpp @@ -0,0 +1,9 @@ +#pragma once +#include + +class MyLib +{ +public: + MyLib() = default; + void hello(); +}; \ No newline at end of file diff --git a/ShangEn/lab2/part1/result b/ShangEn/lab2/part1/result new file mode 120000 index 0000000..8c2380e --- /dev/null +++ b/ShangEn/lab2/part1/result @@ -0,0 +1 @@ +/nix/store/0mb3j4icyhpfvrmbfaa1hr9x0ga8mh2k-easy_cmake-0.1.0 \ No newline at end of file diff --git a/ShangEn/lab2/part1/src/hellolib.cpp b/ShangEn/lab2/part1/src/hellolib.cpp new file mode 100644 index 0000000..c7dec79 --- /dev/null +++ b/ShangEn/lab2/part1/src/hellolib.cpp @@ -0,0 +1,7 @@ +#include +#include + +void MyLib::hello() +{ + std::cout << "Hello, World!!!" << std::endl; +} \ No newline at end of file diff --git a/ShangEn/lab2/part1/src/main.cpp b/ShangEn/lab2/part1/src/main.cpp new file mode 100644 index 0000000..f232536 --- /dev/null +++ b/ShangEn/lab2/part1/src/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + MyLib test; + test.hello(); +} \ No newline at end of file