Skip to content

Commit

Permalink
add developer containers
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jul 18, 2023
1 parent c0897fe commit a498847
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .devcontainers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Developer Containers

This region is reserved for release periods and serves JuleC's build for different platforms. \
Please use `build.sh` to run the whole process automatically.

## Supported Platforms

Listed below are the unique OS-ARCH operations used in the build process. \
The C++ IR file names that these matches should have during compilation are given opposite them.

- `linux-amd64`: `linux_amd64.cpp`
- `linux-arm64`: `linux_arm64.cpp`

## Preparing to Build

It is recommended that you first be in the [`src/julec/`](https://github.com/julelang/jule/tree/master/src/julec) directory.
You need to create a C++ IR for the respective platforms using JuleC's cross-transpilation with your latest compiler and name it as needed.
The nomenclatures are given in the system mappings above.

However, for a correct compilation you need to get rid of absolute include paths.
In absolute paths, you need to delete up to the root directory of the compiler.
Then correctly, you need to change directories to be portable.
If you transpiled in the recommended directory [`src/julec/`](https://github.com/julelang/jule/tree/master/src/julec), your IR files are expected to be in the `dist` directory.
In this case, append `../../../` prefix for each deletion.

For example:

Absolute paths:

```cpp
#include "/foo/bar/jule/api/jule.hpp"

#include <dirent.h>
#include <fcntl.h>
#include <cstdio>
#include <sys/stat.h>
#include "/foo/bar/jule/std/sys/syscall_unix.hpp"
#include "/foo/bar/jule/std/os/proc.hpp"
#include "/foo/bar/jule/std/vector/alloc.hpp"
#include "/foo/bar/jule/std/jule/parser/parser.hpp"
#include "/foo/bar/jule/src/julec/obj/cxx/cxx.hpp"
#include "/foo/bar/jule/src/julec/julec.hpp"
```

Portable paths:

```cpp
#include "../../../api/jule.hpp"

#include <dirent.h>
#include <fcntl.h>
#include <cstdio>
#include <sys/stat.h>
#include "../../../std/sys/syscall_unix.hpp"
#include "../../../std/os/proc.hpp"
#include "../../../std/vector/alloc.hpp"
#include "../../../std/jule/parser/parser.hpp"
#include "../../../src/julec/obj/cxx/cxx.hpp"
#include "../../../src/julec/julec.hpp"
```
32 changes: 32 additions & 0 deletions .devcontainers/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/sh
# Copyright 2023 The Jule Programming Language.
# Use of this source code is governed by a BSD 3-Clause
# license that can be found in the LICENSE file.

# Build for linux-arm64

docker pull --platform linux/arm64 ubuntu:latest

sudo docker build -f ./.devcontainers/linux_arm64.Dockerfile -t jule-linux-arm64 .

id=$(docker create jule-linux-arm64)
docker cp $id:/usr/local/jule/bin/julec ./julec_linux_arm64
docker rm -v $id

docker image rm ubuntu:latest





# Build for linux-amd64

docker pull --platform linux/amd64 ubuntu:latest

sudo docker build -f ./.devcontainers/linux_amd64.Dockerfile -t jule-linux-amd64 .

id=$(docker create jule-linux-amd64)
docker cp $id:/usr/local/jule/bin/julec ./julec_linux_amd64
docker rm -v $id

docker image rm ubuntu:latest
17 changes: 17 additions & 0 deletions .devcontainers/linux_amd64.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM --platform=amd64 ubuntu:latest

RUN apt-get update
RUN apt-get install -y clang

RUN mkdir /usr/local/jule
WORKDIR /usr/local/jule

ADD ../api ./api
ADD ../src ./src
ADD ../std ./std

RUN mkdir ./bin

WORKDIR /usr/local/jule/src/julec
RUN clang++ -Ofast -static -Wno-everything --std=c++17 -o ../../bin/julec ./dist/linux_amd64.cpp
WORKDIR /usr/local/jule
17 changes: 17 additions & 0 deletions .devcontainers/linux_arm64.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM --platform=arm64 ubuntu:latest

RUN apt-get update
RUN apt-get install -y clang

RUN mkdir /usr/local/jule
WORKDIR /usr/local/jule

ADD ../api ./api
ADD ../src ./src
ADD ../std ./std

RUN mkdir ./bin

WORKDIR /usr/local/jule/src/julec
RUN clang++ -Ofast -static -Wno-everything --std=c++17 -o ../../bin/julec ./dist/linux_arm64.cpp
WORKDIR /usr/local/jule

0 comments on commit a498847

Please sign in to comment.