Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/development' into client-serve…
Browse files Browse the repository at this point in the history
…r-hashing
  • Loading branch information
tobil4sk committed Nov 19, 2024
2 parents dd2da1f + 1420a4e commit 8673f80
Show file tree
Hide file tree
Showing 22 changed files with 115 additions and 69 deletions.
20 changes: 15 additions & 5 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,19 @@ run.n:
COPY .git .git
COPY src src
COPY hx3compat hx3compat
COPY client.hxml haxelib.json .
COPY client.hxml each.hxml haxelib.json .
RUN haxe client.hxml
SAVE ARTIFACT run.n AS LOCAL run.n

haxelib-binary:
FROM +devcontainer
COPY .git .git
COPY src src
COPY hx3compat hx3compat
COPY client_cpp.hxml each.hxml haxelib.json .
RUN haxe client_cpp.hxml
SAVE ARTIFACT haxelib AS LOCAL haxelib

package-haxelib:
FROM +devcontainer-base
COPY src src
Expand Down Expand Up @@ -379,7 +388,7 @@ haxelib-server-builder:

haxelib-server-legacy:
FROM +haxelib-server-builder
COPY server_legacy.hxml server_each.hxml .
COPY server_legacy.hxml server_each.hxml each.hxml .
COPY src src
COPY hx3compat hx3compat
COPY www/legacy www/legacy
Expand All @@ -388,7 +397,7 @@ haxelib-server-legacy:

haxelib-server-website:
FROM +haxelib-server-builder
COPY server_website.hxml server_each.hxml .
COPY server_website.hxml server_each.hxml each.hxml .
COPY src src
COPY hx3compat hx3compat
RUN haxe server_website.hxml
Expand All @@ -402,15 +411,15 @@ haxelib-server-website-highlighter:

haxelib-server-tasks:
FROM +haxelib-server-builder
COPY server_tasks.hxml server_each.hxml .
COPY server_tasks.hxml server_each.hxml each.hxml .
COPY src src
COPY hx3compat hx3compat
RUN haxe server_tasks.hxml
SAVE ARTIFACT www/tasks.n

haxelib-server-api:
FROM +haxelib-server-builder
COPY server_api.hxml server_each.hxml .
COPY server_api.hxml server_each.hxml each.hxml .
COPY src src
COPY hx3compat hx3compat
RUN haxe server_api.hxml
Expand Down Expand Up @@ -550,6 +559,7 @@ ci-tests:
# for package.hxml
COPY haxelib.json README.md .
COPY +run.n/run.n .
COPY +haxelib-binary/haxelib .

COPY +ci-runner/ci.n bin/ci.n
ENV HAXELIB_SERVER=localhost
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2005-2024 Haxe Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 1 addition & 4 deletions client.hxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-cp src
-cp hx3compat/std
-cp hx4compat/std
-cp crypto/src
each.hxml
-neko run.n
-main haxelib.client.Main
6 changes: 6 additions & 0 deletions client_cpp.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
each.hxml
--cpp bin/cpp
--main haxelib.client.Main
-D destination=../../haxelib{EXESUFFIX}
--dce full
-D analyzer-optimize
5 changes: 1 addition & 4 deletions client_legacy.hxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-cp src
-cp hx3compat/std
-cp hx4compat/std
-cp crypto/src
each.hxml
-neko bin/legacyhaxelib.n
-main legacyhaxelib.Main
5 changes: 1 addition & 4 deletions client_tests.hxml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
-p src
each.hxml
-p test
-p hx3compat/std
-p hx4compat/std
-p crypto/src
--main HaxelibTests
--debug
--neko bin/test.n
4 changes: 4 additions & 0 deletions each.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-cp src
-cp hx3compat/std
-cp hx4compat/std
-cp crypto/src
7 changes: 2 additions & 5 deletions integration_tests.hxml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
-cp src
-cp test
-cp hx4compat/std
-cp crypto/src
-lib hx3compat
each.hxml
-p test
-lib record-macros
-lib argon2
-main IntegrationTests
Expand Down
1 change: 1 addition & 0 deletions libs.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
-cmd curl -sSLk https://lib.haxe.org/files/3.0/ufront-2,0,0.zip -o haxelib_global/ufront.zip && neko run.n install --always --skip-dependencies haxelib_global/ufront.zip
-cmd curl -sSLk https://lib.haxe.org/files/3.0/utest-1,9,6.zip -o haxelib_global/utest.zip && neko run.n install --always --skip-dependencies haxelib_global/utest.zip
-cmd curl -sSLk https://lib.haxe.org/files/3.0/hxnodejs-12,1,0.zip -o haxelib_global/hxnodejs.zip && neko run.n install --always --skip-dependencies haxelib_global/hxnodejs.zip
-cmd curl -sSLk https://lib.haxe.org/files/3.0/hxcpp-4,3,2.zip -o haxelib_global/hxcpp.zip && neko run.n install --always --skip-dependencies haxelib_global/hxcpp.zip
-cmd neko run.n dev record-macros lib/record-macros
-cmd neko run.n dev argon2 lib/argon2
5 changes: 1 addition & 4 deletions package.hxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
-cp src
-cp hx3compat/std
-cp hx4compat/std
-cp crypto/src
-p src
--run Package
Binary file modified run.n
Binary file not shown.
5 changes: 1 addition & 4 deletions server_each.hxml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
-cp src
-cp hx3compat/std
-cp hx4compat/std
-cp crypto/src
each.hxml
-lib ufront
-lib ufront-mail:1.0.0-rc.4
-lib ufront-ufadmin
Expand Down
5 changes: 1 addition & 4 deletions server_gitrepo.hxml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
--class-path src
each.hxml
--class-path lib/dts2hx-generated
--class-path lib/node-sys-db
--class-path hx3compat/std
--class-path hx4compat/std
--class-path crypto/src
--library hxnodejs
--library record-macros
--js gitrepo.js
Expand Down
1 change: 0 additions & 1 deletion server_legacy.hxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
server_each.hxml
-cp src
-neko www/legacy/index.n
-main legacyhaxelib.Site
-lib hx2compat
Expand Down
1 change: 0 additions & 1 deletion src/Package.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import haxe.zip.Tools;

import sys.io.File;
import sys.FileSystem;
import haxelib.client.Main.VERSION;
import haxelib.Data.Infos;

using StringTools;
Expand Down
2 changes: 1 addition & 1 deletion src/haxelib/api/GlobalScope.hx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GlobalScope extends Scope {
main: info.main
};

ScriptRunner.run(libraryRunData, resolveCompiler(), callData);
ScriptRunner.run(libraryRunData, callData, () -> haxeVersion);
}

public function getVersion(library:ProjectName):Version {
Expand Down
9 changes: 8 additions & 1 deletion src/haxelib/api/Installer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ class Installer {
if (confirmHxmlInstall != null && !confirmHxmlInstall(libVersions))
return;

var hasFailures = false;

for (library in installData) {
if (library.versionData.match(Haxelib(_)) && repository.isVersionInstalled(library.name, library.version)) {
final version = SemVer.ofString(library.version);
Expand All @@ -281,6 +283,7 @@ class Installer {
try
installFromVersionData(library.name, library.versionData)
catch (e) {
hasFailures = true;
userInterface.log(e.toString());
continue;
}
Expand All @@ -296,6 +299,8 @@ class Installer {

handleDependenciesGeneral(libraryName, library.versionData);
}

if (hasFailures) throw "Some libraries could not be installed.";
}

/**
Expand Down Expand Up @@ -762,7 +767,7 @@ class Installer {
userInterface.log('Installing $library from $url' + (branch != null ? " branch: " + branch : ""));
final tag = vcsData.tag;
try {
vcs.clone(libPath, url, branch, tag, userInterface.log.bind(_, Debug));
vcs.clone(libPath, url, branch, tag, userInterface.log.bind(_, Debug), userInterface.log.bind(_, Optional));
} catch (error:VcsError) {
FsUtils.deleteRec(libPath);
switch (error) {
Expand All @@ -774,6 +779,8 @@ class Installer {
throw 'Could not checkout branch, tag or path "$branch": ' + stderr;
case CantCheckoutVersion(_, version, stderr):
throw 'Could not checkout tag "$version": ' + stderr;
case SubmoduleError(_, repo, stderr):
throw 'Could not clone submodule(s) from $repo: ' + stderr;
case CommandFailed(_, code, stdout, stderr):
throw new VcsCommandFailed(id, code, stdout, stderr);
};
Expand Down
10 changes: 5 additions & 5 deletions src/haxelib/api/ScriptRunner.hx
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ class ScriptRunner {
/**
Run `library`, with `callData`.
`compilerData` is used if it is an interpreted script.
`getCompilerVersion` is used if it is an interpreted script.
**/
public static function run(library:LibraryRunData, compilerData:LibraryData, callData:CallData):Void {
public static function run(library:LibraryRunData, callData:CallData, getCompilerVersion:()->SemVer):Void {
final type = getType(library);

final cmd = getCmd(type);
final args = generateArgs(type, callData, SemVer.ofString(compilerData.version));
final args = generateArgs(type, callData, getCompilerVersion);

final oldState = getState();

Expand Down Expand Up @@ -122,15 +122,15 @@ class ScriptRunner {
}
}

static function generateArgs(runType:RunType, callData:CallData, compilerVersion:SemVer):Array<String> {
static function generateArgs(runType:RunType, callData:CallData, getCompilerVersion:() -> SemVer):Array<String> {
switch runType {
case Neko(path):
final callArgs = callData.args.copy();
callArgs.unshift(path);
callArgs.push(callData.dir);
return callArgs;
case Script(main, name, version, dependencies):
final isHaxe4 = SemVer.compare(compilerVersion, SemVer.ofString('4.0.0')) >= 0;
final isHaxe4 = SemVer.compare(getCompilerVersion(), SemVer.ofString('4.0.0')) >= 0;
final useGlobalRepo = isHaxe4 && callData.useGlobalRepo;

final callArgs = generateScriptArgs(main, name, version, dependencies, useGlobalRepo);
Expand Down
38 changes: 31 additions & 7 deletions src/haxelib/api/Vcs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interface IVcs {
`debugLog` will be used to log executable output.
**/
function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void;
function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void;

/**
Updates repository in CWD or CWD/`Vcs.directory` to HEAD.
Expand All @@ -74,6 +74,7 @@ enum VcsError {
CantCheckoutBranch(vcs:Vcs, branch:String, stderr:String);
CantCheckoutVersion(vcs:Vcs, version:String, stderr:String);
CommandFailed(vcs:Vcs, code:Int, stdout:String, stderr:String);
SubmoduleError(vcs:Vcs, repo:String, stderr:String);
}

/** Exception thrown when a vcs update is cancelled. **/
Expand Down Expand Up @@ -230,7 +231,7 @@ abstract class Vcs implements IVcs {
return ret;
}

public abstract function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void;
public abstract function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void;

public abstract function update(?confirm:() -> Bool, ?debugLog:(msg:String) -> Void, ?summaryLog:(msg:String) -> Void):Bool;

Expand Down Expand Up @@ -320,33 +321,56 @@ class Git extends Vcs {
return true;
}

public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void {
public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void {
final oldCwd = Sys.getCwd();

final vcsArgs = ["clone", url, libPath];
var vcsArgs = ["clone", url, libPath];

if (!Vcs.flat)
vcsArgs.push('--recursive');
inline function printOptional(msg)
if (optionalLog != null && msg != "")
optionalLog(msg);

printOptional('Cloning ${name} from ${url}');

if (run(vcsArgs, debugLog).code != 0)
throw VcsError.CantCloneRepo(this, url/*, ret.out*/);

Sys.setCwd(libPath);

if (version != null && version != "") {
printOptional('Checking out tag/version ${version} of ${name}');

final ret = run(["checkout", "tags/" + version], debugLog);
if (ret.code != 0) {
Sys.setCwd(oldCwd);
throw VcsError.CantCheckoutVersion(this, version, ret.out);
}
} else if (branch != null) {
printOptional('Checking out branch/commit ${branch} of ${libPath}');

final ret = run(["checkout", branch], debugLog);
if (ret.code != 0){
Sys.setCwd(oldCwd);
throw VcsError.CantCheckoutBranch(this, branch, ret.out);
}
}

if (!Vcs.flat)
{
printOptional('Syncing submodules for ${name}');
run(["submodule", "sync", "--recursive"], debugLog);

var submoduleArgs = ["submodule", "update", "--init", "--recursive"];

printOptional('Downloading/updating submodules for ${name}');
final ret = run(submoduleArgs, debugLog);
if (ret.code != 0)
{
Sys.setCwd(oldCwd);
throw VcsError.SubmoduleError(this, url, ret.out);
}
}

// return prev. cwd:
Sys.setCwd(oldCwd);
}
Expand Down Expand Up @@ -421,7 +445,7 @@ class Mercurial extends Vcs {
return changed;
}

public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void {
public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void {
final vcsArgs = ["clone", url, libPath];

if (branch != null && version != null) {
Expand Down
Loading

0 comments on commit 8673f80

Please sign in to comment.