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

Llvm intergration #36

Merged
merged 12 commits into from
Aug 8, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
Checks: 'clang-analyzer-*,cppcoreguidelines-*,modernize-*,bugprone-*,performance-*,readability-*,readability-non-const-parameter,misc-const-correctness,misc-use-anonymous-namespace,google-explicit-constructor,-modernize-use-trailing-return-type,-bugprone-exception-escape,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-avoid-magic-numbers,-bugprone-easily-swappable-parameters,-cppcoreguidelines-non-private-member-variables-in-classes,-readability-magic-numbers'
Checks: 'clang-analyzer-*,cppcoreguidelines-*,modernize-*,bugprone-*,performance-*,readability-*,readability-non-const-parameter,misc-const-correctness,misc-use-anonymous-namespace,google-explicit-constructor,-modernize-use-trailing-return-type,-bugprone-exception-escape,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-avoid-magic-numbers,-bugprone-easily-swappable-parameters,-cppcoreguidelines-non-private-member-variables-in-classes,-readability-magic-numbers,-readability-identifier-length'
WarningsAsErrors: ''
HeaderFilterRegex: ''
HeaderFilterRegex: ''
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ build/
target/
vsxmake2022/

compile_commands.json
compile_commands.json
index.html
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libs/llvm-18.1.9-src"]
path = libs/llvm-18.1.9-src
url = https://github.com/kneorain/llvm-project
208 changes: 0 additions & 208 deletions CMakeLists.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
78 changes: 78 additions & 0 deletions language/helix/pkgs/std/build.hlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// build.hx - The build script for std

// this is a hypotechical build script in helix
// syntax is not final tho.

import build_tools as bt;

class Array {
fn map(self, func: Function<(Element_Ty), Element_Ty>) requires <Element_Ty> {

}
}

module build_tools {
class InvalidInput derives BaseError {
fn InvalidInput(self, msg: string) {
super.msg = msg;
}

fn to_string(self) -> string {
return super.msg;
}
}

class BuildConfig {
let target: string;
let cxx_toolchain: string;
// ...

fn BuildConfig(self) {}

fn set_target(self, target: string) -> &self {
self.target = target;

let allowed_targets = (
"x86_64-apple-darwin",
"x86_64-windows-none",
"x86_64-windows-msvc",
// ...
);

if !(target in allowed_targets) {
panic InvalidInput(f"provided target: {target} in invalid use a vali tripple");
}

return &self;
}
}
}

import git;

import python_ffi;

fn build() -> noreturn! {
let config = bt::BuildConfig()
.set_target("x86_64-apple-darwin")
.set_cxx_toolchain("clang++")
.set_output_dir("build")
.set_optimization_level(bt::optimization::RELEASE);

let builder = bt::Builder(config)
.add_source("src/main.helix")
.add_source("src/utils.helix")
.add_ffi(python_ffi::FFI())
.add_ffi(cpp_ffi::FFI())
.add_include_path("include")
.set_output("std")
.set_standalone(true); // no runtime dependents
.set_build("lib"); // lib | bin

if (git::file_changed("src/test.py")) {
bt::run();
}

builder.compile();
bt::run_tests();
}
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions source/controllers/source/read_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <iostream>
#include <optional>
#include <string>
#include <vector>

#include "controllers/include/file_system.hh"
#include "core/error/error.hh"
Expand Down Expand Up @@ -77,7 +78,7 @@ std::string _internal_read_file(const std::string &filename) {
std::ifstream file(filename, std::ios::binary | std::ios::ate);

if (!file) {
error::Error(error::Compiler{filename, "file not found."});
error::Error(error::CompilerError{2.1001, {}, std::vector<string>{filename}});
return "";
}

Expand All @@ -86,7 +87,7 @@ std::string _internal_read_file(const std::string &filename) {

std::string source(size, '\0');
if (!file.read(source.data(), size)) {
error::Error(error::Compiler{filename, "failed to read file."});
error::Error(error::CompilerError{2.1003, {}, std::vector<string>{filename}});
return "";
}

Expand All @@ -98,7 +99,7 @@ std::string _internal_read_file(const std::string &filename) {
std::string read_file(std::string &filename) {
std::optional<std::filesystem::path> path = file_system::resolve_path(filename);
if (!path.has_value()) {
error::Error(error::Compiler{filename, "file not found."});
error::Error(error::CompilerError{2.1001, {}, std::vector<string>{filename}});
std::exit(1);
}

Expand All @@ -113,7 +114,7 @@ std::string read_file(std::string &filename) {
std::string read_file(const std::string &filename) {
std::optional<std::filesystem::path> path = file_system::resolve_path(filename);
if (!path.has_value()) {
error::Error(error::Compiler{filename, "file not found."});
error::Error(error::CompilerError{2.1001, {}, std::vector<string>{filename}});
std::exit(1);
}

Expand Down
Loading
Loading