Skip to content

Commit 88f285f

Browse files
committed
Update CI and code
- Rename CI file - CI, use action/cache for cache cmake build - Add compile option for warning - Fix compiler warning - 'requires' is a keyword in C++20, change to 'requiress' - comparison of integer expressions of different signedness
1 parent 964f95e commit 88f285f

File tree

7 files changed

+87
-93
lines changed

7 files changed

+87
-93
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
trim_trailing_whitespace = true
66
indent_size = 4
77
indent_style = space
8+
9+
[.github/workflows/*]
10+
indent_size = 2

.github/workflows/ci.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
paths:
7+
- 'src/**'
8+
- 'submodules/**'
9+
- 'CMakeLists.txt'
10+
pull_request:
11+
branches: [ "master" ]
12+
13+
jobs:
14+
build:
15+
runs-on: ${{ matrix.os }}
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest, windows-latest]
21+
build_type: [Release]
22+
c_compiler: [gcc, clang, cl]
23+
include:
24+
- os: windows-latest
25+
c_compiler: cl
26+
cpp_compiler: cl
27+
- os: ubuntu-latest
28+
c_compiler: gcc
29+
cpp_compiler: g++
30+
- os: ubuntu-latest
31+
c_compiler: clang
32+
cpp_compiler: clang++
33+
exclude:
34+
- os: windows-latest
35+
c_compiler: gcc
36+
- os: windows-latest
37+
c_compiler: clang
38+
- os: ubuntu-latest
39+
c_compiler: cl
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
submodules: recursive
45+
46+
- name: Cache CMake
47+
id: cache-cmake
48+
uses: actions/cache@v4
49+
with:
50+
path: build
51+
key: cache-cmake-${{ runner.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}
52+
53+
- name: Check Cache Hit
54+
if: steps.cache-cmake.outputs.cache-hit == 'true'
55+
run: echo "Cache hit"
56+
57+
- name: Configure CMake
58+
run: >
59+
cmake -B ./build
60+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
61+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
62+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
63+
-S ${{ github.workspace }}
64+
65+
- name: Build
66+
run: cmake --build ./build --config ${{ matrix.build_type }} --parallel

.github/workflows/cmake-multi-platform.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@ include_directories(submodules/base64/include)
1010

1111
add_executable(luaumb src/luaumb.cpp src/localizer.cpp src/bundle.cpp src/utils.cpp)
1212

13+
if (MSVC)
14+
target_compile_options(luaumb PRIVATE /W4)
15+
else()
16+
target_compile_options(luaumb PRIVATE -Wall -Wextra -Wpedantic)
17+
endif()
18+
1319
target_link_libraries(luaumb PRIVATE Luau.Ast Luau.Analysis Luau.CLI.lib)

src/bundle.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ bool LuauModuleBundle::is_loaded(const string& name) {
1212
return this->modules.find(name) != this->modules.end();
1313
}
1414

15-
void LuauModuleBundle::set_module(const RelativePathModule& module_path, const string& source, const vector<ExprCallRequire>& requires) {
16-
this->modules[module_path.relative.string()] = {module_path.relative.string(), source, requires, module_path};
15+
void LuauModuleBundle::set_module(const RelativePathModule& module_path, const string& source, const vector<ExprCallRequire>& requiress) {
16+
this->modules[module_path.relative.string()] = {module_path.relative.string(), source, requiress, module_path};
1717
}
1818

1919
void LuauModuleBundle::add_dependency(const string& a, const string& b) {
@@ -31,9 +31,9 @@ vector<string> LuauModuleBundle::load_order() {
3131
vector<int> result;
3232
vector<string> result_str(size);
3333

34-
for (int i = 0; i < size; i++) adj[i] = this->dependencies[i];
35-
for (int i = 0; i < size; i++) for (auto it : adj[i]) indeg[it]++;
36-
for (int i = 0; i < size; i++) if (indeg[i] == 0) q.push(i);
34+
for (size_t i = 0; i < size; i++) adj[i] = this->dependencies[i];
35+
for (size_t i = 0; i < size; i++) for (auto it : adj[i]) indeg[it]++;
36+
for (size_t i = 0; i < size; i++) if (indeg[i] == 0) q.push(i);
3737

3838
while (!q.empty()) {
3939
int node = q.front();
@@ -47,7 +47,7 @@ vector<string> LuauModuleBundle::load_order() {
4747
}
4848

4949
if (result.size() != size) throw runtime_error("Error cyclic module dependency");
50-
for (int i = 0; i < size; i++) result_str[size - i - 1] = this->module_map_id[result[i]];
50+
for (size_t i = 0; i < size; i++) result_str[size - i - 1] = this->module_map_id[result[i]];
5151

5252
return result_str;
5353
}
@@ -77,7 +77,7 @@ string LuauModuleBundle::build() {
7777
unsigned int pos_line = 0;
7878
unsigned int pos_col = 0;
7979

80-
for (const ExprCallRequire& require : module.requires) {
80+
for (const ExprCallRequire& require : module.requiress) {
8181
const string call = "(_LUAUMB_" + mapped_order[require.name] + "())";
8282
const Location& location = require.location;
8383

@@ -86,7 +86,7 @@ string LuauModuleBundle::build() {
8686
} else {
8787
out += lines[pos_line++].substr(pos_col);
8888
pos_col = 0;
89-
for (int i = pos_line; i < location.begin_line; i++) out += lines[i];
89+
for (unsigned int i = pos_line; i < location.begin_line; i++) out += lines[i];
9090
out += lines[location.begin_line].substr(pos_col, location.begin_column) + call;
9191
}
9292

@@ -95,7 +95,7 @@ string LuauModuleBundle::build() {
9595
}
9696

9797
out += lines[pos_line++].substr(pos_col);
98-
if (pos_line < lines.size()) for (int i = pos_line; i < lines.size(); i++) out += lines[i];
98+
if (pos_line < lines.size()) for (unsigned int i = pos_line; i < lines.size(); i++) out += lines[i];
9999
out += "\nend)\n";
100100
out += "local _LUAUMB_LOADED_" + mapped_name + " = nil\n";
101101
out += "local _LUAUMB_" + mapped_name + " = (function() if _LUAUMB_LOADED_" + mapped_name + " == nil then ";

src/bundle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
struct ModuleFile {
1313
std::string name;
1414
std::string source;
15-
std::vector<ExprCallRequire> requires;
15+
std::vector<ExprCallRequire> requiress;
1616
RelativePathModule path;
1717
};
1818

@@ -25,7 +25,7 @@ class LuauModuleBundle {
2525

2626
LuauModuleBundle(const RelativePathModule& main_path);
2727
bool is_loaded(const std::string& name);
28-
void set_module(const RelativePathModule& module_path, const std::string& source, const std::vector<ExprCallRequire>& requires);
28+
void set_module(const RelativePathModule& module_path, const std::string& source, const std::vector<ExprCallRequire>& requiress);
2929
void add_dependency(const std::string& a, const std::string& b);
3030
std::vector<std::string> load_order();
3131
std::string build();

src/luaumb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int main(int argc, char** argv) {
6666
for (const std::string& name : lmb.load_order()) {
6767
const ModuleFile& module = lmb.modules[name];
6868
std::cout << " " << name << "" << std::endl;
69-
for (const ExprCallRequire& require : module.requires) {
69+
for (const ExprCallRequire& require : module.requiress) {
7070
std::cout << " └─ [" << require.path << "] (" << require.name << ") -- " << std::string(require.location) << std::endl;
7171
}
7272
}

0 commit comments

Comments
 (0)