Skip to content

Commit c96b4eb

Browse files
authored
Merge pull request #6 from DragonRuby/alexdenisov/devcontainers
Add linux support
2 parents 09042d2 + a4f8985 commit c96b4eb

File tree

12 files changed

+88
-11
lines changed

12 files changed

+88
-11
lines changed

.devcontainer/Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
2+
3+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
4+
&& apt-get -y install --no-install-recommends \
5+
software-properties-common fish
6+
7+
RUN add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main"
8+
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
9+
10+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
11+
&& apt-get -y install --no-install-recommends \
12+
clang-19 clang++-19 llvm-19-dev libmlir-19-dev mlir-19-tools \
13+
rake python3-pip libzstd-dev
14+
15+
RUN pip install lit filecheck==0.0.24 pre-commit --break-system-packages

.devcontainer/devcontainer.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "Lightstorm",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"features": {
7+
// Switch to the "official" version as soon as
8+
// https://github.com/devcontainers-community/features-cmake/pull/2
9+
// merged
10+
"ghcr.io/alexdenisov/features/feature-cmake": {
11+
"version": "3.29.3"
12+
}
13+
},
14+
"postCreateCommand": "sh .devcontainer/post_create.sh"
15+
}

.devcontainer/post_create.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set -e
2+
3+
pre-commit install
4+
git submodule update --init --recursive

.github/workflows/linux-ci.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Linux CI
2+
on:
3+
push:
4+
branches: ["main"]
5+
pull_request:
6+
branches: ["main"]
7+
jobs:
8+
build-and-test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: docker/login-action@v2
13+
with:
14+
registry: ghcr.io
15+
username: ${{ github.repository_owner }}
16+
password: ${{ secrets.GITHUB_TOKEN }}
17+
- uses: devcontainers/[email protected]
18+
with:
19+
imageName: ghcr.io/dragonruby/internal-lightstorm-ci
20+
runCmd: |
21+
cmake --preset lightstorm
22+
cmake --build ./build.debug.dir/build -t run-integration-tests

.github/workflows/macos-ci.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ on:
55
pull_request:
66
branches: ["main"]
77
jobs:
8-
build:
9-
runs-on: ${{ matrix.os }}
10-
strategy:
11-
fail-fast: false
12-
matrix:
13-
os: [macos-latest]
8+
build-and-test:
9+
runs-on: macos-latest
1410
steps:
1511
- uses: actions/checkout@v4
1612
with:

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
Output
2+
build*dir
3+
*.lit_test_times.txt

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "third_party/mruby"]
22
path = third_party/mruby
3-
url = git@github.com:mruby/mruby.git
3+
url = https://github.com/mruby/mruby.git

CMakePresets.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": 8,
3+
"configurePresets": [
4+
{
5+
"name": "lightstorm",
6+
"displayName": "lightstorm",
7+
"description": "Sets Ninja generator, build and install directory",
8+
"generator": "Ninja",
9+
"binaryDir": "${sourceDir}/build.debug.dir/build",
10+
"cacheVariables": {
11+
"CMAKE_BUILD_TYPE": "Debug",
12+
"CMAKE_C_COMPILER": "clang-19",
13+
"CMAKE_CXX_COMPILER": "clang++-19",
14+
"CMAKE_PREFIX_PATH": "/usr/lib/llvm-19/lib/cmake",
15+
"CMAKE_INSTALL_PREFIX": "${sourceDir}/build.debug.dir/install"
16+
}
17+
}
18+
]
19+
}

cmake/mruby.cmake

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ ExternalProject_Add(
88
mruby
99
SOURCE_DIR ${MRUBY_DIR}
1010
CONFIGURE_COMMAND ""
11-
BUILD_COMMAND ${CMAKE_COMMAND} -E env CFLAGS="${LIGHTSTORM_CFLAGS}"
12-
LDFLAGS="${LIGHTSTORM_CFLAGS}" rake all --verbose
11+
BUILD_COMMAND
12+
${CMAKE_COMMAND} -E env CC=${CMAKE_C_COMPILER} CPP=${CMAKE_CXX_COMPILER}
13+
CFLAGS="${LIGHTSTORM_CFLAGS}" LDFLAGS="${LIGHTSTORM_CFLAGS}" rake all
14+
--verbose
1315
BUILD_IN_SOURCE ON
1416
INSTALL_COMMAND ""
1517
BUILD_BYPRODUCTS ${MRUBY_STATIC} ${MRUBY_BINARY} ${MRBC_BINARY}

lib/conversion/c_conversion.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "lightstorm/conversion/conversion.h"
22
#include "lightstorm/dialect/rite.h"
3+
#include <ctype.h>
34
#include <mlir/Conversion/ArithToEmitC/ArithToEmitC.h>
45
#include <mlir/Conversion/FuncToEmitC/FuncToEmitC.h>
56
#include <mlir/Dialect/Arith/IR/Arith.h>
@@ -55,7 +56,7 @@ static std::string cCompatibleSymName(const std::string &sym) {
5556
std::string s;
5657
std::stringstream ss(s);
5758
for (auto c : sym) {
58-
if (isalpha(c) || isnumber(c)) {
59+
if (isalpha(c) || isdigit(c)) {
5960
ss << c;
6061
continue;
6162
}

lib/runtime/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ target_include_directories(
66
${CMAKE_SOURCE_DIR}/third_party/mruby/build/host/include)
77
target_compile_options(lightstorm_runtime_main PRIVATE ${LIGHTSTORM_CFLAGS})
88
target_link_options(lightstorm_runtime_main PRIVATE ${LIGHTSTORM_CFLAGS})
9+
target_link_libraries(lightstorm_runtime_main PUBLIC m)
910
add_dependencies(lightstorm_runtime_main mruby_static)

tests/benchmarks/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function(add_bench_executable ruby)
1313
PRIVATE ${CMAKE_SOURCE_DIR}/third_party/mruby/include
1414
${CMAKE_SOURCE_DIR}/third_party/mruby/build/host/include)
1515
target_compile_options(${target_name} PRIVATE -g)
16-
target_link_libraries(${target_name} PRIVATE mruby_static)
16+
target_link_libraries(${target_name} PRIVATE mruby_static m)
1717
add_dependencies(${target_name} mruby_static)
1818
endfunction()
1919

0 commit comments

Comments
 (0)