From 9e38b7ca638ed4ef9cecb54f13d7e46c8daa8d59 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Mon, 12 May 2025 05:18:28 +0900 Subject: [PATCH] add src-space/* and clear src files --- .gitignore | 5 ++++- README.md | 20 ++++++++++++-------- config.yaml | 1 - space/src-c/src/main.c | 17 ----------------- space/src-cpp/src/main.cpp | 17 ----------------- space/src-kt/build.gradle.kts | 6 +++--- space/src-kt/src/main.kt | 13 ------------- space/src-lua/Makefile | 6 ++++-- space/src-lua/src/main.lua | 11 ----------- space/src-py/make.py | 33 +++++++++++++++++++++++++++++++++ space/src-rs/Cargo.lock | 7 +++++++ space/src-rs/Cargo.toml | 9 +++++++++ space/src-rs/build.rs | 18 ++++++++++++++++++ 13 files changed, 90 insertions(+), 73 deletions(-) delete mode 100644 config.yaml delete mode 100644 space/src-c/src/main.c delete mode 100644 space/src-cpp/src/main.cpp delete mode 100644 space/src-kt/src/main.kt delete mode 100644 space/src-lua/src/main.lua create mode 100755 space/src-py/make.py create mode 100644 space/src-rs/Cargo.lock create mode 100644 space/src-rs/Cargo.toml create mode 100644 space/src-rs/build.rs diff --git a/.gitignore b/.gitignore index ca63760..4591203 100644 --- a/.gitignore +++ b/.gitignore @@ -30,4 +30,7 @@ __pycache__ *.pyc -target \ No newline at end of file +target + +state.yml +config.yml \ No newline at end of file diff --git a/README.md b/README.md index 28d39cb..29eeaea 100644 --- a/README.md +++ b/README.md @@ -35,15 +35,19 @@ yenru0 code storage * `run` ```sh -# workspace로 불러오는 file -run load 1000 to py # load 1000.py from python repository -# if there loaded file -run load 1000.py # run type inference by extension -run load 1000.py from zeta # default is `zeta`/* -run load 1000.rs from zeta/c- -run load 1000.rs from zet -run export 1000.py --to zeta/completed +# 테스트 케이스 생성 with count=5 +run init 5 + +# workspace로 불러오는 file +run load 1000 --to py # load 1000.py from python source space +# if there loaded file +run load 1000.py # language inference by extension +run load 1000.py --from zeta +run load 1000.rs --from zeta --force # already in src space force overwrite + + +run export --from c --completed run time rust.it diff --git a/config.yaml b/config.yaml deleted file mode 100644 index e88328e..0000000 --- a/config.yaml +++ /dev/null @@ -1 +0,0 @@ -curret-source = \ No newline at end of file diff --git a/space/src-c/src/main.c b/space/src-c/src/main.c deleted file mode 100644 index f57f1fa..0000000 --- a/space/src-c/src/main.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -int fib(int n) { - if (n == 1 || n == 0) { - return n; - } else { - return fib(n - 1) + fib(n - 2); - } -} - -int main() { - int temp; - scanf("%d", &temp); - printf("%d\n", fib(temp)); - return 0; -} \ No newline at end of file diff --git a/space/src-cpp/src/main.cpp b/space/src-cpp/src/main.cpp deleted file mode 100644 index 618ba8e..0000000 --- a/space/src-cpp/src/main.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include - -int fib(int n) { - if (n == 0 || n == 1) { - return n; - } - return fib(n - 1) + fib(n - 2); -} - -int main() { - int temp; - std::cin >> temp; - - std::cout << fib(temp) << std::endl; - - return 0; -} \ No newline at end of file diff --git a/space/src-kt/build.gradle.kts b/space/src-kt/build.gradle.kts index 5b24f77..6643326 100644 --- a/space/src-kt/build.gradle.kts +++ b/space/src-kt/build.gradle.kts @@ -1,6 +1,3 @@ -import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.archivesName - - plugins { val kotlinVersion = "1.9.10" kotlin("jvm") version kotlinVersion @@ -52,6 +49,9 @@ tasks.named("jar") { manifest { attributes["Main-Class"] = "MainKt" } + from(configurations.runtimeClasspath.get().map { if(it.isDirectory) it else zipTree(it)}) + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + finalizedBy("copyJarToBuild") } diff --git a/space/src-kt/src/main.kt b/space/src-kt/src/main.kt deleted file mode 100644 index 38a98ba..0000000 --- a/space/src-kt/src/main.kt +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.Scanner - -fun fib(n: Int): Int { - if (n == 0 || n == 1) { - return n - } else return fib(n - 1) + fib(n - 2) -} - -fun main() { - val sc = Scanner(System.`in`) - val n = sc.nextInt() - println(fib(n)) -} \ No newline at end of file diff --git a/space/src-lua/Makefile b/space/src-lua/Makefile index 8b56847..fe4fe74 100644 --- a/space/src-lua/Makefile +++ b/space/src-lua/Makefile @@ -6,8 +6,10 @@ TARGET = main.lua BUILD_DIR = ../../build +OUTPUT = lua.luac + build: - ${CC} -o ${BUILD_DIR}/lua.luac ${SRC_DIR}/${TARGET} + ${CC} -o ${BUILD_DIR}/$(OUTPUT) ${SRC_DIR}/${TARGET} run: build - lua ${BUILD_DIR}/lua.luac \ No newline at end of file + lua ${BUILD_DIR}/$(OUTPUT) \ No newline at end of file diff --git a/space/src-lua/src/main.lua b/space/src-lua/src/main.lua deleted file mode 100644 index fff1fc8..0000000 --- a/space/src-lua/src/main.lua +++ /dev/null @@ -1,11 +0,0 @@ -local function fib(n) - if n == 0 or n == 1 then - return n - else - return fib(n - 1) + fib(n - 2) - end -end - - -local n = io.read("*n") -print(fib(n)) diff --git a/space/src-py/make.py b/space/src-py/make.py new file mode 100755 index 0000000..1212771 --- /dev/null +++ b/space/src-py/make.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +import py_compile + +import click + +SRC_DIR = r"./src" + +TARGET = r"main.py" + +OUTPUT = r"py.pyc" + +BUILD_DIR = r"../../build" + + +@click.group() +def cli(): + pass + + +@click.command(name="build") +def build(): + try: + py_compile.compile( + f"{SRC_DIR}/{TARGET}", f"{BUILD_DIR}/{OUTPUT}", optimize=2, doraise=True + ) + except Exception as e: + raise click.ClickException(e) + + +cli.add_command(build) + +if __name__ == "__main__": + cli() diff --git a/space/src-rs/Cargo.lock b/space/src-rs/Cargo.lock new file mode 100644 index 0000000..ec6d519 --- /dev/null +++ b/space/src-rs/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "srcrs" +version = "0.1.0" diff --git a/space/src-rs/Cargo.toml b/space/src-rs/Cargo.toml new file mode 100644 index 0000000..ed93c32 --- /dev/null +++ b/space/src-rs/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "srcrs" +version = "0.1.0" +edition = "2021" + +[dependencies] + +[profile.dev] +opt-level = 2 \ No newline at end of file diff --git a/space/src-rs/build.rs b/space/src-rs/build.rs new file mode 100644 index 0000000..d7d50ce --- /dev/null +++ b/space/src-rs/build.rs @@ -0,0 +1,18 @@ +use std::env; +use std::fs; +use std::path::Path; + +fn main() { + let target_dir = env::var("CARGO_TARGET_DIR").unwrap_or_else(|_| "target".to_string()); + let profile = env::var("PROFILE").unwrap(); + let exe_name = env::var("CARGO_PKG_NAME").unwrap(); + + println!("cargo::warning={}", profile); + + let target_path = Path::new(&target_dir).join(&profile).join(&exe_name); + let dest_path = Path::new("../../build").join("rs.out"); + + if target_path.exists() { + fs::copy(&target_path, &dest_path).expect("Failed to copy executable"); + } +}