Compare commits

...

2 Commits

Author SHA1 Message Date
Sameer Rahmani 9622dc8382
Add a flake.nix to replace our current dev environment
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-11-25 21:18:22 +00:00
Sameer Rahmani 3e2aaea218
Replace catch2 with google test 2023-08-15 21:50:16 +01:00
9 changed files with 279 additions and 19 deletions

View File

@ -32,7 +32,7 @@ cmake_policy(SET CMP0116 OLD)
# User Options
# =============================================================================
option(CPP_20_SUPPORT "C++20 Support" ON)
option(SERENE_BUILD_TESTING "Enable tests" OFF)
option(SERENE_BUILD_TESTING "Enable tests" ON)
option(SERENE_ENABLE_BUILDID "Enable build id." OFF)
option(SERENE_ENABLE_THINLTO "Enable ThisLTO." ON)
option(SERENE_ENABLE_DOCS "Enable document generation" OFF)
@ -129,18 +129,11 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
endif()
endif()
Include(FetchContent)
if(SERENE_BUILD_TESTING)
message(STATUS "Fetching Catch2 v3...")
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.0.0-preview4
)
FetchContent_MakeAvailable(Catch2)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
enable_testing()
find_package(GTest REQUIRED)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif()
# LLVM setup ==================================================================

View File

@ -151,10 +151,8 @@ function popd_build() {
function build-gen() {
local args
setup_toolchain
#setup_toolchain
args=(
"-DSERENE_TOOLCHAIN_PATH=$SERENE_TOOLCHAIN_PATH"
"-DCMAKE_TOOLCHAIN_FILE=$ME/cmake/toolchains/x86_64-linux-musl.cmake"
"-C"
"$ME/cmake/caches/$1.cmake"
)

59
flake.lock Normal file
View File

@ -0,0 +1,59 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"dirtyRev": "aa8d093e3bede559e5681ca69aa05e6e1ad4ee9a-dirty",
"dirtyShortRev": "aa8d093e3bed-dirty",
"lastModified": 1700918627,
"narHash": "sha256-gcbm/2a4Hp4k2dpOl33hGARAiHMHH5HKyCSkzRGhpLQ=",
"type": "git",
"url": "file:///home/lxsameer/src/nixpkgs"
},
"original": {
"type": "git",
"url": "file:///home/lxsameer/src/nixpkgs"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

136
flake.nix Normal file
View File

@ -0,0 +1,136 @@
{
description = "Serene programming language";
inputs.nixpkgs.url = "/home/lxsameer/src/nixpkgs/";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
llvm = {
url = "https://devheroes.codes/Serene/llvm-project.git";
major = "16";
version = "16.0.6";
rev = "b2c0361bcc08afdf466a605a23924bcd64fa2b86";
hash = "sha256-wUKHwWYYlKa0v5zEJXxndleYtK7wzJKi0vqr3lNkGMI=";
rev-version = "17-disable-shared-1";
};
overlays = [
(self: super:
{
serene_toolchain = (super.callPackage (super.path + "/pkgs/development/compilers/llvm/${llvm.major}") ({
inherit (super.stdenvAdapters) overrideCC;
buildLlvmTools = super.buildPackages.serene_toolchain.tools;
targetLlvmLibraries = self.targetPackages.serene_toolchain.libraries or self.serene_toolchain.libraries;
targetLlvm = self.targetPackages.serene_toolchain.llvm or self.serene_toolchain.llvm;
monorepoSrc = super.fetchgit {
url = llvm.url;
rev = llvm.rev;
hash = llvm.hash;
};
officialRelease = null;
gitRelease = {
version = llvm.version;
rev = llvm.rev;
rev-version = llvm.rev-version;
};
}));
})
(final: prev: {
cpio = prev.cpio.overrideAttrs (old: {
patches = [
./patches/0001-configure-Include-needed-header-for-major-minor-macr.patch
];
nativeBuildInputs = [ prev.autoreconfHook ];
NIX_CFLAGS_COMPILE = "-Wno-implicit-function-declaration";
});
libedit = prev.libedit.overrideAttrs (old: {
# Musl is ISO 10646 compliant but doesn't define __STDC_ISO_10646__ we need to do it ourselves
NIX_CFLAGS_COMPILE = "-D__STDC_ISO_10646__=201103L";
});
elfutils = prev.elfutils.overrideAttrs (old: {
# libcxx does not have __cxa_demangle
configureFlags = old.configureFlags ++ [ "--disable-demangler" ];
});
ccache = prev.ccache.overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ final.elfutils ];
});
# We don't need systemd at all
util-linux = prev.util-linux.override { systemdSupport = false; };
})
];
get_pkgs = system:
if system == "x86_64-linux"
then import nixpkgs {
inherit system overlays;
crossSystem = nixpkgs.lib.systems.examples.musl64 // { useLLVM = true; };
config.replaceCrossStdenv = { buildPackages, baseStdenv }:
buildPackages.stdenvAdapters.overrideCC baseStdenv buildPackages.llvmPackages_16.clangUseLLVM;
}
else import nixpkgs {
inherit system overlays;
};
pkgs = get_pkgs system;
#with pkgs;
native_build_inputs =
let
git' = pkgs.git.overrideAttrs (old: {
preInstallCheck =
pkgs.lib.replaceStrings [ ''disable_test t0201-gettext-fallbacks'' ]
[ ''
disable_test t0201-gettext-fallbacks
disable_test t2082-parallel-checkout-attributes
'' ]
old.preInstallCheck;
});
in with pkgs; [
cmake
ninja
ccache
# serene_toolchain.lldb
# serene_toolchain.lld
# serene_toolchain.libcxx
# serene_toolchain.libcxxabi
# serene_toolchain.compiler-rt
git'
zsh
python3
];
build_inputs = with pkgs; [
boehmgc
# llvm_16
gtest
gmock
# zlib-ng
# zstd
include-what-you-use
];
in {
inherit pkgs;
devShells.default = pkgs.mkShell {
nativeBuildInputs = native_build_inputs;
buildInputs = build_inputs;
shellHook = ''zsh --norcs && exit'';
};
packages.cmake = pkgs.cmake;
packages.blah = pkgs.stdenv.mkDerivation {
pname = "blah";
version = "0.1";
nativeBuildInputs = native_build_inputs;
buildInputs = build_inputs;
};
}
);
}

View File

@ -134,3 +134,8 @@ install(TARGETS serene EXPORT SereneTargets
add_subdirectory(src)
add_subdirectory(include)
if(SERENE_BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()

View File

@ -19,6 +19,7 @@
#include "jit/jit.h"
#include "options.h" // for Options
#include "source_mgr.h"
#include <__type_traits/remove_reference.h> // for remov...
#include <__utility/move.h> // for move
@ -130,9 +131,7 @@ size_t JIT::getNumberOfJITDylibs(const llvm::StringRef &nsName) {
JIT::JIT(llvm::orc::JITTargetMachineBuilder &&jtmb,
std::unique_ptr<Options> opts)
:
options(std::move(opts)),
: options(std::move(opts)),
cache(options->JITenableObjectCache ? new ObjectCache() : nullptr),
gdbListener(options->JITenableGDBNotificationListener
? llvm::JITEventListener::createGDBRegistrationListener()

View File

@ -27,6 +27,7 @@
#define JIT_JIT_H
#include "options.h"
#include "source_mgr.h"
#include <__memory/unique_ptr.h>
@ -60,7 +61,7 @@ class LLLazyJIT;
} // namespace llvm::orc
namespace serene {
class Namespace;
class SourceMgr;
} // namespace serene
#define MAIN_PROCESS_JD_NAME "*main*"
@ -109,6 +110,9 @@ class JIT {
std::vector<const char *> loadPaths;
// The source manager is the owner of all the sources and there can be
// just one source manager.
SourceMgr srcMgr;
// We keep the jibDylibs for each name space in a mapping from the ns
// name to a vector of jitdylibs, the last element is always the newest
// jitDylib

View File

@ -0,0 +1,43 @@
# Serene Programming Language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if(SERENE_BUILD_TESTING)
include(GoogleTest)
add_executable(serene_test
reader_tests.cpp
)
target_link_libraries(serene_test PRIVATE
GTest::gtest_main
LLVMSupport)
target_include_directories(serene_test
SYSTEM PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../include
${CMAKE_CURRENT_SOURCE_DIR}/../src
)
target_include_directories(serene_test SYSTEM PUBLIC
# We don't want the generated files from table gen
# to be treated as local since the contain warnings
${PROJECT_BINARY_DIR}/serene/include)
gtest_discover_tests(serene_test)
endif()

View File

@ -0,0 +1,23 @@
/* -*- C++ -*-
* Serene Programming Language
*
* Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "reader.h"
#include <gtest/gtest.h>
TEST(Reader, ReadNumber) { EXPECT_EQ(1, 1); }