Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate nix-file for example and vmbuild, fix conflicts #2238

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
74 changes: 2 additions & 72 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
{ nixpkgs ? ./pinned.nix, # Builds cleanly May 9. 2024
pkgs ? (import nixpkgs { }).pkgsStatic,

llvmPkgs ? pkgs.llvmPackages_16,

# This env has musl and LLVM's libc++ as static libraries.
stdenv ? llvmPkgs.libcxxStdenv
stdenv ? pkgs.llvmPackages_16.libcxxStdenv
}:

assert (stdenv.buildPlatform.isLinux == false) ->
Expand Down Expand Up @@ -95,7 +93,6 @@ let
#inherit s2n-tls;
inherit musl-includeos;
inherit cmake;
inherit microsoft_gsl;
};

meta = {
Expand All @@ -104,72 +101,5 @@ let
license = pkgs.lib.licenses.asl20;
};
};

# A bootable example binary
example = stdenv.mkDerivation rec {

pname = "inludeos_example";
src = pkgs.lib.cleanSource ./example/.;

nativeBuildInputs = [
cmake
pkgs.nasm
];

buildInputs = [
includeos.microsoft_gsl
includeos
];

# TODO:
# We currently need to explicitly pass in because we link with a linker script
# and need to control linking order.
# This can be moved to os.cmake eventually, once we figure out how to expose
# them to cmake from nix without having to make cmake depend on nix.
# * Maybe we should make symlinks from the includeos package to them.

libcxx = "${stdenv.cc.libcxx}/lib/libc++.a";
libcxxabi = "${stdenv.cc.libcxx}/lib/libc++abi.a";
libunwind = "${llvmPkgs.libraries.libunwind}/lib/libunwind.a";

linkdeps = [
libcxx
libcxxabi
libunwind
];

cmakeFlags = [
"-DINCLUDEOS_PACKAGE=${includeos}"
"-DINCLUDEOS_LIBC_PATH=${musl-includeos}/lib/libc.a"
"-DINCLUDEOS_LIBCXX_PATH=${libcxx}"
"-DINCLUDEOS_LIBCXXABI_PATH=${libcxxabi}"
"-DINCLUDEOS_LIBUNWIND_PATH=${libunwind}"

"-DARCH=x86_64"
"-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
];

preBuild = ''
echo ""
echo "📣 preBuild: about to build - can it work? Yes! 🥁🥁🥁"
echo "Validating dependencies: "
for dep in ${toString linkdeps}; do
echo "Checking $dep:"
file $dep
done
echo ""
'';

postBuild = ''
echo "🎉 POST BUILD - you made it pretty far! 🗻⛅"
if [[ $? -ne 0 ]]; then
echo "Build failed. Running post-processing..."
echo "Performing cleanup or logging"
fi
'';

version = "dev";
};
in
#includeos
example
includeos
71 changes: 71 additions & 0 deletions example.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{ nixpkgs ? ./pinned.nix,
includeos ? import ./default.nix { },
pkgs ? (import nixpkgs { }).pkgsStatic,
llvmPkgs ? pkgs.llvmPackages_16
}:

includeos.stdenv.mkDerivation rec {
pname = "includeos_example";
src = pkgs.lib.cleanSource ./example;
doCheck = false;
dontStrip = true;

nativeBuildInputs = [
pkgs.buildPackages.nasm
pkgs.buildPackages.cmake
];

buildInputs = [
pkgs.microsoft_gsl
includeos
];

# TODO:
# We currently need to explicitly pass in because we link with a linker script
# and need to control linking order.
# This can be moved to os.cmake eventually, once we figure out how to expose
# them to cmake from nix without having to make cmake depend on nix.
# * Maybe we should make symlinks from the includeos package to them.

libcxx = "${includeos.stdenv.cc.libcxx}/lib/libc++.a";
libcxxabi = "${includeos.stdenv.cc.libcxx}/lib/libc++abi.a";
libunwind = "${llvmPkgs.libraries.libunwind}/lib/libunwind.a";

linkdeps = [
libcxx
libcxxabi
libunwind
];

cmakeFlags = [
"-DINCLUDEOS_PACKAGE=${includeos}"
"-DINCLUDEOS_LIBC_PATH=${includeos.musl-includeos}/lib/libc.a"
"-DINCLUDEOS_LIBCXX_PATH=${libcxx}"
"-DINCLUDEOS_LIBCXXABI_PATH=${libcxxabi}"
"-DINCLUDEOS_LIBUNWIND_PATH=${libunwind}"

"-DARCH=x86_64"
"-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
];

preBuild = ''
echo ""
echo "📣 preBuild: about to build - can it work? Yes! 🥁🥁🥁"
echo "Validating dependencies: "
for dep in ${toString linkdeps}; do
echo "Checking $dep:"
file $dep
done
echo ""
'';

postBuild = ''
echo "🎉 POST BUILD - you made it pretty far! 🗻⛅"
if [[ $? -ne 0 ]]; then
echo "Build failed. Running post-processing..."
echo "Performing cleanup or logging"
fi
'';

version = "dev";
}
26 changes: 26 additions & 0 deletions vmbuild.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{ nixpkgs ? ./pinned.nix,
pkgs ? import nixpkgs { config = { }; overlays = [ ]; },
}:

pkgs.stdenv.mkDerivation rec {
pname = "vmbuild";
version = "dev";

sourceRoot = pname;

srcs = [
./vmbuild
./src
./api
];

nativeBuildInputs = [
pkgs.cmake
pkgs.nasm
];

buildInputs = [
pkgs.microsoft_gsl
];

}
21 changes: 0 additions & 21 deletions vmbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,11 @@ endif()
set(SOURCES vmbuild.cpp)
set(ELF_SYMS_SOURCES elf_syms.cpp ../src/util/crc32.cpp)



set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "-std=c++14 -Wall -Wextra -O2 -g")


if(CONAN_EXPORTED) # in conan local cache
# standard conan installation, deps will be defined in conanfile.py
# and not necessary to call conan again, conan is already running
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
else()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif()
##needed by conaningans

include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_run(
REQUIRES GSL/2.0.0@includeos/test
BASIC_SETUP
)
endif(CONAN_EXPORTED)
#TODO pull vmbuild conanfile.py inn when not building with conan to get deps
# TODO: write scripts that automatically find include directories
include_directories(
Expand Down