Skip to content

Commit 7203045

Browse files
committed
Merge: Update build/install process
2 parents 0012708 + 015479a commit 7203045

27 files changed

+786
-542
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
*.milone linguist-language=fsharp
44
*.c linguist-detectable=false
55

6+
*.ps1 text eol=crlf
7+
*.sh text eol=lf
8+
69
# <https://github.com/github/linguist#generated-code>
710
boot/MiloneLang/Records.fs linguist-generated
811
boot/scripts/**/*.c linguist-generated

Makefile

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,14 @@
77

88
default: test
99

10-
.PHONY: build clean default install install-dev test uninstall
11-
12-
# ------------------------------------------------
13-
# entrypoints
14-
# ------------------------------------------------
10+
.PHONY: build clean default install install-dev pack test uninstall
1511

1612
clean:
1713
scripts/clean
1814

19-
install:
20-
scripts/install
21-
2215
install-dev:
2316
scripts/install-dev
2417

25-
uninstall:
26-
scripts/uninstall
27-
2818
# ------------------------------------------------
2919
# misc
3020
# ------------------------------------------------
@@ -52,6 +42,15 @@ ${MY_BUILD_TIMESTAMP}: target/.timestamp/dotnet_restore \
5242

5343
my_build: ${MY_BUILD_TIMESTAMP}
5444

45+
install: ${MY_BUILD_TIMESTAMP}
46+
${MY_BUILD} self-install
47+
48+
uninstall: ${MY_BUILD_TIMESTAMP}
49+
${MY_BUILD} self-uninstall
50+
51+
pack: ${MY_BUILD_TIMESTAMP}
52+
${MY_BUILD} pack
53+
5554
target/milone: bin/ninja ${MY_BUILD_TIMESTAMP} \
5655
runtime/milone.h \
5756
runtime/milone.c \

README.md

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
- [#About](#about)
66
- [#Install](#install)
77
- ~~With package manager~~ (yet)
8-
- From binary -> [install_from_binary.md](install_from_binary.md)
98
- [#From sources on Linux](#install-from-sources-on-linux)
10-
- [#From sources on Windows](#install-from-sources-on-windows)
9+
- [#From binary package on Windows](#install-from-binary-package-on-windows)
1110
- [#How it works](#how-it-works)
1211
- Documentation
1312
- Language -> [docs/refs](docs/refs)
@@ -39,6 +38,7 @@ Prerequisites:
3938

4039
- Ubuntu 18.04 (or similar platform)
4140
- Install [.NET SDK 5](https://dotnet.microsoft.com/download/dotnet/5.0)
41+
- Install GNU make
4242
- Install GCC 7.5.0
4343
- Install `busybox`, which is likely pre-installed, by:
4444
`apt install -y busybox-static`
@@ -51,42 +51,27 @@ git clone 'https://github.com/vain0x/milone-lang' --filter=blob:none
5151

5252
# Build and install.
5353
cd milone-lang
54-
scripts/install
54+
make install
5555
```
5656

57-
- To uninstall, do `scripts/uninstall`.
57+
- To uninstall, do `make uninstall`.
5858

59-
### Install from sources on Windows
59+
### Install from binary package on Windows
6060

6161
Prerequisites:
6262

6363
- Windows 10
64-
- Install [Git for Windows](https://gitforwindows.org/)
65-
- Install [.NET SDK 5](https://dotnet.microsoft.com/download/dotnet/5.0)
66-
- Install [Visual Studio 2019](https://visualstudio.microsoft.com/ja/downloads/) with "Desktop development with C++" option
67-
68-
Do with Git Bash:
69-
70-
```sh
71-
# Download the source code.
72-
git clone 'https://github.com/vain0x/milone-lang' --filter=blob:none
73-
cd milone-lang
74-
75-
# ---- BUILD ----
64+
- Install `MSBuild.exe` in some way:
65+
- install Visual Studio 2019 with "Desktop development with C++" option, *OR*
66+
- install [Visual Studio 2019 Build Tools](https://visualstudio.microsoft.com/ja/downloads/?q=build+tools#build-tools-for-visual-studio-2019).
7667

77-
scripts/build-milone-windows
68+
Instructions:
7869

79-
# ---- INSTALL ----
70+
- Download a binary package from [GitHub Releases](https://github.com/vain0x/milone-lang/releases)
71+
- Unarchive it somewhere
72+
- Follow instructions written in [INSTALL.md](scripts/MyBuildTool/assets/INSTALL.md)
8073

81-
# Copy the generated executable to some directory as you want.
82-
mkdir -p $USERPROFILE/bin
83-
cp 'target/MiloneCli/target/x64-Release-bin/MiloneCli.exe' $USERPROFILE/bin/milone.exe
84-
85-
# Create '.milone' directory in user directory.
86-
# Copy libraries to it.
87-
mkdir -p $USERPROFILE/.milone
88-
cp milone_libs $USERPROFILE/.milone
89-
```
74+
See also [docs/binary_package.md](docs/binary_package.md).
9075

9176
## Install VSCode Extension
9277

docs/binary_package.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Binary package
2+
3+
Binary packages are distributed in [GitHub Releases](https://github.com/vain0x/milone-lang/releases).
4+
Package file extension is either `.tar.gz` or `.zip`.
5+
6+
## Usage
7+
8+
- Download and unarchive a package file
9+
- Follow instruction written in `INSTALL.md`
10+
11+
----
12+
13+
## Package structure
14+
15+
Package should consist of these files.
16+
17+
- `milone-X.Y.Z/` (root of package)
18+
- `.milone/`
19+
- `bin/`
20+
- `INSTALL.md` (this)
21+
- `install.sh`
22+
- `install.ps1`
23+
- `LICENSE`
24+
- `README.md`
25+
26+
## Generated files by installation
27+
28+
Installation script should place these files (and these files only):
29+
30+
- `$HOME/bin/`
31+
- `milone.exe` (or `milone`)
32+
- `$HOME/.milone/`
33+
- `bin/`
34+
- `milone_dotnet/`
35+
- `milone_lsp/`
36+
- `milone_libs/`
37+
- `version`
38+
39+
where `$HOME` is your home directory.

docs/cli.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Options:
4545
- `-- ARGS...`
4646
- Arguments for generated executable.
4747
- Note that `--` is required to pass some args.
48+
- `--release`
49+
- Compile in release mode.
4850
- `--target-dir <DIR>` (defaults to `target/<PROJECT-NAME>`)
4951
- Specify target directory.
5052
- That directory contains intermediate files and output files.
@@ -74,11 +76,13 @@ milone build ./MiloneProject
7476
```
7577

7678
```sh
77-
milone build ./MiloneProject --target-dir ../build
79+
milone build ./MiloneProject --release --target-dir ../build
7880
```
7981

8082
Options:
8183

84+
- `--release`
85+
- Compile in release mode.
8286
- `--target-dir <DIR>` (defaults to `target/<PROJECT-NAME>`)
8387
- Specify target directory.
8488
- That directory contains intermediate files and output files.
@@ -93,7 +97,7 @@ Output:
9397
- `<TARGET-DIR>/<PROJECT-NAME>.exe`: Executable (if success)
9498
- where `TARGET-DIR` is specified by `--target-dir` option
9599
- On linux:
96-
- `<TARGET-DIR>/build.ninja`
100+
- `<TARGET-DIR>/build.ninja`
97101
- On windows:
98102
- `<TARGET-DIR>/<PROJECT-NAME>.sln`
99103
- `<TARGET-DIR>/<PROJECT-NAME>/<PROJECT-NAME>.vcxproj`
@@ -248,6 +252,15 @@ Notes:
248252

249253
----
250254

255+
## Less Important Features
256+
257+
- `-p <PROJECT-DIR>`, `--project-dir <PROJECT-DIR>`
258+
- Subcommands that take `<PROJECT-DIR>` as positional argument also support `-p`/`--project-dir` option instead.
259+
- That's to match behavior with `dotnet run`.
260+
- `--release` and `--target-dir`
261+
- `check` and `compile` subcommands accept these flags but ignore. (So that you can replace `build` subcommand with `check` without changing other args.)
262+
- `--debug` (inversion of `--release`) is accepted but ignored.
263+
251264
## Misc notes
252265

253266
- I'm NOT familiar with external tools; please teach me.

install_from_binary.md

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

internals.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Notes for milone-lang developers.
1010

1111
Scripts are written for `bash` because I use a Ubuntu desktop for development.
1212

13+
TODO: prepare scripts/unused/.devcontainer
14+
1315
### Dev: Prerequisites
1416

1517
See the "install from sources" section in README.
@@ -19,20 +21,18 @@ For incremental building and testing, `ninja` command is also used.
1921
`git` command is used in tests to generate diff.
2022

2123
- Install Git 2.30.0
24+
- Install GNU make
2225
- Install [ninja 1.10.2](https://github.com/ninja-build/ninja) (build tool)
2326
with `scripts/install-ninja`
2427

2528
### Dev: Build
2629

2730
```sh
28-
# If you have make:
2931
make
30-
31-
# Otherwise:
32-
scripts/build-ninja-gen
33-
bin/ninja
3432
```
3533

34+
See also Makefile.
35+
3636
### Dev: Testing
3737

3838
```
@@ -77,13 +77,12 @@ In tests, there are some categories of test cases:
7777
- Merge to master branch
7878

7979
```sh
80-
# Make a git tag.
81-
make target/milone
82-
git tag v$(target/milone --version)
80+
# Make Git tag.
81+
git tag v0.0.0
8382
git push --tags
8483

8584
# Create package.
86-
scripts/pack
85+
make pack
8786
```
8887

8988
- Make a release in GitHub

runtime/milone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ void file_write_all_text(struct String file_name, struct String content) {
668668
}
669669

670670
// -----------------------------------------------
671-
// environemnt
671+
// environment
672672
// -----------------------------------------------
673673

674674
struct String milone_get_env(struct String name) {

runtime/milone_platform.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,34 @@ struct String milone_get_platform(void) {
155155
#endif
156156
}
157157

158+
// -----------------------------------------------
159+
// environment
160+
// -----------------------------------------------
161+
162+
struct String milone_get_cwd(void) {
163+
#if defined(MILONE_PLATFORM_UNIX)
164+
char buf[FILENAME_MAX + 1];
165+
bool ok = getcwd(buf, sizeof buf) != NULL;
166+
if (!ok) {
167+
perror("getcwd");
168+
exit(1);
169+
}
170+
171+
return str_of_c_str(buf);
172+
#elif defined(MILONE_PLATFORM_WINDOWS)
173+
TCHAR buf[MAX_PATH + 1] = {0};
174+
DWORD len = GetCurrentDirectory(sizeof(buf), buf);
175+
if (len == 0 || len >= sizeof(buf)) {
176+
failwith("GetCurrentDirectory");
177+
exit(1);
178+
}
179+
180+
return os_string_to((struct OsString){.str = buf, .len = len});
181+
#else
182+
#error no platform
183+
#endif
184+
}
185+
158186
// -----------------------------------------------
159187
// file IO
160188
// -----------------------------------------------

0 commit comments

Comments
 (0)