Skip to content

Commit

Permalink
Join embbeded files and directories
Browse files Browse the repository at this point in the history
  • Loading branch information
hernoufM committed Sep 17, 2023
1 parent 4444a56 commit 460fb56
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 33 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ OTHER OPTIONS
The package GUID that will be used to update the same package with
different version without processing throught Windows Apps &
features panel
--conf=PATH
Configuration file for the binary to install.
```
### Config file

Expand Down Expand Up @@ -160,14 +163,12 @@ Configuration
binary-path, binary
These are the same as their respective arguments.
embed-file
A list of file paths to include in the installation directory.
embed-dir
A list of directory paths to include in the installation directory.
embbed
A list of files paths to include in the installation directory.
Each element in this list should be a list of two elements: the
first being the destination basename (the name of the directory in
first being the destination basename (the name of the file in
the installation directory), and the second being the path to the
directory itself. For example: ["data" "path/to/data"].
directory itself. For example: ["file.txt" "path/to/file"].
envvar
A list of environment variables to set/unset in the Windows
Expand Down
13 changes: 4 additions & 9 deletions src/file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ module Syntax = struct
c_images: images;
c_binary_path: string option;
c_binary: string option;
c_embbed_dir : (string * string) list;
c_embbed_file : string list;
c_embbed : (string * string) list;
c_envvar: (string * string) list;
}

Expand All @@ -37,8 +36,7 @@ module Syntax = struct
};
c_binary_path = None;
c_binary = None;
c_embbed_dir = [];
c_embbed_file = [];
c_embbed = [];
c_envvar = [];
}

Expand All @@ -65,11 +63,8 @@ module Syntax = struct
"binary", OpamPp.ppacc_opt
(fun binary t -> { t with c_binary = Some binary }) (fun t -> t.c_binary)
OpamFormat.V.string;
"embbed-file", OpamPp.ppacc
(fun file t -> { t with c_embbed_file = file }) (fun t -> t.c_embbed_file)
(OpamFormat.V.map_list ~depth:1 OpamFormat.V.string);
"embbed-dir", OpamPp.ppacc
(fun dir t -> { t with c_embbed_dir = dir }) (fun t -> t.c_embbed_dir)
"embbed", OpamPp.ppacc
(fun file t -> { t with c_embbed = file }) (fun t -> t.c_embbed)
(OpamFormat.V.map_list ~depth:2
(OpamFormat.V.map_pair OpamFormat.V.string OpamFormat.V.string));
"envvar", OpamPp.ppacc
Expand Down
3 changes: 1 addition & 2 deletions src/file.mli
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ module Conf: sig
c_images: images; (* Images files that are treated not as other embedded files *)
c_binary_path: string option; (* Path to binary to install *)
c_binary: string option; (* Binary name to install *)
c_embbed_dir : (string * string) list; (* Directories to embed in installation directory *)
c_embbed_file : string list; (* Files to embed in installation directory *)
c_embbed : (string * string) list; (* Files/directories to embed in installation directory *)
c_envvar: (string * string) list; (* Environement variables to set in Windows Terminal on installation *)
}

Expand Down
28 changes: 12 additions & 16 deletions src/opamWixMain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,14 @@ let create_bundle cli =
F.copy ~src ~dst;
F.basename dst, dst
in
let embbed_dirs, embbed_files = List.partition (fun (_,path) ->
Sys.is_directory path) conffile.File.Conf.c_embbed
in
let embedded_dirs = List.map (fun (name, dirname) ->
copy_embedded (module Dir_impl) dirname name)
conffile.File.Conf.c_embbed_dir
copy_embedded (module Dir_impl) dirname name) embbed_dirs
in
let embedded_files = List.map (fun filename ->
copy_embedded (module File_impl) filename (Filename.basename filename)
|> fst) conffile.File.Conf.c_embbed_file
let embedded_files = List.map (fun (name, filename) ->
copy_embedded (module File_impl) filename name) embbed_files
in
OpamConsole.formatted_msg "Bundle created.";
OpamConsole.header_msg "WiX setup";
Expand Down Expand Up @@ -336,7 +337,8 @@ let create_bundle cli =
let embedded_dirs = List.map (fun (base,_) ->
let base = OpamFilename.Base.to_string base in
base, component_group base, dir_ref base) embedded_dirs
let embedded_files = List.map OpamFilename.Base.to_string embedded_files
let embedded_files = List.map (fun (base,_) ->
OpamFilename.Base.to_string base) embedded_files
let environement = conffile.File.Conf.c_envvar
end in
System.call_list @@ List.map (fun (basename, dirname) ->
Expand All @@ -355,7 +357,7 @@ let create_bundle cli =
) embedded_dirs;
let wxs = Wix.main_wxs (module Info) in
let name = Filename.chop_extension (OpamFilename.Base.to_string exe_base) in
let (addwxs1,content1),(addwxs2,content2) =
let (addwxs1,content1),(addwxs2,content2) =
DataDir.Wix.custom_install_dir,
DataDir.Wix.custom_install_dir_dlg
in
Expand All @@ -367,11 +369,6 @@ let create_bundle cli =
in
let main_path = OpamFilename.Op.(tmp_dir // (name ^ ".wxs")) in
Wix.write_wxs (OpamFilename.to_string main_path) wxs;


OpamFilename.copy_in main_path (OpamFilename.Dir.of_string ".");


OpamConsole.formatted_msg "Compiling WiX components...\n";
System.call_list @@ List.map (fun (basename, _) ->
let basename = OpamFilename.Base.to_string basename in
Expand Down Expand Up @@ -474,11 +471,10 @@ let create_bundle cli =
`I ("$(i,opamwix-version)","The version of the config file. The current version is $(b,0.1).");
`I ("$(i,ico, bng, ban)","These are the same as their respective arguments.");
`I ("$(i,binary-path, binary)","These are the same as their respective arguments.");
`I ("$(i,embed-file)","A list of file paths to include in the installation directory.");
`I ("$(i,embed-dir)", "A list of directory paths to include in the installation directory. \
`I ("$(i,embbed)", "A list of files paths to include in the installation directory. \
Each element in this list should be a list of two elements: the first being the destination \
basename (the name of the directory in the installation directory), and the second being the \
path to the directory itself. For example: $(i,[\"data\" \"path/to/data\"]).");
basename (the name of the file in the installation directory), and the second being the \
path to the directory itself. For example: $(i,[\"file.txt\" \"path/to/file\"]).");
`I ("$(i,envvar)", "A list of environment variables to set/unset in the Windows Terminal during \
install/uninstall. Each element in this list should be a list of two elements: the name and the \
value of the variable.");
Expand Down

0 comments on commit 460fb56

Please sign in to comment.